diff --git a/kcm/kcm.h b/kcm/kcm.h --- a/kcm/kcm.h +++ b/kcm/kcm.h @@ -47,6 +47,8 @@ NOTIFY globalScaleChanged) Q_PROPERTY(int outputRetention READ outputRetention WRITE setOutputRetention NOTIFY outputRetentionChanged) + Q_PROPERTY(int numberOfOutputs READ numberOfOutputs + NOTIFY numberOfOutputsChanged) public: explicit KCMKScreen (QObject *parent = nullptr, @@ -76,6 +78,8 @@ int outputRetention() const; void setOutputRetention(int retention); + int numberOfOutputs() const; + Q_INVOKABLE void forceSave(); void doSave(bool force); @@ -89,6 +93,7 @@ void outputReplicationSupportedChanged(); void globalScaleChanged(); void outputRetentionChanged(); + void numberOfOutputsChanged(); void dangerousSave(); void errorOnSave(); void globalScaleWritten(); diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -389,5 +389,14 @@ return m_config->setRetention(retention); } +int KCMKScreen::numberOfOutputs() const +{ + if (!m_config) { + return -1; + } + return m_config->outputModel()->rowCount(); +} + + #include "kcm.moc" diff --git a/kcm/output_model.cpp b/kcm/output_model.cpp --- a/kcm/output_model.cpp +++ b/kcm/output_model.cpp @@ -16,6 +16,8 @@ *********************************************************************/ #include "output_model.h" +#include "../common/utils.h" + #include "config_handler.h" #include @@ -44,7 +46,7 @@ const KScreen::OutputPtr &output = m_outputs[index.row()].ptr; switch (role) { case Qt::DisplayRole: - return output->name(); + return Utils::outputName(output); case EnabledRole: return output->isEnabled(); case PrimaryRole: diff --git a/kcm/package/contents/ui/OutputIdentifier.qml b/kcm/package/contents/ui/OutputIdentifier.qml --- a/kcm/package/contents/ui/OutputIdentifier.qml +++ b/kcm/package/contents/ui/OutputIdentifier.qml @@ -28,8 +28,8 @@ color: theme.backgroundColor border { - color: theme.textColor - width: Math.ceil(units.gridUnit / 20) + color: "red" + width: units.smallSpacing * 2 } width: childrenRect.width + 2 * childrenRect.x 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 @@ -19,27 +19,34 @@ 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.numberOfOutputs > 1 + } + Kirigami.FormLayout { - Controls.Label { -// Kirigami.FormData.label: i18n("Name") - text: element.display - } Controls.CheckBox { text: i18n("Enabled") checked: element.enabled onClicked: element.enabled = checked + visible: kcm.numberOfOutputs > 1 } Controls.CheckBox { text: i18n("Primary") checked: element.primary onClicked: element.primary = checked - visible: kcm.primaryOutputSupported + visible: kcm.primaryOutputSupported && kcm.numberOfOutputs > 1 } Controls.ComboBox { @@ -55,6 +62,8 @@ visible: kcm.perOutputScaling Kirigami.FormData.label: i18n("Scale:") + Kirigami.FormData.buddyFor: scaleSlider + Controls.Slider { id: scaleSlider 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 @@ -22,19 +22,6 @@ import org.kde.private.kcm.kscreen 1.0 as KScreen ColumnLayout { - Kirigami.FormLayout { - twinFormLayouts: globalSettingsLayout - Item { - Kirigami.FormData.isSection: true - Kirigami.FormData.label: i18n("Output settings") - - Rectangle { - anchors.fill: parent - opacity: 0.5 - } - } - } - Controls.SwipeView { id: panelView currentIndex: root.selectedOutput @@ -54,7 +41,7 @@ id: indicator Layout.alignment: Qt.AlignHCenter - opacity: count > 1 ? 1 : 0 + visible: count > 1 ? 1 : 0 count: panelView.count currentIndex: panelView.currentIndex @@ -65,18 +52,13 @@ Kirigami.FormLayout { id: globalSettingsLayout Layout.fillWidth: true - Layout.topMargin: 20 + Kirigami.Separator { Layout.fillWidth: true Kirigami.FormData.isSection: true } - Item { - Layout.fillWidth: true - Kirigami.FormData.isSection: true - Kirigami.FormData.label: i18n("Arrangement settings") - } - ColumnLayout { + RowLayout { Layout.fillWidth: true Kirigami.FormData.label: i18n("Global scale:") @@ -94,8 +76,7 @@ onMoved: kcm.globalScale = value } Controls.Label { - Layout.alignment: Qt.AlignHCenter - text: 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", 1)) } } diff --git a/kcm/package/contents/ui/Screen.qml b/kcm/package/contents/ui/Screen.qml --- a/kcm/package/contents/ui/Screen.qml +++ b/kcm/package/contents/ui/Screen.qml @@ -17,6 +17,7 @@ import QtQuick 2.9 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.3 as Controls +import org.kde.kirigami 2.5 as Kirigami Rectangle { property var outputs @@ -44,8 +45,11 @@ property int xOffset: (width - totalSize.width / relativeFactor) / 2; property int yOffset: (height - totalSize.height / relativeFactor) / 2; - implicitHeight: root.height * 0.45 + implicitHeight: Math.max(root.height * 0.4, units.gridUnit * 14) + radius: units.smallSpacing color: "white" + border.color: Qt.tint(Kirigami.Theme.textColor, Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.8)) + border.width: 1 clip: true Row { @@ -59,12 +63,14 @@ Controls.Button { onClicked: kcm.identifyOutputs() text: i18n("Identify") + icon.name: "documentinfo" focusPolicy: Qt.NoFocus } Controls.Button { enabled: !kcm.screenNormalized onClicked: resetTotalSize() - text: i18n("Center view") + text: i18n("Center View") + icon.name: "zoom-original" focusPolicy: Qt.NoFocus } } 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,12 +24,13 @@ KCM.SimpleKCM { id: root - implicitWidth: units.gridUnit * 40 - implicitHeight: units.gridUnit * 50 + implicitWidth: units.gridUnit * 30 + implicitHeight: units.gridUnit * 34 property int selectedOutput: 0 ColumnLayout { + id: mainLayout Kirigami.InlineMessage { // Note1: There is an implicit height binding loop error on // first invokation. Seems to be an issue in Kirigami. @@ -116,8 +117,10 @@ Screen { id: screen Layout.fillWidth: true + Layout.margins: Kirigami.Units.largeSpacing enabled: kcm.outputModel && !kcm.backendError outputs: kcm.outputModel +// visible: kcm.numberOfOutputs > 1 // FIXME: this is -1 here; does it get set too late? } Panel {