]> cloud.milkyroute.net Git - dolphin.git/blob - src/statusbar/diskspaceusagemenu.h
KItemListView: Don't allow starting role editing when animation is running
[dolphin.git] / src / statusbar / diskspaceusagemenu.h
1 /*
2 SPDX-FileCopyrightText: 2025 Felix Ernst <felixernst@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6
7 #ifndef DISKSPACEUSAGEMENU_H
8 #define DISKSPACEUSAGEMENU_H
9
10 #include <KMessageWidget>
11
12 #include <QMenu>
13 #include <QPointer>
14 #include <QUrl>
15
16 class QShowEvent;
17 class QWidgetAction;
18
19 /**
20 * A menu that allows launching tools to view disk usage statistics like Filelight and KDiskFree when those are installed.
21 * If none are installed, this menu instead allows installing Filelight.
22 */
23 class DiskSpaceUsageMenu : public QMenu
24 {
25 Q_OBJECT
26
27 public:
28 explicit DiskSpaceUsageMenu(QWidget *parent);
29
30 inline void setUrl(const QUrl &url)
31 {
32 m_url = url;
33 };
34
35 Q_SIGNALS:
36 /**
37 * Requests for @p message with the given @p messageType to be shown to the user in a non-modal way.
38 */
39 void showMessage(const QString &message, KMessageWidget::MessageType messageType);
40
41 /**
42 * Requests for a progress update to be shown to the user in a non-modal way.
43 * @param currentlyRunningTaskTitle The task that is currently progressing.
44 * @param installationProgressPercent The current percentage of completion.
45 */
46 void showInstallationProgress(const QString &currentlyRunningTaskTitle, int installationProgressPercent);
47
48 private Q_SLOTS:
49 /**
50 * Asynchronously starts a Filelight installation using DolphinPackageInstaller. @see DolphinPackageInstaller.
51 * Installation success or failure is reported through showMessage(). @see StatusBarSpaceInfo::showMessage().
52 * Installation progress is reported through showInstallationProgress(). @see StatusBarSpaceInfo::showInstallationProgress().
53 */
54 void slotInstallFilelightButtonClicked();
55
56 void updateMenu();
57
58 protected:
59 /** Moves keyboard focus to the "Install Filelight" button if the Installation UI is shown. */
60 void showEvent(QShowEvent *event) override;
61
62 private:
63 /**
64 * Creates a new QWidgetAction that contains a UI to install Filelight.
65 * m_installFilelightWidgetAction is initialised after calling this method once.
66 */
67 void initialiseInstallFilelightWidgetAction();
68
69 private:
70 /** An action containing a UI to install Filelight. */
71 QPointer<QWidgetAction> m_installFilelightWidgetAction = nullptr;
72 /** The current url of the view. Filelight can be launched to show this directory. */
73 QUrl m_url;
74 };
75
76 #endif // DISKSPACEUSAGEMENU_H