From e4bb84e74b42568904759fe3f18465d6e5700612 Mon Sep 17 00:00:00 2001 From: Lubos Date: Tue, 19 Dec 2023 09:43:56 +0100 Subject: [PATCH] Applied review comments --- app/qml/components/MMSwitch.qml | 22 ++++------------------ app/qml/inputs/MMSwitchEditor.qml | 5 ----- gallery/qml/pages/ChecksPage.qml | 3 +-- 3 files changed, 5 insertions(+), 25 deletions(-) diff --git a/app/qml/components/MMSwitch.qml b/app/qml/components/MMSwitch.qml index f9426a470..887af9522 100644 --- a/app/qml/components/MMSwitch.qml +++ b/app/qml/components/MMSwitch.qml @@ -9,26 +9,12 @@ import QtQuick import QtQuick.Controls -import QtQuick.Controls.Basic Switch { id: control - property string textOn - property string textOff - property bool visibleText: true - contentItem: Text { - text: { - if(control.visibleText) { - if(control.textOn.length > 0 && control.textOff.length > 0) { - if(control.checked) - return control.textOn - return control.textOff - } - return control.text - } - } + text: control.text font: __style.p5 color: control.enabled ? __style.forestColor : __style.mediumGreenColor verticalAlignment: Text.AlignVCenter @@ -36,8 +22,8 @@ Switch { } indicator: Rectangle { - implicitWidth: 48 - implicitHeight: 28 + implicitWidth: 48 * __dp + implicitHeight: 28 * __dp x: control.leftPadding y: parent.height / 2 - height / 2 radius: implicitHeight / 2 @@ -45,7 +31,7 @@ Switch { Rectangle { x: control.checked ? parent.width - width - radius/2 : radius/2 - width: 20 + width: 20 * __dp height: width radius: width / 2 color: control.enabled ? __style.forestColor : __style.mediumGreenColor diff --git a/app/qml/inputs/MMSwitchEditor.qml b/app/qml/inputs/MMSwitchEditor.qml index e8351e444..3385da5c7 100644 --- a/app/qml/inputs/MMSwitchEditor.qml +++ b/app/qml/inputs/MMSwitchEditor.qml @@ -10,8 +10,6 @@ import QtQuick import QtQuick.Controls import QtQuick.Controls.Basic -import QtQuick.Layouts -import Qt5Compat.GraphicalEffects import "../components" MMAbstractEditor { @@ -49,9 +47,6 @@ MMAbstractEditor { x: -30 * __dp checked: root.checked - textOn: root.textOn - textOff: root.textOff - visibleText: false onCheckedChanged: focus = true } diff --git a/gallery/qml/pages/ChecksPage.qml b/gallery/qml/pages/ChecksPage.qml index 6b20522b4..10fb69108 100644 --- a/gallery/qml/pages/ChecksPage.qml +++ b/gallery/qml/pages/ChecksPage.qml @@ -175,9 +175,8 @@ Column { spacing: 20 anchors.fill: parent MMSwitch { - textOn: "ON" - textOff: "OFF" checked: false + text: checked ? "ON" : "OFF" } MMSwitch { text: "static"