|
1 | 1 | import Quickshell |
2 | 2 | import Quickshell.Services.Polkit |
3 | 3 | import QtQuick |
| 4 | +import QtQuick.Layouts |
4 | 5 | import QtQuick.Controls |
5 | 6 |
|
6 | 7 | Scope { |
7 | 8 | id: root |
8 | 9 |
|
9 | | - FloatingWindow { |
10 | | - title: "Authentication Required" |
| 10 | + FloatingWindow { |
| 11 | + title: "Authentication Required" |
11 | 12 |
|
12 | | - visible: polkitAgent.isActive |
| 13 | + visible: polkitAgent.isActive |
| 14 | + color: contentItem.palette.window |
13 | 15 |
|
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 |
19 | 21 |
|
20 | | - Label { |
21 | | - text: polkitAgent.flow?.message ?? "" |
22 | | - wrapMode: Text.Wrap |
23 | | - font.bold: true |
24 | | - } |
| 22 | + Item { Layout.fillHeight: true } |
25 | 23 |
|
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 | + } |
32 | 30 |
|
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 | + } |
37 | 37 |
|
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 | + } |
46 | 43 |
|
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 | + } |
69 | 52 |
|
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 | + } |
79 | 87 |
|
80 | 88 | PolkitAgent { |
81 | 89 | id: polkitAgent |
|
0 commit comments