Warning, file /plasma/libkscreen/src/libdpms/dpms.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: 2016 Sebastian Kügler <sebas@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 KSCREENDPMS_DPMS_H
0007 #define KSCREENDPMS_DPMS_H
0008 
0009 #include <QScreen>
0010 
0011 #include "kscreendpms_export.h"
0012 
0013 namespace KScreen
0014 {
0015 
0016 class AbstractDpmsHelper;
0017 
0018 /**
0019  * @class Dpms, allows controlling the system's Display Power Management Signaling
0020  *
0021  * Provides an API to switch the system's mode on a per-display basis.
0022  *
0023  * It has backends for X11 and Wayland.
0024  */
0025 class KSCREENDPMS_EXPORT Dpms : public QObject
0026 {
0027     Q_OBJECT
0028     Q_PROPERTY(bool isSupported READ isSupported NOTIFY supportedChanged)
0029     Q_PROPERTY(bool hasPendingChanges READ hasPendingChanges NOTIFY hasPendingChangesChanged)
0030 
0031 public:
0032     explicit Dpms(QObject *parent = nullptr);
0033     ~Dpms() override;
0034 
0035     enum Mode {
0036         On,
0037         Standby,
0038         Suspend,
0039         Off,
0040         Toggle,
0041     };
0042     Q_ENUM(Mode)
0043 
0044     /**
0045      * @returns true if the DPMS system is supported
0046      *
0047      * If we are still figuring out if it's supported, it will block.
0048      */
0049     bool isSupported() const;
0050 
0051     /**
0052      * @returns true if there still are pending DPMS changes
0053      * This would happen after @m switchMode is called as most implementations will be async.
0054      */
0055     bool hasPendingChanges() const;
0056 
0057     /**
0058      * Switches the @p screens to @p mode
0059      *
0060      * If @p screens is empty, it will use all the screens as returned by QGuiApplication::screens()
0061      */
0062     Q_SCRIPTABLE void switchMode(Mode mode, const QList<QScreen *> &screen = {});
0063 
0064 Q_SIGNALS:
0065     /**
0066      * Notifies about the class being ready for usage
0067      */
0068     void supportedChanged(bool supported);
0069 
0070     /**
0071      * Tells which is the new @p mode that the @p screen just adopted
0072      */
0073     void modeChanged(Mode mode, QScreen *screen);
0074 
0075     void hasPendingChangesChanged(bool hasPendingChanges);
0076 
0077 private:
0078     QScopedPointer<AbstractDpmsHelper> m_helper;
0079 };
0080 
0081 } // namespace
0082 
0083 #endif // KSCREENDPMS_DPMS_H