Changeset View
Changeset View
Standalone View
Standalone View
kded/config.cpp
Show First 20 Lines • Show All 111 Lines • ▼ Show 20 Line(s) | 95 | { | |||
---|---|---|---|---|---|
112 | } | 112 | } | ||
113 | 113 | | |||
114 | QJsonDocument parser; | 114 | QJsonDocument parser; | ||
115 | QVariantList outputs = parser.fromJson(file.readAll()).toVariant().toList(); | 115 | QVariantList outputs = parser.fromJson(file.readAll()).toVariant().toList(); | ||
116 | Output::readInOutputs(config->data(), outputs); | 116 | Output::readInOutputs(config->data(), outputs); | ||
117 | 117 | | |||
118 | QSize screenSize; | 118 | QSize screenSize; | ||
119 | for (const auto &output : config->data()->outputs()) { | 119 | for (const auto &output : config->data()->outputs()) { | ||
120 | if (!output->isConnected() || !output->isEnabled()) { | 120 | if (!output->isPositionable()) { | ||
121 | continue; | 121 | continue; | ||
122 | } | 122 | } | ||
123 | 123 | | |||
124 | const QRect geom = output->geometry(); | 124 | const QRect geom = output->geometry(); | ||
125 | if (geom.x() + geom.width() > screenSize.width()) { | 125 | if (geom.x() + geom.width() > screenSize.width()) { | ||
126 | screenSize.setWidth(geom.x() + geom.width()); | 126 | screenSize.setWidth(geom.x() + geom.width()); | ||
127 | } | 127 | } | ||
128 | if (geom.y() + geom.height() > screenSize.height()) { | 128 | if (geom.y() + geom.height() > screenSize.height()) { | ||
Show All 37 Lines | |||||
166 | { | 166 | { | ||
167 | if (id().isEmpty()) { | 167 | if (id().isEmpty()) { | ||
168 | return false; | 168 | return false; | ||
169 | } | 169 | } | ||
170 | const KScreen::OutputList outputs = m_data->outputs(); | 170 | const KScreen::OutputList outputs = m_data->outputs(); | ||
171 | 171 | | |||
172 | const auto control = ControlConfig(m_data); | 172 | const auto control = ControlConfig(m_data); | ||
173 | 173 | | |||
174 | const auto oldConfig = readFile(); | ||||
175 | KScreen::OutputList oldOutputs; | ||||
176 | if (oldConfig) { | ||||
177 | oldOutputs = oldConfig->data()->outputs(); | ||||
178 | } | ||||
179 | | ||||
174 | QVariantList outputList; | 180 | QVariantList outputList; | ||
175 | Q_FOREACH(const KScreen::OutputPtr &output, outputs) { | 181 | for (const KScreen::OutputPtr &output : outputs) { | ||
176 | QVariantMap info; | 182 | QVariantMap info; | ||
177 | 183 | | |||
184 | const auto oldOutputIt = std::find_if(oldOutputs.constBegin(), oldOutputs.constEnd(), | ||||
185 | [output](const KScreen::OutputPtr &out) { | ||||
186 | return out->hashMd5() == output->hashMd5(); | ||||
187 | } | ||||
188 | ); | ||||
189 | const KScreen::OutputPtr oldOutput = oldOutputIt != oldOutputs.constEnd() ? *oldOutputIt : | ||||
190 | nullptr; | ||||
191 | | ||||
178 | if (!output->isConnected()) { | 192 | if (!output->isConnected()) { | ||
179 | continue; | 193 | continue; | ||
180 | } | 194 | } | ||
181 | if (!Output::writeGlobalPart(output, info)) { | | |||
182 | continue; | | |||
183 | } | | |||
184 | 195 | | |||
196 | Output::writeGlobalPart(output, info, oldOutput); | ||||
185 | info[QStringLiteral("primary")] = output->isPrimary(); | 197 | info[QStringLiteral("primary")] = output->isPrimary(); | ||
186 | info[QStringLiteral("enabled")] = output->isEnabled(); | 198 | info[QStringLiteral("enabled")] = output->isEnabled(); | ||
187 | 199 | | |||
200 | auto setOutputConfigInfo = [this, &info](const KScreen::OutputPtr &out) { | ||||
201 | if (!out) { | ||||
202 | return; | ||||
203 | } | ||||
188 | QString replicationSourceHash; | 204 | QString replicationSourceHash; | ||
189 | if (int sourceId = output->replicationSource()) { | 205 | if (int sourceId = out->replicationSource()) { | ||
190 | replicationSourceHash = m_data->output(sourceId)->hashMd5(); | 206 | replicationSourceHash = m_data->output(sourceId)->hashMd5(); | ||
191 | } | 207 | } | ||
192 | info[QStringLiteral("replicate")] = replicationSourceHash; | 208 | info[QStringLiteral("replicate")] = replicationSourceHash; | ||
193 | 209 | | |||
194 | QVariantMap pos; | 210 | QVariantMap pos; | ||
195 | pos[QStringLiteral("x")] = output->pos().x(); | 211 | pos[QStringLiteral("x")] = out->pos().x(); | ||
196 | pos[QStringLiteral("y")] = output->pos().y(); | 212 | pos[QStringLiteral("y")] = out->pos().y(); | ||
197 | info[QStringLiteral("pos")] = pos; | 213 | info[QStringLiteral("pos")] = pos; | ||
214 | }; | ||||
215 | setOutputConfigInfo(output->isEnabled() ? output : oldOutput); | ||||
198 | 216 | | |||
199 | if (control.getOutputRetention(output->hash(), output->name()) != Control::OutputRetention::Individual) { | 217 | if (output->isEnabled() && | ||
218 | control.getOutputRetention(output->hash(), output->name()) != | ||||
219 | Control::OutputRetention::Individual) { | ||||
200 | // try to update global output data | 220 | // try to update global output data | ||
201 | Output::writeGlobal(output); | 221 | Output::writeGlobal(output); | ||
202 | } | 222 | } | ||
203 | 223 | | |||
204 | outputList.append(info); | 224 | outputList.append(info); | ||
205 | } | 225 | } | ||
206 | 226 | | |||
207 | QFile file(filePath); | 227 | QFile file(filePath); | ||
Show All 22 Lines |