File indexing completed on 2024-04-28 16:55:15

0001 /********************************************************************
0002 Copyright 2016  Martin Gräßlin <mgraesslin@kde.org>
0003 
0004 This library is free software; you can redistribute it and/or
0005 modify it under the terms of the GNU Lesser General Public
0006 License as published by the Free Software Foundation; either
0007 version 2.1 of the License, or (at your option) version 3, or any
0008 later version accepted by the membership of KDE e.V. (or its
0009 successor approved by the membership of KDE e.V.), which shall
0010 act as a proxy defined in Section 6 of version 3 of the license.
0011 
0012 This library is distributed in the hope that it will be useful,
0013 but WITHOUT ANY WARRANTY; without even the implied warranty of
0014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015 Lesser General Public License for more details.
0016 
0017 You should have received a copy of the GNU Lesser General Public
0018 License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0019 *********************************************************************/
0020 
0021 #ifndef POWERDEVIL_POWERMANAGEMENT_H
0022 #define POWERDEVIL_POWERMANAGEMENT_H
0023 
0024 #include <QObject>
0025 
0026 namespace PowerDevil {
0027 
0028 class Q_DECL_EXPORT PowerManagement : public QObject
0029 {
0030     Q_OBJECT
0031     Q_PROPERTY(bool canSuspend READ canSuspend NOTIFY canSuspendChanged)
0032     Q_PROPERTY(bool canHibernate READ canHibernate NOTIFY canHibernateChanged)
0033     Q_PROPERTY(bool canHybridSuspend READ canHybridSuspend NOTIFY canHybridSuspendChanged)
0034     Q_PROPERTY(bool canSuspendThenHibernate READ canSuspendThenHibernate NOTIFY canSuspendThenHibernateChanged)
0035 public:
0036     ~PowerManagement() override;
0037 
0038     bool isVirtualMachine();
0039     bool canSuspend() const;
0040     bool canHibernate() const;
0041     bool canHybridSuspend() const;
0042     bool canSuspendThenHibernate() const;
0043 
0044     static PowerManagement *instance();
0045 
0046 public Q_SLOTS:
0047     void suspend();
0048     void hibernate();
0049     void hybridSuspend();
0050     void suspendThenHibernate();
0051 
0052 Q_SIGNALS:
0053     void canSuspendChanged();
0054     void canSuspendThenHibernateChanged();
0055     void canHibernateChanged();
0056     void canHybridSuspendChanged();
0057 
0058 protected:
0059     explicit PowerManagement();
0060 
0061 private:
0062     class Private;
0063     QScopedPointer<Private> d;
0064 };
0065 
0066 } // namespace PowerDevil
0067 
0068 #endif // POWERDEVIL_POWERMANAGEMENT_H