Changeset View
Changeset View
Standalone View
Standalone View
kcm/config_handler.cpp
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | 36 | { | |||
---|---|---|---|---|---|
62 | connect(m_config.data(), &KScreen::Config::outputRemoved, | 62 | connect(m_config.data(), &KScreen::Config::outputRemoved, | ||
63 | this, [this]() { Q_EMIT outputConnect(false); }); | 63 | this, [this]() { Q_EMIT outputConnect(false); }); | ||
64 | connect(m_config.data(), &KScreen::Config::primaryOutputChanged, | 64 | connect(m_config.data(), &KScreen::Config::primaryOutputChanged, | ||
65 | this, &ConfigHandler::primaryOutputChanged); | 65 | this, &ConfigHandler::primaryOutputChanged); | ||
66 | 66 | | |||
67 | Q_EMIT outputModelChanged(); | 67 | Q_EMIT outputModelChanged(); | ||
68 | } | 68 | } | ||
69 | 69 | | |||
70 | void ConfigHandler::resetScale(const KScreen::OutputPtr &output) | ||||
71 | { | ||||
72 | // Load scale control (either not set, same or windowing system does not transmit scale). | ||||
73 | const qreal scale = m_control->getScale(output); | ||||
74 | if (scale > 0) { | ||||
75 | output->setScale(scale); | ||||
76 | for (auto initialOutput : m_initialConfig->outputs()) { | ||||
77 | if (initialOutput->id() == output->id()) { | ||||
78 | initialOutput->setScale(scale); | ||||
79 | break; | ||||
80 | } | ||||
81 | } | ||||
82 | } | ||||
83 | } | ||||
84 | | ||||
70 | void ConfigHandler::initOutput(const KScreen::OutputPtr &output) | 85 | void ConfigHandler::initOutput(const KScreen::OutputPtr &output) | ||
71 | { | 86 | { | ||
72 | if (output->isConnected()) { | 87 | if (output->isConnected()) { | ||
88 | resetScale(output); | ||||
73 | m_outputs->add(output); | 89 | m_outputs->add(output); | ||
74 | } | 90 | } | ||
75 | connect(output.data(), &KScreen::Output::isConnectedChanged, | 91 | connect(output.data(), &KScreen::Output::isConnectedChanged, | ||
76 | this, [this, output]() { | 92 | this, [this, output]() { | ||
77 | Q_EMIT outputConnect(output->isConnected()); | 93 | Q_EMIT outputConnect(output->isConnected()); | ||
78 | }); | 94 | }); | ||
79 | } | 95 | } | ||
80 | 96 | | |||
81 | void ConfigHandler::updateInitialConfig() | 97 | void ConfigHandler::updateInitialConfig() | ||
82 | { | 98 | { | ||
83 | m_initialRetention = getRetention(); | 99 | m_initialRetention = getRetention(); | ||
84 | connect(new GetConfigOperation(), &GetConfigOperation::finished, | 100 | connect(new GetConfigOperation(), &GetConfigOperation::finished, | ||
85 | this, [this](ConfigOperation *op) { | 101 | this, [this](ConfigOperation *op) { | ||
86 | if (op->hasError()) { | 102 | if (op->hasError()) { | ||
87 | return; | 103 | return; | ||
88 | } | 104 | } | ||
89 | m_initialConfig = qobject_cast<GetConfigOperation*>(op)->config(); | 105 | m_initialConfig = qobject_cast<GetConfigOperation*>(op)->config(); | ||
106 | for (auto output : m_config->outputs()) { | ||||
107 | resetScale(output); | ||||
108 | } | ||||
90 | checkNeedsSave(); | 109 | checkNeedsSave(); | ||
91 | }); | 110 | }); | ||
92 | } | 111 | } | ||
93 | 112 | | |||
94 | void ConfigHandler::checkNeedsSave() | 113 | void ConfigHandler::checkNeedsSave() | ||
95 | { | 114 | { | ||
96 | if (m_config->supportedFeatures() & | 115 | if (m_config->supportedFeatures() & | ||
97 | KScreen::Config::Feature::PrimaryDisplay) { | 116 | KScreen::Config::Feature::PrimaryDisplay) { | ||
▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Line(s) | 261 | { | |||
257 | for (const auto &output : m_config->connectedOutputs()) { | 276 | for (const auto &output : m_config->connectedOutputs()) { | ||
258 | m_control->setOutputRetention(output, ret); | 277 | m_control->setOutputRetention(output, ret); | ||
259 | } | 278 | } | ||
260 | checkNeedsSave(); | 279 | checkNeedsSave(); | ||
261 | Q_EMIT retentionChanged(); | 280 | Q_EMIT retentionChanged(); | ||
262 | Q_EMIT changed(); | 281 | Q_EMIT changed(); | ||
263 | } | 282 | } | ||
264 | 283 | | |||
284 | qreal ConfigHandler::scale(const KScreen::OutputPtr &output) const | ||||
285 | { | ||||
286 | return m_control->getScale(output); | ||||
287 | } | ||||
288 | | ||||
289 | void ConfigHandler::setScale(KScreen::OutputPtr &output, qreal scale) | ||||
290 | { | ||||
291 | m_control->setScale(output, scale); | ||||
292 | } | ||||
293 | | ||||
265 | KScreen::OutputPtr ConfigHandler::replicationSource(const KScreen::OutputPtr &output) const | 294 | KScreen::OutputPtr ConfigHandler::replicationSource(const KScreen::OutputPtr &output) const | ||
266 | { | 295 | { | ||
267 | return m_control->getReplicationSource(output); | 296 | return m_control->getReplicationSource(output); | ||
268 | } | 297 | } | ||
269 | 298 | | |||
270 | void ConfigHandler::setReplicationSource(KScreen::OutputPtr &output, | 299 | void ConfigHandler::setReplicationSource(KScreen::OutputPtr &output, | ||
271 | const KScreen::OutputPtr &source) | 300 | const KScreen::OutputPtr &source) | ||
272 | { | 301 | { | ||
Show All 10 Lines |