File indexing completed on 2024-04-28 05:45:19

0001 /*
0002  * SPDX-FileCopyrightText: 2006 Peter Penz (peter.penz@gmx.at) and Patrice Tremblay
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 #ifndef STATUSBARSPACEINFO_H
0007 #define STATUSBARSPACEINFO_H
0008 
0009 #include <QUrl>
0010 #include <QWidget>
0011 
0012 class QHideEvent;
0013 class QShowEvent;
0014 class QMenu;
0015 class QMouseEvent;
0016 class QToolButton;
0017 
0018 class KCapacityBar;
0019 
0020 class SpaceInfoObserver;
0021 
0022 /**
0023  * @short Shows the available space for the volume represented
0024  *        by the given URL as part of the status bar.
0025  */
0026 class StatusBarSpaceInfo : public QWidget
0027 {
0028     Q_OBJECT
0029 
0030 public:
0031     explicit StatusBarSpaceInfo(QWidget *parent = nullptr);
0032     ~StatusBarSpaceInfo() override;
0033 
0034     /**
0035      * Use this to set the widget visibility as it can hide itself
0036      */
0037     void setShown(bool);
0038     void setUrl(const QUrl &url);
0039     QUrl url() const;
0040 
0041     void update();
0042 
0043 protected:
0044     void showEvent(QShowEvent *event) override;
0045     void hideEvent(QHideEvent *event) override;
0046     QSize minimumSizeHint() const override;
0047 
0048     void updateMenu();
0049 
0050 private Q_SLOTS:
0051     void slotValuesChanged();
0052 
0053 private:
0054     QScopedPointer<SpaceInfoObserver> m_observer;
0055     KCapacityBar *m_capacityBar;
0056     QToolButton *m_textInfoButton;
0057     QMenu *m_buttonMenu;
0058     QUrl m_url;
0059     bool m_ready;
0060     bool m_shown;
0061 };
0062 
0063 #endif