// Copyright (C) 2026 Danilo M. // // 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(); } } }