Changeset View
Changeset View
Standalone View
Standalone View
kded/output.cpp
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | 42 | { | |||
---|---|---|---|---|---|
44 | if (!QDir().mkpath(dir)) { | 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::readInPart(KScreen::OutputPtr output, const QVariantMap &info) | 50 | void Output::readInPart(KScreen::OutputPtr output, const QVariantMap &info) | ||
51 | { | 51 | { | ||
52 | output->setRotation(static_cast<KScreen::Output::Rotation>(info[QStringLiteral("rotation")].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 | output->setScale(info.value(QStringLiteral("scale"), 1).toInt()); | ||
54 | 54 | | |||
55 | const QVariantMap modeInfo = info[QStringLiteral("mode")].toMap(); | 55 | const QVariantMap modeInfo = info[QStringLiteral("mode")].toMap(); | ||
56 | const QVariantMap modeSize = modeInfo[QStringLiteral("size")].toMap(); | 56 | const QVariantMap modeSize = modeInfo[QStringLiteral("size")].toMap(); | ||
57 | const QSize size = QSize(modeSize[QStringLiteral("width")].toInt(), modeSize[QStringLiteral("height")].toInt()); | 57 | const QSize size = QSize(modeSize[QStringLiteral("width")].toInt(), modeSize[QStringLiteral("height")].toInt()); | ||
58 | 58 | | |||
59 | qCDebug(KSCREEN_KDED) << "Finding a mode for" << size << "@" << modeInfo[QStringLiteral("refresh")].toFloat(); | 59 | qCDebug(KSCREEN_KDED) << "Finding a mode for" << size << "@" << modeInfo[QStringLiteral("refresh")].toFloat(); | ||
60 | 60 | | |||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | |||||
112 | void Output::readIn(KScreen::OutputPtr output, const QVariantMap &info, Control::OutputRetention retention) | 112 | void Output::readIn(KScreen::OutputPtr output, const QVariantMap &info, Control::OutputRetention retention) | ||
113 | { | 113 | { | ||
114 | const QVariantMap posInfo = info[QStringLiteral("pos")].toMap(); | 114 | const QVariantMap posInfo = info[QStringLiteral("pos")].toMap(); | ||
115 | QPoint point(posInfo[QStringLiteral("x")].toInt(), posInfo[QStringLiteral("y")].toInt()); | 115 | QPoint point(posInfo[QStringLiteral("x")].toInt(), posInfo[QStringLiteral("y")].toInt()); | ||
116 | output->setPos(point); | 116 | output->setPos(point); | ||
117 | output->setPrimary(info[QStringLiteral("primary")].toBool()); | 117 | output->setPrimary(info[QStringLiteral("primary")].toBool()); | ||
118 | output->setEnabled(info[QStringLiteral("enabled")].toBool()); | 118 | output->setEnabled(info[QStringLiteral("enabled")].toBool()); | ||
119 | 119 | | |||
120 | if (retention == Control::OutputRetention::Global) { | 120 | if (retention == Control::OutputRetention::Undefined || retention == Control::OutputRetention::Global) { | ||
121 | // output data read from global output file | 121 | // output data read from global output file | ||
122 | readInGlobal(output); | 122 | readInGlobal(output); | ||
123 | } else { | 123 | } else { | ||
124 | // output data read directly from info | 124 | // output data read directly from info | ||
125 | readInPart(output, info); | 125 | readInPart(output, info); | ||
126 | } | 126 | } | ||
127 | } | 127 | } | ||
128 | 128 | | |||
129 | void Output::readInOutputs(KScreen::OutputList outputs, const QVariantList &outputsInfo) | 129 | void Output::readInOutputs(KScreen::ConfigPtr config, const QVariantList &outputsInfo) | ||
130 | { | 130 | { | ||
131 | KScreen::OutputList outputs = config->outputs(); | ||||
132 | ControlConfig control(config); | ||||
131 | // As global outputs are indexed by a hash of their edid, which is not unique, | 133 | // As global outputs are indexed by a hash of their edid, which is not unique, | ||
132 | // to be able to tell apart multiple identical outputs, these need special treatment | 134 | // to be able to tell apart multiple identical outputs, these need special treatment | ||
133 | QStringList duplicateIds; | 135 | QStringList duplicateIds; | ||
134 | { | 136 | { | ||
135 | QStringList allIds; | 137 | QStringList allIds; | ||
136 | allIds.reserve(outputs.count()); | 138 | allIds.reserve(outputs.count()); | ||
137 | for (const KScreen::OutputPtr &output : outputs) { | 139 | for (const KScreen::OutputPtr &output : outputs) { | ||
138 | const auto outputId = output->hash(); | 140 | const auto outputId = output->hash(); | ||
Show All 23 Lines | 161 | if (!output->name().isEmpty() && duplicateIds.contains(outputId)) { | |||
162 | const auto metadata = info[QStringLiteral("metadata")].toMap(); | 164 | const auto metadata = info[QStringLiteral("metadata")].toMap(); | ||
163 | const auto outputName = metadata[QStringLiteral("name")].toString(); | 165 | const auto outputName = metadata[QStringLiteral("name")].toString(); | ||
164 | if (output->name() != outputName) { | 166 | if (output->name() != outputName) { | ||
165 | // was a duplicate id, but info not for this output | 167 | // was a duplicate id, but info not for this output | ||
166 | continue; | 168 | continue; | ||
167 | } | 169 | } | ||
168 | } | 170 | } | ||
169 | infoFound = true; | 171 | infoFound = true; | ||
170 | 172 | readIn(output, info, control.getOutputRetention(output)); | |||
171 | Control::OutputRetention retention = Control::OutputRetention::Global; | | |||
172 | const auto retentionVariant = info[QStringLiteral("retention")]; | | |||
173 | if (retentionVariant.canConvert<int>() && retentionVariant.toInt() == (int)Control::OutputRetention::Individual) { | | |||
174 | retention = Control::OutputRetention::Individual; | | |||
175 | } | | |||
176 | | ||||
177 | readIn(output, info, retention); | | |||
178 | break; | 173 | break; | ||
179 | } | 174 | } | ||
180 | if (!infoFound) { | 175 | if (!infoFound) { | ||
181 | // no info in info for this output, try reading in global output info atleast | 176 | // no info in info for this output, try reading in global output info atleast | ||
182 | 177 | | |||
183 | qCWarning(KSCREEN_KDED) << "\tFailed to find a matching output in the current info data - this means that our info is corrupted" | 178 | qCWarning(KSCREEN_KDED) << "\tFailed to find a matching output in the current info data - this means that our info is corrupted" | ||
184 | "or a different device with the same serial number has been connected (very unlikely)."; | 179 | "or a different device with the same serial number has been connected (very unlikely)."; | ||
185 | readInGlobal(output); | 180 | readInGlobal(output); | ||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |