LockScreen: fix scaling

This commit is contained in:
quadbyte 2025-08-18 23:07:13 -04:00
parent 14ea1f5e66
commit 1564992442
2 changed files with 32 additions and 16 deletions

View file

@ -30,8 +30,9 @@ NLoader {
// Tie session lock to loader visibility // Tie session lock to loader visibility
locked: lockScreen.isLoaded locked: lockScreen.isLoaded
// Lockscreen is a different beast, needs a capital 'S' in 'Screen' to get the current screen // Lockscreen is a different beast, needs a capital 'S' in 'Screen' to access the current screen
readonly property real scaling: ScalingService.scale(Screen) // Also we use a different scaling algorithm based on the resolution, as the design is full screen
readonly property real scaling: ScalingService.dynamicScale(Screen)
property string errorMessage: "" property string errorMessage: ""
property bool authenticating: false property bool authenticating: false
@ -239,9 +240,9 @@ NLoader {
id: timeText id: timeText
text: Qt.formatDateTime(new Date(), "HH:mm") text: Qt.formatDateTime(new Date(), "HH:mm")
font.family: "Inter" font.family: "Inter"
font.pointSize: Style.fontSizeXXXL * 6 font.pointSize: Style.fontSizeXXXL * 6 * scaling
font.weight: Font.Bold font.weight: Font.Bold
font.letterSpacing: -2 font.letterSpacing: -2 * scaling
color: Color.mOnSurface color: Color.mOnSurface
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
@ -264,7 +265,7 @@ NLoader {
id: dateText id: dateText
text: Qt.formatDateTime(new Date(), "dddd, MMMM d") text: Qt.formatDateTime(new Date(), "dddd, MMMM d")
font.family: "Inter" font.family: "Inter"
font.pointSize: Style.fontSizeXXL font.pointSize: Style.fontSizeXXL * scaling
font.weight: Font.Light font.weight: Font.Light
color: Color.mOnSurface color: Color.mOnSurface
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
@ -407,7 +408,7 @@ NLoader {
text: "SECURE TERMINAL" text: "SECURE TERMINAL"
color: Color.mOnSurface color: Color.mOnSurface
font.family: "DejaVu Sans Mono" font.family: "DejaVu Sans Mono"
font.pointSize: Style.fontSizeL font.pointSize: Style.fontSizeL * scaling
font.weight: Font.Bold font.weight: Font.Bold
Layout.fillWidth: true Layout.fillWidth: true
} }
@ -419,7 +420,7 @@ NLoader {
NIcon { NIcon {
text: batteryIndicator.getIcon() text: batteryIndicator.getIcon()
font.pointSize: Style.fontSizeM font.pointSize: Style.fontSizeM * scaling
color: batteryIndicator.charging ? Color.mPrimary : Color.mOnSurface color: batteryIndicator.charging ? Color.mPrimary : Color.mOnSurface
} }
@ -427,7 +428,7 @@ NLoader {
text: Math.round(batteryIndicator.percent) + "%" text: Math.round(batteryIndicator.percent) + "%"
color: Color.mOnSurface color: Color.mOnSurface
font.family: "DejaVu Sans Mono" font.family: "DejaVu Sans Mono"
font.pointSize: Style.fontSizeM font.pointSize: Style.fontSizeM * scaling
font.weight: Font.Bold font.weight: Font.Bold
} }
} }
@ -453,7 +454,7 @@ NLoader {
text: "root@noctalia:~$" text: "root@noctalia:~$"
color: Color.mPrimary color: Color.mPrimary
font.family: "DejaVu Sans Mono" font.family: "DejaVu Sans Mono"
font.pointSize: Style.fontSizeL font.pointSize: Style.fontSizeL * scaling
font.weight: Font.Bold font.weight: Font.Bold
} }
@ -462,7 +463,7 @@ NLoader {
text: "" text: ""
color: Color.mOnSurface color: Color.mOnSurface
font.family: "DejaVu Sans Mono" font.family: "DejaVu Sans Mono"
font.pointSize: Style.fontSizeL font.pointSize: Style.fontSizeL * scaling
property int currentIndex: 0 property int currentIndex: 0
property string fullText: "Welcome back, " + Quickshell.env("USER") + "!" property string fullText: "Welcome back, " + Quickshell.env("USER") + "!"
@ -491,7 +492,7 @@ NLoader {
text: "root@noctalia:~$" text: "root@noctalia:~$"
color: Color.mPrimary color: Color.mPrimary
font.family: "DejaVu Sans Mono" font.family: "DejaVu Sans Mono"
font.pointSize: Style.fontSizeL font.pointSize: Style.fontSizeL * scaling
font.weight: Font.Bold font.weight: Font.Bold
} }
@ -499,7 +500,7 @@ NLoader {
text: "sudo unlock-session" text: "sudo unlock-session"
color: Color.mOnSurface color: Color.mOnSurface
font.family: "DejaVu Sans Mono" font.family: "DejaVu Sans Mono"
font.pointSize: Style.fontSizeL font.pointSize: Style.fontSizeL * scaling
} }
// Integrated password input (invisible, just for functionality) // Integrated password input (invisible, just for functionality)
@ -509,7 +510,7 @@ NLoader {
height: 0 height: 0
visible: false visible: false
font.family: "DejaVu Sans Mono" font.family: "DejaVu Sans Mono"
font.pointSize: Style.fontSizeL font.pointSize: Style.fontSizeL * scaling
color: Color.mOnSurface color: Color.mOnSurface
echoMode: TextInput.Password echoMode: TextInput.Password
passwordCharacter: "*" passwordCharacter: "*"
@ -539,7 +540,7 @@ NLoader {
text: "*".repeat(passwordInput.text.length) text: "*".repeat(passwordInput.text.length)
color: Color.mOnSurface color: Color.mOnSurface
font.family: "DejaVu Sans Mono" font.family: "DejaVu Sans Mono"
font.pointSize: Style.fontSizeL font.pointSize: Style.fontSizeL * scaling
visible: passwordInput.activeFocus visible: passwordInput.activeFocus
// Typing effect animation // Typing effect animation
@ -588,7 +589,7 @@ NLoader {
text: lock.authenticating ? "Authenticating..." : (lock.errorMessage !== "" ? "Authentication failed." : "") text: lock.authenticating ? "Authenticating..." : (lock.errorMessage !== "" ? "Authentication failed." : "")
color: lock.authenticating ? Color.mPrimary : (lock.errorMessage !== "" ? Color.mError : Color.transparent) color: lock.authenticating ? Color.mPrimary : (lock.errorMessage !== "" ? Color.mError : Color.transparent)
font.family: "DejaVu Sans Mono" font.family: "DejaVu Sans Mono"
font.pointSize: Style.fontSizeL font.pointSize: Style.fontSizeL * scaling
Layout.fillWidth: true Layout.fillWidth: true
SequentialAnimation on opacity { SequentialAnimation on opacity {
@ -622,7 +623,7 @@ NLoader {
text: lock.authenticating ? "EXECUTING" : "EXECUTE" text: lock.authenticating ? "EXECUTING" : "EXECUTE"
color: executeButtonArea.containsMouse ? Color.mOnPrimary : Color.mPrimary color: executeButtonArea.containsMouse ? Color.mOnPrimary : Color.mPrimary
font.family: "DejaVu Sans Mono" font.family: "DejaVu Sans Mono"
font.pointSize: Style.fontSizeM font.pointSize: Style.fontSizeM * scaling
font.weight: Font.Bold font.weight: Font.Bold
} }

View file

@ -6,6 +6,8 @@ import qs.Commons
Singleton { Singleton {
id: root id: root
// -------------------------------------------
// Manual scaling via Settings
function scale(aScreen) { function scale(aScreen) {
return scaleByName(aScreen.name) return scaleByName(aScreen.name)
} }
@ -23,4 +25,17 @@ Singleton {
return 1.0 return 1.0
} }
// -------------------------------------------
// Dynamic scaling based on resolution
// Design reference resolution (for scale = 1.0)
readonly property int designScreenWidth: 2560
readonly property int designScreenHeight: 1440
function dynamicScale(aScreen) {
var ratioW = aScreen.width / designScreenWidth
var ratioH = aScreen.height / designScreenHeight
return Math.min(ratioW, ratioH)
}
} }