Changeset View
Changeset View
Standalone View
Standalone View
kcm/kcm.cpp
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 57 | KAboutData *about = new KAboutData(QStringLiteral("kcm_kscreen"), | |||
---|---|---|---|---|---|
60 | i18n("Manage and configure monitors and displays"), | 60 | i18n("Manage and configure monitors and displays"), | ||
61 | KAboutLicense::GPL, | 61 | KAboutLicense::GPL, | ||
62 | i18n("Copyright © 2019 Roman Gilg")); | 62 | i18n("Copyright © 2019 Roman Gilg")); | ||
63 | about->addAuthor(i18n("Roman Gilg"), | 63 | about->addAuthor(i18n("Roman Gilg"), | ||
64 | i18n("Maintainer"), | 64 | i18n("Maintainer"), | ||
65 | QStringLiteral("subdiff@gmail.com")); | 65 | QStringLiteral("subdiff@gmail.com")); | ||
66 | setAboutData(about); | 66 | setAboutData(about); | ||
67 | setButtons(Apply); | 67 | setButtons(Apply); | ||
68 | | ||||
69 | m_loadCompressor = new QTimer(this); | ||||
70 | m_loadCompressor->setInterval(1000); | ||||
71 | m_loadCompressor->setSingleShot(true); | ||||
72 | connect (m_loadCompressor, &QTimer::timeout, this, &KCMKScreen::load); | ||||
68 | } | 73 | } | ||
69 | 74 | | |||
70 | void KCMKScreen::configReady(ConfigOperation *op) | 75 | void KCMKScreen::configReady(ConfigOperation *op) | ||
71 | { | 76 | { | ||
72 | qCDebug(KSCREEN_KCM) << "Reading in config now."; | 77 | qCDebug(KSCREEN_KCM) << "Reading in config now."; | ||
73 | 78 | | |||
74 | if (op->hasError()) { | 79 | if (op->hasError()) { | ||
75 | m_config.reset(); | 80 | m_config.reset(); | ||
76 | setBackendError(true); | 81 | Q_EMIT backendError(); | ||
77 | return; | 82 | return; | ||
78 | } | 83 | } | ||
79 | m_config->setConfig(qobject_cast<GetConfigOperation*>(op)->config()); | 84 | m_config->setConfig(qobject_cast<GetConfigOperation*>(op)->config()); | ||
85 | setBackendReady(true); | ||||
80 | Q_EMIT perOutputScalingChanged(); | 86 | Q_EMIT perOutputScalingChanged(); | ||
81 | Q_EMIT primaryOutputSupportedChanged(); | 87 | Q_EMIT primaryOutputSupportedChanged(); | ||
82 | Q_EMIT outputReplicationSupportedChanged(); | 88 | Q_EMIT outputReplicationSupportedChanged(); | ||
83 | } | 89 | } | ||
84 | 90 | | |||
85 | void KCMKScreen::forceSave() | 91 | void KCMKScreen::forceSave() | ||
86 | { | 92 | { | ||
87 | doSave(true); | 93 | doSave(true); | ||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | 158 | if (!m_config) { | |||
153 | setNeedsSave(false); | 159 | setNeedsSave(false); | ||
154 | return; | 160 | return; | ||
155 | } | 161 | } | ||
156 | m_config->updateInitialConfig(); | 162 | m_config->updateInitialConfig(); | ||
157 | } | 163 | } | ||
158 | ); | 164 | ); | ||
159 | } | 165 | } | ||
160 | 166 | | |||
161 | bool KCMKScreen::backendError() const | 167 | bool KCMKScreen::backendReady() const | ||
162 | { | 168 | { | ||
163 | return m_backendError; | 169 | return m_backendReady; | ||
164 | } | 170 | } | ||
165 | 171 | | |||
166 | void KCMKScreen::setBackendError(bool error) | 172 | void KCMKScreen::setBackendReady(bool ready) | ||
167 | { | 173 | { | ||
168 | if (m_backendError == error) { | 174 | if (m_backendReady == ready) { | ||
169 | return; | 175 | return; | ||
170 | } | 176 | } | ||
171 | m_backendError = error; | 177 | m_backendReady = ready; | ||
172 | Q_EMIT backendErrorChanged(); | 178 | Q_EMIT backendReadyChanged(); | ||
173 | } | 179 | } | ||
174 | 180 | | |||
175 | OutputModel* KCMKScreen::outputModel() const | 181 | OutputModel* KCMKScreen::outputModel() const | ||
176 | { | 182 | { | ||
177 | if (!m_config) { | 183 | if (!m_config) { | ||
178 | return nullptr; | 184 | return nullptr; | ||
179 | } | 185 | } | ||
180 | return m_config->outputModel(); | 186 | return m_config->outputModel(); | ||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 252 | { | |||
247 | qCDebug(KSCREEN_KCM) << "Applying defaults."; | 253 | qCDebug(KSCREEN_KCM) << "Applying defaults."; | ||
248 | load(); | 254 | load(); | ||
249 | } | 255 | } | ||
250 | 256 | | |||
251 | void KCMKScreen::load() | 257 | void KCMKScreen::load() | ||
252 | { | 258 | { | ||
253 | qCDebug(KSCREEN_KCM) << "About to read in config."; | 259 | qCDebug(KSCREEN_KCM) << "About to read in config."; | ||
254 | 260 | | |||
255 | setBackendError(false); | 261 | setBackendReady(false); | ||
256 | setNeedsSave(false); | 262 | setNeedsSave(false); | ||
257 | if (!screenNormalized()) { | 263 | if (!screenNormalized()) { | ||
258 | Q_EMIT screenNormalizedChanged(); | 264 | Q_EMIT screenNormalizedChanged(); | ||
259 | } | 265 | } | ||
260 | fetchGlobalScale(); | 266 | fetchGlobalScale(); | ||
261 | 267 | | |||
262 | m_config.reset(new ConfigHandler(this)); | 268 | m_config.reset(new ConfigHandler(this)); | ||
263 | Q_EMIT perOutputScalingChanged(); | 269 | Q_EMIT perOutputScalingChanged(); | ||
264 | connect (m_config.get(), &ConfigHandler::outputModelChanged, | 270 | connect (m_config.get(), &ConfigHandler::outputModelChanged, | ||
265 | this, &KCMKScreen::outputModelChanged); | 271 | this, &KCMKScreen::outputModelChanged); | ||
266 | connect (m_config.get(), &ConfigHandler::outputConnect, | 272 | connect (m_config.get(), &ConfigHandler::outputConnect, | ||
267 | this, [this](bool connected) { | 273 | this, [this](bool connected) { | ||
268 | load(); | 274 | | ||
269 | Q_EMIT outputConnect(connected); | 275 | Q_EMIT outputConnect(connected); | ||
276 | setBackendReady(false); | ||||
277 | | ||||
278 | // Reload settings delayed such that daemon can update output values. | ||||
279 | m_loadCompressor->start(); | ||||
270 | }); | 280 | }); | ||
271 | connect (m_config.get(), &ConfigHandler::screenNormalizationUpdate, | 281 | connect (m_config.get(), &ConfigHandler::screenNormalizationUpdate, | ||
272 | this, &KCMKScreen::setScreenNormalized); | 282 | this, &KCMKScreen::setScreenNormalized); | ||
273 | connect (m_config.get(), &ConfigHandler::retentionChanged, | 283 | connect (m_config.get(), &ConfigHandler::retentionChanged, | ||
274 | this, &KCMKScreen::outputRetentionChanged); | 284 | this, &KCMKScreen::outputRetentionChanged); | ||
275 | 285 | | |||
276 | // This is a queued connection so that we can fire the event from | 286 | // This is a queued connection so that we can fire the event from | ||
277 | // within the save() call in case it failed. | 287 | // within the save() call in case it failed. | ||
▲ Show 20 Lines • Show All 116 Lines • Show Last 20 Lines |