Changeset View
Changeset View
Standalone View
Standalone View
common/control.h
Show All 16 Lines | |||||
17 | #ifndef COMMON_CONTROL_H | 17 | #ifndef COMMON_CONTROL_H | ||
18 | #define COMMON_CONTROL_H | 18 | #define COMMON_CONTROL_H | ||
19 | 19 | | |||
20 | #include <kscreen/types.h> | 20 | #include <kscreen/types.h> | ||
21 | 21 | | |||
22 | #include <QObject> | 22 | #include <QObject> | ||
23 | #include <QVariantMap> | 23 | #include <QVariantMap> | ||
24 | 24 | | |||
25 | class QFileSystemWatcher; | ||||
26 | | ||||
25 | class Control : public QObject | 27 | class Control : public QObject | ||
26 | { | 28 | { | ||
27 | Q_OBJECT | 29 | Q_OBJECT | ||
28 | public: | 30 | public: | ||
29 | enum class OutputRetention { | 31 | enum class OutputRetention { | ||
30 | Undefined = -1, | 32 | Undefined = -1, | ||
31 | Global = 0, | 33 | Global = 0, | ||
32 | Individual = 1, | 34 | Individual = 1, | ||
33 | }; | 35 | }; | ||
34 | Q_ENUM(OutputRetention) | 36 | Q_ENUM(OutputRetention) | ||
35 | 37 | | |||
36 | explicit Control(QObject *parent = nullptr); | 38 | explicit Control(QObject *parent = nullptr); | ||
37 | 39 | | |||
38 | 40 | | |||
39 | ~Control() override = default; | 41 | ~Control() override = default; | ||
40 | 42 | | |||
41 | virtual bool writeFile(); | 43 | virtual bool writeFile(); | ||
44 | virtual void activateWatcher(); | ||||
45 | | ||||
46 | Q_SIGNALS: | ||||
47 | void changed(); | ||||
42 | 48 | | |||
43 | protected: | 49 | protected: | ||
44 | virtual QString dirPath() const; | 50 | virtual QString dirPath() const; | ||
45 | virtual QString filePath() const = 0; | 51 | virtual QString filePath() const = 0; | ||
46 | QString filePathFromHash(const QString &hash) const; | 52 | QString filePathFromHash(const QString &hash) const; | ||
47 | void readFile(); | 53 | void readFile(); | ||
48 | QVariantMap& info(); | 54 | QVariantMap& info(); | ||
49 | const QVariantMap& constInfo() const; | 55 | const QVariantMap& constInfo() const; | ||
56 | QFileSystemWatcher* watcher() const; | ||||
50 | 57 | | |||
51 | static OutputRetention convertVariantToOutputRetention(QVariant variant); | 58 | static OutputRetention convertVariantToOutputRetention(QVariant variant); | ||
52 | 59 | | |||
53 | private: | 60 | private: | ||
54 | static QString s_dirName; | 61 | static QString s_dirName; | ||
55 | QVariantMap m_info; | 62 | QVariantMap m_info; | ||
63 | QFileSystemWatcher *m_watcher = nullptr; | ||||
56 | }; | 64 | }; | ||
57 | 65 | | |||
58 | class ControlOutput; | 66 | class ControlOutput; | ||
59 | 67 | | |||
60 | class ControlConfig : public Control | 68 | class ControlConfig : public Control | ||
61 | { | 69 | { | ||
62 | Q_OBJECT | 70 | Q_OBJECT | ||
63 | public: | 71 | public: | ||
64 | explicit ControlConfig(KScreen::ConfigPtr config, QObject *parent = nullptr); | 72 | explicit ControlConfig(KScreen::ConfigPtr config, QObject *parent = nullptr); | ||
65 | 73 | | |||
66 | OutputRetention getOutputRetention(const KScreen::OutputPtr &output) const; | 74 | OutputRetention getOutputRetention(const KScreen::OutputPtr &output) const; | ||
67 | OutputRetention getOutputRetention(const QString &outputId, const QString &outputName) const; | 75 | OutputRetention getOutputRetention(const QString &outputId, const QString &outputName) const; | ||
68 | void setOutputRetention(const KScreen::OutputPtr &output, OutputRetention value); | 76 | void setOutputRetention(const KScreen::OutputPtr &output, OutputRetention value); | ||
69 | void setOutputRetention(const QString &outputId, const QString &outputName, OutputRetention value); | 77 | void setOutputRetention(const QString &outputId, const QString &outputName, OutputRetention value); | ||
70 | 78 | | |||
71 | bool getAutoRotate(const KScreen::OutputPtr &output) const; | 79 | bool getAutoRotate(const KScreen::OutputPtr &output) const; | ||
72 | bool getAutoRotate(const QString &outputId, const QString &outputName) const; | 80 | bool getAutoRotate(const QString &outputId, const QString &outputName) const; | ||
73 | void setAutoRotate(const KScreen::OutputPtr &output, bool value); | 81 | void setAutoRotate(const KScreen::OutputPtr &output, bool value); | ||
74 | void setAutoRotate(const QString &outputId, const QString &outputName, bool value); | 82 | void setAutoRotate(const QString &outputId, const QString &outputName, bool value); | ||
75 | 83 | | |||
76 | QString dirPath() const override; | 84 | QString dirPath() const override; | ||
77 | QString filePath() const override; | 85 | QString filePath() const override; | ||
78 | 86 | | |||
79 | bool writeFile() override; | 87 | bool writeFile() override; | ||
88 | void activateWatcher() override; | ||||
80 | 89 | | |||
81 | private: | 90 | private: | ||
82 | QVariantList getOutputs() const; | 91 | QVariantList getOutputs() const; | ||
83 | void setOutputs(QVariantList outputsInfo); | 92 | void setOutputs(QVariantList outputsInfo); | ||
84 | bool infoIsOutput(const QVariantMap &info, const QString &outputId, const QString &outputName) const; | 93 | bool infoIsOutput(const QVariantMap &info, const QString &outputId, const QString &outputName) const; | ||
85 | ControlOutput* getOutputControl(const QString &outputId, const QString &outputName) const; | 94 | ControlOutput* getOutputControl(const QString &outputId, const QString &outputName) const; | ||
86 | 95 | | |||
87 | KScreen::ConfigPtr m_config; | 96 | KScreen::ConfigPtr m_config; | ||
Show All 26 Lines |