diff --git a/kcm/package/contents/ui/OutputPanel.qml b/kcm/package/contents/ui/OutputPanel.qml index aac5daf..dff24ad 100644 --- a/kcm/package/contents/ui/OutputPanel.qml +++ b/kcm/package/contents/ui/OutputPanel.qml @@ -1,145 +1,137 @@ /******************************************************************** Copyright © 2019 Roman Gilg 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.1 import QtQuick.Controls 2.3 as Controls import org.kde.kirigami 2.4 as Kirigami import org.kde.kcm 1.2 as KCM ColumnLayout { id: outputPanel property var element: model - Kirigami.Heading { - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - level: 2 - text: i18n("Settings for %1", element.display) - visible: kcm.outputModel.rowCount() > 1 - } - Kirigami.FormLayout { twinFormLayouts: globalSettingsLayout Controls.CheckBox { text: i18n("Enabled") checked: element.enabled onClicked: element.enabled = checked visible: kcm.outputModel.rowCount() > 1 } Controls.CheckBox { text: i18n("Primary") checked: element.primary onClicked: element.primary = checked visible: kcm.primaryOutputSupported && kcm.outputModel.rowCount() > 1 } Controls.ComboBox { Kirigami.FormData.label: i18n("Resolution:") model: element.resolutions currentIndex: element.resolutionIndex !== undefined ? element.resolutionIndex : -1 onActivated: element.resolutionIndex = currentIndex } RowLayout { Layout.fillWidth: true visible: kcm.perOutputScaling Kirigami.FormData.label: i18n("Scale:") Controls.Slider { id: scaleSlider Layout.fillWidth: true from: 0.5 to: 3 stepSize: 0.1 live: true value: element.scale onMoved: element.scale = value } 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 i18nc("Global scale factor expressed in percentage form", "%1%", parseFloat(value * 1.0 / factor * 100.0)); } valueFromText: function(text, locale) { return Number.fromLocaleString(locale, text) * factor / 100.0 } onValueModified: element.scale = realValue } } Controls.ButtonGroup { buttons: orientation.children } RowLayout { id: orientation Kirigami.FormData.label: i18n("Orientation:") RotationButton { value: 0 } RotationButton { value: 90 } RotationButton { value: 180 } RotationButton { value: 270 } } Controls.ComboBox { Kirigami.FormData.label: i18n("Refresh rate:") model: element.refreshRates currentIndex: element.refreshRateIndex ? element.refreshRateIndex : 0 onActivated: element.refreshRateIndex = currentIndex } Controls.ComboBox { Kirigami.FormData.label: i18n("Replica of:") model: element.replicationSourceModel visible: kcm.outputReplicationSupported && kcm.outputModel && kcm.outputModel.rowCount() > 1 onModelChanged: enabled = (count > 1); onCountChanged: enabled = (count > 1); currentIndex: element.replicationSourceIndex onActivated: element.replicationSourceIndex = currentIndex } } } diff --git a/kcm/package/contents/ui/Panel.qml b/kcm/package/contents/ui/Panel.qml index 69e27de..17c1f6f 100644 --- a/kcm/package/contents/ui/Panel.qml +++ b/kcm/package/contents/ui/Panel.qml @@ -1,151 +1,176 @@ /******************************************************************** Copyright © 2019 Roman Gilg 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.1 import QtQuick.Controls 2.3 as Controls import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.kirigami 2.4 as Kirigami import org.kde.private.kcm.kscreen 1.0 as KScreen ColumnLayout { + RowLayout { + Layout.alignment: Qt.AlignHCenter + spacing: 0 + visible: kcm.outputModel.rowCount() > 1 + + Kirigami.Heading { + horizontalAlignment: Text.AlignHCenter + level: 2 + // FIXME i18n change text in master + text: i18n("Settings for %1", " ") + } + + Controls.ComboBox { + model: kcm.outputModel + textRole: "display" + currentIndex: root.selectedOutput + onActivated: { + root.selectedOutput = index + currentIndex = Qt.binding(function() { + return root.selectedOutput; + }); + } + } + } + Controls.SwipeView { id: panelView currentIndex: root.selectedOutput onCurrentIndexChanged: root.selectedOutput = Qt.binding(function() { return currentIndex; }); Layout.fillWidth: true Repeater { model: kcm.outputModel OutputPanel {} } } Controls.PageIndicator { id: indicator Layout.alignment: Qt.AlignHCenter visible: count > 1 count: panelView.count - currentIndex: panelView.currentIndex + currentIndex: root.selectedOutput interactive: true onCurrentIndexChanged: root.selectedOutput = currentIndex } Kirigami.FormLayout { id: globalSettingsLayout Layout.fillWidth: true Kirigami.Separator { Layout.fillWidth: true Kirigami.FormData.isSection: true } RowLayout { Layout.fillWidth: true Kirigami.FormData.label: i18n("Global scale:") visible: !kcm.perOutputScaling Controls.Slider { id: globalScaleSlider Layout.fillWidth: true from: 1 to: 3 stepSize: 0.25 live: true value: kcm.globalScale onMoved: kcm.globalScale = value; } Controls.SpinBox { id: spinbox Layout.minimumWidth: Kirigami.Units.gridUnit * 6 // Because QQC2 SpinBox doesn't natively support decimal step // sizes: https://bugreports.qt.io/browse/QTBUG-67349 property real factor: 16.0 property real realValue: value / factor from : 1.0 * factor to : 3.0 * factor // On X11 We set the increment to this weird value to compensate // for inherent difficulties with floating-point math and this // Qt bug: https://bugreports.qt.io/browse/QTBUG-66036 stepSize: 0.0625 * 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 i18nc("Global scale factor expressed in percentage form", "%1%", parseFloat(value * 1.0 / factor * 100.0)); } valueFromText: function(text, locale) { return Number.fromLocaleString(locale, text) * factor / 100.0 } onValueModified: { kcm.globalScale = realValue; if (kcm.globalScale % 0.25) { weirdScaleFactorMsg.visible = true; } else { weirdScaleFactorMsg.visible = false; } } } } Kirigami.InlineMessage { id: weirdScaleFactorMsg Kirigami.FormData.isSection: true Layout.fillWidth: true type: Kirigami.MessageType.Info text: i18n("The global scale factor is limited to multiples of 6.25% to minimize visual glitches in applications using the X11 windowing system.") visible: false showCloseButton: true } Controls.ButtonGroup { buttons: retentionSelector.children } ColumnLayout { id: retentionSelector Kirigami.FormData.label: i18n("Save displays' properties:") Kirigami.FormData.buddyFor: globalRetentionRadio spacing: Kirigami.Units.smallSpacing Controls.RadioButton { id: globalRetentionRadio text: i18n("For any display arrangement") checked: !individualRetentionRadio.checked onClicked: kcm.outputRetention = KScreen.Control.Global } Controls.RadioButton { id: individualRetentionRadio text: i18n("For only this specific display arrangement") checked: kcm.outputRetention === KScreen.Control.Individual onClicked: kcm.outputRetention = KScreen.Control.Individual } } } }