config options: add fixed bg clock pos

This commit is contained in:
end-4
2025-06-16 23:41:45 +02:00
parent 5dfa1b3445
commit 00b1aa1222
2 changed files with 21 additions and 11 deletions
@@ -15,8 +15,12 @@ import Quickshell.Services.UPower
Scope {
id: root
property string filePath: `${Directories.state}/user/generated/wallpaper/least_busy_region.json`
property real centerX: -500
property real centerY: -500
property real defaultX: (ConfigOptions?.background.clockX ?? -500)
property real defaultY: (ConfigOptions?.background.clockY ?? -500)
property real centerX: defaultX
property real centerY: defaultY
property real effectiveCenterX: ConfigOptions?.background.fixedClockPosition ? defaultX : centerX
property real effectiveCenterY: ConfigOptions?.background.fixedClockPosition ? defaultY : centerY
property color dominantColor: Appearance.colors.colPrimary
property bool dominantColorIsDark: dominantColor.hslLightness < 0.5
property color colBackground: ColorUtils.transparentize(ColorUtils.mix(Appearance.colors.colPrimary, Appearance.colors.colSecondaryContainer), 1)
@@ -42,7 +46,7 @@ Scope {
FileView {
id: leastBusyRegionFileView
path: Qt.resolvedUrl(root.filePath)
watchChanges: true
watchChanges: !ConfigOptions?.background.fixedClockPosition
onFileChanged: {
this.reload()
delayedFileRead.start()
@@ -63,8 +67,8 @@ Scope {
component: PanelWindow { // Window
id: windowRoot
screen: modelData
property var textHorizontalAlignment: root.centerX / monitor.scale < windowRoot.width / 3 ? Text.AlignLeft :
(root.centerX / monitor.scale > windowRoot.width * 2 / 3 ? Text.AlignRight : Text.AlignHCenter)
property var textHorizontalAlignment: root.effectiveCenterX / monitor.scale < windowRoot.width / 3 ? Text.AlignLeft :
(root.effectiveCenterX / monitor.scale > windowRoot.width * 2 / 3 ? Text.AlignRight : Text.AlignHCenter)
WlrLayershell.layer: WlrLayer.Bottom
WlrLayershell.namespace: "quickshell:backgroundWidgets"
@@ -91,8 +95,8 @@ Scope {
anchors {
left: parent.left
top: parent.top
leftMargin: (root.centerX / monitor.scale - implicitWidth / 2)
topMargin: (root.centerY / monitor.scale - implicitHeight / 2)
leftMargin: (root.effectiveCenterX / monitor.scale - implicitWidth / 2)
topMargin: (root.effectiveCenterY / monitor.scale - implicitHeight / 2)
Behavior on leftMargin {
animation: Appearance.animation.elementMove.numberAnimation.createObject(this)
}
@@ -39,10 +39,10 @@ Singleton {
property string terminal: "kitty -1" // This is only for shell actions
}
property QtObject battery: QtObject {
property int low: 20
property int critical: 5
property int suspend: 2
property QtObject background: QtObject {
property bool fixedClockPosition: false
property real clockX: -500
property real clockY: -500
}
property QtObject bar: QtObject {
@@ -70,6 +70,12 @@ Singleton {
}
}
property QtObject battery: QtObject {
property int low: 20
property int critical: 5
property int suspend: 2
}
property QtObject dock: QtObject {
property real height: 60
property real hoverRegionHeight: 3