Scaling service

This commit is contained in:
quadbyte 2025-08-09 13:12:13 -04:00
parent b5a2bb3fe0
commit c8f4599ff1
5 changed files with 95 additions and 43 deletions

View file

@ -0,0 +1,36 @@
import QtQuick
import Quickshell
import Quickshell.Widgets
import qs.Settings
MouseArea {
id: root
property string icon
property bool enabled: true
property bool hovering: false
property real size: 32
cursorShape: Qt.PointingHandCursor
implicitWidth: size
implicitHeight: size
hoverEnabled: true
onEntered: hovering = true
onExited: hovering = false
Rectangle {
anchors.fill: parent
radius: 8
color: root.hovering ? Theme.accentPrimary : "transparent"
}
Text {
id: iconText
anchors.centerIn: parent
text: root.icon
font.family: "Material Symbols Outlined"
font.pixelSize: 24 * Theme.scale(screen)
color: root.hovering ? Theme.onAccent : Theme.textPrimary
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
opacity: root.enabled ? 1.0 : 0.5
}
}

View file

@ -1,19 +1,21 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import qs.Services
import qs.Theme
RowLayout {
id: root
// Local scale convenience with safe fallback
readonly property real scale: (typeof screen !== 'undefined'
&& screen) ? Theme.scale(screen) : 1.0
&& screen) ? Scaling.scale(screen) : 1.0
property string label: ""
property string description: ""
property bool value: false
property var onToggled: function () {}
property var onToggled: function (value: bool) {}
Layout.fillWidth: true
@ -69,7 +71,8 @@ RowLayout {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
root.onToggled()
value = !value;
root.onToggled(value);
}
}
}