Commit 7a9387ed authored by Nate Graham's avatar Nate Graham 💤
Browse files

[KCM] Scale more coarsely with the slider, but more finely with a spinbox

Summary:
Right now we have a problem in that the important scale factors of 1.25 and 1.75 are
not reachable using the UI. However just reducing the slider increment to 0.05 would
result in way too many slider values. Instead, this patch implements the following:
- The slider goes by increments of 0.25
- There's a spinbox beside the slider that allows the user to set the scale factor by 0.05 increments
- On X11 with global scaling, the user is shown a warning message when using scale factors that are not a multiple of 0.25

This way the commonly-used scale factors are more accessible, but finer values are
made available to people who really need them and are likely to go poking around.

BUG: 412447
FIXED-IN: 5.18.0

Test Plan: {F7489713}

Reviewers: #vdg, #plasma, romangg, ndavis

Reviewed By: #vdg, #plasma, romangg, ndavis

Subscribers: dhaumann, davidedmundson, ouwerkerk, GB_2, ndavis, cullmann, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D24321
parent 46376685
......@@ -75,9 +75,28 @@ ColumnLayout {
value: element.scale
onMoved: element.scale = value
}
Controls.Label {
Layout.alignment: Qt.AlignHCenter
text: i18nc("Scale factor (e.g. 1.0x, 1.5x, 2.0x)","%1x", scaleSlider.value.toLocaleString(Qt.locale(), "f", 1))
Controls.SpinBox {
id: spinbox
// Because QQC2 SpinBox doesn't natively support decimal step
// sizes: https://bugreports.qt.io/browse/QTBUG-67349
property real factor: 20.0
property real realValue: value / factor
from : 0.5 * factor
to : 3.0 * factor
stepSize: 0.05 * factor
value: element.scale * factor
validator: DoubleValidator {
bottom: Math.min(spinbox.from, spinbox.to) * spinbox.factor
top: Math.max(spinbox.from, spinbox.to) * spinbox.factor
}
textFromValue: function(value, locale) {
return parseFloat(value * 1.0 / factor).toFixed(2);
}
valueFromText: function(text, locale) {
return Number.fromLocaleString(locale, text) * factor
}
onValueModified: element.scale = realValue
}
}
......
......@@ -70,16 +70,52 @@ ColumnLayout {
Layout.fillWidth: true
from: 1
to: 3
stepSize: 0.1
stepSize: 0.25
live: true
value: kcm.globalScale
onMoved: kcm.globalScale = value
onMoved: kcm.globalScale = value;
}
Controls.Label {
text: i18nc("Scale factor (e.g. 1.0x, 1.5x, 2.0x)","%1x", globalScaleSlider.value.toLocaleString(Qt.locale(), "f", 1))
Controls.SpinBox {
id: spinbox
// Because QQC2 SpinBox doesn't natively support decimal step
// sizes: https://bugreports.qt.io/browse/QTBUG-67349
property real factor: 20.0
property real realValue: value / factor
from : 1.0 * factor
to : 3.0 * factor
stepSize: 0.05 * factor
value: kcm.globalScale * factor
validator: DoubleValidator {
bottom: Math.min(spinbox.from, spinbox.to)*spinbox.factor
top: Math.max(spinbox.from, spinbox.to)*spinbox.factor
}
textFromValue: function(value, locale) {
return parseFloat(value * 1.0 / factor).toFixed(2);
}
valueFromText: function(text, locale) {
return Number.fromLocaleString(locale, text) * factor
}
onValueModified: {
kcm.globalScale = realValue;
if (kcm.globalScale % 0.25) {
weirdScaleFactorMsg.visible = true;
} else {
weirdScaleFactorMsg.visible = false;
}
}
}
}
Kirigami.InlineMessage {
id: weirdScaleFactorMsg
Layout.fillWidth: true
type: Kirigami.MessageType.Warning
text: i18n("Scale factors that are not a multiple of 0.25 may cause visual glitches in applications. Consider setting the scale factor to a multiple of 0.25 and adjusting the font size instead.")
visible: false
showCloseButton: true
}
Controls.ButtonGroup {
buttons: retentionSelector.children
}
......
......@@ -24,7 +24,7 @@ import org.kde.kcm 1.2 as KCM
KCM.SimpleKCM {
id: root
implicitWidth: units.gridUnit * 30
implicitWidth: units.gridUnit * 32
implicitHeight: units.gridUnit * 38
property int selectedOutput: 0
......
......@@ -359,8 +359,8 @@ bool Output::writeGlobalPart(const KScreen::OutputPtr &output, QVariantMap &info
info[QStringLiteral("metadata")] = metadata(output);
info[QStringLiteral("rotation")] = output->rotation();
// Round scale to one digit.
info[QStringLiteral("scale")] = int(output->scale() * 10 + 0.5) / 10.;
// Round scale to two digits
info[QStringLiteral("scale")] = int(output->scale() * 100 + 0.5) / 100.;
QVariantMap modeInfo;
float refreshRate = -1.;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment