lock: allow centering clock when not blurred

This commit is contained in:
end-4
2025-09-22 21:50:25 +02:00
parent a67a8d746f
commit 036d8b4852
5 changed files with 53 additions and 41 deletions
@@ -54,7 +54,7 @@ Variants {
property real clockX: (modelData.width / 2) property real clockX: (modelData.width / 2)
property real clockY: (modelData.height / 2) property real clockY: (modelData.height / 2)
property var textHorizontalAlignment: { property var textHorizontalAlignment: {
if ((Config.options.background.lockBlur.enable && Config.options.background.lockBlur.centerClock && GlobalStates.screenLocked) || wallpaperSafetyTriggered) if ((Config.options.lock.centerClock && GlobalStates.screenLocked) || wallpaperSafetyTriggered)
return Text.AlignHCenter; return Text.AlignHCenter;
if (clockX < screen.width / 3) if (clockX < screen.width / 3)
return Text.AlignLeft; return Text.AlignLeft;
@@ -63,7 +63,7 @@ Variants {
return Text.AlignHCenter; return Text.AlignHCenter;
} }
// Colors // Colors
property bool shouldBlur: (GlobalStates.screenLocked && Config.options.background.lockBlur.enable) property bool shouldBlur: (GlobalStates.screenLocked && Config.options.lock.blur.enable)
property color dominantColor: Appearance.colors.colPrimary property color dominantColor: Appearance.colors.colPrimary
property bool dominantColorIsDark: dominantColor.hslLightness < 0.5 property bool dominantColorIsDark: dominantColor.hslLightness < 0.5
property color colText: { property color colText: {
@@ -230,9 +230,9 @@ Variants {
Loader { Loader {
id: blurLoader id: blurLoader
active: Config.options.background.lockBlur.enable && (GlobalStates.screenLocked || scaleAnim.running) active: Config.options.lock.blur.enable && (GlobalStates.screenLocked || scaleAnim.running)
anchors.fill: wallpaper anchors.fill: wallpaper
scale: GlobalStates.screenLocked ? Config.options.background.lockBlur.extraZoom : 1 scale: GlobalStates.screenLocked ? Config.options.lock.blur.extraZoom : 1
Behavior on scale { Behavior on scale {
NumberAnimation { NumberAnimation {
id: scaleAnim id: scaleAnim
@@ -243,7 +243,7 @@ Variants {
} }
sourceComponent: GaussianBlur { sourceComponent: GaussianBlur {
source: wallpaper source: wallpaper
radius: GlobalStates.screenLocked ? Config.options.background.lockBlur.radius : 0 radius: GlobalStates.screenLocked ? Config.options.lock.blur.radius : 0
samples: radius * 2 + 1 samples: radius * 2 + 1
Rectangle { Rectangle {
@@ -279,7 +279,7 @@ Variants {
} }
states: State { states: State {
name: "centered" name: "centered"
when: (bgRoot.shouldBlur && Config.options.background.lockBlur.centerClock) || bgRoot.wallpaperSafetyTriggered when: (GlobalStates.screenLocked && Config.options.lock.centerClock) || bgRoot.wallpaperSafetyTriggered
AnchorChanges { AnchorChanges {
target: clockLoader target: clockLoader
anchors { anchors {
@@ -345,13 +345,19 @@ Variants {
} }
Item { Item {
Layout.alignment: Qt.AlignHCenter Layout.alignment: {
if (bgRoot.textHorizontalAlignment === Text.AlignHCenter || root.clockStyle === "cookie")
return Qt.AlignHCenter;
return (bgRoot.textHorizontalAlignment === Text.AlignLeft ? Qt.AlignLeft : Qt.AlignRight)
}
Layout.leftMargin: -26
Layout.rightMargin: -26
implicitWidth: statusTextBg.implicitWidth implicitWidth: statusTextBg.implicitWidth
implicitHeight: statusTextBg.implicitHeight implicitHeight: statusTextBg.implicitHeight
StyledRectangularShadow { StyledRectangularShadow {
target: statusTextBg target: statusTextBg
visible: statusTextBg.visible visible: statusTextBg.visible && cookieClockLoader.active
opacity: statusTextBg.opacity opacity: statusTextBg.opacity
} }
@@ -390,7 +396,7 @@ Variants {
} }
ClockStatusText { ClockStatusText {
id: lockStatusText id: lockStatusText
shown: GlobalStates.screenLocked && (!Config.options.background.lockBlur.enable || Config.options.background.lockBlur.showLockedText) shown: GlobalStates.screenLocked && Config.options.lock.showLockedText
statusIcon: "lock" statusIcon: "lock"
statusText: qsTr("Locked") statusText: qsTr("Locked")
} }
@@ -33,7 +33,7 @@ Item {
anchors.fill: source anchors.fill: source
horizontalOffset: 0 horizontalOffset: 0
verticalOffset: 2 verticalOffset: 2
radius: 8 radius: 12
samples: radius * 2 + 1 samples: radius * 2 + 1
color: Appearance.colors.colShadow color: Appearance.colors.colShadow
transparentBorder: true transparentBorder: true
@@ -141,13 +141,6 @@ Singleton {
property real workspaceZoom: 1.07 // Relative to your screen, not wallpaper size property real workspaceZoom: 1.07 // Relative to your screen, not wallpaper size
property bool enableSidebar: true property bool enableSidebar: true
} }
property JsonObject lockBlur: JsonObject {
property bool enable: false
property int radius: 100
property bool centerClock: true
property bool showLockedText: true
property real extraZoom: 1.1
}
property JsonObject wallpaperSafety: JsonObject { property JsonObject wallpaperSafety: JsonObject {
property bool enable: true property bool enable: true
property JsonObject triggerCondition: JsonObject { property JsonObject triggerCondition: JsonObject {
@@ -273,6 +266,16 @@ Singleton {
} }
} }
property JsonObject lock: JsonObject {
property JsonObject blur: JsonObject {
property bool enable: false
property real radius: 100
property real extraZoom: 1.1
}
property bool centerClock: true
property bool showLockedText: true
}
property JsonObject media: JsonObject { property JsonObject media: JsonObject {
// Attempt to remove dupes (the aggregator playerctl one and browsers' native ones when there's plasma browser integration) // Attempt to remove dupes (the aggregator playerctl one and browsers' native ones when there's plasma browser integration)
property bool filterDuplicatePlayers: true property bool filterDuplicatePlayers: true
@@ -24,7 +24,6 @@ RowLayout {
id: labelWidget id: labelWidget
Layout.fillWidth: true Layout.fillWidth: true
text: root.text text: root.text
font.pixelSize: Appearance.font.pixelSize.small
color: Appearance.colors.colOnSecondaryContainer color: Appearance.colors.colOnSecondaryContainer
} }
} }
@@ -171,37 +171,41 @@ ContentPage {
title: Translation.tr("Blurred style") title: Translation.tr("Blurred style")
ConfigSwitch { ConfigSwitch {
font.pixelSize: Appearance.font.pixelSize.large
text: Translation.tr('Enable blur') text: Translation.tr('Enable blur')
checked: Config.options.background.lockBlur.enable checked: Config.options.lock.blur.enable
onCheckedChanged: { onCheckedChanged: {
Config.options.background.lockBlur.enable = checked; Config.options.lock.blur.enable = checked;
} }
} }
ConfigRow { ConfigSpinBox {
uniform: true text: Translation.tr("Blur: Extra zoom (%)")
value: Config.options.lock.blur.extraZoom * 100
ConfigSwitch { from: 1
enabled: Config.options.background.lockBlur.enable to: 150
font.pixelSize: Appearance.font.pixelSize.large stepSize: 2
text: Translation.tr('Center clock') onValueChanged: {
checked: Config.options.background.lockBlur.centerClock Config.options.lock.blur.extraZoom = value / 100;
onCheckedChanged: {
Config.options.background.lockBlur.centerClock = checked;
}
}
ConfigSwitch {
enabled: Config.options.background.lockBlur.enable
font.pixelSize: Appearance.font.pixelSize.large
text: Translation.tr('Show "Locked" text')
checked: Config.options.background.lockBlur.showLockedText
onCheckedChanged: {
Config.options.background.lockBlur.showLockedText = checked;
}
} }
} }
ConfigSwitch {
text: Translation.tr('Center clock')
checked: Config.options.lock.centerClock
onCheckedChanged: {
Config.options.lock.centerClock = checked;
}
}
ConfigSwitch {
text: Translation.tr('Show "Locked" text')
checked: Config.options.lock.showLockedText
onCheckedChanged: {
Config.options.lock.showLockedText = checked;
}
}
} }
} }