File indexing completed on 2024-04-21 04:49:01

0001 /*
0002    SPDX-FileCopyrightText: 2019 (c) Matthieu Gallien <matthieu_gallien@yahoo.fr>
0003 
0004    SPDX-License-Identifier: LGPL-3.0-or-later
0005  */
0006 
0007 #ifndef POWERMANAGEMENTINTERFACE_H
0008 #define POWERMANAGEMENTINTERFACE_H
0009 
0010 #include <QObject>
0011 
0012 #include <memory>
0013 
0014 class QDBusPendingCallWatcher;
0015 class PowerManagementInterfacePrivate;
0016 
0017 class PowerManagementInterface : public QObject
0018 {
0019 
0020     Q_OBJECT
0021 
0022     Q_PROPERTY(bool preventSleep
0023                READ preventSleep
0024                WRITE setPreventSleep
0025                NOTIFY preventSleepChanged)
0026 
0027     Q_PROPERTY(bool sleepInhibited
0028                READ sleepInhibited
0029                NOTIFY sleepInhibitedChanged)
0030 
0031 public:
0032 
0033     explicit PowerManagementInterface(QObject *parent = nullptr);
0034 
0035     ~PowerManagementInterface() override;
0036 
0037     [[nodiscard]] bool preventSleep() const;
0038 
0039     [[nodiscard]] bool sleepInhibited() const;
0040 
0041 Q_SIGNALS:
0042 
0043     void preventSleepChanged();
0044 
0045     void sleepInhibitedChanged();
0046 
0047 public Q_SLOTS:
0048 
0049     void setPreventSleep(bool value);
0050 
0051     void retryInhibitingSleep();
0052 
0053 private Q_SLOTS:
0054 
0055     void hostSleepInhibitChanged();
0056 
0057     void inhibitDBusCallFinishedPlasmaWorkspace(QDBusPendingCallWatcher *aWatcher);
0058 
0059     void uninhibitDBusCallFinishedPlasmaWorkspace(QDBusPendingCallWatcher *aWatcher);
0060 
0061     void inhibitDBusCallFinishedGnomeWorkspace(QDBusPendingCallWatcher *aWatcher);
0062 
0063     void uninhibitDBusCallFinishedGnomeWorkspace(QDBusPendingCallWatcher *aWatcher);
0064 
0065 private:
0066 
0067     void inhibitSleepPlasmaWorkspace();
0068 
0069     void uninhibitSleepPlasmaWorkspace();
0070 
0071     void inhibitSleepGnomeWorkspace();
0072 
0073     void uninhibitSleepGnomeWorkspace();
0074 
0075     void inhibitSleepWindowsWorkspace();
0076 
0077     void uninhibitSleepWindowsWorkspace();
0078 
0079     std::unique_ptr<PowerManagementInterfacePrivate> d;
0080 
0081 };
0082 
0083 #endif // POWERMANAGEMENTINTERFACE_H