From 93ec03105e58e128a363fcf25521e7b0e06e5c9d Mon Sep 17 00:00:00 2001 From: Joakim Bygdell Date: Mon, 24 Jul 2017 19:54:34 +0200 Subject: [PATCH] QML UI: add our own styled switch This adds a switch styled for us, size is about the same as the material default. Signed-off-by: Joakim Bygdell --- mobile-widgets/qml/SsrfSwitch.qml | 29 +++++++++++++++++++++++++ mobile-widgets/qml/mobile-resources.qrc | 1 + 2 files changed, 30 insertions(+) create mode 100644 mobile-widgets/qml/SsrfSwitch.qml diff --git a/mobile-widgets/qml/SsrfSwitch.qml b/mobile-widgets/qml/SsrfSwitch.qml new file mode 100644 index 000000000..a88b94aea --- /dev/null +++ b/mobile-widgets/qml/SsrfSwitch.qml @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0 +import QtQuick 2.3 +import QtQuick.Controls 2.2 +import org.kde.kirigami 2.0 as Kirigami + +Switch { + id: root + indicator: Rectangle { + implicitWidth: Kirigami.Units.largeSpacing * 2.2 + implicitHeight: Kirigami.Units.largeSpacing * 0.75 + x: root.leftPadding + y: parent.height / 2 - height / 2 + radius: height / 2 + color: root.checked ? + subsurfaceTheme.lightPrimaryColor : subsurfaceTheme.backgroundColor + border.color: subsurfaceTheme.darkerPrimaryColor + + Rectangle { + x: root.checked ? parent.width - width : 0 + y: parent.height / 2 - height / 2 + width: Kirigami.Units.largeSpacing * 1.1 + height: Kirigami.Units.largeSpacing * 1.1 + radius: height / 2 + color: root.down || root.checked ? + subsurfaceTheme.primaryColor : subsurfaceTheme.lightPrimaryColor + border.color: subsurfaceTheme.darkerPrimaryColor + } + } +} diff --git a/mobile-widgets/qml/mobile-resources.qrc b/mobile-widgets/qml/mobile-resources.qrc index 9adae7403..b480d7a3b 100644 --- a/mobile-widgets/qml/mobile-resources.qrc +++ b/mobile-widgets/qml/mobile-resources.qrc @@ -22,6 +22,7 @@ icons/menu-edit.png icons/menu-back.png icons/nocloud.svg + SsrfSwitch.qml qtquickcontrols2.conf