]> cloud.milkyroute.net Git - dolphin.git/blob - src/statusbar/statusbarspaceinfo.h
SVN_SILENT made messages (.desktop file) - always resolve ours
[dolphin.git] / src / statusbar / statusbarspaceinfo.h
1 /*
2 * SPDX-FileCopyrightText: 2006 Peter Penz (peter.penz@gmx.at) and Patrice Tremblay
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 #ifndef STATUSBARSPACEINFO_H
7 #define STATUSBARSPACEINFO_H
8
9 #include <KMessageWidget>
10
11 #include <QUrl>
12 #include <QWidget>
13
14 class QHideEvent;
15 class QShowEvent;
16 class QMenu;
17 class QMouseEvent;
18 class QToolButton;
19 class QWidgetAction;
20
21 class KCapacityBar;
22
23 class SpaceInfoObserver;
24
25 /**
26 * @short Shows the available space for the volume represented
27 * by the given URL as part of the status bar.
28 */
29 class StatusBarSpaceInfo : public QWidget
30 {
31 Q_OBJECT
32
33 public:
34 explicit StatusBarSpaceInfo(QWidget *parent = nullptr);
35 ~StatusBarSpaceInfo() override;
36
37 /**
38 * Works similar to QWidget::setVisible() except that this will postpone showing the widget until space info has been retrieved. Hiding happens instantly.
39 *
40 * @param shown Whether this widget is supposed to be visible long-term
41 */
42 void setShown(bool shown);
43 void setUrl(const QUrl &url);
44 QUrl url() const;
45
46 void update();
47
48 Q_SIGNALS:
49 /**
50 * Requests for @p message with the given @p messageType to be shown to the user in a non-modal way.
51 */
52 void showMessage(const QString &message, KMessageWidget::MessageType messageType);
53
54 /**
55 * Requests for a progress update to be shown to the user in a non-modal way.
56 * @param currentlyRunningTaskTitle The task that is currently progressing.
57 * @param installationProgressPercent The current percentage of completion.
58 */
59 void showInstallationProgress(const QString &currentlyRunningTaskTitle, int installationProgressPercent);
60
61 protected:
62 void showEvent(QShowEvent *event) override;
63 void hideEvent(QHideEvent *event) override;
64 QSize minimumSizeHint() const override;
65
66 private Q_SLOTS:
67 void slotValuesChanged();
68
69 private:
70 // The following three methods are only for private use.
71 using QWidget::hide; // Use StatusBarSpaceInfo::setShown() instead.
72 using QWidget::setVisible; // Use StatusBarSpaceInfo::setShown() instead.
73 using QWidget::show; // Use StatusBarSpaceInfo::setShown() instead.
74
75 private:
76 QScopedPointer<SpaceInfoObserver> m_observer;
77 KCapacityBar *m_capacityBar;
78 QToolButton *m_textInfoButton;
79 QUrl m_url;
80 /** Whether m_observer has already retrieved space information for the current url. */
81 bool m_hasSpaceInfo;
82 /** Whether this widget is supposed to be visible long-term. @see StatusBarSpaceInfo::setShown(). */
83 bool m_shown;
84 };
85
86 #endif