summaryrefslogtreecommitdiff
path: root/raveos-hyprland-theme/theme-data/dms/Modules/ControlCenter/Widgets/SmallToggleButton.qml
diff options
context:
space:
mode:
authorNippy <nippy@rp1.hu>2026-05-08 19:50:49 +0200
committerNippy <nippy@rp1.hu>2026-05-08 19:50:49 +0200
commit3462bcc46ecf74f576ea4397f16492c16bd75b10 (patch)
treec5ab7aef4498647e057bda8d49c11e5f9dda74c9 /raveos-hyprland-theme/theme-data/dms/Modules/ControlCenter/Widgets/SmallToggleButton.qml
parent56616f693b4f263cbf0d47da43b67424efa6022d (diff)
downloadRaveOS-PKGBUILD-3462bcc46ecf74f576ea4397f16492c16bd75b10.tar.gz
RaveOS-PKGBUILD-3462bcc46ecf74f576ea4397f16492c16bd75b10.zip
raveos update
Diffstat (limited to 'raveos-hyprland-theme/theme-data/dms/Modules/ControlCenter/Widgets/SmallToggleButton.qml')
-rw-r--r--raveos-hyprland-theme/theme-data/dms/Modules/ControlCenter/Widgets/SmallToggleButton.qml90
1 files changed, 90 insertions, 0 deletions
diff --git a/raveos-hyprland-theme/theme-data/dms/Modules/ControlCenter/Widgets/SmallToggleButton.qml b/raveos-hyprland-theme/theme-data/dms/Modules/ControlCenter/Widgets/SmallToggleButton.qml
new file mode 100644
index 0000000..7d86947
--- /dev/null
+++ b/raveos-hyprland-theme/theme-data/dms/Modules/ControlCenter/Widgets/SmallToggleButton.qml
@@ -0,0 +1,90 @@
+import QtQuick
+import qs.Common
+import qs.Widgets
+
+Rectangle {
+ id: root
+
+ property string iconName: ""
+ property bool isActive: false
+ property bool enabled: true
+ property real iconRotation: 0
+
+ signal clicked
+ signal iconRotationCompleted
+
+ width: parent ? ((parent.width - parent.spacing * 3) / 4) : 48
+ height: 48
+ radius: {
+ if (Theme.cornerRadius === 0)
+ return 0;
+ return isActive ? Theme.cornerRadius : Theme.cornerRadius + 4;
+ }
+
+ function hoverTint(base) {
+ const factor = 1.2;
+ return Theme.isLightMode ? Qt.darker(base, factor) : Qt.lighter(base, factor);
+ }
+
+ readonly property color _tileBgActive: Theme.ccTileActiveBg
+ readonly property color _tileBgInactive: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
+ readonly property color _tileRingActive: Theme.ccTileRing
+ readonly property color _tileIconActive: Theme.ccTileActiveText
+ readonly property color _tileIconInactive: Theme.ccTileInactiveIcon
+
+ color: {
+ if (isActive)
+ return _tileBgActive;
+ const baseColor = mouseArea.containsMouse ? Theme.primaryPressed : _tileBgInactive;
+ return baseColor;
+ }
+ border.color: isActive ? _tileRingActive : "transparent"
+ border.width: isActive ? 1 : 0
+ antialiasing: true
+ opacity: enabled ? 1.0 : 0.6
+
+ Rectangle {
+ anchors.fill: parent
+ radius: parent.radius
+ color: hoverTint(root.color)
+ opacity: mouseArea.pressed ? 0.3 : (mouseArea.containsMouse ? 0.2 : 0.0)
+ visible: opacity > 0
+ antialiasing: true
+ Behavior on opacity {
+ NumberAnimation {
+ duration: Theme.shortDuration
+ }
+ }
+ }
+
+ DankIcon {
+ anchors.centerIn: parent
+ name: iconName
+ size: Theme.iconSize
+ color: isActive ? _tileIconActive : _tileIconInactive
+ rotation: iconRotation
+ onRotationCompleted: root.iconRotationCompleted()
+ }
+
+ DankRipple {
+ id: ripple
+ cornerRadius: root.radius
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+ cursorShape: Qt.PointingHandCursor
+ enabled: root.enabled
+ onPressed: mouse => ripple.trigger(mouse.x, mouse.y)
+ onClicked: root.clicked()
+ }
+
+ Behavior on radius {
+ NumberAnimation {
+ duration: Theme.shortDuration
+ easing.type: Theme.standardEasing
+ }
+ }
+}