Changeset View
Changeset View
Standalone View
Standalone View
kcm/src/outputconfig.cpp
Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Line(s) | 65 | { | |||
---|---|---|---|---|---|
100 | vbox->addLayout(formLayout); | 100 | vbox->addLayout(formLayout); | ||
101 | 101 | | |||
102 | mEnabled = new QCheckBox(i18n("Enabled"), this); | 102 | mEnabled = new QCheckBox(i18n("Enabled"), this); | ||
103 | mEnabled->setChecked(mOutput->isEnabled()); | 103 | mEnabled->setChecked(mOutput->isEnabled()); | ||
104 | connect(mEnabled, &QCheckBox::clicked, | 104 | connect(mEnabled, &QCheckBox::clicked, | ||
105 | this, [=](bool checked) { | 105 | this, [=](bool checked) { | ||
106 | mOutput->setEnabled(checked); | 106 | mOutput->setEnabled(checked); | ||
107 | qCDebug(KSCREEN_KCM) << mOutput.data() << mOutput->name() << mOutput->isEnabled(); | 107 | qCDebug(KSCREEN_KCM) << mOutput.data() << mOutput->name() << mOutput->isEnabled(); | ||
108 | mChanged = true; | ||||
108 | Q_EMIT changed(); | 109 | Q_EMIT changed(); | ||
109 | }); | 110 | }); | ||
110 | formLayout->addRow(i18n("Display:"), mEnabled); | 111 | formLayout->addRow(i18n("Display:"), mEnabled); | ||
111 | 112 | | |||
112 | mResolution = new ResolutionSlider(mOutput, this); | 113 | mResolution = new ResolutionSlider(mOutput, this); | ||
113 | connect(mResolution, &ResolutionSlider::resolutionChanged, | 114 | connect(mResolution, &ResolutionSlider::resolutionChanged, | ||
114 | this, &OutputConfig::slotResolutionChanged); | 115 | this, &OutputConfig::slotResolutionChanged); | ||
115 | formLayout->addRow(i18n("Resolution:"), mResolution); | 116 | formLayout->addRow(i18n("Resolution:"), mResolution); | ||
Show All 28 Lines | |||||
144 | } | 145 | } | ||
145 | 146 | | |||
146 | mRefreshRate = new QComboBox(this); | 147 | mRefreshRate = new QComboBox(this); | ||
147 | mRefreshRate->addItem(i18n("Auto"), -1); | 148 | mRefreshRate->addItem(i18n("Auto"), -1); | ||
148 | formLayout->addRow(i18n("Refresh rate:"), mRefreshRate); | 149 | formLayout->addRow(i18n("Refresh rate:"), mRefreshRate); | ||
149 | slotResolutionChanged(mResolution->currentResolution()); | 150 | slotResolutionChanged(mResolution->currentResolution()); | ||
150 | connect(mRefreshRate, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated), | 151 | connect(mRefreshRate, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated), | ||
151 | this, &OutputConfig::slotRefreshRateChanged); | 152 | this, &OutputConfig::slotRefreshRateChanged); | ||
153 | | ||||
154 | | ||||
155 | mRetentionGroupBox = new QGroupBox(i18n("Retention of values"), this); | ||||
156 | mGlobalRetentionButton = new QRadioButton(i18n("Save as new global values for this display."), this); | ||||
157 | mIndividualRetentionButton = new QRadioButton(i18n("Save values only for display in this specific configuration."), this); | ||||
158 | mIndividualRetentionButton->setChecked(mRetention == Control::OutputRetention::Individual); | ||||
159 | mGlobalRetentionButton->setChecked(!mIndividualRetentionButton->isChecked()); | ||||
160 | | ||||
161 | QVBoxLayout *vbox2 = new QVBoxLayout(mRetentionGroupBox); | ||||
162 | vbox2->addWidget(mGlobalRetentionButton); | ||||
163 | vbox2->addWidget(mIndividualRetentionButton); | ||||
164 | mRetentionGroupBox->setLayout(vbox2); | ||||
165 | | ||||
166 | vbox->addWidget(mRetentionGroupBox); | ||||
152 | } | 167 | } | ||
153 | 168 | | |||
154 | void OutputConfig::setOutput(const KScreen::OutputPtr &output) | 169 | void OutputConfig::setOutput(const KScreen::OutputPtr &output, Control::OutputRetention retention) | ||
155 | { | 170 | { | ||
156 | mOutput = output; | 171 | mOutput = output; | ||
172 | mRetention = retention; | ||||
173 | | ||||
157 | initUi(); | 174 | initUi(); | ||
158 | } | 175 | } | ||
159 | 176 | | |||
160 | KScreen::OutputPtr OutputConfig::output() const | 177 | KScreen::OutputPtr OutputConfig::output() const | ||
161 | { | 178 | { | ||
162 | return mOutput; | 179 | return mOutput; | ||
163 | } | 180 | } | ||
164 | 181 | | |||
Show All 31 Lines | 210 | for (int i = 0, total = modes.count(); i < total; ++i) { | |||
196 | // If selected refresh rate is other then what we consider the "Auto" value | 213 | // If selected refresh rate is other then what we consider the "Auto" value | ||
197 | // - that is it's not the highest resolution - then select it, otherwise | 214 | // - that is it's not the highest resolution - then select it, otherwise | ||
198 | // we stick with "Auto" | 215 | // we stick with "Auto" | ||
199 | if (mode == selectedMode && i > 1) { | 216 | if (mode == selectedMode && i > 1) { | ||
200 | // i + 1 since 0 is auto | 217 | // i + 1 since 0 is auto | ||
201 | mRefreshRate->setCurrentIndex(i + 1); | 218 | mRefreshRate->setCurrentIndex(i + 1); | ||
202 | } | 219 | } | ||
203 | } | 220 | } | ||
204 | 221 | mChanged = true; | |||
205 | Q_EMIT changed(); | 222 | Q_EMIT changed(); | ||
206 | } | 223 | } | ||
207 | 224 | | |||
208 | void OutputConfig::slotRotationChanged(int index) | 225 | void OutputConfig::slotRotationChanged(int index) | ||
209 | { | 226 | { | ||
210 | KScreen::Output::Rotation rotation = | 227 | KScreen::Output::Rotation rotation = | ||
211 | static_cast<KScreen::Output::Rotation>(mRotation->itemData(index).toInt()); | 228 | static_cast<KScreen::Output::Rotation>(mRotation->itemData(index).toInt()); | ||
212 | mOutput->setRotation(rotation); | 229 | mOutput->setRotation(rotation); | ||
213 | 230 | | |||
231 | mChanged = true; | ||||
214 | Q_EMIT changed(); | 232 | Q_EMIT changed(); | ||
215 | } | 233 | } | ||
216 | 234 | | |||
217 | void OutputConfig::slotRefreshRateChanged(int index) | 235 | void OutputConfig::slotRefreshRateChanged(int index) | ||
218 | { | 236 | { | ||
219 | QString modeId; | 237 | QString modeId; | ||
220 | if (index == 0) { | 238 | if (index == 0) { | ||
221 | // Item 0 is "Auto" - "Auto" is equal to highest refresh rate (at least | 239 | // Item 0 is "Auto" - "Auto" is equal to highest refresh rate (at least | ||
222 | // that's how I understand it, and since the combobox is sorted in descending | 240 | // that's how I understand it, and since the combobox is sorted in descending | ||
223 | // order, we just pick the second item from top | 241 | // order, we just pick the second item from top | ||
224 | modeId = mRefreshRate->itemData(1).toString(); | 242 | modeId = mRefreshRate->itemData(1).toString(); | ||
225 | } else { | 243 | } else { | ||
226 | modeId = mRefreshRate->itemData(index).toString(); | 244 | modeId = mRefreshRate->itemData(index).toString(); | ||
227 | } | 245 | } | ||
228 | mOutput->setCurrentModeId(modeId); | 246 | mOutput->setCurrentModeId(modeId); | ||
229 | 247 | | |||
248 | mChanged = true; | ||||
230 | Q_EMIT changed(); | 249 | Q_EMIT changed(); | ||
231 | } | 250 | } | ||
232 | 251 | | |||
233 | void OutputConfig::slotScaleChanged(int index) | 252 | void OutputConfig::slotScaleChanged(int index) | ||
234 | { | 253 | { | ||
235 | auto scale = mScale->itemData(index).toInt(); | 254 | auto scale = mScale->itemData(index).toInt(); | ||
236 | mOutput->setScale(scale); | 255 | mOutput->setScale(scale); | ||
256 | mChanged = true; | ||||
237 | Q_EMIT changed(); | 257 | Q_EMIT changed(); | ||
238 | } | 258 | } | ||
239 | 259 | | |||
240 | void OutputConfig::setShowScaleOption(bool showScaleOption) | 260 | void OutputConfig::setShowScaleOption(bool showScaleOption) | ||
241 | { | 261 | { | ||
242 | mShowScaleOption = showScaleOption; | 262 | mShowScaleOption = showScaleOption; | ||
243 | if (mOutput) { | 263 | if (mOutput) { | ||
244 | initUi(); | 264 | initUi(); | ||
245 | } | 265 | } | ||
246 | } | 266 | } | ||
247 | 267 | | |||
248 | bool OutputConfig::showScaleOption() const | 268 | bool OutputConfig::showScaleOption() const | ||
249 | { | 269 | { | ||
250 | return mShowScaleOption; | 270 | return mShowScaleOption; | ||
251 | } | 271 | } | ||
272 | | ||||
273 | Control::OutputRetention OutputConfig::applyRetention() | ||||
274 | { | ||||
275 | if (mIndividualRetentionButton->isChecked()) { | ||||
276 | mRetention = Control::OutputRetention::Individual; | ||||
277 | } else { | ||||
278 | mRetention = Control::OutputRetention::Global; | ||||
279 | } | ||||
280 | return mRetention; | ||||
281 | } | ||||
282 | | ||||
283 | bool OutputConfig::hasChange() const | ||||
284 | { | ||||
285 | return mChanged; | ||||
286 | } |