diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-14 18:30:14 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-14 18:30:14 +0200 |
| commit | fd462620e21b0b880a958d461425d26879389413 (patch) | |
| tree | 699992a9d80850e9f2c941e5100fafb748597893 /desktop | |
| parent | 39b9074a47a17ca509c730ec6590e3ecde497c99 (diff) | |
| download | quickshell-fd462620e21b0b880a958d461425d26879389413.tar.gz quickshell-fd462620e21b0b880a958d461425d26879389413.zip | |
feat(desktop): a theme-coloured Switch
Diffstat (limited to 'desktop')
| -rw-r--r-- | desktop/Switch.qml | 47 | ||||
| -rw-r--r-- | desktop/modules/bluetooth/BluetoothPage.qml | 1 | ||||
| -rw-r--r-- | desktop/modules/network/NetworkPage.qml | 1 |
3 files changed, 47 insertions, 2 deletions
diff --git a/desktop/Switch.qml b/desktop/Switch.qml new file mode 100644 index 0000000..f14c986 --- /dev/null +++ b/desktop/Switch.qml @@ -0,0 +1,47 @@ +// Copyright (C) 2026 Danilo M. <danix@danix.xyz> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// 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. + +import QtQuick + +// A themed toggle. The stock QtQuick.Controls Switch follows no style the +// shell defines, and every other control here is hand-rolled, so this is too. +// It trades the Controls keyboard handling for a consistent look; Button.qml +// already makes the same trade. +Rectangle { + id: sw + + property bool checked: false + property bool enabled: true + + signal toggled + + implicitWidth: 42 + implicitHeight: 24 + radius: height / 2 + opacity: sw.enabled ? 1 : 0.45 + color: sw.checked ? Qt.alpha(Theme.accent, 0.85) : Qt.alpha(Theme.surface, 0.9) + border.width: 1 + border.color: Qt.alpha(Theme.text, 0.15) + + Rectangle { + x: sw.checked ? sw.width - width - 3 : 3 + anchors.verticalCenter: parent.verticalCenter + width: 18; height: 18; radius: 9 + color: Theme.text + Behavior on x { NumberAnimation { duration: 120 } } + } + + MouseArea { + anchors.fill: parent + cursorShape: sw.enabled ? Qt.PointingHandCursor : Qt.ArrowCursor + onClicked: if (sw.enabled) { sw.checked = !sw.checked; sw.toggled(); } + } +} diff --git a/desktop/modules/bluetooth/BluetoothPage.qml b/desktop/modules/bluetooth/BluetoothPage.qml index 26cb0ef..2f7051d 100644 --- a/desktop/modules/bluetooth/BluetoothPage.qml +++ b/desktop/modules/bluetooth/BluetoothPage.qml @@ -10,7 +10,6 @@ // GNU General Public License for more details. import QtQuick -import QtQuick.Controls import "../.." Column { diff --git a/desktop/modules/network/NetworkPage.qml b/desktop/modules/network/NetworkPage.qml index e40f233..975e68c 100644 --- a/desktop/modules/network/NetworkPage.qml +++ b/desktop/modules/network/NetworkPage.qml @@ -11,7 +11,6 @@ import Quickshell.Networking import QtQuick -import QtQuick.Controls import "../.." Column { |
