mirror of
https://github.com/Sn3akyy1/lucid.git
synced 2026-11-19 21:27:56 +03:00
c0ebc5c3bc
- Tray: both looks rebuilt in Material You, every app in a slot of its own or three stacked with a count; a click opens the tray, each app a row with its menu opening in place - Pointer: Bibata Modern's shapes drawn from source in the palette's colours, fading with it, the tilt card, and the shell drawing the pointer itself in drags - Clock's engine in the shell (Alarms, ClockLink): alarms ring with the app closed and always post Snooze and Stop - Lumen: network drives (Connect to server, shares, Nearby); Lens: videos - Bar: Content size, notch edges as quarter ellipses up to 64 px, frosted and lit on hover; fixes across the dock, desktop, widgets, LucidShot and Settings Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
272 lines
9.3 KiB
QML
272 lines
9.3 KiB
QML
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
import qs
|
|
import "../lucidnotif"
|
|
|
|
// lock, suspend, log out, restart or shut down from the bar. the last three
|
|
// take a second click, so a stray one does nothing
|
|
BarPill {
|
|
id: root
|
|
|
|
// material symbols, as NotifIcon draws them
|
|
readonly property var icons: ({
|
|
"power": "power_settings_new",
|
|
"lock": "lock",
|
|
"logout": "logout",
|
|
"suspend": "bedtime",
|
|
"hibernate": "mode_standby",
|
|
"reboot": "restart_alt"
|
|
})
|
|
// hibernate only where logind says it can
|
|
property bool canHibernate: false
|
|
readonly property var catalogue: [{
|
|
"id": "lock",
|
|
"label": "Lock",
|
|
"icon": "lock",
|
|
"confirm": false
|
|
}, {
|
|
"id": "suspend",
|
|
"label": "Suspend",
|
|
"icon": "suspend",
|
|
"confirm": false
|
|
}, {
|
|
"id": "hibernate",
|
|
"label": "Hibernate",
|
|
"icon": "hibernate",
|
|
"confirm": false
|
|
}, {
|
|
"id": "logout",
|
|
"label": "Log out",
|
|
"icon": "logout",
|
|
"confirm": true
|
|
}, {
|
|
"id": "reboot",
|
|
"label": "Restart",
|
|
"icon": "reboot",
|
|
"confirm": true
|
|
}, {
|
|
"id": "shutdown",
|
|
"label": "Shut down",
|
|
"icon": "power",
|
|
"confirm": true
|
|
}]
|
|
// the ones picked in Settings, in the order picked
|
|
readonly property var actions: String(Prefs.powerModuleActions || "").split(",").map((id) => {
|
|
return root.catalogue.find((a) => {
|
|
return a.id === id;
|
|
});
|
|
}).filter((a) => {
|
|
return !!a && (a.id !== "hibernate" || root.canHibernate);
|
|
})
|
|
// the action waiting for its second click
|
|
property string armed: ""
|
|
property string uptime: ""
|
|
readonly property int horizontalPadding: Theme.barDp(11)
|
|
|
|
function run(id) {
|
|
const a = root.actions.find((x) => {
|
|
return x.id === id;
|
|
});
|
|
if (!a)
|
|
return ;
|
|
|
|
if (a.confirm && Prefs.powerModuleConfirm && root.armed !== id) {
|
|
root.armed = id;
|
|
disarm.restart();
|
|
return ;
|
|
}
|
|
root.armed = "";
|
|
root.expanded = false;
|
|
// the same actions as the session screen and the lock screen, from one place
|
|
Power.run(id);
|
|
}
|
|
|
|
// the looks, from its card on the Bar page
|
|
lookPref: Prefs.powerModuleStyle
|
|
readonly property bool accentFace: root.look === "accent"
|
|
readonly property bool gridPanel: Prefs.powerModulePanelStyle === "grid"
|
|
|
|
shown: Prefs.showPower
|
|
compactWidth: (root.accentFace ? Theme.barDp(24) : Theme.barDp(18)) + root.horizontalPadding * 2
|
|
panelWidth: root.gridPanel ? Theme.dp(300) : Theme.dp(260)
|
|
panelHeight: panelColumn.implicitHeight + Theme.dp(32)
|
|
expandedRadius: Theme.shapeXl
|
|
onExpandedChanged: {
|
|
root.armed = "";
|
|
if (root.expanded)
|
|
probe.running = true;
|
|
|
|
}
|
|
|
|
Timer {
|
|
id: disarm
|
|
|
|
interval: 3000
|
|
onTriggered: root.armed = ""
|
|
}
|
|
|
|
// how long the machine has been up, and whether it can hibernate
|
|
Process {
|
|
id: probe
|
|
|
|
command: ["sh", "-c", "cut -d. -f1 /proc/uptime; busctl call org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager CanHibernate 2>/dev/null"]
|
|
|
|
stdout: StdioCollector {
|
|
onStreamFinished: {
|
|
const lines = this.text.split("\n");
|
|
const s = parseInt(lines[0]);
|
|
if (!isNaN(s)) {
|
|
const d = Math.floor(s / 86400);
|
|
const h = Math.floor(s % 86400 / 3600);
|
|
const m = Math.floor(s % 3600 / 60);
|
|
root.uptime = "Up " + (d > 0 ? d + (d === 1 ? " day " : " days ") : "") + (d > 0 || h > 0 ? h + " h " : "") + m + " min";
|
|
}
|
|
root.canHibernate = /"yes"/.test(lines[1] || "");
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
compactContent: [
|
|
Rectangle {
|
|
anchors.centerIn: parent
|
|
width: Theme.barDp(24)
|
|
height: Theme.barDp(24)
|
|
radius: height / 2
|
|
color: Theme.accent
|
|
visible: root.accentFace
|
|
},
|
|
NotifIcon {
|
|
anchors.centerIn: parent
|
|
size: root.accentFace ? Theme.barDp(15) : Theme.barDp(17)
|
|
path: root.icons.power
|
|
color: root.accentFace ? Theme.fgAccent : Theme.text
|
|
}
|
|
]
|
|
|
|
panelContent: [
|
|
Column {
|
|
id: panelColumn
|
|
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
anchors.top: parent.top
|
|
anchors.margins: Theme.dp(16)
|
|
spacing: Theme.dp(4)
|
|
|
|
Item {
|
|
width: parent.width
|
|
height: Theme.dp(34)
|
|
|
|
Text {
|
|
anchors.left: parent.left
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
text: "Power"
|
|
color: Theme.accent
|
|
font.family: Theme.fontFamily
|
|
font.pixelSize: Theme.fontTitleSm
|
|
font.weight: Font.DemiBold
|
|
}
|
|
|
|
Rectangle {
|
|
visible: Prefs.powerModuleUptime && root.uptime !== ""
|
|
anchors.right: parent.right
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
width: uptimeLabel.implicitWidth + Theme.dp(20)
|
|
height: Theme.dp(26)
|
|
radius: Theme.dp(13)
|
|
color: Theme.accentContainer
|
|
|
|
Text {
|
|
id: uptimeLabel
|
|
|
|
anchors.centerIn: parent
|
|
text: root.uptime
|
|
color: Theme.fgAccentContainer
|
|
font.family: Theme.fontFamily
|
|
font.pixelSize: Theme.fontLabelMd
|
|
font.weight: Font.Medium
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// a list, or three to a row with the label under the icon
|
|
Grid {
|
|
columns: root.gridPanel ? 3 : 1
|
|
spacing: root.gridPanel ? Theme.dp(8) : Theme.dp(4)
|
|
|
|
Repeater {
|
|
model: root.actions
|
|
|
|
Rectangle {
|
|
id: actionRow
|
|
|
|
required property var modelData
|
|
readonly property bool isArmed: root.armed === actionRow.modelData.id
|
|
readonly property bool danger: actionRow.modelData.id === "reboot" || actionRow.modelData.id === "shutdown"
|
|
|
|
width: root.gridPanel ? (panelColumn.width - Theme.dp(16)) / 3 : panelColumn.width
|
|
height: root.gridPanel ? Theme.dp(84) : Theme.dp(48)
|
|
radius: Theme.radiusMd
|
|
color: actionRow.isArmed ? Theme.alpha(Theme.error, 0.9) : (actionArea.containsMouse ? Theme.withBlur(Theme.bgHover) : "transparent")
|
|
|
|
Rectangle {
|
|
id: actionIcon
|
|
|
|
x: root.gridPanel ? (parent.width - width) / 2 : Theme.dp(8)
|
|
y: root.gridPanel ? Theme.dp(12) : (parent.height - height) / 2
|
|
width: Theme.dp(34)
|
|
height: Theme.dp(34)
|
|
radius: Theme.dp(17)
|
|
color: actionRow.isArmed ? Theme.alpha(Theme.fgError, 0.18) : (actionRow.danger ? Theme.errorContainer : Theme.accentContainer)
|
|
|
|
NotifIcon {
|
|
anchors.centerIn: parent
|
|
size: Theme.dp(18)
|
|
path: root.icons[actionRow.modelData.icon]
|
|
color: actionRow.isArmed ? Theme.fgError : (actionRow.danger ? Theme.fgErrorContainer : Theme.fgAccentContainer)
|
|
}
|
|
|
|
}
|
|
|
|
Text {
|
|
x: root.gridPanel ? Theme.dp(6) : actionIcon.x + actionIcon.width + Theme.dp(12)
|
|
y: root.gridPanel ? actionIcon.y + actionIcon.height + Theme.dp(8) : (parent.height - height) / 2
|
|
width: parent.width - x - (root.gridPanel ? Theme.dp(6) : Theme.dp(12))
|
|
horizontalAlignment: root.gridPanel ? Text.AlignHCenter : Text.AlignLeft
|
|
text: actionRow.isArmed ? actionRow.modelData.label + (root.gridPanel ? "?" : "? Click again") : actionRow.modelData.label
|
|
color: actionRow.isArmed ? Theme.fgError : Theme.text
|
|
font.family: Theme.fontFamily
|
|
font.pixelSize: Theme.fontBodyLg
|
|
elide: Text.ElideRight
|
|
}
|
|
|
|
MouseArea {
|
|
id: actionArea
|
|
|
|
anchors.fill: parent
|
|
hoverEnabled: true
|
|
cursorShape: Qt.PointingHandCursor
|
|
onClicked: root.run(actionRow.modelData.id)
|
|
}
|
|
|
|
Behavior on color {
|
|
ColorAnimation {
|
|
duration: Theme.durShort
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
]
|
|
}
|