Add ThemedSlider, change all Slider to ThemedSlider, add scaling to Display.qml, fix scaling for ToggleOption

This commit is contained in:
Ly-sec 2025-08-08 14:23:04 +02:00
parent d3c9820ddb
commit d48eb9099b
6 changed files with 97 additions and 103 deletions

View file

@ -4,6 +4,7 @@ import QtQuick.Layouts
import Quickshell
import qs.Components
import qs.Settings
import qs.Components
ColumnLayout {
id: root
@ -417,6 +418,38 @@ ColumnLayout {
Settings.settings.notificationMonitors = monitors;
}
}
// Scale slider
ColumnLayout {
Layout.fillWidth: true
spacing: 4 * Theme.scale(screen)
Text { text: "Scale"; color: Theme.textSecondary; font.pixelSize: 10 * Theme.scale(screen) }
RowLayout {
Layout.fillWidth: true
spacing: 8 * Theme.scale(screen)
// Value read from settings override, default to Theme.scale(modelData)
property real currentValue: (Settings.settings.monitorScaleOverrides && Settings.settings.monitorScaleOverrides[monitorCard.monitorName] !== undefined) ? Settings.settings.monitorScaleOverrides[monitorCard.monitorName] : Theme.scale(modelData)
// Reusable slider component (exact style from Wallpaper.qml)
ThemedSlider {
id: scaleSlider
Layout.fillWidth: true
screen: modelData
from: 0.8
to: 2.0
stepSize: 0.05
snapAlways: true
value: parent.currentValue
onValueChanged: {
let overrides = Settings.settings.monitorScaleOverrides || {};
overrides = Object.assign({}, overrides);
overrides[monitorCard.monitorName] = value;
Settings.settings.monitorScaleOverrides = overrides;
parent.currentValue = value;
}
}
Text { text: parent.currentValue.toFixed(2); font.pixelSize: 12 * Theme.scale(screen); color: Theme.textPrimary; width: 36 }
}
}
}
}
}

View file

@ -197,49 +197,17 @@ ColumnLayout {
}
Slider {
ThemedSlider {
id: intervalSlider
Layout.fillWidth: true
from: 10
to: 900
stepSize: 10
value: Settings.settings.wallpaperInterval
snapMode: Slider.SnapAlways
snapAlways: true
onMoved: {
Settings.settings.wallpaperInterval = Math.round(value);
}
background: Rectangle {
x: intervalSlider.leftPadding
y: intervalSlider.topPadding + intervalSlider.availableHeight / 2 - height / 2
implicitWidth: 200
implicitHeight: 4
width: intervalSlider.availableWidth
height: implicitHeight
radius: 2
color: Theme.surfaceVariant
Rectangle {
width: intervalSlider.visualPosition * parent.width
height: parent.height
color: Theme.accentPrimary
radius: 2
}
}
handle: Rectangle {
x: intervalSlider.leftPadding + intervalSlider.visualPosition * (intervalSlider.availableWidth - width)
y: intervalSlider.topPadding + intervalSlider.availableHeight / 2 - height / 2
implicitWidth: 20
implicitHeight: 20
radius: 10
color: intervalSlider.pressed ? Theme.surfaceVariant : Theme.surface
border.color: Theme.accentPrimary
border.width: 2
}
}
}
@ -529,49 +497,17 @@ ColumnLayout {
}
Slider {
ThemedSlider {
id: fpsSlider
Layout.fillWidth: true
from: 30
to: 500
stepSize: 5
value: Settings.settings.transitionFps
snapMode: Slider.SnapAlways
snapAlways: true
onMoved: {
Settings.settings.transitionFps = Math.round(value);
}
background: Rectangle {
x: fpsSlider.leftPadding
y: fpsSlider.topPadding + fpsSlider.availableHeight / 2 - height / 2
implicitWidth: 200
implicitHeight: 4
width: fpsSlider.availableWidth
height: implicitHeight
radius: 2
color: Theme.surfaceVariant
Rectangle {
width: fpsSlider.visualPosition * parent.width
height: parent.height
color: Theme.accentPrimary
radius: 2
}
}
handle: Rectangle {
x: fpsSlider.leftPadding + fpsSlider.visualPosition * (fpsSlider.availableWidth - width)
y: fpsSlider.topPadding + fpsSlider.availableHeight / 2 - height / 2
implicitWidth: 20
implicitHeight: 20
radius: 10
color: fpsSlider.pressed ? Theme.surfaceVariant : Theme.surface
border.color: Theme.accentPrimary
border.width: 2
}
}
}
@ -612,49 +548,17 @@ ColumnLayout {
}
Slider {
ThemedSlider {
id: durationSlider
Layout.fillWidth: true
from: 0.25
to: 10
stepSize: 0.05
value: Settings.settings.transitionDuration
snapMode: Slider.SnapAlways
snapAlways: true
onMoved: {
Settings.settings.transitionDuration = value;
}
background: Rectangle {
x: durationSlider.leftPadding
y: durationSlider.topPadding + durationSlider.availableHeight / 2 - height / 2
implicitWidth: 200
implicitHeight: 4
width: durationSlider.availableWidth
height: implicitHeight
radius: 2
color: Theme.surfaceVariant
Rectangle {
width: durationSlider.visualPosition * parent.width
height: parent.height
color: Theme.accentPrimary
radius: 2
}
}
handle: Rectangle {
x: durationSlider.leftPadding + durationSlider.visualPosition * (durationSlider.availableWidth - width)
y: durationSlider.topPadding + durationSlider.availableHeight / 2 - height / 2
implicitWidth: 20
implicitHeight: 20
radius: 10
color: durationSlider.pressed ? Theme.surfaceVariant : Theme.surface
border.color: Theme.accentPrimary
border.width: 2
}
}
}