File indexing completed on 2024-04-28 05:34:57

0001 /*
0002     SPDX-FileCopyrightText: 2006 Lukas Tinkl <ltinkl@suse.cz>
0003     SPDX-FileCopyrightText: 2008 Lubos Lunak <l.lunak@suse.cz>
0004     SPDX-FileCopyrightText: 2009 Ivo Anjo <knuckles@gmail.com>
0005     SPDX-FileCopyrightText: 2020 Kai Uwe Broulik <kde@broulik.de>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #pragma once
0011 
0012 #include <QPointer>
0013 #include <QTimer>
0014 
0015 #include <KLocalizedString>
0016 #include <KService>
0017 
0018 class KNotification;
0019 
0020 class FreeSpaceNotifier : public QObject
0021 {
0022     Q_OBJECT
0023 
0024 public:
0025     explicit FreeSpaceNotifier(const QString &path, const KLocalizedString &notificationText, QObject *parent = nullptr);
0026     ~FreeSpaceNotifier() override;
0027 
0028 Q_SIGNALS:
0029     void configureRequested();
0030 
0031 private:
0032     void checkFreeDiskSpace();
0033     void resetLastAvailable();
0034 
0035     KService::Ptr filelightService() const;
0036     void exploreDrive();
0037     void onNotificationClosed();
0038 
0039     QString m_path;
0040     KLocalizedString m_notificationText;
0041 
0042     QTimer m_timer;
0043     QTimer *m_lastAvailTimer = nullptr;
0044     QPointer<KNotification> m_notification;
0045     qint64 m_lastAvail = -1; // used to suppress repeated warnings when available space hasn't changed
0046 };