File indexing completed on 2025-01-19 04:28:11

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