File indexing completed on 2025-01-19 04:23:50

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 
0019     Q_OBJECT
0020 
0021     Q_PROPERTY(bool preventSleep
0022                READ preventSleep
0023                WRITE setPreventSleep
0024                NOTIFY preventSleepChanged)
0025 
0026     Q_PROPERTY(bool sleepInhibited
0027                READ sleepInhibited
0028                NOTIFY sleepInhibitedChanged)
0029 
0030 public:
0031 
0032     explicit PowerManagementInterface(QObject *parent = nullptr);
0033 
0034     ~PowerManagementInterface() override;
0035 
0036     [[nodiscard]] bool preventSleep() const;
0037 
0038     [[nodiscard]] bool sleepInhibited() const;
0039 
0040 Q_SIGNALS:
0041 
0042     void preventSleepChanged();
0043 
0044     void sleepInhibitedChanged();
0045 
0046 public Q_SLOTS:
0047 
0048     void setPreventSleep(bool value);
0049 
0050     void retryInhibitingSleep();
0051 
0052 private Q_SLOTS:
0053 
0054     void hostSleepInhibitChanged();
0055 
0056     void inhibitDBusCallFinishedPlasmaWorkspace(QDBusPendingCallWatcher *aWatcher);
0057 
0058     void uninhibitDBusCallFinishedPlasmaWorkspace(QDBusPendingCallWatcher *aWatcher);
0059 
0060     void inhibitDBusCallFinishedGnomeWorkspace(QDBusPendingCallWatcher *aWatcher);
0061 
0062     void uninhibitDBusCallFinishedGnomeWorkspace(QDBusPendingCallWatcher *aWatcher);
0063 
0064 private:
0065 
0066     void inhibitSleepPlasmaWorkspace();
0067 
0068     void uninhibitSleepPlasmaWorkspace();
0069 
0070     void inhibitSleepGnomeWorkspace();
0071 
0072     void uninhibitSleepGnomeWorkspace();
0073 
0074     void inhibitSleepWindowsWorkspace();
0075 
0076     void uninhibitSleepWindowsWorkspace();
0077 
0078     std::unique_ptr<PowerManagementInterfacePrivate> d;
0079 
0080 };