diff options
| author | Felix Ernst <[email protected]> | 2025-04-19 14:32:25 +0200 |
|---|---|---|
| committer | Felix Ernst <[email protected]> | 2025-04-19 14:32:25 +0200 |
| commit | b889a446bfe851a7f49821d469c5f3041b6e5774 (patch) | |
| tree | e14a8ddec8efc56c27fd11cbb46f72d9b325784b /src/statusbar/diskspaceusagemenu.h | |
| parent | 81627bbf9a8eace35f87b6bb09d25afef5ea8421 (diff) | |
Add Filelight menu to Tools menu
The menu for installing and launching Filelight was only available
through the status bar free space info button until now. By default
we do no longer show the free space info button because the status
bar has been changed to show less information by default.
This commit adds the "Manage Disk Space Usage" menu to the "Tools"
menu in the menu bar so it is more discoverable for users.
Diffstat (limited to 'src/statusbar/diskspaceusagemenu.h')
| -rw-r--r-- | src/statusbar/diskspaceusagemenu.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/statusbar/diskspaceusagemenu.h b/src/statusbar/diskspaceusagemenu.h new file mode 100644 index 000000000..50984a734 --- /dev/null +++ b/src/statusbar/diskspaceusagemenu.h @@ -0,0 +1,76 @@ +/* + SPDX-FileCopyrightText: 2025 Felix Ernst <[email protected]> + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#ifndef DISKSPACEUSAGEMENU_H +#define DISKSPACEUSAGEMENU_H + +#include <KMessageWidget> + +#include <QMenu> +#include <QPointer> +#include <QUrl> + +class QShowEvent; +class QWidgetAction; + +/** + * A menu that allows launching tools to view disk usage statistics like Filelight and KDiskFree when those are installed. + * If none are installed, this menu instead allows installing Filelight. + */ +class DiskSpaceUsageMenu : public QMenu +{ + Q_OBJECT + +public: + explicit DiskSpaceUsageMenu(QWidget *parent); + + inline void setUrl(const QUrl &url) + { + m_url = url; + }; + +Q_SIGNALS: + /** + * Requests for @p message with the given @p messageType to be shown to the user in a non-modal way. + */ + void showMessage(const QString &message, KMessageWidget::MessageType messageType); + + /** + * Requests for a progress update to be shown to the user in a non-modal way. + * @param currentlyRunningTaskTitle The task that is currently progressing. + * @param installationProgressPercent The current percentage of completion. + */ + void showInstallationProgress(const QString ¤tlyRunningTaskTitle, int installationProgressPercent); + +private Q_SLOTS: + /** + * Asynchronously starts a Filelight installation using DolphinPackageInstaller. @see DolphinPackageInstaller. + * Installation success or failure is reported through showMessage(). @see StatusBarSpaceInfo::showMessage(). + * Installation progress is reported through showInstallationProgress(). @see StatusBarSpaceInfo::showInstallationProgress(). + */ + void slotInstallFilelightButtonClicked(); + + void updateMenu(); + +protected: + /** Moves keyboard focus to the "Install Filelight" button if the Installation UI is shown. */ + void showEvent(QShowEvent *event) override; + +private: + /** + * Creates a new QWidgetAction that contains a UI to install Filelight. + * m_installFilelightWidgetAction is initialised after calling this method once. + */ + void initialiseInstallFilelightWidgetAction(); + +private: + /** An action containing a UI to install Filelight. */ + QPointer<QWidgetAction> m_installFilelightWidgetAction = nullptr; + /** The current url of the view. Filelight can be launched to show this directory. */ + QUrl m_url; +}; + +#endif // DISKSPACEUSAGEMENU_H |
