diff options
Diffstat (limited to '')
| -rw-r--r-- | modules/IdleMonitors.qml | 51 | ||||
| -rw-r--r-- | modules/lock/Content.qml | 27 | ||||
| -rw-r--r-- | modules/lock/InputField.qml | 149 | ||||
| -rw-r--r-- | modules/lock/Lock.qml | 55 | ||||
| -rw-r--r-- | modules/lock/LockSurface.qml | 231 | ||||
| -rw-r--r-- | modules/lock/Pam.qml | 193 | ||||
| -rw-r--r-- | modules/utilities/Content.qml | 2 | ||||
| -rw-r--r-- | modules/utilities/cards/IdleInhibit.qml | 125 |
8 files changed, 0 insertions, 833 deletions
diff --git a/modules/IdleMonitors.qml b/modules/IdleMonitors.qml deleted file mode 100644 index b7ce058..0000000 --- a/modules/IdleMonitors.qml +++ /dev/null @@ -1,51 +0,0 @@ -pragma ComponentBehavior: Bound - -import "lock" -import qs.config -import qs.services -import Caelestia.Internal -import Quickshell -import Quickshell.Wayland - -Scope { - id: root - - required property Lock lock - readonly property bool enabled: !Config.general.idle.inhibitWhenAudio || !Players.list.some(p => p.isPlaying) - - function handleIdleAction(action: var): void { - if (!action) - return; - - if (action === "lock") - lock.lock.locked = true; - else if (action === "unlock") - lock.lock.locked = false; - else if (typeof action === "string") - Hypr.dispatch(action); - else - Quickshell.execDetached(action); - } - - LogindManager { - onAboutToSleep: { - if (Config.general.idle.lockBeforeSleep) - root.lock.lock.locked = true; - } - onLockRequested: root.lock.lock.locked = true - onUnlockRequested: root.lock.lock.unlock() - } - - Variants { - model: Config.general.idle.timeouts - - IdleMonitor { - required property var modelData - - enabled: root.enabled && (modelData.enabled ?? true) - timeout: modelData.timeout - respectInhibitors: modelData.respectInhibitors ?? true - onIsIdleChanged: root.handleIdleAction(isIdle ? modelData.idleAction : modelData.returnAction) - } - } -} diff --git a/modules/lock/Content.qml b/modules/lock/Content.qml deleted file mode 100644 index daa87ac..0000000 --- a/modules/lock/Content.qml +++ /dev/null @@ -1,27 +0,0 @@ -import qs.components -import qs.services -import qs.config -import QtQuick -import QtQuick.Layouts - -RowLayout { - id: root - - required property var lock - - spacing: Appearance.spacing.large * 2 - - ColumnLayout { - Layout.fillWidth: true - spacing: Appearance.spacing.normal - } - - Center { - lock: root.lock - } - - ColumnLayout { - Layout.fillWidth: true - spacing: Appearance.spacing.normal - } -} diff --git a/modules/lock/InputField.qml b/modules/lock/InputField.qml deleted file mode 100644 index 1acc787..0000000 --- a/modules/lock/InputField.qml +++ /dev/null @@ -1,149 +0,0 @@ -pragma ComponentBehavior: Bound - -import qs.components -import qs.services -import qs.config -import Quickshell -import QtQuick -import QtQuick.Layouts - -Item { - id: root - - required property Pam pam - readonly property alias placeholder: placeholder - property string buffer - - Layout.fillWidth: true - Layout.fillHeight: true - - clip: true - - Connections { - target: root.pam - - function onBufferChanged(): void { - if (root.pam.buffer.length > root.buffer.length) { - charList.bindImWidth(); - } else if (root.pam.buffer.length === 0) { - charList.implicitWidth = charList.implicitWidth; - placeholder.animate = true; - } - - root.buffer = root.pam.buffer; - } - } - - StyledText { - id: placeholder - - anchors.centerIn: parent - - text: { - if (root.pam.passwd.active) - return qsTr("Loading..."); - if (root.pam.state === "max") - return qsTr("You have reached the maximum number of tries"); - return qsTr("Enter your password"); - } - - animate: true - color: root.pam.passwd.active ? Colours.palette.m3secondary : Colours.palette.m3outline - font.pointSize: Appearance.font.size.normal - font.family: Appearance.font.family.mono - - opacity: root.buffer ? 0 : 1 - - Behavior on opacity { - Anim {} - } - } - - ListView { - id: charList - - readonly property int fullWidth: count * (implicitHeight + spacing) - spacing - - function bindImWidth(): void { - imWidthBehavior.enabled = false; - implicitWidth = Qt.binding(() => fullWidth); - imWidthBehavior.enabled = true; - } - - anchors.centerIn: parent - anchors.horizontalCenterOffset: implicitWidth > root.width ? -(implicitWidth - root.width) / 2 : 0 - - implicitWidth: fullWidth - implicitHeight: Appearance.font.size.normal - - orientation: Qt.Horizontal - spacing: Appearance.spacing.small / 2 - interactive: false - - model: ScriptModel { - values: root.buffer.split("") - } - - delegate: StyledRect { - id: ch - - implicitWidth: implicitHeight - implicitHeight: charList.implicitHeight - - color: Colours.palette.m3onSurface - radius: Appearance.rounding.full - - opacity: 0 - scale: 0 - Component.onCompleted: { - opacity = 1; - scale = 1; - } - ListView.onRemove: removeAnim.start() - - SequentialAnimation { - id: removeAnim - - PropertyAction { - target: ch - property: "ListView.delayRemove" - value: true - } - ParallelAnimation { - Anim { - target: ch - property: "opacity" - to: 0 - } - Anim { - target: ch - property: "scale" - to: 0.5 - } - } - PropertyAction { - target: ch - property: "ListView.delayRemove" - value: false - } - } - - Behavior on opacity { - Anim {} - } - - Behavior on scale { - Anim { - duration: Appearance.anim.durations.expressiveFastSpatial - easing.bezierCurve: Appearance.anim.curves.expressiveFastSpatial - } - } - } - - Behavior on implicitWidth { - id: imWidthBehavior - - Anim {} - } - } -} diff --git a/modules/lock/Lock.qml b/modules/lock/Lock.qml deleted file mode 100644 index 6fd5277..0000000 --- a/modules/lock/Lock.qml +++ /dev/null @@ -1,55 +0,0 @@ -pragma ComponentBehavior: Bound - -import qs.components.misc -import Quickshell -import Quickshell.Io -import Quickshell.Wayland - -Scope { - property alias lock: lock - - WlSessionLock { - id: lock - - signal unlock - - LockSurface { - lock: lock - pam: pam - } - } - - Pam { - id: pam - - lock: lock - } - - CustomShortcut { - name: "lock" - description: "Lock the current session" - onPressed: lock.locked = true - } - - CustomShortcut { - name: "unlock" - description: "Unlock the current session" - onPressed: lock.unlock() - } - - IpcHandler { - target: "lock" - - function lock(): void { - lock.locked = true; - } - - function unlock(): void { - lock.unlock(); - } - - function isLocked(): bool { - return lock.locked; - } - } -} diff --git a/modules/lock/LockSurface.qml b/modules/lock/LockSurface.qml deleted file mode 100644 index 0c3ce69..0000000 --- a/modules/lock/LockSurface.qml +++ /dev/null @@ -1,231 +0,0 @@ -pragma ComponentBehavior: Bound - -import qs.components -import qs.services -import qs.config -import qs.utils -import Quickshell.Wayland -import QtQuick -import QtQuick.Effects - -WlSessionLockSurface { - id: root - - required property WlSessionLock lock - required property Pam pam - - readonly property alias unlocking: unlockAnim.running - - color: "transparent" - - Connections { - target: root.lock - - function onUnlock(): void { - unlockAnim.start(); - } - } - - SequentialAnimation { - id: unlockAnim - - ParallelAnimation { - Anim { - target: lockContent - properties: "implicitWidth,implicitHeight" - to: lockContent.size - duration: Appearance.anim.durations.expressiveDefaultSpatial - easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial - } - Anim { - target: lockBg - property: "radius" - to: lockContent.radius - } - Anim { - target: content - property: "scale" - to: 0 - duration: Appearance.anim.durations.expressiveDefaultSpatial - easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial - } - Anim { - target: content - property: "opacity" - to: 0 - duration: Appearance.anim.durations.small - } - Anim { - target: lockIcon - property: "opacity" - to: 1 - duration: Appearance.anim.durations.large - } - Anim { - target: background - property: "opacity" - to: 0 - duration: Appearance.anim.durations.large - } - SequentialAnimation { - PauseAnimation { - duration: Appearance.anim.durations.small - } - Anim { - target: lockContent - property: "opacity" - to: 0 - } - } - } - PropertyAction { - target: root.lock - property: "locked" - value: false - } - } - - ParallelAnimation { - id: initAnim - - running: true - - Anim { - target: background - property: "opacity" - to: 1 - duration: Appearance.anim.durations.large - } - SequentialAnimation { - ParallelAnimation { - Anim { - target: lockContent - property: "scale" - to: 1 - duration: Appearance.anim.durations.expressiveFastSpatial - easing.bezierCurve: Appearance.anim.curves.expressiveFastSpatial - } - Anim { - target: lockContent - property: "rotation" - to: 360 - duration: Appearance.anim.durations.expressiveFastSpatial - easing.bezierCurve: Appearance.anim.curves.standardAccel - } - } - ParallelAnimation { - Anim { - target: lockIcon - property: "rotation" - to: 360 - easing.bezierCurve: Appearance.anim.curves.standardDecel - } - Anim { - target: lockIcon - property: "opacity" - to: 0 - } - Anim { - target: content - property: "opacity" - to: 1 - } - Anim { - target: content - property: "scale" - to: 1 - duration: Appearance.anim.durations.expressiveDefaultSpatial - easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial - } - Anim { - target: lockBg - property: "radius" - to: Appearance.rounding.large * 1.5 - } - Anim { - target: lockContent - property: "implicitWidth" - to: root.screen?.height * Config.lock.sizes.heightMult * Config.lock.sizes.ratio - duration: Appearance.anim.durations.expressiveDefaultSpatial - easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial - } - Anim { - target: lockContent - property: "implicitHeight" - to: root.screen?.height * Config.lock.sizes.heightMult - duration: Appearance.anim.durations.expressiveDefaultSpatial - easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial - } - } - } - } - - Image { - id: background - - anchors.fill: parent - source: Paths.wallpaper ?? "" - opacity: 1 - - layer.enabled: true - layer.effect: MultiEffect { - autoPaddingEnabled: false - blurEnabled: true - blur: 1 - blurMax: 64 - blurMultiplier: 1 - } - } - - Item { - id: lockContent - - readonly property int size: lockIcon.implicitHeight + Appearance.padding.large * 4 - readonly property int radius: size / 4 * Appearance.rounding.scale - - anchors.centerIn: parent - implicitWidth: size - implicitHeight: size - - rotation: 180 - scale: 0 - - StyledRect { - id: lockBg - - anchors.fill: parent - color: Colours.palette.m3surface - radius: parent.radius - opacity: Colours.transparency.enabled ? Colours.transparency.base : 1 - - layer.enabled: true - layer.effect: MultiEffect { - shadowEnabled: true - blurMax: 15 - shadowColor: Qt.alpha(Colours.palette.m3shadow, 0.7) - } - } - - MaterialIcon { - id: lockIcon - - anchors.centerIn: parent - text: "lock" - font.pointSize: Appearance.font.size.extraLarge * 4 - font.bold: true - rotation: 180 - } - - Content { - id: content - - anchors.centerIn: parent - width: (root.screen?.height ?? 0) * Config.lock.sizes.heightMult * Config.lock.sizes.ratio - Appearance.padding.large * 2 - height: (root.screen?.height ?? 0) * Config.lock.sizes.heightMult - Appearance.padding.large * 2 - - lock: root - opacity: 0 - scale: 0 - } - } -} diff --git a/modules/lock/Pam.qml b/modules/lock/Pam.qml deleted file mode 100644 index 0186c2f..0000000 --- a/modules/lock/Pam.qml +++ /dev/null @@ -1,193 +0,0 @@ -import qs.config -import Quickshell -import Quickshell.Io -import Quickshell.Wayland -import Quickshell.Services.Pam -import QtQuick - -Scope { - id: root - - required property WlSessionLock lock - - readonly property alias passwd: passwd - readonly property alias fprint: fprint - property string lockMessage - property string state - property string fprintState - property string buffer - - signal flashMsg - - function handleKey(event: KeyEvent): void { - if (passwd.active || state === "max") - return; - - if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) { - passwd.start(); - } else if (event.key === Qt.Key_Backspace) { - if (event.modifiers & Qt.ControlModifier) { - buffer = ""; - } else { - buffer = buffer.slice(0, -1); - } - } else if (" abcdefghijklmnopqrstuvwxyz1234567890`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?".includes(event.text.toLowerCase())) { - // No illegal characters (you are insane if you use unicode in your password) - buffer += event.text; - } - } - - PamContext { - id: passwd - - config: "passwd" - configDirectory: Quickshell.shellDir + "/assets/pam.d" - - onMessageChanged: { - if (message.startsWith("The account is locked")) - root.lockMessage = message; - else if (root.lockMessage && message.endsWith(" left to unlock)")) - root.lockMessage += "\n" + message; - } - - onResponseRequiredChanged: { - if (!responseRequired) - return; - - respond(root.buffer); - root.buffer = ""; - } - - onCompleted: res => { - if (res === PamResult.Success) - return root.lock.unlock(); - - if (res === PamResult.Error) - root.state = "error"; - else if (res === PamResult.MaxTries) - root.state = "max"; - else if (res === PamResult.Failed) - root.state = "fail"; - - root.flashMsg(); - stateReset.restart(); - } - } - - PamContext { - id: fprint - - property bool available - property int tries - property int errorTries - - function checkAvail(): void { - if (!available || !Config.lock.enableFprint || !root.lock.secure) { - abort(); - return; - } - - tries = 0; - errorTries = 0; - start(); - } - - config: "fprint" - configDirectory: Quickshell.shellDir + "/assets/pam.d" - - onCompleted: res => { - if (!available) - return; - - if (res === PamResult.Success) - return root.lock.unlock(); - - if (res === PamResult.Error) { - root.fprintState = "error"; - errorTries++; - if (errorTries < 5) { - abort(); - errorRetry.restart(); - } - } else if (res === PamResult.MaxTries) { - // Isn't actually the real max tries as pam only reports completed - // when max tries is reached. - tries++; - if (tries < Config.lock.maxFprintTries) { - // Restart if not actually real max tries - root.fprintState = "fail"; - start(); - } else { - root.fprintState = "max"; - abort(); - } - } - - root.flashMsg(); - fprintStateReset.start(); - } - } - - Process { - id: availProc - - command: ["sh", "-c", "fprintd-list $USER"] - onExited: code => { - fprint.available = code === 0; - fprint.checkAvail(); - } - } - - Timer { - id: errorRetry - - interval: 800 - onTriggered: fprint.start() - } - - Timer { - id: stateReset - - interval: 4000 - onTriggered: { - if (root.state !== "max") - root.state = ""; - } - } - - Timer { - id: fprintStateReset - - interval: 4000 - onTriggered: { - root.fprintState = ""; - fprint.errorTries = 0; - } - } - - Connections { - target: root.lock - - function onSecureChanged(): void { - if (root.lock.secure) { - availProc.running = true; - root.buffer = ""; - root.state = ""; - root.fprintState = ""; - root.lockMessage = ""; - } - } - - function onUnlock(): void { - fprint.abort(); - } - } - - Connections { - target: Config.lock - - function onEnableFprintChanged(): void { - fprint.checkAvail(); - } - } -} diff --git a/modules/utilities/Content.qml b/modules/utilities/Content.qml index f6d8d63..770a774 100644 --- a/modules/utilities/Content.qml +++ b/modules/utilities/Content.qml @@ -19,8 +19,6 @@ Item { anchors.fill: parent spacing: Appearance.spacing.normal - IdleInhibit {} - Toggles { visibilities: root.visibilities popouts: root.popouts diff --git a/modules/utilities/cards/IdleInhibit.qml b/modules/utilities/cards/IdleInhibit.qml deleted file mode 100644 index 0344e3a..0000000 --- a/modules/utilities/cards/IdleInhibit.qml +++ /dev/null @@ -1,125 +0,0 @@ -import qs.components -import qs.components.controls -import qs.services -import qs.config -import QtQuick -import QtQuick.Layouts - -StyledRect { - id: root - - Layout.fillWidth: true - implicitHeight: layout.implicitHeight + (IdleInhibitor.enabled ? activeChip.implicitHeight + activeChip.anchors.topMargin : 0) + Appearance.padding.large * 2 - - radius: Appearance.rounding.normal - color: Colours.tPalette.m3surfaceContainer - clip: true - - RowLayout { - id: layout - - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.margins: Appearance.padding.large - spacing: Appearance.spacing.normal - - StyledRect { - implicitWidth: implicitHeight - implicitHeight: icon.implicitHeight + Appearance.padding.smaller * 2 - - radius: Appearance.rounding.full - color: IdleInhibitor.enabled ? Colours.palette.m3secondary : Colours.palette.m3secondaryContainer - - MaterialIcon { - id: icon - - anchors.centerIn: parent - text: "coffee" - color: IdleInhibitor.enabled ? Colours.palette.m3onSecondary : Colours.palette.m3onSecondaryContainer - font.pointSize: Appearance.font.size.large - } - } - - ColumnLayout { - Layout.fillWidth: true - spacing: 0 - - StyledText { - Layout.fillWidth: true - text: qsTr("Keep Awake") - font.pointSize: Appearance.font.size.normal - elide: Text.ElideRight - } - - StyledText { - Layout.fillWidth: true - text: IdleInhibitor.enabled ? qsTr("Preventing sleep mode") : qsTr("Normal power management") - color: Colours.palette.m3onSurfaceVariant - font.pointSize: Appearance.font.size.small - elide: Text.ElideRight - } - } - - StyledSwitch { - checked: IdleInhibitor.enabled - onToggled: IdleInhibitor.enabled = checked - } - } - - Loader { - id: activeChip - - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.topMargin: Appearance.spacing.larger - anchors.bottomMargin: IdleInhibitor.enabled ? Appearance.padding.large : -implicitHeight - anchors.leftMargin: Appearance.padding.large - - opacity: IdleInhibitor.enabled ? 1 : 0 - scale: IdleInhibitor.enabled ? 1 : 0.5 - - Component.onCompleted: active = Qt.binding(() => opacity > 0) - - sourceComponent: StyledRect { - implicitWidth: activeText.implicitWidth + Appearance.padding.normal * 2 - implicitHeight: activeText.implicitHeight + Appearance.padding.small * 2 - - radius: Appearance.rounding.full - color: Colours.palette.m3primary - - StyledText { - id: activeText - - anchors.centerIn: parent - text: qsTr("Active since %1").arg(Qt.formatTime(IdleInhibitor.enabledSince, Config.services.useTwelveHourClock ? "hh:mm a" : "hh:mm")) - color: Colours.palette.m3onPrimary - font.pointSize: Math.round(Appearance.font.size.small * 0.9) - } - } - - Behavior on anchors.bottomMargin { - Anim { - duration: Appearance.anim.durations.expressiveDefaultSpatial - easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial - } - } - - Behavior on opacity { - Anim { - duration: Appearance.anim.durations.small - } - } - - Behavior on scale { - Anim {} - } - } - - Behavior on implicitHeight { - Anim { - duration: Appearance.anim.durations.expressiveDefaultSpatial - easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial - } - } -} |