File indexing completed on 2024-05-19 16:31:39
0001 /* 0002 * SPDX-FileCopyrightText: 2019 Vlad Zahorodnii <vlad.zahorodnii@kde.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QObject> 0010 0011 /** 0012 * The Inhibitor class provides a convenient way to temporarily disable Night Color. 0013 */ 0014 class Inhibitor : public QObject 0015 { 0016 Q_OBJECT 0017 /** 0018 * This property holds a value to indicate the current state of the inhibitor. 0019 */ 0020 Q_PROPERTY(State state READ state NOTIFY stateChanged) 0021 0022 public: 0023 explicit Inhibitor(QObject *parent = nullptr); 0024 ~Inhibitor() override; 0025 0026 /** 0027 * This enum type is used to specify the state of the inhibitor. 0028 */ 0029 enum State { 0030 Inhibiting, ///< Night Color is being inhibited. 0031 Inhibited, ///< Night Color is inhibited. 0032 Uninhibiting, ///< Night Color is being uninhibited. 0033 Uninhibited, ///< Night Color is uninhibited. 0034 }; 0035 Q_ENUM(State) 0036 0037 /** 0038 * Returns the current state of the inhibitor. 0039 */ 0040 State state() const; 0041 0042 public Q_SLOTS: 0043 /** 0044 * Attempts to temporarily disable Night Color. 0045 * 0046 * After calling this method, the inhibitor will enter the Inhibiting state. 0047 * Eventually, the inhibitor will enter the Inhibited state when the inhibition 0048 * request has been processed successfully by the Night Color manager. 0049 * 0050 * This method does nothing if the inhibitor is in the Inhibited state. 0051 */ 0052 void inhibit(); 0053 0054 /** 0055 * Attempts to undo the previous call to inhibit() method. 0056 * 0057 * After calling this method, the inhibitor will enter the Uninhibiting state. 0058 * Eventually, the inhibitor will enter the Uninhibited state when the uninhibition 0059 * request has been processed by the Night Color manager. 0060 * 0061 * This method does nothing if the inhibitor is in the Uninhibited state. 0062 */ 0063 void uninhibit(); 0064 0065 Q_SIGNALS: 0066 /** 0067 * Emitted whenever the state of the inhibitor has changed. 0068 */ 0069 void stateChanged(); 0070 0071 private: 0072 class Private; 0073 QScopedPointer<Private> d; 0074 };