Changeset View
Changeset View
Standalone View
Standalone View
kcm/config_handler.cpp
Show All 30 Lines | 30 | ConfigHandler::ConfigHandler(QObject *parent) | |||
---|---|---|---|---|---|
31 | : QObject(parent) | 31 | : QObject(parent) | ||
32 | { | 32 | { | ||
33 | } | 33 | } | ||
34 | 34 | | |||
35 | void ConfigHandler::setConfig(KScreen::ConfigPtr config) | 35 | void ConfigHandler::setConfig(KScreen::ConfigPtr config) | ||
36 | { | 36 | { | ||
37 | m_config = config; | 37 | m_config = config; | ||
38 | m_initialConfig = m_config->clone(); | 38 | m_initialConfig = m_config->clone(); | ||
39 | m_initialControl.reset(new ControlConfig(m_initialConfig)); | ||||
davidedmundson: why here?
The point of your control config is that it's independent of the config. | |||||
When the initial config is reset, the initial control should be reset as well at some point. Do you mean that question purely on a semantic level? romangg: When the initial config is reset, the initial control should be reset as well at some point. Do… | |||||
40 | | ||||
39 | KScreen::ConfigMonitor::instance()->addConfig(m_config); | 41 | KScreen::ConfigMonitor::instance()->addConfig(m_config); | ||
40 | m_control.reset(new ControlConfig(config)); | 42 | m_control.reset(new ControlConfig(config)); | ||
41 | 43 | | |||
42 | m_outputs = new OutputModel(this); | 44 | m_outputs = new OutputModel(this); | ||
43 | connect(m_outputs, &OutputModel::positionChanged, | 45 | connect(m_outputs, &OutputModel::positionChanged, | ||
44 | this, &ConfigHandler::checkScreenNormalization); | 46 | this, &ConfigHandler::checkScreenNormalization); | ||
45 | connect(m_outputs, &OutputModel::sizeChanged, | 47 | connect(m_outputs, &OutputModel::sizeChanged, | ||
46 | this, &ConfigHandler::checkScreenNormalization); | 48 | this, &ConfigHandler::checkScreenNormalization); | ||
47 | 49 | | |||
48 | for (const KScreen::OutputPtr &output : config->outputs()) { | 50 | for (const KScreen::OutputPtr &output : config->outputs()) { | ||
49 | initOutput(output); | 51 | initOutput(output); | ||
50 | } | 52 | } | ||
51 | m_lastNormalizedScreenSize = screenSize(); | 53 | m_lastNormalizedScreenSize = screenSize(); | ||
54 | | ||||
55 | // TODO: put this into m_initialControl | ||||
52 | m_initialRetention = getRetention(); | 56 | m_initialRetention = getRetention(); | ||
53 | Q_EMIT retentionChanged(); | 57 | Q_EMIT retentionChanged(); | ||
54 | 58 | | |||
55 | connect(m_outputs, &OutputModel::changed, | 59 | connect(m_outputs, &OutputModel::changed, | ||
56 | this, [this]() { | 60 | this, [this]() { | ||
57 | checkNeedsSave(); | 61 | checkNeedsSave(); | ||
58 | Q_EMIT changed(); | 62 | Q_EMIT changed(); | ||
59 | }); | 63 | }); | ||
Show All 13 Lines | 76 | if (output->isConnected()) { | |||
73 | m_outputs->add(output); | 77 | m_outputs->add(output); | ||
74 | } | 78 | } | ||
75 | connect(output.data(), &KScreen::Output::isConnectedChanged, | 79 | connect(output.data(), &KScreen::Output::isConnectedChanged, | ||
76 | this, [this, output]() { | 80 | this, [this, output]() { | ||
77 | Q_EMIT outputConnect(output->isConnected()); | 81 | Q_EMIT outputConnect(output->isConnected()); | ||
78 | }); | 82 | }); | ||
79 | } | 83 | } | ||
80 | 84 | | |||
81 | void ConfigHandler::updateInitialConfig() | 85 | void ConfigHandler::updateInitialData() | ||
82 | { | 86 | { | ||
83 | m_initialRetention = getRetention(); | 87 | m_initialRetention = getRetention(); | ||
84 | connect(new GetConfigOperation(), &GetConfigOperation::finished, | 88 | connect(new GetConfigOperation(), &GetConfigOperation::finished, | ||
85 | this, [this](ConfigOperation *op) { | 89 | this, [this](ConfigOperation *op) { | ||
86 | if (op->hasError()) { | 90 | if (op->hasError()) { | ||
87 | return; | 91 | return; | ||
88 | } | 92 | } | ||
89 | m_initialConfig = qobject_cast<GetConfigOperation*>(op)->config(); | 93 | m_initialConfig = qobject_cast<GetConfigOperation*>(op)->config(); | ||
94 | m_initialControl.reset(new ControlConfig(m_initialConfig)); | ||||
90 | checkNeedsSave(); | 95 | checkNeedsSave(); | ||
91 | }); | 96 | }); | ||
92 | } | 97 | } | ||
93 | 98 | | |||
94 | void ConfigHandler::checkNeedsSave() | 99 | void ConfigHandler::checkNeedsSave() | ||
95 | { | 100 | { | ||
96 | if (m_config->supportedFeatures() & | 101 | if (m_config->supportedFeatures() & | ||
97 | KScreen::Config::Feature::PrimaryDisplay) { | 102 | KScreen::Config::Feature::PrimaryDisplay) { | ||
Show All 25 Lines | 127 | if (output->isEnabled() != initialOutput->isEnabled()) { | |||
123 | needsSave = true; | 128 | needsSave = true; | ||
124 | } | 129 | } | ||
125 | if (output->isEnabled()) { | 130 | if (output->isEnabled()) { | ||
126 | needsSave |= output->currentModeId() != | 131 | needsSave |= output->currentModeId() != | ||
127 | initialOutput->currentModeId() | 132 | initialOutput->currentModeId() | ||
128 | || output->pos() != initialOutput->pos() | 133 | || output->pos() != initialOutput->pos() | ||
129 | || output->scale() != initialOutput->scale() | 134 | || output->scale() != initialOutput->scale() | ||
130 | || output->rotation() != initialOutput->rotation() | 135 | || output->rotation() != initialOutput->rotation() | ||
131 | || output->replicationSource() != initialOutput->replicationSource(); | 136 | || output->replicationSource() != initialOutput->replicationSource() | ||
137 | || autoRotate(output) != m_initialControl->getAutoRotate(output); | ||||
132 | } | 138 | } | ||
133 | if (needsSave) { | 139 | if (needsSave) { | ||
134 | Q_EMIT needsSaveChecked(true); | 140 | Q_EMIT needsSaveChecked(true); | ||
135 | return; | 141 | return; | ||
136 | } | 142 | } | ||
137 | break; | 143 | break; | ||
138 | } | 144 | } | ||
139 | } | 145 | } | ||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Line(s) | 248 | { | |||
257 | for (const auto &output : m_config->connectedOutputs()) { | 263 | for (const auto &output : m_config->connectedOutputs()) { | ||
258 | m_control->setOutputRetention(output, ret); | 264 | m_control->setOutputRetention(output, ret); | ||
259 | } | 265 | } | ||
260 | checkNeedsSave(); | 266 | checkNeedsSave(); | ||
261 | Q_EMIT retentionChanged(); | 267 | Q_EMIT retentionChanged(); | ||
262 | Q_EMIT changed(); | 268 | Q_EMIT changed(); | ||
263 | } | 269 | } | ||
264 | 270 | | |||
271 | bool ConfigHandler::autoRotate(const KScreen::OutputPtr &output) const | ||||
272 | { | ||||
273 | return m_control->getAutoRotate(output); | ||||
274 | } | ||||
275 | | ||||
276 | void ConfigHandler::setAutoRotate(KScreen::OutputPtr &output, bool autoRotate) | ||||
277 | { | ||||
278 | m_control->setAutoRotate(output, autoRotate); | ||||
279 | } | ||||
280 | | ||||
265 | void ConfigHandler::writeControl() | 281 | void ConfigHandler::writeControl() | ||
266 | { | 282 | { | ||
267 | if (!m_control) { | 283 | if (!m_control) { | ||
268 | return; | 284 | return; | ||
269 | } | 285 | } | ||
270 | m_control->writeFile(); | 286 | m_control->writeFile(); | ||
271 | } | 287 | } |
why here?
The point of your control config is that it's independent of the config.