File indexing completed on 2022-11-29 20:02:27

0001 /********************************************************************
0002  KSld - the KDE Screenlocker Daemon
0003  This file is part of the KDE project.
0004 
0005  Copyright (C) 2016 Martin Gräßlin <mgraesslin@kde.org>
0006 
0007 This program is free software; you can redistribute it and/or modify
0008 it under the terms of the GNU General Public License as published by
0009 the Free Software Foundation; either version 2 of the License, or
0010 (at your option) any later version.
0011 
0012 This program 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
0015 GNU General Public License for more details.
0016 
0017 You should have received a copy of the GNU General Public License
0018 along with this program.  If not, see <http://www.gnu.org/licenses/>.
0019 *********************************************************************/
0020 #ifndef POWERMANAGEMENT_INHIBITION_H
0021 #define POWERMANAGEMENT_INHIBITION_H
0022 
0023 #include <QObject>
0024 
0025 class QDBusServiceWatcher;
0026 
0027 using InhibitionInfo = QPair<QString, QString>;
0028 
0029 class PowerManagementInhibition : public QObject
0030 {
0031     Q_OBJECT
0032 public:
0033     explicit PowerManagementInhibition(QObject *parent = nullptr);
0034     ~PowerManagementInhibition() override;
0035 
0036     bool isInhibited() const
0037     {
0038         return m_inhibited;
0039     }
0040 
0041 private Q_SLOTS:
0042     void inhibitionsChanged(const QList<InhibitionInfo> &added, const QStringList &removed);
0043 
0044 private:
0045     void checkInhibition();
0046     void update();
0047 
0048     QDBusServiceWatcher *m_solidPowerServiceWatcher;
0049     bool m_serviceRegistered = false;
0050     bool m_inhibited = false;
0051 };
0052 
0053 #endif