Changeset View
Changeset View
Standalone View
Standalone View
kcm/kcm.h
- This file was added.
1 | /******************************************************************** | ||||
---|---|---|---|---|---|
2 | Copyright © 2019 Roman Gilg <subdiff@gmail.com> | ||||
3 | | ||||
4 | This program is free software; you can redistribute it and/or modify | ||||
5 | it under the terms of the GNU General Public License as published by | ||||
6 | the Free Software Foundation; either version 2 of the License, or | ||||
7 | (at your option) any later version. | ||||
8 | | ||||
9 | This program is distributed in the hope that it will be useful, | ||||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | GNU General Public License for more details. | ||||
13 | | ||||
14 | You should have received a copy of the GNU General Public License | ||||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
16 | *********************************************************************/ | ||||
17 | #pragma once | ||||
18 | | ||||
19 | #include <KQuickAddons/ConfigModule> | ||||
20 | | ||||
21 | namespace KScreen | ||||
22 | { | ||||
23 | class ConfigOperation; | ||||
24 | } | ||||
25 | | ||||
26 | class ConfigHandler; | ||||
27 | class OutputIdentifier; | ||||
28 | class OutputModel; | ||||
29 | | ||||
30 | class KCMKScreen : public KQuickAddons::ConfigModule | ||||
31 | { | ||||
32 | Q_OBJECT | ||||
33 | | ||||
34 | Q_PROPERTY(OutputModel *outputModel READ outputModel | ||||
35 | NOTIFY outputModelChanged) | ||||
36 | Q_PROPERTY(bool backendError READ backendError | ||||
37 | NOTIFY backendErrorChanged) | ||||
38 | Q_PROPERTY(bool screenNormalized READ screenNormalized | ||||
39 | NOTIFY screenNormalizedChanged) | ||||
40 | Q_PROPERTY(bool perOutputScaling READ perOutputScaling | ||||
41 | NOTIFY perOutputScalingChanged) | ||||
42 | Q_PROPERTY(bool primaryOutputSupported READ primaryOutputSupported | ||||
43 | NOTIFY primaryOutputSupportedChanged) | ||||
44 | Q_PROPERTY(qreal globalScale READ globalScale WRITE setGlobalScale | ||||
45 | NOTIFY globalScaleChanged) | ||||
46 | Q_PROPERTY(int outputRetention READ outputRetention WRITE setOutputRetention | ||||
47 | NOTIFY outputRetentionChanged) | ||||
48 | | ||||
49 | public: | ||||
50 | explicit KCMKScreen (QObject *parent = nullptr, | ||||
51 | const QVariantList &args = QVariantList()); | ||||
52 | ~KCMKScreen() override = default; | ||||
53 | | ||||
54 | void load() override; | ||||
55 | void save() override; | ||||
56 | void defaults() override; | ||||
57 | | ||||
58 | OutputModel* outputModel() const; | ||||
59 | | ||||
60 | Q_INVOKABLE void identifyOutputs(); | ||||
61 | | ||||
62 | bool backendError() const; | ||||
63 | | ||||
64 | Q_INVOKABLE QSize normalizeScreen() const; | ||||
65 | bool screenNormalized() const; | ||||
66 | | ||||
67 | bool perOutputScaling() const; | ||||
68 | bool primaryOutputSupported() const; | ||||
69 | | ||||
70 | qreal globalScale() const; | ||||
71 | void setGlobalScale(qreal scale); | ||||
72 | | ||||
73 | int outputRetention() const; | ||||
74 | void setOutputRetention(int retention); | ||||
75 | | ||||
76 | Q_INVOKABLE void forceSave(); | ||||
77 | void doSave(bool force); | ||||
78 | | ||||
79 | Q_SIGNALS: | ||||
80 | void backendErrorChanged(); | ||||
81 | void outputModelChanged(); | ||||
82 | void changed(); | ||||
83 | void screenNormalizedChanged(); | ||||
84 | void perOutputScalingChanged(); | ||||
85 | void primaryOutputSupportedChanged(); | ||||
86 | void globalScaleChanged(); | ||||
87 | void outputRetentionChanged(); | ||||
88 | void dangerousSave(); | ||||
89 | void errorOnSave(); | ||||
90 | void globalScaleWritten(); | ||||
91 | void outputConnect(bool connected); | ||||
92 | | ||||
93 | private: | ||||
94 | void setBackendError(bool error); | ||||
95 | void setScreenNormalized(bool normalized); | ||||
96 | | ||||
97 | void fetchGlobalScale(); | ||||
98 | void writeGlobalScale(); | ||||
99 | | ||||
100 | void configReady(KScreen::ConfigOperation *op); | ||||
101 | void continueNeedsSaveCheck(bool needs); | ||||
102 | | ||||
103 | std::unique_ptr<OutputIdentifier> m_outputIdentifier; | ||||
104 | std::unique_ptr<ConfigHandler> m_config; | ||||
105 | bool m_backendError = false; | ||||
106 | bool m_screenNormalized = true; | ||||
107 | double m_globalScale = 1.; | ||||
108 | double m_initialGlobalScale = 1.; | ||||
109 | }; |