Changeset View
Changeset View
Standalone View
Standalone View
kcm/config_handler.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 "../common/control.h" | ||||
20 | | ||||
21 | #include <kscreen/config.h> | ||||
22 | | ||||
23 | #include <memory> | ||||
24 | | ||||
25 | class OutputModel; | ||||
26 | | ||||
27 | class ConfigHandler : public QObject | ||||
28 | { | ||||
29 | Q_OBJECT | ||||
30 | public: | ||||
31 | explicit ConfigHandler (QObject *parent = nullptr); | ||||
32 | ~ConfigHandler() override = default; | ||||
33 | | ||||
34 | void setConfig(KScreen::ConfigPtr config); | ||||
35 | void updateInitialConfig(); | ||||
36 | | ||||
37 | OutputModel* outputModel() const { | ||||
38 | return m_outputs; | ||||
39 | } | ||||
40 | | ||||
41 | QSize normalizeScreen(); | ||||
42 | | ||||
43 | KScreen::ConfigPtr config() const { | ||||
44 | return m_config; | ||||
45 | } | ||||
46 | | ||||
47 | int retention() const; | ||||
48 | void setRetention(int retention); | ||||
49 | | ||||
50 | void writeControl(); | ||||
51 | | ||||
52 | void checkNeedsSave(); | ||||
53 | | ||||
54 | Q_SIGNALS: | ||||
55 | void outputModelChanged(); | ||||
56 | void changed(); | ||||
57 | void screenNormalizationUpdate(bool normalized); | ||||
58 | void needsSaveChecked(bool need); | ||||
59 | void retentionChanged(); | ||||
60 | void outputConnect(bool connected); | ||||
61 | | ||||
62 | private: | ||||
63 | void checkScreenNormalization(); | ||||
64 | QSize screenSize() const; | ||||
65 | Control::OutputRetention getRetention() const; | ||||
66 | void primaryOutputSelected(int index); | ||||
67 | void primaryOutputChanged(const KScreen::OutputPtr &output); | ||||
68 | void initOutput(const KScreen::OutputPtr &output); | ||||
69 | | ||||
70 | KScreen::ConfigPtr m_config = nullptr; | ||||
71 | KScreen::ConfigPtr m_initialConfig; | ||||
72 | OutputModel *m_outputs = nullptr; | ||||
73 | | ||||
74 | std::unique_ptr<ControlConfig> m_control; | ||||
75 | Control::OutputRetention m_initialRetention = Control::OutputRetention:: | ||||
76 | Undefined; | ||||
77 | QSize m_lastNormalizedScreenSize; | ||||
78 | }; |