Initial commit of the Quickshell desktop suite: bar, dock, launcher, settings, Control Center, dashboard, OSD, lock screen, desktop widgets, plugin host with the vendored Noctalia/Omarchy compatibility layer, helpers, packaging, tests and phase documentation. Includes the optimization work so far: usage widgets and dashboard gauges no longer animate continuously, desktop widgets pause while covered, system controls stop flickering on background polls, dock app matching uses an indexed catalog, and workspace ghosts are created only for occupied slots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
652 lines
21 KiB
QML
652 lines
21 KiB
QML
pragma ComponentBehavior: Bound
|
||
import QtQuick
|
||
import QtQuick.Effects
|
||
import QtQuick.Layouts
|
||
import Quickshell
|
||
import Quickshell.Services.UPower
|
||
import "../services"
|
||
import "../theme"
|
||
|
||
// 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.
|
||
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 glass: LockState.options.glass
|
||
// 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);
|
||
}
|
||
property bool active: false
|
||
function wake() {
|
||
active = true;
|
||
idle.restart();
|
||
}
|
||
|
||
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.onPressed: event => {
|
||
root.wake();
|
||
if (event.key === Qt.Key_Escape) {
|
||
if (root.preview)
|
||
LockState.cancelPreview();
|
||
else
|
||
field.text = "";
|
||
event.accepted = true;
|
||
} else if (root.primary && !field.activeFocus) {
|
||
field.forceActiveFocus();
|
||
if (event.text && event.text.length === 1 && event.text >= " ") {
|
||
field.insert(field.cursorPosition, event.text);
|
||
event.accepted = true;
|
||
}
|
||
}
|
||
}
|
||
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
|
||
}
|
||
SystemClock {
|
||
id: clock
|
||
precision: SystemClock.Minutes
|
||
}
|
||
|
||
// Backdrop: wallpaper (or the pre-lock screenshot), lightly blurred while typing.
|
||
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: 48
|
||
blur: root.active && root.primary ? 0.35 : 0
|
||
brightness: root.active ? -0.06 : 0
|
||
Behavior on blur {
|
||
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.wake();
|
||
if (root.primary)
|
||
field.forceActiveFocus();
|
||
}
|
||
}
|
||
|
||
// 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
|
||
}
|
||
}
|
||
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
|
||
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)
|
||
}
|
||
}
|
||
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)
|
||
}
|
||
|
||
// 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
|
||
}
|
||
}
|
||
|
||
// Now Playing.
|
||
GlassSurface {
|
||
id: nowPlaying
|
||
readonly property bool shown: root.primary && LockState.options.media && !!MediaService.player
|
||
visible: shown
|
||
backdrop: frostSource
|
||
space: root
|
||
glass: root.glass && wallpaper.status === Image.Ready
|
||
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)
|
||
Rectangle {
|
||
Layout.preferredWidth: root.s(50)
|
||
Layout.preferredHeight: root.s(50)
|
||
radius: root.s(10)
|
||
color: Qt.alpha("#ffffff", 0.15)
|
||
clip: true
|
||
Image {
|
||
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()
|
||
}
|
||
]
|
||
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)
|
||
}
|
||
MouseArea {
|
||
id: controlArea
|
||
anchors.fill: parent
|
||
hoverEnabled: true
|
||
onClicked: control.modelData.run()
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// Avatar, name and password.
|
||
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)
|
||
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(200, 200)
|
||
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.22)
|
||
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: -root.s(3)
|
||
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
|
||
}
|
||
}
|
||
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 = "";
|
||
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 ? [
|
||
{
|
||
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];
|
||
}
|
||
function powerX(index) {
|
||
return Math.round(width / 2 + (index - 1) * s(104) - s(23));
|
||
}
|
||
Repeater {
|
||
model: root.powerActions
|
||
GlassSurface {
|
||
required property var modelData
|
||
required property int index
|
||
objectName: "lockPower-" + modelData.id
|
||
backdrop: frostSource
|
||
space: root
|
||
glass: root.glass && wallpaper.status === Image.Ready
|
||
width: root.s(46)
|
||
height: width
|
||
x: root.powerX(index)
|
||
y: root.height - root.s(118)
|
||
tint: "#ffffff"
|
||
tintAmount: 0.16
|
||
brightness: 1.2
|
||
opacity: root.powerAvailable(modelData.id) ? 1 : 0.4
|
||
}
|
||
}
|
||
Repeater {
|
||
model: root.powerActions
|
||
Item {
|
||
id: power
|
||
required property var modelData
|
||
required property int index
|
||
x: root.powerX(index)
|
||
y: root.height - root.s(118)
|
||
width: root.s(46)
|
||
height: width
|
||
opacity: 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.top: parent.bottom
|
||
anchors.topMargin: 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.powerAvailable(power.modelData.id) && !root.preview
|
||
cursorShape: Qt.PointingHandCursor
|
||
onClicked: SystemService.action("power", power.modelData.id, true)
|
||
}
|
||
}
|
||
}
|
||
}
|