Changeset View
Changeset View
Standalone View
Standalone View
kded/output.cpp
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 44 | if (!QDir().mkpath(dir)) { | |||
---|---|---|---|---|---|
45 | return QString(); | 45 | return QString(); | ||
46 | } | 46 | } | ||
47 | return dir % hash; | 47 | return dir % hash; | ||
48 | } | 48 | } | ||
49 | 49 | | |||
50 | void Output::readInGlobalPartFromInfo(KScreen::OutputPtr output, const QVariantMap &info) | 50 | void Output::readInGlobalPartFromInfo(KScreen::OutputPtr output, const QVariantMap &info) | ||
51 | { | 51 | { | ||
52 | output->setRotation(static_cast<KScreen::Output::Rotation>(info.value(QStringLiteral("rotation"), 1).toInt())); | 52 | output->setRotation(static_cast<KScreen::Output::Rotation>(info.value(QStringLiteral("rotation"), 1).toInt())); | ||
53 | output->setScale(info.value(QStringLiteral("scale"), 1).toInt()); | 53 | | ||
54 | bool scaleOk; | ||||
55 | const qreal scale = info.value(QStringLiteral("scale"), 1.).toDouble(&scaleOk); | ||||
56 | if (scaleOk) { | ||||
57 | output->setScale(scale); | ||||
58 | } | ||||
54 | 59 | | |||
55 | const QVariantMap modeInfo = info[QStringLiteral("mode")].toMap(); | 60 | const QVariantMap modeInfo = info[QStringLiteral("mode")].toMap(); | ||
56 | const QVariantMap modeSize = modeInfo[QStringLiteral("size")].toMap(); | 61 | const QVariantMap modeSize = modeInfo[QStringLiteral("size")].toMap(); | ||
57 | const QSize size = QSize(modeSize[QStringLiteral("width")].toInt(), modeSize[QStringLiteral("height")].toInt()); | 62 | const QSize size = QSize(modeSize[QStringLiteral("width")].toInt(), modeSize[QStringLiteral("height")].toInt()); | ||
58 | 63 | | |||
59 | qCDebug(KSCREEN_KDED) << "Finding a mode for" << size << "@" << modeInfo[QStringLiteral("refresh")].toFloat(); | 64 | qCDebug(KSCREEN_KDED) << "Finding a mode for" << size << "@" << modeInfo[QStringLiteral("refresh")].toFloat(); | ||
60 | 65 | | |||
61 | KScreen::ModeList modes = output->modes(); | 66 | KScreen::ModeList modes = output->modes(); | ||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | 140 | auto getOutputInfoProperties = [outputsInfo](KScreen::OutputPtr output, QRect &geo) -> bool { | |||
152 | const QVariantMap posInfo = outputInfo[QStringLiteral("pos")].toMap(); | 157 | const QVariantMap posInfo = outputInfo[QStringLiteral("pos")].toMap(); | ||
153 | const QVariant scaleInfo = outputInfo[QStringLiteral("scale")]; | 158 | const QVariant scaleInfo = outputInfo[QStringLiteral("scale")]; | ||
154 | const QVariantMap modeInfo = outputInfo[QStringLiteral("mode")].toMap(); | 159 | const QVariantMap modeInfo = outputInfo[QStringLiteral("mode")].toMap(); | ||
155 | const QVariantMap modeSize = modeInfo[QStringLiteral("size")].toMap(); | 160 | const QVariantMap modeSize = modeInfo[QStringLiteral("size")].toMap(); | ||
156 | if (posInfo.isEmpty() || modeSize.isEmpty() || !scaleInfo.canConvert<int>()) { | 161 | if (posInfo.isEmpty() || modeSize.isEmpty() || !scaleInfo.canConvert<int>()) { | ||
157 | return false; | 162 | return false; | ||
158 | } | 163 | } | ||
159 | 164 | | |||
160 | const int scale = scaleInfo.toInt(); | 165 | const qreal scale = scaleInfo.toDouble(); | ||
161 | if (scale <= 0) { | 166 | if (scale <= 0) { | ||
162 | return false; | 167 | return false; | ||
163 | } | 168 | } | ||
164 | const QPoint pos = QPoint(posInfo[QStringLiteral("x")].toInt(), posInfo[QStringLiteral("y")].toInt()); | 169 | const QPoint pos = QPoint(posInfo[QStringLiteral("x")].toInt(), posInfo[QStringLiteral("y")].toInt()); | ||
165 | const QSize size = QSize(modeSize[QStringLiteral("width")].toInt() / scale, modeSize[QStringLiteral("height")].toInt() / scale); | 170 | const QSize size = QSize(modeSize[QStringLiteral("width")].toInt() / scale, modeSize[QStringLiteral("height")].toInt() / scale); | ||
166 | geo = QRect(pos, size); | 171 | geo = QRect(pos, size); | ||
167 | 172 | | |||
168 | return true; | 173 | return true; | ||
▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Line(s) | 343 | { | |||
342 | const KScreen::ModePtr mode = output->currentMode(); | 347 | const KScreen::ModePtr mode = output->currentMode(); | ||
343 | if (!mode) { | 348 | if (!mode) { | ||
344 | qWarning() << "CurrentMode is null" << output->name(); | 349 | qWarning() << "CurrentMode is null" << output->name(); | ||
345 | return false; | 350 | return false; | ||
346 | } | 351 | } | ||
347 | 352 | | |||
348 | info[QStringLiteral("id")] = output->hash(); | 353 | info[QStringLiteral("id")] = output->hash(); | ||
349 | info[QStringLiteral("rotation")] = output->rotation(); | 354 | info[QStringLiteral("rotation")] = output->rotation(); | ||
350 | info[QStringLiteral("scale")] = output->scale(); | 355 | | ||
356 | // Round scale to one digit. | ||||
357 | info[QStringLiteral("scale")] = int(output->scale() * 10 + 0.5) / 10.; | ||||
davidedmundson: i don't understand why we need/want this.
KConfig won't corrupt a double through a… | |||||
358 | | ||||
351 | info[QStringLiteral("metadata")] = metadata(output); | 359 | info[QStringLiteral("metadata")] = metadata(output); | ||
352 | 360 | | |||
353 | QVariantMap modeInfo; | 361 | QVariantMap modeInfo; | ||
354 | modeInfo[QStringLiteral("refresh")] = mode->refreshRate(); | 362 | modeInfo[QStringLiteral("refresh")] = mode->refreshRate(); | ||
355 | 363 | | |||
356 | QVariantMap modeSize; | 364 | QVariantMap modeSize; | ||
357 | modeSize[QStringLiteral("width")] = mode->size().width(); | 365 | modeSize[QStringLiteral("width")] = mode->size().width(); | ||
358 | modeSize[QStringLiteral("height")] = mode->size().height(); | 366 | modeSize[QStringLiteral("height")] = mode->size().height(); | ||
Show All 24 Lines |
i don't understand why we need/want this.
KConfig won't corrupt a double through a save/restore.