Warning, file /plasma/libkscreen/src/libdpms/abstractdpmshelper_p.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // SPDX-FileCopyrightText: 2015 by Martin Gräßlin <mgraesslin@kde.org>
0002 // SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez <aleixpol@kde.org>
0003 //
0004 // SPDX-License-Identifier: LGPL-2.1-or-later
0005 
0006 #ifndef ABSTRACTDPMSHELPER_H
0007 #define ABSTRACTDPMSHELPER_H
0008 
0009 #include "dpms.h"
0010 #include <QObject>
0011 #include <optional>
0012 
0013 class QScreen;
0014 
0015 namespace KScreen
0016 {
0017 
0018 class AbstractDpmsHelper : public QObject
0019 {
0020     Q_OBJECT
0021 public:
0022     virtual ~AbstractDpmsHelper();
0023 
0024     virtual void trigger(Dpms::Mode, const QList<QScreen *> &screens) = 0;
0025 
0026     bool isSupported()
0027     {
0028         if (!m_supported.has_value()) {
0029             blockUntilSupported();
0030         }
0031         Q_ASSERT(m_supported.has_value());
0032         return *m_supported;
0033     }
0034     void setSupported(bool supported)
0035     {
0036         if (m_supported != supported) {
0037             m_supported = supported;
0038             Q_EMIT supportedChanged(supported);
0039         }
0040     }
0041     void setHasPendingChanges(bool hasThem)
0042     {
0043         if (m_hasPendingChanges != hasThem) {
0044             return;
0045         }
0046         m_hasPendingChanges = hasThem;
0047         Q_EMIT hasPendingChangesChanged(hasThem);
0048     }
0049 
0050     bool hasPendingChanges() const
0051     {
0052         return m_hasPendingChanges;
0053     }
0054 
0055 Q_SIGNALS:
0056     void supportedChanged(bool supported);
0057     void modeChanged(Dpms::Mode mode, QScreen *screen);
0058     void hasPendingChangesChanged(bool pendingChanges);
0059 
0060 private:
0061     virtual void blockUntilSupported() {}
0062 
0063     std::optional<bool> m_supported;
0064     bool m_hasPendingChanges = false;
0065 };
0066 
0067 }
0068 
0069 #endif