File indexing completed on 2024-05-05 05:29:12
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 #pragma once 0008 0009 #include <QObject> 0010 0011 #include <memory> 0012 0013 class QDBusPendingCallWatcher; 0014 class PowerManagementInterfacePrivate; 0015 0016 class PowerManagementInterface : public QObject 0017 { 0018 Q_OBJECT 0019 0020 Q_PROPERTY(QString reason READ reason WRITE setReason) 0021 0022 Q_PROPERTY(bool preventSleep READ preventSleep WRITE setPreventSleep NOTIFY preventSleepChanged) 0023 0024 Q_PROPERTY(bool sleepInhibited READ sleepInhibited NOTIFY sleepInhibitedChanged) 0025 0026 public: 0027 explicit PowerManagementInterface(QObject *parent = nullptr); 0028 0029 ~PowerManagementInterface() override; 0030 0031 [[nodiscard]] bool preventSleep() const; 0032 0033 [[nodiscard]] bool sleepInhibited() const; 0034 0035 QString reason() const; 0036 void setReason(const QString &reason); 0037 0038 Q_SIGNALS: 0039 0040 void preventSleepChanged(); 0041 0042 void sleepInhibitedChanged(); 0043 0044 public Q_SLOTS: 0045 0046 void setPreventSleep(bool value); 0047 0048 void retryInhibitingSleep(); 0049 0050 private Q_SLOTS: 0051 0052 void hostSleepInhibitChanged(); 0053 0054 void inhibitDBusCallFinished(QDBusPendingCallWatcher *aWatcher); 0055 0056 void uninhibitDBusCallFinished(QDBusPendingCallWatcher *aWatcher); 0057 0058 private: 0059 void inhibitSleep(); 0060 0061 void uninhibitSleep(); 0062 0063 std::unique_ptr<PowerManagementInterfacePrivate> d; 0064 };