quickshell polkit agent

This commit is contained in:
end-4
2025-10-30 19:37:28 +01:00
parent 81116598cb
commit f9c7bbbe01
13 changed files with 210 additions and 5 deletions
@@ -10,7 +10,8 @@ Rectangle {
property bool show: false
default property alias data: contentColumn.data
property real backgroundHeight: 600
property real backgroundHeight: dialogBackground.implicitHeight
property real backgroundWidth: 350
property real backgroundAnimationMovementDistance: 60
signal dismiss()
@@ -49,7 +50,7 @@ Rectangle {
property real targetY: root.height / 2 - root.backgroundHeight / 2
y: root.show ? targetY : (targetY - root.backgroundAnimationMovementDistance)
implicitWidth: 350
implicitWidth: root.backgroundWidth
implicitHeight: contentColumn.implicitHeight + dialogBackground.radius * 2
Behavior on implicitHeight {
NumberAnimation {
@@ -0,0 +1,12 @@
import QtQuick
import Quickshell
import qs.modules.common
import qs.modules.common.functions
import qs.modules.common.widgets
StyledText {
text: "Some body content"
color: Appearance.colors.colOnSurfaceVariant
font.pixelSize: Appearance.font.pixelSize.small
wrapMode: Text.Wrap
}
@@ -35,7 +35,7 @@ Column {
left: parent.left
right: parent.right
leftMargin: 4
rightMargin: leftMargin
rightMargin: 4
}
configuration: StyledSlider.Configuration.S
onMoved: root.moved()
@@ -6,6 +6,8 @@ import qs.modules.common.widgets
StyledText {
text: "Dialog Title"
color: Appearance.colors.colOnSurface
wrapMode: Text.Wrap
font {
pixelSize: Appearance.font.pixelSize.title
family: Appearance.font.family.title
@@ -0,0 +1,42 @@
import qs
import qs.services
import qs.modules.common
import qs.modules.common.widgets
import qs.modules.common.functions
import QtQuick
import Quickshell
import Quickshell.Wayland
import Quickshell.Hyprland
Scope {
id: root
Loader {
active: PolkitService.active
sourceComponent: Variants {
model: Quickshell.screens
delegate: PanelWindow {
id: panelWindow
required property var modelData
screen: modelData
anchors {
top: true
left: true
right: true
bottom: true
}
color: "transparent"
WlrLayershell.namespace: "quickshell:polkit"
WlrLayershell.keyboardFocus: WlrKeyboardFocus.OnDemand
WlrLayershell.layer: WlrLayer.Overlay
exclusionMode: ExclusionMode.Ignore
PolkitContent {
anchors.fill: parent
}
}
}
}
}
@@ -0,0 +1,107 @@
import QtQuick
import QtQuick.Layouts
import Quickshell
import Quickshell.Widgets
import qs.services
import qs.modules.common
import qs.modules.common.widgets
Item {
id: root
readonly property bool usePasswordChars: !PolkitService.flow?.responseVisible ?? true
Keys.onPressed: event => { // Esc to close
if (event.key === Qt.Key_Escape) {
PolkitService.cancel();
}
}
function submit() {
PolkitService.submit(inputField.text);
}
Connections {
target: PolkitService
function onInteractionAvailableChanged() {
if (!PolkitService.interactionAvailable) return;
inputField.text = "";
inputField.forceActiveFocus();
}
}
Rectangle {
id: bg
anchors.fill: parent
color: Appearance.colors.colScrim
opacity: 0
Component.onCompleted: {
opacity = 1
}
Behavior on opacity {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
}
}
WindowDialog {
anchors.centerIn: parent
backgroundWidth: 450
show: false
Component.onCompleted: {
show = true
}
MaterialSymbol {
Layout.alignment: Qt.AlignHCenter
iconSize: 26
text: "shield_locked"
color: Appearance.colors.colSecondary
}
WindowDialogTitle {
id: titleText
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
text: Translation.tr("Authentication")
}
WindowDialogParagraph {
Layout.fillWidth: true
horizontalAlignment: Text.AlignLeft
text: {
if (!PolkitService.flow) return;
return PolkitService.flow.message.endsWith(".")
? PolkitService.flow.message.slice(0, -1)
: PolkitService.flow.message
}
}
MaterialTextField {
id: inputField
Layout.fillWidth: true
focus: true
enabled: PolkitService.interactionAvailable
placeholderText: {
const inputPrompt = PolkitService.flow?.inputPrompt.trim() ?? "";
const cleanedInputPrompt = inputPrompt.endsWith(":") ? inputPrompt.slice(0, -1) : inputPrompt;
return cleanedInputPrompt || (root.usePasswordChars ? Translation.tr("Password") : Translation.tr("Input"))
}
echoMode: root.usePasswordChars ? TextInput.Password : TextInput.Normal
onAccepted: root.submit();
}
WindowDialogButtonRow {
Item {
Layout.fillWidth: true
}
DialogButton {
buttonText: Translation.tr("Cancel")
onClicked: PolkitService.cancel();
}
DialogButton {
enabled: PolkitService.interactionAvailable
buttonText: Translation.tr("OK")
onClicked: root.submit();
}
}
}
}
@@ -15,6 +15,7 @@ import Quickshell.Hyprland
WindowDialog {
id: root
backgroundHeight: 600
WindowDialogTitle {
text: Translation.tr("Bluetooth devices")
@@ -15,6 +15,7 @@ WindowDialog {
id: root
property var screen: root.QsWindow.window?.screen
property var brightnessMonitor: Brightness.getMonitorForScreen(screen)
backgroundHeight: 600
WindowDialogTitle {
text: Translation.tr("Eye protection")
@@ -9,6 +9,7 @@ import Quickshell
WindowDialog {
id: root
backgroundHeight: 600
WindowDialogTitle {
text: Translation.tr("Connect to Wi-Fi")