diff --git a/quickshell/config/defaults.json b/quickshell/config/defaults.json index 440d7c5..57f156b 100644 --- a/quickshell/config/defaults.json +++ b/quickshell/config/defaults.json @@ -99,6 +99,8 @@ "backdrop": "wallpaper", "glass": true, "media": true, + "dashboard": true, + "notificationPreviews": true, "powerButtons": true, "pamService": "" }, diff --git a/quickshell/core/SettingsRegistry.qml b/quickshell/core/SettingsRegistry.qml index b8cf5f9..d69fc04 100644 --- a/quickshell/core/SettingsRegistry.qml +++ b/quickshell/core/SettingsRegistry.qml @@ -222,7 +222,7 @@ Singleton { available: true, group: "system", icon: "󰌾", - keywords: ["Lock now", "Preview lock screen", "Test password", "Backdrop", "Glass", "PAM", "Now Playing on lock screen", "Power buttons"] + keywords: ["Lock now", "Preview lock screen", "Test password", "Backdrop", "Glass", "PAM", "Now Playing on lock screen", "Lock screen dashboard", "Notification previews", "Power buttons"] }, { id: "notifications", diff --git a/quickshell/helpers/weather.py b/quickshell/helpers/weather.py index 462eea9..b08bc15 100644 --- a/quickshell/helpers/weather.py +++ b/quickshell/helpers/weather.py @@ -1,6 +1,24 @@ #!/usr/bin/env python3 -"""Current weather from wttr.in as compact JSON: {ok, place, temperature, feels, code, description}.""" -import json, sys, urllib.parse, urllib.request +"""Current weather from wttr.in as compact JSON: {ok, place, celsius, feelsCelsius, code, description, humidity, wind, hourly}.""" +import datetime, json, sys, urllib.parse, urllib.request + +def upcoming(data, now, count=4): + """The next `count` three-hourly forecasts: [{hour, celsius, code}]. wttr.in + usually omits the local observation time, so this machine's clock stands in.""" + try: + observed = datetime.datetime.strptime(now['localObsDateTime'], '%Y-%m-%d %I:%M %p') + except (KeyError, ValueError): + observed = datetime.datetime.now() + slots = [] + for day in data.get('weather') or []: + for slot in day.get('hourly') or []: + try: + at = datetime.datetime.strptime(day['date'], '%Y-%m-%d') + datetime.timedelta(hours=int(slot['time']) // 100) + if at > observed: + slots.append(dict(hour=at.hour, celsius=float(slot['tempC']), code=int(slot['weatherCode']))) + except (KeyError, ValueError): + continue + return slots[:count] def main(): location = sys.argv[1] if len(sys.argv) > 1 else '' @@ -13,7 +31,7 @@ def main(): place = (area.get('areaName') or [{'value': ''}])[0]['value'] print(json.dumps(dict(ok=True, place=place or location, celsius=float(now['temp_C']), feelsCelsius=float(now['FeelsLikeC']), code=int(now['weatherCode']), description=now['weatherDesc'][0]['value'].strip(), - humidity=int(now['humidity']), wind=float(now['windspeedKmph'])))) + humidity=int(now['humidity']), wind=float(now['windspeedKmph']), hourly=upcoming(data, now)))) except Exception as error: # Network, HTTP and format errors all surface as a message. print(json.dumps(dict(ok=False, error=str(error)))) diff --git a/quickshell/lock/LockNotifications.qml b/quickshell/lock/LockNotifications.qml new file mode 100644 index 0000000..5a16b4b --- /dev/null +++ b/quickshell/lock/LockNotifications.qml @@ -0,0 +1,163 @@ +pragma ComponentBehavior: Bound +import QtQuick +import QtQuick.Layouts +import Quickshell +import "../services" +import "../theme" + +// Notifications on the lock screen, newest first. Read-only: nothing can be +// opened or acted on while locked, and bodies show only with previews on. +ColumnLayout { + id: root + property real unit: 1 + function s(value) { + return Math.round(value * unit); + } + readonly property bool previews: LockState.options.notificationPreviews + spacing: s(10) + + RowLayout { + Layout.fillWidth: true + Layout.leftMargin: root.s(4) + spacing: root.s(8) + Text { + text: "Notifications" + color: "#ffffff" + font.pixelSize: root.s(13) + font.weight: Font.DemiBold + Layout.fillWidth: true + } + Text { + visible: NotificationService.dnd + text: Icons.available ? "󰽥" : "Do Not Disturb" + font.family: Icons.available ? Icons.family : "" + color: Qt.alpha("#ffffff", 0.6) + font.pixelSize: root.s(13) + } + Rectangle { + visible: list.count > 0 + implicitWidth: Math.max(height, countText.implicitWidth + root.s(12)) + implicitHeight: root.s(20) + radius: height / 2 + color: Qt.alpha("#ffffff", 0.14) + Text { + id: countText + anchors.centerIn: parent + text: list.count + color: "#ffffff" + font.pixelSize: root.s(11) + font.weight: Font.DemiBold + } + } + } + ListView { + id: list + objectName: "lockNotifications" + Layout.fillWidth: true + Layout.fillHeight: true + clip: true + spacing: root.s(8) + boundsBehavior: Flickable.StopAtBounds + model: ScriptModel { + values: NotificationService.active ? NotificationService.list : [] + } + delegate: Rectangle { + id: card + required property var modelData + readonly property string icon: NotificationService.iconFor(modelData) + width: list.width + height: row.implicitHeight + root.s(20) + radius: root.s(14) + color: Qt.alpha("#ffffff", 0.08) + border.width: NotificationService.critical(modelData) ? 1 : 0 + border.color: Qt.alpha(Theme.urgent, 0.6) + RowLayout { + id: row + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + anchors.margins: root.s(10) + spacing: root.s(10) + Item { + Layout.alignment: Qt.AlignTop + Layout.preferredWidth: root.s(30) + Layout.preferredHeight: root.s(30) + Image { + id: appIcon + anchors.fill: parent + source: card.icon + sourceSize: Qt.size(64, 64) + fillMode: Image.PreserveAspectFit + asynchronous: true + visible: status === Image.Ready + } + Rectangle { + anchors.fill: parent + visible: appIcon.status !== Image.Ready + radius: root.s(8) + color: Qt.alpha("#ffffff", 0.15) + Text { + anchors.centerIn: parent + text: NotificationService.appLabel(card.modelData).charAt(0).toUpperCase() + color: "#ffffff" + font.pixelSize: root.s(13) + font.weight: Font.DemiBold + } + } + } + ColumnLayout { + Layout.fillWidth: true + spacing: root.s(2) + RowLayout { + Layout.fillWidth: true + spacing: root.s(6) + Text { + text: NotificationService.appLabel(card.modelData) + color: Qt.alpha("#ffffff", 0.7) + font.pixelSize: root.s(11) + font.weight: Font.DemiBold + elide: Text.ElideRight + textFormat: Text.PlainText + Layout.fillWidth: true + } + Text { + text: NotificationService.since(card.modelData) + color: Qt.alpha("#ffffff", 0.5) + font.pixelSize: root.s(10) + } + } + Text { + text: card.modelData.summary + color: "#ffffff" + font.pixelSize: root.s(12) + font.weight: Font.DemiBold + elide: Text.ElideRight + textFormat: Text.PlainText + Layout.fillWidth: true + } + Text { + visible: root.previews && text !== "" + text: card.modelData.body + color: Qt.alpha("#ffffff", 0.75) + font.pixelSize: root.s(11) + textFormat: Text.StyledText + wrapMode: Text.Wrap + maximumLineCount: 2 + elide: Text.ElideRight + Layout.fillWidth: true + } + } + } + } + Text { + anchors.centerIn: parent + width: parent.width - root.s(24) + visible: list.count === 0 + horizontalAlignment: Text.AlignHCenter + wrapMode: Text.Wrap + text: NotificationService.active ? "No Notifications" : NotificationService.notice || "Notifications are off" + color: Qt.alpha("#ffffff", 0.55) + font.pixelSize: root.s(12) + } + } +} diff --git a/quickshell/lock/LockState.qml b/quickshell/lock/LockState.qml index e31f746..e300f91 100644 --- a/quickshell/lock/LockState.qml +++ b/quickshell/lock/LockState.qml @@ -35,8 +35,10 @@ Singleton { // Live lock surfaces, for diagnostics and tests. property var surfaces: [] property string realName: "" - // Active keyboard layout, read from Hyprland when the lock screen shows. + // Active keyboard layout and Caps Lock, read from Hyprland when the lock + // screen shows and again whenever Caps Lock is pressed. property string layout: "" + property bool capsLock: false readonly property bool shown: locked || previewing readonly property string runtimeDir: (Quickshell.env("XDG_RUNTIME_DIR") || "/tmp") + "/glassMxrph" @@ -107,6 +109,10 @@ Singleton { testResult = ""; return submit(password, "test"); } + function probeKeyboard() { + layoutProbe.running = false; + layoutProbe.running = true; + } function finishUnlock() { unlocking = true; unlockTimer.restart(); @@ -184,7 +190,7 @@ Singleton { } } onShownChanged: if (shown) - layoutProbe.running = true + probeKeyboard() Process { id: layoutProbe command: ["hyprctl", "devices", "-j"] @@ -194,8 +200,10 @@ Singleton { const keyboards = JSON.parse(text).keyboards || []; const main = keyboards.find(k => k.main) || keyboards[0]; root.layout = main && main.active_keymap ? main.active_keymap.slice(0, 2).toUpperCase() : ""; + root.capsLock = keyboards.some(k => k.capsLock); } catch (e) { root.layout = ""; + root.capsLock = false; } } } diff --git a/quickshell/lock/LockSurface.qml b/quickshell/lock/LockSurface.qml index e755671..e0c2f72 100644 --- a/quickshell/lock/LockSurface.qml +++ b/quickshell/lock/LockSurface.qml @@ -4,32 +4,115 @@ import QtQuick.Effects import QtQuick.Layouts import Quickshell import Quickshell.Services.UPower +import "../media" import "../services" import "../theme" +import "../widgets/faces" -// One output of the lock screen, in the style of the macOS lock screen: date -// and a large glass clock at the top, Now Playing below it, and the avatar, -// name and password capsule near the bottom with power controls underneath. -// Secondary outputs show only the backdrop and the clock. +// One output of the lock screen, after Serpantinum's: at rest only the date +// and a large glass clock (with Now Playing). Typing or clicking replaces them +// with a glass dashboard, first the centre (avatar, name, status, password), +// then wings unfolding outwards: weather and system usage on the left, +// notifications and media on the right. Power controls sit behind a corner +// button. Secondary outputs show only the backdrop and the clock. Item { id: root required property string screenName property bool preview: false readonly property bool primary: screenName === LockState.primary || !Quickshell.screens.some(s => s.name === LockState.primary) readonly property var byMonitor: ConfigService.ready ? ConfigService.data.wallpaper.byMonitor : ({}) - readonly property string backdropPath: LockState.options.backdrop === "screenshot" && LockState.shots[screenName] ? LockState.shots[screenName] : (byMonitor[screenName] || Object.values(byMonitor)[0] || "") + readonly property bool screenshot: LockState.options.backdrop === "screenshot" && !!LockState.shots[screenName] + readonly property string backdropPath: screenshot ? LockState.shots[screenName] : (byMonitor[screenName] || Object.values(byMonitor)[0] || "") readonly property bool glass: LockState.options.glass + readonly property bool glassReady: glass && wallpaper.status === Image.Ready // Interface scale: about 1 on a 1500×1050 logical output, never below 0.85 // (so portrait outputs keep readable controls) or above 1.3. readonly property real unit: Math.max(0.85, Math.min(1.3, Math.min(width / 1500, height / 1050))) function s(value) { return Math.round(value * unit); } + readonly property bool motion: Theme.intensity > 0 + + // Activity: any input wakes the screen (and lightly blurs the backdrop); + // typing, Enter or a click opens the dashboard. Both lapse after 20 s idle. property bool active: false + property bool open: false + property bool powerOpen: false function wake() { active = true; idle.restart(); } + function openDashboard() { + wake(); + if (primary) + open = true; + } + function closeDashboard() { + open = false; + powerOpen = false; + field.text = ""; + } + + // Dashboard geometry. Wings need room for the centre plus both sides. + readonly property int centerWidth: s(400) + readonly property int wingWidth: s(380) + readonly property int shellHeight: Math.min(s(520), height - s(180)) + readonly property bool wingsAllowed: LockState.options.dashboard && width >= centerWidth + 2 * wingWidth + s(64) && shellHeight >= s(440) + property real centerReveal: 0 + property real wingsReveal: 0 + // Live widgets sample only while the dashboard is open. + readonly property bool live: open && LockState.shown && !LockState.unlocking + readonly property string weatherLocation: { + const items = ConfigService.ready ? ConfigService.data.desktopWidgets.items : []; + const item = items.find(i => i.type === "weather" && i.options && i.options.location); + return item ? item.options.location : ""; + } + readonly property bool weatherFahrenheit: { + const items = ConfigService.ready ? ConfigService.data.desktopWidgets.items : []; + const item = items.find(i => i.type === "weather"); + return !!item && !!item.options && !!item.options.fahrenheit; + } + + states: State { + name: "open" + when: root.open + PropertyChanges { + root.centerReveal: 1 + root.wingsReveal: root.wingsAllowed ? 1 : 0 + } + } + transitions: [ + Transition { + to: "open" + SequentialAnimation { + NumberAnimation { + property: "centerReveal" + duration: root.motion ? 240 : 0 + easing.type: Easing.OutCubic + } + NumberAnimation { + property: "wingsReveal" + duration: root.motion ? 420 : 0 + easing.type: Easing.OutCubic + } + } + }, + Transition { + from: "open" + SequentialAnimation { + NumberAnimation { + property: "wingsReveal" + duration: root.motion ? 260 : 0 + easing.type: Easing.InOutCubic + } + NumberAnimation { + property: "centerReveal" + duration: root.motion ? 200 : 0 + easing.type: Easing.InCubic + } + } + } + ] focus: true opacity: LockState.unlocking ? 0 : 1 @@ -46,15 +129,23 @@ Item { easing.type: Easing.OutCubic } } + // Keys the password field leaves unhandled arrive here. Keys.onPressed: event => { root.wake(); if (event.key === Qt.Key_Escape) { - if (root.preview) + if (root.powerOpen) + root.powerOpen = false; + else if (root.open) + root.closeDashboard(); + else if (root.preview) LockState.cancelPreview(); - else - field.text = ""; event.accepted = true; - } else if (root.primary && !field.activeFocus) { + return; + } + if (event.key === Qt.Key_CapsLock || !root.primary) + return; + root.openDashboard(); + if (!field.activeFocus) { field.forceActiveFocus(); if (event.text && event.text.length === 1 && event.text >= " ") { field.insert(field.cursorPosition, event.text); @@ -62,6 +153,10 @@ Item { } } } + Keys.onReleased: event => { + if (event.key === Qt.Key_CapsLock) + LockState.probeKeyboard(); + } Component.onCompleted: { LockState.surfaces = LockState.surfaces.concat([root]); if (primary) @@ -71,14 +166,20 @@ Item { Timer { id: idle interval: 20000 - onTriggered: root.active = false + onTriggered: { + root.active = false; + if (!field.text && !LockState.busy) + root.closeDashboard(); + } } SystemClock { id: clock precision: SystemClock.Minutes } + readonly property string timeText: Qt.formatTime(clock.date, ConfigService.ready && !ConfigService.data.bar.clock.use24Hour ? "h:mm" : "HH:mm") - // Backdrop: wallpaper (or the pre-lock screenshot), lightly blurred while typing. + // Backdrop: wallpaper, lightly blurred while typing, or the pre-lock + // screenshot, always blurred and dimmed so nothing on it stays legible. Rectangle { anchors.fill: parent gradient: Gradient { @@ -106,15 +207,21 @@ Item { source: wallpaper visible: wallpaper.status === Image.Ready blurEnabled: true - blurMax: 48 - blur: root.active && root.primary ? 0.35 : 0 - brightness: root.active ? -0.06 : 0 + blurMax: root.screenshot ? 64 : 48 + blur: root.screenshot ? 1 : root.open ? 0.5 : root.active && root.primary ? 0.25 : 0 + brightness: root.screenshot ? -0.18 : root.open ? -0.1 : root.active ? -0.04 : 0 Behavior on blur { NumberAnimation { duration: 350 easing.type: Easing.OutCubic } } + Behavior on brightness { + NumberAnimation { + duration: 350 + easing.type: Easing.OutCubic + } + } } Rectangle { anchors.fill: parent @@ -159,58 +266,256 @@ Item { hoverEnabled: true onPositionChanged: root.wake() onPressed: { - root.wake(); - if (root.primary) + root.powerOpen = false; + if (root.primary) { + root.openDashboard(); field.forceActiveFocus(); + } else + root.wake(); } } - // Date and glass clock. - Text { - id: date - anchors.horizontalCenter: parent.horizontalCenter - y: root.height * 0.085 - text: Qt.formatDate(clock.date, "dddd d MMMM") - color: Qt.alpha("#ffffff", 0.92) - font.pixelSize: root.s(24) - font.weight: Font.DemiBold - layer.enabled: true - layer.effect: MultiEffect { - shadowEnabled: true - shadowColor: "#66000000" - shadowBlur: 0.5 - } + component Card: Rectangle { + radius: Theme.radius + color: Qt.alpha("#ffffff", 0.07) + border.width: 1 + border.color: Qt.alpha("#ffffff", 0.1) } - GlassSurface { - id: clockGlass - objectName: "lockClock" - backdrop: frostSource - space: root - glass: root.glass && wallpaper.status === Image.Ready - x: Math.round((root.width - width) / 2) - y: date.y + date.height - root.s(6) - width: digits.implicitWidth + root.s(24) - height: digits.implicitHeight - brightness: 1.3 - tint: "#ffffff" - tintAmount: 0.2 - Text { - id: digits + component Pill: Rectangle { + id: pill + property real unit: 1 + function s(value) { + return Math.round(value * unit); + } + property string glyph + property string text + property color textColor: "#ffffff" + implicitWidth: pillRow.implicitWidth + pill.s(24) + implicitHeight: pill.s(32) + radius: height / 2 + color: Qt.alpha("#ffffff", 0.1) + border.width: 1 + border.color: Qt.alpha("#ffffff", 0.12) + Row { + id: pillRow anchors.centerIn: parent - text: Qt.formatTime(clock.date, ConfigService.ready && !ConfigService.data.bar.clock.use24Hour ? "h:mm" : "HH:mm") - color: "#ffffff" - font.pixelSize: Math.min(root.s(176), root.height * 0.2) - font.weight: Font.Bold - font.letterSpacing: -root.s(3) + spacing: pill.s(7) + Text { + visible: Icons.available && pill.glyph !== "" + anchors.verticalCenter: parent.verticalCenter + text: pill.glyph + font.family: Icons.family + color: pill.textColor + font.pixelSize: pill.s(14) + } + Text { + anchors.verticalCenter: parent.verticalCenter + text: pill.text + color: pill.textColor + font.pixelSize: pill.s(12) + font.weight: Font.DemiBold + } } } - Text { - visible: root.preview && root.primary - anchors.horizontalCenter: parent.horizontalCenter - y: root.s(18) - text: "Preview · type your password to test it, or press Esc to close" - color: Qt.alpha("#ffffff", 0.75) - font.pixelSize: root.s(12) + + // Date and glass clock, at rest. They rise and fade as the dashboard opens. + Item { + id: restClock + anchors.fill: parent + opacity: root.primary ? 1 - root.centerReveal : 1 + visible: opacity > 0.01 + Text { + id: date + anchors.horizontalCenter: parent.horizontalCenter + y: Math.round(root.height * 0.2 - root.s(24) * root.centerReveal) + text: Qt.formatDate(clock.date, "dddd d MMMM") + color: Qt.alpha("#ffffff", 0.92) + font.pixelSize: root.s(24) + font.weight: Font.DemiBold + layer.enabled: true + layer.effect: MultiEffect { + shadowEnabled: true + shadowColor: "#66000000" + shadowBlur: 0.5 + } + } + GlassSurface { + id: clockGlass + objectName: "lockClock" + backdrop: frostSource + space: restClock + glass: root.glassReady + x: Math.round((root.width - width) / 2) + y: date.y + date.height - root.s(6) + width: digits.implicitWidth + root.s(24) + height: digits.implicitHeight + brightness: 1.3 + tint: "#ffffff" + tintAmount: 0.2 + Text { + id: digits + anchors.centerIn: parent + text: root.timeText + color: "#ffffff" + font.pixelSize: Math.min(root.s(176), root.height * 0.2) + font.weight: Font.Bold + font.letterSpacing: -root.s(3) + } + } + + // Now Playing. + GlassSurface { + id: nowPlaying + readonly property bool shown: root.primary && LockState.options.media && !!MediaService.player + visible: shown + backdrop: frostSource + space: restClock + glass: root.glassReady + x: Math.round((root.width - width) / 2) + y: clockGlass.y + clockGlass.height + root.s(22) + width: root.s(380) + height: root.s(74) + radius: root.s(24) + // Darker material keeps white text readable over bright wallpapers. + tint: "#000000" + tintAmount: 0.45 + brightness: 0.8 + } + RowLayout { + visible: nowPlaying.shown + x: nowPlaying.x + root.s(12) + y: nowPlaying.y + width: nowPlaying.width - root.s(24) + height: nowPlaying.height + spacing: root.s(12) + Artwork { + unit: root.unit + size: root.s(50) + } + TrackText { + unit: root.unit + Layout.fillWidth: true + } + MediaControls { + unit: root.unit + } + } + + Text { + visible: root.primary + anchors.horizontalCenter: parent.horizontalCenter + y: root.height - root.s(64) + text: root.preview ? "Preview · type your password to test it, or press Esc to close" : "Type your password or click to unlock" + color: Qt.alpha("#ffffff", 0.7) + font.pixelSize: root.s(13) + layer.enabled: true + layer.effect: MultiEffect { + shadowEnabled: true + shadowColor: "#66000000" + shadowBlur: 0.4 + } + } + } + + component Artwork: Rectangle { + id: artwork + property real unit: 1 + function s(value) { + return Math.round(value * unit); + } + property int size + Layout.preferredWidth: size + Layout.preferredHeight: size + radius: artwork.s(10) + color: Qt.alpha("#ffffff", 0.15) + clip: true + Text { + anchors.centerIn: parent + visible: art.status !== Image.Ready + text: "♫" + color: Qt.alpha("#ffffff", 0.6) + font.pixelSize: parent.size * 0.4 + } + Image { + id: art + anchors.fill: parent + source: MediaService.artwork + fillMode: Image.PreserveAspectCrop + asynchronous: true + sourceSize: Qt.size(120, 120) + } + } + component TrackText: ColumnLayout { + id: track + property real unit: 1 + function s(value) { + return Math.round(value * unit); + } + spacing: 0 + Text { + text: MediaService.title + color: "#ffffff" + font.pixelSize: track.s(14) + font.weight: Font.DemiBold + elide: Text.ElideRight + Layout.fillWidth: true + } + Text { + visible: text !== "" + text: MediaService.artist + color: Qt.alpha("#ffffff", 0.7) + font.pixelSize: track.s(12) + elide: Text.ElideRight + Layout.fillWidth: true + } + } + component MediaControls: Row { + id: controls + property real unit: 1 + function s(value) { + return Math.round(value * unit); + } + Repeater { + model: [ + { + glyph: "󰒮", + fallback: "‹‹", + run: () => MediaService.previous() + }, + { + glyph: MediaService.playing ? "󰏤" : "󰐊", + fallback: MediaService.playing ? "❚❚" : "▶", + run: () => MediaService.toggle() + }, + { + glyph: "󰒭", + fallback: "››", + run: () => MediaService.next() + } + ] + Rectangle { + id: control + required property var modelData + width: controls.s(32) + height: width + radius: width / 2 + color: controlArea.containsMouse ? Qt.alpha("#ffffff", 0.18) : "transparent" + Text { + anchors.centerIn: parent + text: Icons.available ? control.modelData.glyph : control.modelData.fallback + font.family: Icons.available ? Icons.family : "" + color: "#ffffff" + font.pixelSize: controls.s(18) + } + MouseArea { + id: controlArea + anchors.fill: parent + hoverEnabled: true + enabled: !!MediaService.player + onClicked: control.modelData.run() + } + } + } } // Status: keyboard layout, Wi-Fi and battery. @@ -244,114 +549,384 @@ Item { } } - // Now Playing. + // While open, the time moves to a compact line at the top. + Text { + visible: root.primary && opacity > 0.01 + opacity: root.centerReveal + anchors.horizontalCenter: parent.horizontalCenter + y: root.s(22) + text: root.timeText + " · " + Qt.formatDate(clock.date, "dddd d MMMM") + color: "#ffffff" + font.pixelSize: root.s(15) + font.weight: Font.DemiBold + layer.enabled: true + layer.effect: MultiEffect { + shadowEnabled: true + shadowColor: "#66000000" + shadowBlur: 0.4 + } + } + + // The dashboard: one glass shell that widens as the wings unfold. GlassSurface { - id: nowPlaying - readonly property bool shown: root.primary && LockState.options.media && !!MediaService.player - visible: shown + id: shell + objectName: "lockDashboard" + visible: root.primary && root.centerReveal > 0.01 backdrop: frostSource space: root - glass: root.glass && wallpaper.status === Image.Ready + glass: root.glassReady + width: root.centerWidth + 2 * root.wingWidth * root.wingsReveal + height: root.shellHeight x: Math.round((root.width - width) / 2) - y: clockGlass.y + clockGlass.height + root.s(22) - width: root.s(380) - height: root.s(74) - radius: root.s(24) - // Darker material keeps white text readable over bright wallpapers. + y: Math.round((root.height - height) / 2 + root.s(10) + root.s(36) * (1 - root.centerReveal)) + radius: root.s(36) + opacity: root.centerReveal tint: "#000000" - tintAmount: 0.45 + tintAmount: 0.42 brightness: 0.8 } - RowLayout { - visible: nowPlaying.shown - x: nowPlaying.x + root.s(12) - y: nowPlaying.y - width: nowPlaying.width - root.s(24) - height: nowPlaying.height - spacing: root.s(12) - Rectangle { - Layout.preferredWidth: root.s(50) - Layout.preferredHeight: root.s(50) - radius: root.s(10) - color: Qt.alpha("#ffffff", 0.15) + Item { + id: dashboard + // Stays visible (at zero opacity) so the password field keeps focus + // and the first keystroke lands in it. + visible: root.primary + x: shell.x + y: shell.y + width: shell.width + height: shell.height + opacity: root.centerReveal + clip: true + + // Left wing: weather and system usage. Its content is anchored to the + // centre so it unfolds outwards. + Item { + id: leftWing + enabled: root.open + width: root.wingWidth * root.wingsReveal + height: parent.height clip: true - Image { + opacity: root.wingsReveal + Loader { + x: leftWing.width - root.wingWidth + width: root.wingWidth + height: parent.height + active: root.primary && root.wingsAllowed + sourceComponent: ColumnLayout { + spacing: root.s(10) + Card { + Layout.fillWidth: true + Layout.preferredHeight: root.s(170) + Layout.topMargin: root.s(16) + Layout.leftMargin: root.s(16) + WeatherFace { + anchors.fill: parent + kind: "weather" + desktopVisible: root.live + options: ({ + location: root.weatherLocation, + fahrenheit: root.weatherFahrenheit + }) + } + } + GridLayout { + Layout.fillWidth: true + Layout.fillHeight: true + Layout.leftMargin: root.s(16) + Layout.bottomMargin: root.s(16) + columns: 6 + rowSpacing: root.s(10) + columnSpacing: root.s(10) + Repeater { + model: ["cpu", "ram", "temp", "disk"] + Card { + id: usageCard + required property string modelData + required property int index + Layout.columnSpan: index < 3 ? 2 : 3 + Layout.fillWidth: true + Layout.fillHeight: true + Layout.preferredWidth: index < 3 ? 2 : 3 + UsageFace { + anchors.fill: parent + kind: usageCard.modelData + desktopVisible: root.live + } + } + } + Card { + Layout.columnSpan: 3 + Layout.fillWidth: true + Layout.fillHeight: true + Layout.preferredWidth: 3 + NetworkFace { + anchors.fill: parent + kind: "network" + desktopVisible: root.live + } + } + } + } + } + } + + // Centre: avatar, name and status, password, keyboard state. + Item { + id: center + x: leftWing.width + width: root.centerWidth + height: parent.height + ColumnLayout { anchors.fill: parent - source: MediaService.artwork - fillMode: Image.PreserveAspectCrop - asynchronous: true - sourceSize: Qt.size(120, 120) - } - } - ColumnLayout { - Layout.fillWidth: true - spacing: 0 - Text { - text: MediaService.title - color: "#ffffff" - font.pixelSize: root.s(14) - font.weight: Font.DemiBold - elide: Text.ElideRight - Layout.fillWidth: true - } - Text { - text: MediaService.artist - color: Qt.alpha("#ffffff", 0.7) - font.pixelSize: root.s(12) - elide: Text.ElideRight - Layout.fillWidth: true - } - } - Repeater { - model: [ - { - glyph: "󰒮", - fallback: "‹‹", - run: () => MediaService.previous() - }, - { - glyph: MediaService.playing ? "󰏤" : "󰐊", - fallback: MediaService.playing ? "❚❚" : "▶", - run: () => MediaService.toggle() - }, - { - glyph: "󰒭", - fallback: "››", - run: () => MediaService.next() + anchors.margins: root.s(28) + spacing: 0 + Item { + Layout.fillHeight: true + } + Avatar { + unit: root.unit + Layout.alignment: Qt.AlignHCenter + size: Math.min(root.s(150), root.shellHeight * 0.3) + } + Item { + Layout.fillHeight: true + Layout.maximumHeight: root.s(28) + Layout.minimumHeight: root.s(12) + } + RowLayout { + Layout.alignment: Qt.AlignHCenter + spacing: root.s(8) + Pill { + unit: root.unit + glyph: "󰀉" + text: LockState.realName || Quickshell.env("USER") || "" + } + Pill { + unit: root.unit + objectName: "lockStatus" + readonly property bool failed: LockState.status !== "" && !LockState.busy + glyph: LockState.busy ? "󰔟" : failed ? "󰀦" : "󰌾" + text: LockState.busy ? "Checking…" : failed ? LockState.status : root.preview ? "Preview" : "Locked" + textColor: failed ? "#ffb4a8" : "#ffffff" + } + } + Item { + Layout.preferredHeight: root.s(16) + } + Rectangle { + Layout.fillWidth: true + Layout.preferredHeight: root.s(46) + objectName: "lockField" + radius: height / 2 + color: Qt.alpha("#ffffff", 0.12) + border.width: 1 + border.color: Qt.alpha("#ffffff", field.activeFocus ? 0.38 : 0.16) + transform: Translate { + x: root.shake + } + TextInput { + id: field + objectName: "lockPassword" + anchors.left: parent.left + anchors.right: submit.left + anchors.leftMargin: submit.width + root.s(10) + anchors.rightMargin: root.s(4) + anchors.verticalCenter: parent.verticalCenter + horizontalAlignment: TextInput.AlignHCenter + echoMode: TextInput.Password + passwordCharacter: "●" + color: "#ffffff" + selectionColor: Qt.alpha("#ffffff", 0.3) + font.pixelSize: root.s(14) + font.letterSpacing: root.s(1) + enabled: !LockState.busy && !LockState.unlocking + clip: true + onTextChanged: { + root.wake(); + if (text) + root.openDashboard(); + } + onAccepted: { + if (!text) + root.openDashboard(); + else + LockState.submit(text, root.preview ? "preview" : "unlock"); + } + Text { + anchors.fill: parent + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + visible: !field.text + text: LockState.busy ? "Checking…" : "Enter Password" + color: Qt.alpha("#ffffff", 0.55) + font.pixelSize: root.s(14) + } + } + Rectangle { + id: submit + anchors.right: parent.right + anchors.rightMargin: root.s(6) + anchors.verticalCenter: parent.verticalCenter + width: parent.height - root.s(12) + height: width + radius: width / 2 + visible: field.text.length > 0 || LockState.busy + color: submitArea.containsMouse ? Qt.alpha("#ffffff", 0.35) : Qt.alpha("#ffffff", 0.22) + Text { + anchors.centerIn: parent + visible: !LockState.busy + text: Icons.available ? "󰁔" : "→" + font.family: Icons.available ? Icons.family : "" + color: "#ffffff" + font.pixelSize: root.s(15) + } + Rectangle { + anchors.centerIn: parent + visible: LockState.busy + width: parent.width * 0.55 + height: width + radius: width / 2 + color: "transparent" + border.width: root.s(2) + border.color: "#ffffff" + opacity: 0.8 + RotationAnimation on rotation { + running: LockState.busy + from: 0 + to: 360 + duration: 900 + loops: Animation.Infinite + } + Rectangle { + width: parent.width / 2 + height: parent.height / 2 + color: "#000000" + opacity: 0.6 + } + } + MouseArea { + id: submitArea + anchors.fill: parent + hoverEnabled: true + onClicked: LockState.submit(field.text, root.preview ? "preview" : "unlock") + } + } + } + Item { + Layout.preferredHeight: root.s(14) + } + RowLayout { + Layout.alignment: Qt.AlignHCenter + spacing: root.s(8) + Pill { + unit: root.unit + visible: LockState.layout !== "" + glyph: "󰌌" + text: LockState.layout + } + Pill { + unit: root.unit + objectName: "lockCapsLock" + visible: LockState.capsLock + glyph: "󰘲" + text: "Caps Lock" + textColor: "#ffd59a" + } + Pill { + unit: root.unit + readonly property var battery: UPower.displayDevice + visible: battery.ready && battery.isLaptopBattery + glyph: battery.state === UPowerDeviceState.Charging ? "󰂄" : "󰁹" + text: Math.round(battery.percentage * 100) + "%" + } + } + Item { + Layout.fillHeight: true } - ] - Rectangle { - id: control - required property var modelData - Layout.preferredWidth: root.s(32) - Layout.preferredHeight: root.s(32) - radius: width / 2 - color: controlArea.containsMouse ? Qt.alpha("#ffffff", 0.18) : "transparent" Text { - anchors.centerIn: parent - text: Icons.available ? control.modelData.glyph : control.modelData.fallback - font.family: Icons.available ? Icons.family : "" - color: "#ffffff" - font.pixelSize: root.s(18) + Layout.alignment: Qt.AlignHCenter + visible: root.preview + text: "Your password is checked but nothing is locked" + color: Qt.alpha("#ffffff", 0.6) + font.pixelSize: root.s(11) } - MouseArea { - id: controlArea - anchors.fill: parent - hoverEnabled: true - onClicked: control.modelData.run() + } + } + + // Right wing: notifications and media, unfolding outwards. + Item { + id: rightWing + enabled: root.open + x: center.x + center.width + width: root.wingWidth * root.wingsReveal + height: parent.height + clip: true + opacity: root.wingsReveal + Loader { + width: root.wingWidth + height: parent.height + active: root.primary && root.wingsAllowed + sourceComponent: ColumnLayout { + spacing: root.s(10) + Card { + Layout.fillWidth: true + Layout.fillHeight: true + Layout.topMargin: root.s(16) + Layout.rightMargin: root.s(16) + Layout.bottomMargin: LockState.options.media ? 0 : root.s(16) + LockNotifications { + anchors.fill: parent + unit: root.unit + anchors.margins: root.s(12) + } + } + Card { + visible: LockState.options.media + Layout.fillWidth: true + Layout.preferredHeight: root.s(92) + Layout.rightMargin: root.s(16) + Layout.bottomMargin: root.s(16) + clip: true + Loader { + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.margins: root.s(12) + height: parent.height * 0.6 + opacity: 0.22 + active: root.live && MediaService.playing + sourceComponent: CavaView {} + } + RowLayout { + anchors.fill: parent + anchors.margins: root.s(14) + spacing: root.s(12) + Artwork { + unit: root.unit + size: root.s(60) + } + TrackText { + unit: root.unit + Layout.fillWidth: true + } + MediaControls { + unit: root.unit + } + } + } } } } } - // Avatar, name and password. - Item { + component Avatar: Item { id: avatar - visible: root.primary - width: root.s(84) - height: width - x: Math.round((root.width - width) / 2) - y: root.height - root.s(LockState.options.powerButtons ? 330 : 250) + property real unit: 1 + function s(value) { + return Math.round(value * unit); + } + property int size + Layout.preferredWidth: size + Layout.preferredHeight: size readonly property var candidates: ["file://" + Quickshell.env("HOME") + "/.face", "file://" + Quickshell.env("HOME") + "/.face.icon", "file:///var/lib/AccountsService/icons/" + (Quickshell.env("USER") || "")] property int candidate: 0 Image { @@ -359,7 +934,7 @@ Item { anchors.fill: parent visible: false source: avatar.candidate < avatar.candidates.length ? avatar.candidates[avatar.candidate] : "" - sourceSize: Qt.size(200, 200) + sourceSize: Qt.size(300, 300) fillMode: Image.PreserveAspectCrop onStatusChanged: if (status === Image.Error) avatar.candidate++ @@ -382,7 +957,7 @@ Item { anchors.fill: parent radius: width / 2 visible: face.status !== Image.Ready - color: Qt.alpha("#ffffff", 0.22) + color: Qt.alpha("#ffffff", 0.18) Text { anchors.centerIn: parent text: (LockState.realName || Quickshell.env("USER") || "?").charAt(0).toUpperCase() @@ -393,29 +968,14 @@ Item { } Rectangle { anchors.fill: parent - anchors.margins: -root.s(3) + anchors.margins: -avatar.s(4) radius: width / 2 color: "transparent" - border.width: root.s(2) - border.color: Qt.alpha("#ffffff", 0.35) - } - } - Text { - id: userName - visible: root.primary - anchors.horizontalCenter: parent.horizontalCenter - y: avatar.y + avatar.height + root.s(12) - text: LockState.realName || Quickshell.env("USER") || "" - color: "#ffffff" - font.pixelSize: root.s(17) - font.weight: Font.DemiBold - layer.enabled: true - layer.effect: MultiEffect { - shadowEnabled: true - shadowColor: "#66000000" - shadowBlur: 0.4 + border.width: avatar.s(2) + border.color: Qt.alpha("#ffffff", 0.3) } } + property real shake: 0 SequentialAnimation { id: shakeAnimation @@ -454,118 +1014,15 @@ Item { target: LockState function onFailuresChanged() { field.text = ""; + root.openDashboard(); shakeAnimation.restart(); } } - GlassSurface { - id: fieldGlass - objectName: "lockField" - visible: root.primary - backdrop: frostSource - space: root - glass: root.glass && wallpaper.status === Image.Ready - width: root.s(250) - height: root.s(36) - x: Math.round((root.width - width) / 2 + root.shake) - y: userName.y + userName.height + root.s(14) - tint: "#ffffff" - tintAmount: 0.16 - brightness: 1.2 - } - Item { - visible: root.primary - x: fieldGlass.x - y: fieldGlass.y - width: fieldGlass.width - height: fieldGlass.height - TextInput { - id: field - objectName: "lockPassword" - anchors.left: parent.left - anchors.right: submit.left - anchors.leftMargin: root.s(16) - anchors.rightMargin: root.s(6) - anchors.verticalCenter: parent.verticalCenter - echoMode: TextInput.Password - passwordCharacter: "●" - color: "#ffffff" - selectionColor: Qt.alpha("#ffffff", 0.3) - font.pixelSize: root.s(13) - font.letterSpacing: root.s(1) - enabled: !LockState.busy && !LockState.unlocking - clip: true - onTextChanged: root.wake() - onAccepted: LockState.submit(text, root.preview ? "preview" : "unlock") - Text { - anchors.verticalCenter: parent.verticalCenter - visible: !field.text - text: LockState.busy ? "Checking…" : "Enter Password" - color: Qt.alpha("#ffffff", 0.6) - font.pixelSize: root.s(13) - } - } - Rectangle { - id: submit - anchors.right: parent.right - anchors.rightMargin: root.s(5) - anchors.verticalCenter: parent.verticalCenter - width: parent.height - root.s(10) - height: width - radius: width / 2 - visible: field.text.length > 0 || LockState.busy - color: submitArea.containsMouse ? Qt.alpha("#ffffff", 0.35) : Qt.alpha("#ffffff", 0.22) - Text { - anchors.centerIn: parent - visible: !LockState.busy - text: Icons.available ? "󰁔" : "→" - font.family: Icons.available ? Icons.family : "" - color: "#ffffff" - font.pixelSize: root.s(14) - } - Rectangle { - anchors.centerIn: parent - visible: LockState.busy - width: parent.width * 0.55 - height: width - radius: width / 2 - color: "transparent" - border.width: root.s(2) - border.color: "#ffffff" - opacity: 0.8 - RotationAnimation on rotation { - running: LockState.busy - from: 0 - to: 360 - duration: 900 - loops: Animation.Infinite - } - Rectangle { - width: parent.width / 2 - height: parent.height / 2 - color: "#000000" - opacity: 0.6 - } - } - MouseArea { - id: submitArea - anchors.fill: parent - hoverEnabled: true - onClicked: LockState.submit(field.text, root.preview ? "preview" : "unlock") - } - } - } - Text { - visible: root.primary - anchors.horizontalCenter: parent.horizontalCenter - y: fieldGlass.y + fieldGlass.height + root.s(12) - text: LockState.status || (root.preview ? "Your password is checked but nothing is locked" : "") - color: Qt.alpha("#ffffff", LockState.status ? 0.95 : 0.65) - font.pixelSize: root.s(12) - font.weight: LockState.status ? Font.DemiBold : Font.Normal - } - // Power controls, as on the macOS login window. Inert in preview. - readonly property var powerActions: root.primary && LockState.options.powerButtons ? [ + // Power controls behind a corner button, so a stray click cannot shut + // down. Inert in preview. + readonly property bool powerShown: root.primary && LockState.options.powerButtons && root.centerReveal > 0.01 + readonly property var powerActions: [ { id: "suspend", label: "Sleep", @@ -581,43 +1038,55 @@ Item { label: "Shut Down", glyph: "󰐥" } - ] : [] + ] function powerAvailable(id) { return !!SystemService.state.power && !!SystemService.state.power[id]; } + readonly property int powerSize: s(48) + readonly property int powerY: height - s(28) - powerSize function powerX(index) { - return Math.round(width / 2 + (index - 1) * s(104) - s(23)); + // index 3 is the toggle in the corner; actions open to its left. + return Math.round(width - s(28) - powerSize - (3 - index) * s(72) * powerReveal); + } + property real powerReveal: powerOpen ? 1 : 0 + Behavior on powerReveal { + NumberAnimation { + duration: root.motion ? 260 : 0 + easing.type: Easing.OutCubic + } } Repeater { - model: root.powerActions + model: root.powerShown ? root.powerActions : [] GlassSurface { required property var modelData required property int index objectName: "lockPower-" + modelData.id + visible: root.powerReveal > 0.01 backdrop: frostSource space: root - glass: root.glass && wallpaper.status === Image.Ready - width: root.s(46) + glass: root.glassReady + width: root.powerSize height: width x: root.powerX(index) - y: root.height - root.s(118) + y: root.powerY tint: "#ffffff" tintAmount: 0.16 brightness: 1.2 - opacity: root.powerAvailable(modelData.id) ? 1 : 0.4 + opacity: root.centerReveal * root.powerReveal * (root.powerAvailable(modelData.id) ? 1 : 0.4) } } Repeater { - model: root.powerActions + model: root.powerShown ? root.powerActions : [] Item { id: power required property var modelData required property int index + visible: root.powerReveal > 0.01 x: root.powerX(index) - y: root.height - root.s(118) - width: root.s(46) + y: root.powerY + width: root.powerSize height: width - opacity: root.powerAvailable(modelData.id) ? 1 : 0.4 + opacity: root.centerReveal * root.powerReveal * (root.powerAvailable(modelData.id) ? 1 : 0.4) Rectangle { anchors.fill: parent radius: width / 2 @@ -632,8 +1101,8 @@ Item { } Text { anchors.horizontalCenter: parent.horizontalCenter - anchors.top: parent.bottom - anchors.topMargin: root.s(8) + anchors.bottom: parent.top + anchors.bottomMargin: root.s(8) text: power.modelData.label color: Qt.alpha("#ffffff", 0.85) font.pixelSize: root.s(12) @@ -642,10 +1111,51 @@ Item { id: powerArea anchors.fill: parent hoverEnabled: true - enabled: root.powerAvailable(power.modelData.id) && !root.preview + enabled: root.powerOpen && root.powerAvailable(power.modelData.id) && !root.preview cursorShape: Qt.PointingHandCursor onClicked: SystemService.action("power", power.modelData.id, true) } } } + GlassSurface { + objectName: "lockPowerToggle" + visible: root.powerShown + backdrop: frostSource + space: root + glass: root.glassReady + width: root.powerSize + height: width + x: root.powerX(3) + y: root.powerY + tint: root.powerOpen ? "#ffffff" : "#000000" + tintAmount: root.powerOpen ? 0.3 : 0.35 + brightness: root.powerOpen ? 1.2 : 0.85 + opacity: root.centerReveal + } + Item { + visible: root.powerShown + x: root.powerX(3) + y: root.powerY + width: root.powerSize + height: width + opacity: root.centerReveal + Text { + anchors.centerIn: parent + text: Icons.available ? (root.powerOpen ? "󰅖" : "󰐥") : (root.powerOpen ? "×" : "⏻") + font.family: Icons.available ? Icons.family : "" + color: root.powerOpen ? "#ffffff" : "#ffb4a8" + font.pixelSize: root.s(20) + } + MouseArea { + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + Accessible.role: Accessible.Button + Accessible.name: root.powerOpen ? "Close power options" : "Power options" + onClicked: { + root.wake(); + root.powerOpen = !root.powerOpen; + } + } + } } diff --git a/quickshell/lock/qmldir b/quickshell/lock/qmldir index 78c668a..bac30d0 100644 --- a/quickshell/lock/qmldir +++ b/quickshell/lock/qmldir @@ -2,3 +2,4 @@ singleton LockState 1.0 LockState.qml Lock 1.0 Lock.qml LockSurface 1.0 LockSurface.qml GlassSurface 1.0 GlassSurface.qml +LockNotifications 1.0 LockNotifications.qml diff --git a/quickshell/services/ConfigLogic.js b/quickshell/services/ConfigLogic.js index f68a18a..b19cc99 100644 --- a/quickshell/services/ConfigLogic.js +++ b/quickshell/services/ConfigLogic.js @@ -70,7 +70,7 @@ function validate(c) { for(const key of ["showAlbumArt","showProgress","showAlbum","showCava"])if(typeof c.media[key]!=="boolean")throw Error("Invalid media toggle"); if(typeof c.media.preferredPlayer!=="string")throw Error("Invalid media preferences"); const lock=c.lock; - if(!lock || ["enabled","glass","media","powerButtons"].some(k=>typeof lock[k]!=="boolean") || !["wallpaper","screenshot"].includes(lock.backdrop) || typeof lock.pamService!=="string" || !/^[A-Za-z0-9._-]{0,64}$/.test(lock.pamService))throw Error("Invalid lock screen preferences"); + if(!lock || ["enabled","glass","media","dashboard","notificationPreviews","powerButtons"].some(k=>typeof lock[k]!=="boolean") || !["wallpaper","screenshot"].includes(lock.backdrop) || typeof lock.pamService!=="string" || !/^[A-Za-z0-9._-]{0,64}$/.test(lock.pamService))throw Error("Invalid lock screen preferences"); const dw=c.desktopWidgets; if(!dw || dw.version!==1 || typeof dw.grid!=="boolean" || !Array.isArray(dw.items))throw Error("Invalid desktop widgets"); const widgetIds=new Set(); diff --git a/quickshell/settings/pages/Lock.qml b/quickshell/settings/pages/Lock.qml index 2d66644..7257a30 100644 --- a/quickshell/settings/pages/Lock.qml +++ b/quickshell/settings/pages/Lock.qml @@ -60,7 +60,7 @@ SettingsPage { title: "Appearance" PreferenceChoice { label: "Backdrop" - description: "Your wallpaper, like macOS, or a snapshot of the desktop taken when locking" + description: "Your wallpaper, like macOS, or a heavily blurred snapshot of the desktop taken when locking" icon: "󰸉" setting: "lock.backdrop" choices: ["wallpaper", "screenshot"] @@ -71,14 +71,27 @@ SettingsPage { icon: "󰂵" setting: "lock.glass" } + PreferenceToggle { + label: "Dashboard" + description: "When you start typing, weather and system usage unfold on the left, notifications and media on the right" + icon: "󰕮" + setting: "lock.dashboard" + } PreferenceToggle { label: "Now Playing" + description: "Below the clock, and as a media card in the dashboard" icon: "󰝚" setting: "lock.media" } + PreferenceToggle { + label: "Notification previews" + description: "Show message text in the dashboard, not just the app and title" + icon: "󰂚" + setting: "lock.notificationPreviews" + } PreferenceToggle { label: "Power buttons" - description: "Sleep, Restart and Shut Down below the password field" + description: "Sleep, Restart and Shut Down behind a button in the corner" icon: "󰐥" setting: "lock.powerButtons" } diff --git a/quickshell/testing/SettingsDriver.qml b/quickshell/testing/SettingsDriver.qml index ed0e456..797bc3b 100644 --- a/quickshell/testing/SettingsDriver.qml +++ b/quickshell/testing/SettingsDriver.qml @@ -141,6 +141,15 @@ Item { const surface = LockState.surfaces[index]; return !!surface && surface.grabToImage(result => result.saveToFile(path)); } + function lockDashboard(open: bool): int { + for (const surface of LockState.surfaces) { + if (open) + surface.openDashboard(); + else + surface.closeDashboard(); + } + return LockState.surfaces.length; + } function lockSubmit(text: string): bool { return LockState.submit(text, LockState.previewing ? "preview" : "test"); } diff --git a/quickshell/widgets/faces/WeatherFace.qml b/quickshell/widgets/faces/WeatherFace.qml index d5931cc..e4852c7 100644 --- a/quickshell/widgets/faces/WeatherFace.qml +++ b/quickshell/widgets/faces/WeatherFace.qml @@ -1,8 +1,10 @@ +pragma ComponentBehavior: Bound import QtQuick import QtQuick.Layouts import Quickshell import Quickshell.Io import "../../components" +import "../../services" import "../../theme" // Current conditions from wttr.in, refreshed every 30 minutes. @@ -59,41 +61,96 @@ Face { } onLocationChanged: if (!fetch.running) fetch.running = true - RowLayout { + // The next few forecasts appear below once the face is large enough. + readonly property var hourly: current && current.hourly ? current.hourly : [] + readonly property bool showHourly: hourly.length > 0 && height >= 150 && width >= 260 + function hourLabel(hour) { + if (ConfigService.ready && !ConfigService.data.bar.clock.use24Hour) + return (hour % 12 || 12) + (hour < 12 ? " AM" : " PM"); + return (hour < 10 ? "0" : "") + hour + ":00"; + } + ColumnLayout { anchors.fill: parent anchors.margins: 14 - spacing: 12 - GlassIcon { - size: Math.min(root.height - 28, 64) - glyphSize: size * 0.62 - glyph: root.current ? root.glyph(root.current.code) : "󰖐" - fallback: "☁" - color: Theme.transparent - border.width: 0 + spacing: 10 + RowLayout { + Layout.fillWidth: true + Layout.fillHeight: true + spacing: 12 + GlassIcon { + size: Math.min((root.showHourly ? root.height * 0.55 : root.height) - 28, 64) + glyphSize: size * 0.62 + glyph: root.current ? root.glyph(root.current.code) : "󰖐" + fallback: "☁" + color: Theme.transparent + border.width: 0 + } + ColumnLayout { + Layout.fillWidth: true + spacing: 0 + Text { + text: root.current ? root.temperature(root.current.celsius) : "—" + color: Theme.text + font.pixelSize: Math.max(20, Math.min(root.height * 0.3, 44)) + font.weight: Font.Light + } + Text { + text: root.current ? root.current.description : root.error || "Loading…" + color: Theme.text + font.pixelSize: 12 + elide: Text.ElideRight + Layout.fillWidth: true + } + Text { + visible: !!root.current && root.height > 110 + text: root.current ? root.current.place + " · feels " + root.temperature(root.current.feelsCelsius) : "" + color: Theme.textSecondary + font.pixelSize: 10 + elide: Text.ElideRight + Layout.fillWidth: true + } + } } - ColumnLayout { + RowLayout { + visible: root.showHourly Layout.fillWidth: true spacing: 0 - Text { - text: root.current ? root.temperature(root.current.celsius) : "—" - color: Theme.text - font.pixelSize: Math.max(20, root.height * 0.3) - font.weight: Font.Light - } - Text { - text: root.current ? root.current.description : root.error || "Loading…" - color: Theme.text - font.pixelSize: 12 - elide: Text.ElideRight - Layout.fillWidth: true - } - Text { - visible: !!root.current && root.height > 110 - text: root.current ? root.current.place + " · feels " + root.temperature(root.current.feelsCelsius) : "" - color: Theme.textSecondary - font.pixelSize: 10 - elide: Text.ElideRight - Layout.fillWidth: true + Repeater { + model: root.showHourly ? root.hourly : [] + // Equal-width slots: a nested layout only grows when a child fills. + Item { + id: slot + required property var modelData + Layout.fillWidth: true + Layout.preferredWidth: 1 + implicitHeight: slotColumn.implicitHeight + Column { + id: slotColumn + anchors.horizontalCenter: parent.horizontalCenter + spacing: 2 + Text { + anchors.horizontalCenter: parent.horizontalCenter + text: root.hourLabel(slot.modelData.hour) + color: Theme.textSecondary + font.pixelSize: 10 + } + Text { + anchors.horizontalCenter: parent.horizontalCenter + visible: Icons.available + text: Icons.available ? root.glyph(slot.modelData.code) : "" + font.family: Icons.family + color: Theme.text + font.pixelSize: 18 + } + Text { + anchors.horizontalCenter: parent.horizontalCenter + text: root.temperature(slot.modelData.celsius) + color: Theme.text + font.pixelSize: 11 + font.weight: Font.DemiBold + } + } + } } } } diff --git a/quickshell/widgets/faces/qmldir b/quickshell/widgets/faces/qmldir index 94e8efa..4ecd134 100644 --- a/quickshell/widgets/faces/qmldir +++ b/quickshell/widgets/faces/qmldir @@ -1 +1,4 @@ Face 1.0 Face.qml +NetworkFace 1.0 NetworkFace.qml +UsageFace 1.0 UsageFace.qml +WeatherFace 1.0 WeatherFace.qml