diff --git a/kcm/package/contents/ui/CustomScalingSheet.qml b/kcm/package/contents/ui/CustomScalingSheet.qml new file mode 100644 --- /dev/null +++ b/kcm/package/contents/ui/CustomScalingSheet.qml @@ -0,0 +1,85 @@ +/******************************************************************** +Copyright © 2019 Nate Graham + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*********************************************************************/ +import QtQuick 2.9 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.5 as QQC2 +import org.kde.kirigami 2.5 as Kirigami +import org.kde.private.kcm.kscreen 1.0 as KScreen + + +Kirigami.OverlaySheet { + id: customScaleFactorSheet + + parent: root + property var screen + + ColumnLayout { + + RowLayout { + Layout.alignment: Qt.AlignHCenter + QQC2.Label { + text: i18n("Enter custom scale factor:") + } + QQC2.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: screen ? screen.scale * factor : 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 + } + + } + } + + RowLayout { + Layout.alignment: Qt.AlignRight + QQC2.Button { + text: i18n("OK") + icon.name: "dialog-ok" + onClicked: { + if (screen) { + screen.scale = spinbox.realValue + } else { + kcm.globalScale = spinbox.realValue + } + customScaleFactorSheet.close() + } + } + QQC2.Button { + text: i18n("Cancel") + icon.name: "dialog-cancel" + onClicked: { + customScaleFactorSheet.close() + } + } + } + } +} diff --git a/kcm/package/contents/ui/OutputPanel.qml b/kcm/package/contents/ui/OutputPanel.qml --- a/kcm/package/contents/ui/OutputPanel.qml +++ b/kcm/package/contents/ui/OutputPanel.qml @@ -77,7 +77,17 @@ } 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)) + text: i18nc("Scale factor (e.g. 1.0x, 1.5x, 2.0x)","%1x", scaleSlider.value.toLocaleString(Qt.locale(), "f", 2)) + } + Controls.Button { + text: i18n("Show Advanced Settings...") + + CustomScalingSheet { + id: sheet + screen: element + } + + onClicked: sheet.open(); } } diff --git a/kcm/package/contents/ui/Panel.qml b/kcm/package/contents/ui/Panel.qml --- a/kcm/package/contents/ui/Panel.qml +++ b/kcm/package/contents/ui/Panel.qml @@ -70,13 +70,22 @@ Layout.fillWidth: true from: 1 to: 3 - stepSize: 0.1 + stepSize: 0.25 live: true value: kcm.globalScale 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)) + text: i18nc("Scale factor (e.g. 1.0x, 1.5x, 2.0x)","%1x", globalScaleSlider.value.toLocaleString(Qt.locale(), "f", 2)) + } + Controls.Button { + text: i18n("Show Advanced Settings...") + + CustomScalingSheet { + id: sheet + } + + onClicked: sheet.open(); } } diff --git a/kcm/package/contents/ui/main.qml b/kcm/package/contents/ui/main.qml --- a/kcm/package/contents/ui/main.qml +++ b/kcm/package/contents/ui/main.qml @@ -24,7 +24,7 @@ KCM.SimpleKCM { id: root - implicitWidth: units.gridUnit * 30 + implicitWidth: units.gridUnit * 37 implicitHeight: units.gridUnit * 38 property int selectedOutput: 0