Changeset View
Changeset View
Standalone View
Standalone View
kcm/kcm.cpp
Show All 15 Lines | |||||
16 | *********************************************************************/ | 16 | *********************************************************************/ | ||
17 | #include "kcm.h" | 17 | #include "kcm.h" | ||
18 | 18 | | |||
19 | #include "config_handler.h" | 19 | #include "config_handler.h" | ||
20 | #include "kcm_screen_debug.h" | 20 | #include "kcm_screen_debug.h" | ||
21 | #include "output_identifier.h" | 21 | #include "output_identifier.h" | ||
22 | #include "output_model.h" | 22 | #include "output_model.h" | ||
23 | #include "../common/control.h" | 23 | #include "../common/control.h" | ||
24 | #include "../common/orientation_sensor.h" | ||||
24 | 25 | | |||
25 | #include <kscreen/config.h> | 26 | #include <kscreen/config.h> | ||
26 | #include <kscreen/getconfigoperation.h> | 27 | #include <kscreen/getconfigoperation.h> | ||
27 | #include <kscreen/log.h> | 28 | #include <kscreen/log.h> | ||
28 | #include <kscreen/output.h> | 29 | #include <kscreen/output.h> | ||
29 | #include <kscreen/setconfigoperation.h> | 30 | #include <kscreen/setconfigoperation.h> | ||
30 | 31 | | |||
31 | #include <KAboutData> | 32 | #include <KAboutData> | ||
Show All 33 Lines | 64 | about->addAuthor(i18n("Roman Gilg"), | |||
65 | QStringLiteral("subdiff@gmail.com")); | 66 | QStringLiteral("subdiff@gmail.com")); | ||
66 | setAboutData(about); | 67 | setAboutData(about); | ||
67 | setButtons(Apply); | 68 | setButtons(Apply); | ||
68 | 69 | | |||
69 | m_loadCompressor = new QTimer(this); | 70 | m_loadCompressor = new QTimer(this); | ||
70 | m_loadCompressor->setInterval(1000); | 71 | m_loadCompressor->setInterval(1000); | ||
71 | m_loadCompressor->setSingleShot(true); | 72 | m_loadCompressor->setSingleShot(true); | ||
72 | connect (m_loadCompressor, &QTimer::timeout, this, &KCMKScreen::load); | 73 | connect (m_loadCompressor, &QTimer::timeout, this, &KCMKScreen::load); | ||
74 | | ||||
75 | m_orientationSensor = new OrientationSensor(this); | ||||
76 | connect(m_orientationSensor, &OrientationSensor::availableChanged, | ||||
77 | this, &KCMKScreen::orientationSensorAvailableChanged); | ||||
73 | } | 78 | } | ||
74 | 79 | | |||
75 | void KCMKScreen::configReady(ConfigOperation *op) | 80 | void KCMKScreen::configReady(ConfigOperation *op) | ||
76 | { | 81 | { | ||
77 | qCDebug(KSCREEN_KCM) << "Reading in config now."; | 82 | qCDebug(KSCREEN_KCM) << "Reading in config now."; | ||
78 | | ||||
79 | if (op->hasError()) { | 83 | if (op->hasError()) { | ||
80 | m_config.reset(); | 84 | m_config.reset(); | ||
81 | Q_EMIT backendError(); | 85 | Q_EMIT backendError(); | ||
82 | return; | 86 | return; | ||
83 | } | 87 | } | ||
84 | m_config->setConfig(qobject_cast<GetConfigOperation*>(op)->config()); | 88 | | ||
89 | KScreen::ConfigPtr config = qobject_cast<GetConfigOperation*>(op)->config(); | ||||
90 | const bool autoRotationSupported = | ||||
91 | config->supportedFeatures() & (KScreen::Config::Feature::AutoRotation | ||||
92 | | KScreen::Config::Feature::TabletMode); | ||||
93 | m_orientationSensor->setEnabled(autoRotationSupported); | ||||
94 | | ||||
95 | m_config->setConfig(config); | ||||
85 | setBackendReady(true); | 96 | setBackendReady(true); | ||
86 | Q_EMIT perOutputScalingChanged(); | 97 | Q_EMIT perOutputScalingChanged(); | ||
87 | Q_EMIT primaryOutputSupportedChanged(); | 98 | Q_EMIT primaryOutputSupportedChanged(); | ||
88 | Q_EMIT outputReplicationSupportedChanged(); | 99 | Q_EMIT outputReplicationSupportedChanged(); | ||
100 | Q_EMIT tabletModeAvailableChanged(); | ||||
101 | Q_EMIT autoRotationSupportedChanged(); | ||||
89 | } | 102 | } | ||
90 | 103 | | |||
91 | void KCMKScreen::forceSave() | 104 | void KCMKScreen::forceSave() | ||
92 | { | 105 | { | ||
93 | doSave(true); | 106 | doSave(true); | ||
94 | } | 107 | } | ||
95 | 108 | | |||
96 | void KCMKScreen::save() | 109 | void KCMKScreen::save() | ||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | 115 | { | |||
154 | // The 1000ms is a legacy value tested to work for randr having | 167 | // The 1000ms is a legacy value tested to work for randr having | ||
155 | // enough time to change configuration. | 168 | // enough time to change configuration. | ||
156 | QTimer::singleShot(1000, this, | 169 | QTimer::singleShot(1000, this, | ||
157 | [this] () { | 170 | [this] () { | ||
158 | if (!m_config) { | 171 | if (!m_config) { | ||
159 | setNeedsSave(false); | 172 | setNeedsSave(false); | ||
160 | return; | 173 | return; | ||
161 | } | 174 | } | ||
162 | m_config->updateInitialConfig(); | 175 | m_config->updateInitialData(); | ||
163 | } | 176 | } | ||
164 | ); | 177 | ); | ||
165 | } | 178 | } | ||
166 | 179 | | |||
167 | bool KCMKScreen::backendReady() const | 180 | bool KCMKScreen::backendReady() const | ||
168 | { | 181 | { | ||
169 | return m_backendReady; | 182 | return m_backendReady; | ||
170 | } | 183 | } | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | |||||
234 | { | 247 | { | ||
235 | if (!m_config || !m_config->config()) { | 248 | if (!m_config || !m_config->config()) { | ||
236 | return false; | 249 | return false; | ||
237 | } | 250 | } | ||
238 | return m_config->config()->supportedFeatures().testFlag(Config::Feature:: | 251 | return m_config->config()->supportedFeatures().testFlag(Config::Feature:: | ||
239 | OutputReplication); | 252 | OutputReplication); | ||
240 | } | 253 | } | ||
241 | 254 | | |||
255 | bool KCMKScreen::autoRotationSupported() const | ||||
256 | { | ||||
257 | if (!m_config || !m_config->config()) { | ||||
258 | return false; | ||||
259 | } | ||||
260 | return m_config->config()->supportedFeatures() & (KScreen::Config::Feature::AutoRotation | ||||
261 | | KScreen::Config::Feature::TabletMode); | ||||
262 | } | ||||
263 | | ||||
264 | bool KCMKScreen::orientationSensorAvailable() const | ||||
265 | { | ||||
266 | return m_orientationSensor->available(); | ||||
267 | } | ||||
268 | | ||||
269 | bool KCMKScreen::tabletModeAvailable() const | ||||
270 | { | ||||
271 | if (!m_config || !m_config->config()) { | ||||
272 | return false; | ||||
273 | } | ||||
274 | return m_config->config()->tabletModeAvailable(); | ||||
275 | } | ||||
276 | | ||||
242 | void KCMKScreen::setScreenNormalized(bool normalized) | 277 | void KCMKScreen::setScreenNormalized(bool normalized) | ||
243 | { | 278 | { | ||
244 | if (m_screenNormalized == normalized) { | 279 | if (m_screenNormalized == normalized) { | ||
245 | return; | 280 | return; | ||
246 | } | 281 | } | ||
247 | m_screenNormalized = normalized; | 282 | m_screenNormalized = normalized; | ||
248 | Q_EMIT screenNormalizedChanged(); | 283 | Q_EMIT screenNormalizedChanged(); | ||
249 | } | 284 | } | ||
▲ Show 20 Lines • Show All 164 Lines • Show Last 20 Lines |