1 /* 2 SPDX-FileCopyrightText: 2012 Alejandro Fiestas Olivares <afiestas@kde.org> 3 4 SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 7 #ifndef KDED_DEVICE_H 8 #define KDED_DEVICE_H 9 10 #include <QObject> 11 12 class QDBusPendingCallWatcher; 13 class QDBusInterface; 14 class OrgFreedesktopDBusPropertiesInterface; 15 16 class Device : public QObject 17 { 18 Q_OBJECT 19 public: 20 static Device *self(); 21 static void destroy(); 22 23 bool isReady() const; 24 bool isLaptop() const; 25 bool isLidClosed() const; 26 bool isDocked() const; 27 28 private Q_SLOTS: 29 void changed(); 30 void isLaptopFetched(QDBusPendingCallWatcher *watcher); 31 void isLidClosedFetched(QDBusPendingCallWatcher *watcher); 32 33 Q_SIGNALS: 34 void ready(); 35 void lidClosedChanged(bool closed); 36 void resumingFromSuspend(); 37 void aboutToSuspend(); 38 39 private: 40 explicit Device(QObject *parent = nullptr); 41 ~Device() override; 42 43 void setReady(); 44 void fetchIsLaptop(); 45 void fetchLidIsClosed(); 46 void fetchIsDocked(); 47 48 bool m_isReady; 49 bool m_isLaptop; 50 bool m_isLidClosed; 51 bool m_isDocked; 52 53 static Device *m_instance; 54 55 OrgFreedesktopDBusPropertiesInterface *m_freedesktop; 56 QDBusInterface *m_suspendSession; 57 }; 58 59 #endif // KDED_DEVICE_H 60