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