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 Control | 25 | class Control : public QObject | ||
26 | { | 26 | { | ||
27 | Q_GADGET | 27 | Q_OBJECT | ||
28 | public: | 28 | public: | ||
29 | enum class OutputRetention { | 29 | enum class OutputRetention { | ||
30 | Undefined = -1, | 30 | Undefined = -1, | ||
31 | Global = 0, | 31 | Global = 0, | ||
32 | Individual = 1, | 32 | Individual = 1, | ||
33 | }; | 33 | }; | ||
34 | Q_ENUM(OutputRetention) | 34 | Q_ENUM(OutputRetention) | ||
35 | 35 | | |||
36 | explicit Control(QObject *parent = nullptr); | ||||
36 | 37 | | |||
37 | virtual ~Control() = default; | 38 | | ||
39 | ~Control() override = default; | ||||
davidedmundson: -> override | |||||
38 | 40 | | |||
39 | protected: | 41 | protected: | ||
40 | virtual QString dirPath() const; | 42 | virtual QString dirPath() const; | ||
41 | virtual QString filePath() const = 0; | 43 | virtual QString filePath() const = 0; | ||
42 | QString filePathFromHash(const QString &hash) const; | 44 | QString filePathFromHash(const QString &hash) const; | ||
43 | 45 | | |||
44 | static OutputRetention convertVariantToOutputRetention(QVariant variant); | 46 | static OutputRetention convertVariantToOutputRetention(QVariant variant); | ||
45 | 47 | | |||
46 | private: | 48 | private: | ||
47 | static QString s_dirName; | 49 | static QString s_dirName; | ||
48 | }; | 50 | }; | ||
49 | 51 | | |||
50 | class ControlConfig : public Control | 52 | class ControlConfig : public Control | ||
51 | { | 53 | { | ||
52 | Q_GADGET | 54 | Q_OBJECT | ||
53 | public: | 55 | public: | ||
54 | ControlConfig(KScreen::ConfigPtr config); | 56 | explicit ControlConfig(KScreen::ConfigPtr config, QObject *parent = nullptr); | ||
55 | 57 | | |||
56 | OutputRetention getOutputRetention(const KScreen::OutputPtr &output) const; | 58 | OutputRetention getOutputRetention(const KScreen::OutputPtr &output) const; | ||
57 | OutputRetention getOutputRetention(const QString &outputId, const QString &outputName) const; | 59 | OutputRetention getOutputRetention(const QString &outputId, const QString &outputName) const; | ||
58 | void setOutputRetention(const KScreen::OutputPtr &output, OutputRetention value); | 60 | void setOutputRetention(const KScreen::OutputPtr &output, OutputRetention value); | ||
59 | void setOutputRetention(const QString &outputId, const QString &outputName, OutputRetention value); | 61 | void setOutputRetention(const QString &outputId, const QString &outputName, OutputRetention value); | ||
60 | 62 | | |||
61 | bool writeFile(); | 63 | bool writeFile(); | ||
62 | 64 | | |||
63 | QString dirPath() const override; | 65 | QString dirPath() const override; | ||
64 | QString filePath() const override; | 66 | QString filePath() const override; | ||
65 | 67 | | |||
66 | private: | 68 | private: | ||
67 | QVariantList getOutputs() const; | 69 | QVariantList getOutputs() const; | ||
68 | void setOutputs(QVariantList outputsInfo); | 70 | void setOutputs(QVariantList outputsInfo); | ||
69 | bool infoIsOutput(const QVariantMap &info, const QString &outputId, const QString &outputName) const; | 71 | bool infoIsOutput(const QVariantMap &info, const QString &outputId, const QString &outputName) const; | ||
70 | 72 | | |||
71 | KScreen::ConfigPtr m_config; | 73 | KScreen::ConfigPtr m_config; | ||
72 | QVariantMap m_info; | 74 | QVariantMap m_info; | ||
73 | QStringList m_duplicateOutputIds; | 75 | QStringList m_duplicateOutputIds; | ||
74 | }; | 76 | }; | ||
75 | 77 | | |||
76 | class ControlOutput : public Control | 78 | class ControlOutput : public Control | ||
77 | { | 79 | { | ||
78 | Q_GADGET | 80 | Q_OBJECT | ||
79 | public: | 81 | public: | ||
80 | ControlOutput(KScreen::OutputPtr output); | 82 | explicit ControlOutput(KScreen::OutputPtr output, QObject *parent = nullptr); | ||
81 | 83 | | |||
82 | // TODO: scale auto value | 84 | // TODO: scale auto value | ||
83 | 85 | | |||
84 | QString dirPath() const override; | 86 | QString dirPath() const override; | ||
85 | QString filePath() const override; | 87 | QString filePath() const override; | ||
86 | 88 | | |||
87 | private: | 89 | private: | ||
88 | KScreen::OutputPtr m_output; | 90 | KScreen::OutputPtr m_output; | ||
89 | }; | 91 | }; | ||
90 | 92 | | |||
91 | #endif | 93 | #endif |
-> override