pragma ComponentBehavior: Bound import QtQuick 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, 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 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 scale: LockState.unlocking ? 1.04 : 1 Behavior on opacity { NumberAnimation { duration: 380 easing.type: Easing.OutCubic } } Behavior on scale { NumberAnimation { duration: 380 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.powerOpen) root.powerOpen = false; else if (root.open) root.closeDashboard(); else if (root.preview) LockState.cancelPreview(); event.accepted = true; 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); event.accepted = true; } } } Keys.onReleased: event => { if (event.key === Qt.Key_CapsLock) LockState.probeKeyboard(); } Component.onCompleted: { LockState.surfaces = LockState.surfaces.concat([root]); if (primary) field.forceActiveFocus(); } Component.onDestruction: LockState.surfaces = LockState.surfaces.filter(s => s !== root) Timer { id: idle interval: 20000 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, 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 { GradientStop { position: 0 color: Qt.darker(Theme.accent, 2.2) } GradientStop { position: 1 color: "#050507" } } } Image { id: wallpaper anchors.fill: parent visible: false source: root.backdropPath ? "file://" + encodeURI(root.backdropPath).replace(/#/g, "%23").replace(/\?/g, "%3F") : "" sourceSize: Qt.size(root.width, root.height) fillMode: Image.PreserveAspectCrop cache: false } MultiEffect { anchors.fill: parent source: wallpaper visible: wallpaper.status === Image.Ready blurEnabled: true 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 gradient: Gradient { GradientStop { position: 0 color: "#4d000000" } GradientStop { position: 0.32 color: "#00000000" } GradientStop { position: 0.62 color: "#00000000" } GradientStop { position: 1 color: "#80000000" } } } // Frosted copy of the backdrop that every glass surface refracts. MultiEffect { id: frost anchors.fill: parent visible: false source: wallpaper.status === Image.Ready ? wallpaper : null blurEnabled: true blurMax: 64 blur: LockState.glass.frost saturation: 0.15 } ShaderEffectSource { id: frostSource sourceItem: frost hideSource: true visible: false } MouseArea { anchors.fill: parent hoverEnabled: true onPositionChanged: root.wake() onPressed: { root.powerOpen = false; if (root.primary) { root.openDashboard(); field.forceActiveFocus(); } else root.wake(); } } component Card: Rectangle { radius: Theme.radius color: Qt.alpha("#ffffff", 0.07) border.width: 1 border.color: Qt.alpha("#ffffff", 0.1) } 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 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 } } } // 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. Row { visible: root.primary anchors.right: parent.right anchors.top: parent.top anchors.margins: root.s(18) spacing: root.s(14) Text { visible: LockState.layout !== "" text: LockState.layout color: "#ffffff" font.pixelSize: root.s(13) font.weight: Font.DemiBold } Text { visible: NetworkService.available text: Icons.available ? (NetworkService.enabled ? "󰖩" : "󰖪") : (NetworkService.enabled ? "Wi-Fi" : "Wi-Fi off") font.family: Icons.available ? Icons.family : "" color: "#ffffff" font.pixelSize: root.s(15) } Text { readonly property var battery: UPower.displayDevice visible: battery.ready && battery.isLaptopBattery text: Math.round(battery.percentage * 100) + "%" + (battery.state === UPowerDeviceState.Charging ? " ⚡" : "") color: "#ffffff" font.pixelSize: root.s(13) font.weight: Font.DemiBold } } // 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: shell objectName: "lockDashboard" visible: root.primary && root.centerReveal > 0.01 backdrop: frostSource space: root glass: root.glassReady width: root.centerWidth + 2 * root.wingWidth * root.wingsReveal height: root.shellHeight x: Math.round((root.width - width) / 2) 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.42 brightness: 0.8 } 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 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 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 } Text { 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) } } } // 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 } } } } } } } component Avatar: Item { id: avatar 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 { id: face anchors.fill: parent visible: false source: avatar.candidate < avatar.candidates.length ? avatar.candidates[avatar.candidate] : "" sourceSize: Qt.size(300, 300) fillMode: Image.PreserveAspectCrop onStatusChanged: if (status === Image.Error) avatar.candidate++ } Rectangle { id: faceMask anchors.fill: parent radius: width / 2 visible: false layer.enabled: true } MultiEffect { anchors.fill: parent source: face maskEnabled: true maskSource: faceMask visible: face.status === Image.Ready } Rectangle { anchors.fill: parent radius: width / 2 visible: face.status !== Image.Ready color: Qt.alpha("#ffffff", 0.18) Text { anchors.centerIn: parent text: (LockState.realName || Quickshell.env("USER") || "?").charAt(0).toUpperCase() color: "#ffffff" font.pixelSize: parent.width * 0.42 font.weight: Font.DemiBold } } Rectangle { anchors.fill: parent anchors.margins: -avatar.s(4) radius: width / 2 color: "transparent" border.width: avatar.s(2) border.color: Qt.alpha("#ffffff", 0.3) } } property real shake: 0 SequentialAnimation { id: shakeAnimation NumberAnimation { target: root property: "shake" to: -root.s(14) duration: 50 } NumberAnimation { target: root property: "shake" to: root.s(12) duration: 70 } NumberAnimation { target: root property: "shake" to: -root.s(8) duration: 70 } NumberAnimation { target: root property: "shake" to: root.s(4) duration: 60 } NumberAnimation { target: root property: "shake" to: 0 duration: 50 } } Connections { target: LockState function onFailuresChanged() { field.text = ""; root.openDashboard(); shakeAnimation.restart(); } } // 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", glyph: "󰤄" }, { id: "reboot", label: "Restart", glyph: "󰜉" }, { id: "shutdown", 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) { // 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.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.glassReady width: root.powerSize height: width x: root.powerX(index) y: root.powerY tint: "#ffffff" tintAmount: 0.16 brightness: 1.2 opacity: root.centerReveal * root.powerReveal * (root.powerAvailable(modelData.id) ? 1 : 0.4) } } Repeater { 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.powerY width: root.powerSize height: width opacity: root.centerReveal * root.powerReveal * (root.powerAvailable(modelData.id) ? 1 : 0.4) Rectangle { anchors.fill: parent radius: width / 2 color: Qt.alpha("#ffffff", powerArea.containsMouse && powerArea.enabled ? 0.18 : 0) } Text { anchors.centerIn: parent text: Icons.available ? power.modelData.glyph : power.modelData.label.charAt(0) font.family: Icons.available ? Icons.family : "" color: "#ffffff" font.pixelSize: root.s(20) } Text { anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.top anchors.bottomMargin: root.s(8) text: power.modelData.label color: Qt.alpha("#ffffff", 0.85) font.pixelSize: root.s(12) } MouseArea { id: powerArea anchors.fill: parent hoverEnabled: true 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; } } } }