Skip to content

Commit 38759b4

Browse files
committed
service/polkit: tweak tester
1 parent d9f898e commit 38759b4

File tree

1 file changed

+70
-62
lines changed

1 file changed

+70
-62
lines changed

src/services/polkit/test/manual/agent.qml

Lines changed: 70 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,89 @@
11
import Quickshell
22
import Quickshell.Services.Polkit
33
import QtQuick
4+
import QtQuick.Layouts
45
import QtQuick.Controls
56

67
Scope {
78
id: root
89

9-
FloatingWindow {
10-
title: "Authentication Required"
10+
FloatingWindow {
11+
title: "Authentication Required"
1112

12-
visible: polkitAgent.isActive
13+
visible: polkitAgent.isActive
14+
color: contentItem.palette.window
1315

14-
Column {
15-
id: contentColumn
16-
anchors.fill: parent
17-
anchors.margins: 18
18-
spacing: 12
16+
ColumnLayout {
17+
id: contentColumn
18+
anchors.fill: parent
19+
anchors.margins: 18
20+
spacing: 12
1921

20-
Label {
21-
text: polkitAgent.flow?.message ?? ""
22-
wrapMode: Text.Wrap
23-
font.bold: true
24-
}
22+
Item { Layout.fillHeight: true }
2523

26-
Label {
27-
visible: polkitAgent.flow?.supplementaryMessage.length > 0
28-
text: polkitAgent.flow?.supplementaryMessage ?? ""
29-
wrapMode: Text.Wrap
30-
opacity: 0.8
31-
}
24+
Label {
25+
Layout.fillWidth: true
26+
text: polkitAgent.flow?.message || "<no message>"
27+
wrapMode: Text.Wrap
28+
font.bold: true
29+
}
3230

33-
Label {
34-
text: polkitAgent.flow?.inputPrompt ?? ""
35-
wrapMode: Text.Wrap
36-
}
31+
Label {
32+
Layout.fillWidth: true
33+
text: polkitAgent.flow?.supplementaryMessage || "<no supplementary message>"
34+
wrapMode: Text.Wrap
35+
opacity: 0.8
36+
}
3737

38-
TextInput {
39-
id: passwordInput
40-
echoMode: polkitAgent.flow?.responseVisible
41-
? TextInput.Normal : TextInput.Password
42-
selectByMouse: true
43-
width: parent.width
44-
onAccepted: okButton.clicked()
45-
}
38+
Label {
39+
Layout.fillWidth: true
40+
text: polkitAgent.flow?.inputPrompt || "<no input prompt>"
41+
wrapMode: Text.Wrap
42+
}
4643

47-
Row {
48-
spacing: 8
49-
Button {
50-
id: okButton
51-
text: "OK"
52-
enabled: passwordInput.text.length > 0 || !!polkitAgent.flow?.isResponseRequired
53-
onClicked: {
54-
polkitAgent.flow.submit(passwordInput.text)
55-
passwordInput.text = ""
56-
passwordInput.forceActiveFocus()
57-
}
58-
}
59-
Button {
60-
text: "Cancel"
61-
visible: polkitAgent.isActive
62-
onClicked: {
63-
polkitAgent.flow.cancelAuthenticationRequest()
64-
passwordInput.text = ""
65-
}
66-
}
67-
}
68-
}
44+
TextField {
45+
id: passwordInput
46+
echoMode: polkitAgent.flow?.responseVisible
47+
? TextInput.Normal : TextInput.Password
48+
selectByMouse: true
49+
Layout.fillWidth: true
50+
onAccepted: okButton.clicked()
51+
}
6952

70-
Connections {
71-
target: polkitAgent.flow
72-
function onIsResponseRequiredChanged() {
73-
passwordInput.text = ""
74-
if (polkitAgent.flow.isResponseRequired)
75-
passwordInput.forceActiveFocus()
76-
}
77-
}
78-
}
53+
RowLayout {
54+
spacing: 8
55+
Button {
56+
id: okButton
57+
text: "OK"
58+
enabled: passwordInput.text.length > 0 || !!polkitAgent.flow?.isResponseRequired
59+
onClicked: {
60+
polkitAgent.flow.submit(passwordInput.text)
61+
passwordInput.text = ""
62+
passwordInput.forceActiveFocus()
63+
}
64+
}
65+
Button {
66+
text: "Cancel"
67+
visible: polkitAgent.isActive
68+
onClicked: {
69+
polkitAgent.flow.cancelAuthenticationRequest()
70+
passwordInput.text = ""
71+
}
72+
}
73+
}
74+
75+
Item { Layout.fillHeight: true }
76+
}
77+
78+
Connections {
79+
target: polkitAgent.flow
80+
function onIsResponseRequiredChanged() {
81+
passwordInput.text = ""
82+
if (polkitAgent.flow.isResponseRequired)
83+
passwordInput.forceActiveFocus()
84+
}
85+
}
86+
}
7987

8088
PolkitAgent {
8189
id: polkitAgent

0 commit comments

Comments
 (0)