]> cloud.milkyroute.net Git - dolphin.git/blob - src/statusbar/statusbarspaceinfo.h
Rewrite search integration
[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 void updateMenu();
67
68 private Q_SLOTS:
69 /**
70 * Asynchronously starts a Filelight installation using DolphinPackageInstaller. @see DolphinPackageInstaller.
71 * Installation success or failure is reported through showMessage(). @see StatusBarSpaceInfo::showMessage().
72 * Installation progress is reported through showInstallationProgress(). @see StatusBarSpaceInfo::showInstallationProgress().
73 */
74 void slotInstallFilelightButtonClicked();
75
76 void slotValuesChanged();
77
78 private:
79 /**
80 * Creates a new QWidgetAction that contains a UI to install Filelight.
81 * m_installFilelightWidgetAction is initialised after calling this method once.
82 */
83 void initialiseInstallFilelightWidgetAction();
84
85 // The following three methods are only for private use.
86 using QWidget::hide; // Use StatusBarSpaceInfo::setShown() instead.
87 using QWidget::setVisible; // Use StatusBarSpaceInfo::setShown() instead.
88 using QWidget::show; // Use StatusBarSpaceInfo::setShown() instead.
89
90 private:
91 QScopedPointer<SpaceInfoObserver> m_observer;
92 KCapacityBar *m_capacityBar;
93 QToolButton *m_textInfoButton;
94 QMenu *m_buttonMenu;
95 /** An action containing a UI to install Filelight. */
96 QWidgetAction *m_installFilelightWidgetAction;
97 QUrl m_url;
98 /** Whether m_observer has already retrieved space information for the current url. */
99 bool m_hasSpaceInfo;
100 /** Whether this widget is supposed to be visible long-term. @see StatusBarSpaceInfo::setShown(). */
101 bool m_shown;
102 };
103
104 #endif