summaryrefslogtreecommitdiff
path: root/raveos-calamares-module/raveusers/ui/raveusers.qml
blob: 25e090fdfb0ae7014146bb5336b7e17467b944a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import "." as RaveUsersModule

Rectangle {
    id: root
    color: "#2B2B2B"
    radius: 14

    readonly property color cCardBg: "#20232a"
    readonly property color cCardBorder: "#333947"
    readonly property color cInputBg: "#303030"
    readonly property color cInputBorder: "#303030"
    readonly property color cAccentGreen: "#3d7839"
    readonly property color cTextWhite: "#ffffff"
    readonly property color cTextMuted: "#8b93a3"
    readonly property color cTextFaint: "#5b6270"
    readonly property color cErrorRed: "#ff6b6b"

    property bool showUserPassword: false
    property bool showRootPassword: false

    function updateLanguage() {
        RaveUsersModule.Translations.setLanguage(systemLocale)
    }

    Component.onCompleted: {
        RaveUsersModule.Translations.setLanguage(systemLocale)
    }

    ColumnLayout {
        anchors.fill: parent
        anchors.margins: 40
        spacing: 0

        Item {
            Layout.fillWidth: true
            Layout.fillHeight: true

            ColumnLayout {
                anchors.horizontalCenter: parent.horizontalCenter
                anchors.top: parent.top
                anchors.topMargin: 10
                width: Math.min(parent.width - 40, 540)
                spacing: 16

                Image {
                    source: "raveos-logo.png"
                    sourceSize.width: 96
                    sourceSize.height: 96
                    fillMode: Image.PreserveAspectFit
                    Layout.preferredWidth: 96
                    Layout.preferredHeight: 96
                    Layout.alignment: Qt.AlignHCenter
                }

                Text {
                    text: RaveUsersModule.Translations.title
                    font.pixelSize: 28
                    font.bold: true
                    color: cTextWhite
                    Layout.alignment: Qt.AlignHCenter
                }

                Text {
                    text: RaveUsersModule.Translations.description
                    font.pixelSize: 15
                    lineHeight: 1.45
                    color: cTextMuted
                    wrapMode: Text.WordWrap
                    Layout.fillWidth: true
                    Layout.alignment: Qt.AlignHCenter
                }

                Item { height: 6 }

                ColumnLayout {
                    Layout.fillWidth: true
                    spacing: 6

                    Text {
                        text: RaveUsersModule.Translations.usernameLabel
                        color: "#c7ccd6"
                        font.pixelSize: 14
                        font.weight: Font.Medium
                    }

                    TextField {
                        id: usernameField
                        Layout.fillWidth: true
                        implicitHeight: 52
                        leftPadding: 14
                        rightPadding: 14
                        text: backend.username
                        placeholderText: "raveuser"
                        color: cTextWhite
                        placeholderTextColor: "#5b6270"
                        font.pixelSize: 15
                        background: Rectangle {
                            radius: 7
                            color: cInputBg
                            border.color: usernameField.activeFocus ? cAccentGreen : cInputBorder
                            border.width: usernameField.activeFocus ? 1.5 : 1
                        }
                        onTextEdited: backend.setUsername(text)
                    }

                    Text {
                        visible: backend.usernameStatus !== ""
                        text: backend.usernameStatus
                        color: cErrorRed
                        font.pixelSize: 12
                    }
                }

                ColumnLayout {
                    Layout.fillWidth: true
                    spacing: 6

                    Text {
                        text: RaveUsersModule.Translations.hostnameLabel
                        color: "#c7ccd6"
                        font.pixelSize: 14
                        font.weight: Font.Medium
                    }

                    TextField {
                        id: hostnameField
                        Layout.fillWidth: true
                        implicitHeight: 52
                        leftPadding: 14
                        rightPadding: 14
                        text: backend.hostname
                        placeholderText: "raveos-pc"
                        color: cTextWhite
                        placeholderTextColor: "#5b6270"
                        font.pixelSize: 15
                        background: Rectangle {
                            radius: 7
                            color: cInputBg
                            border.color: hostnameField.activeFocus ? cAccentGreen : cInputBorder
                            border.width: hostnameField.activeFocus ? 1.5 : 1
                        }
                        onTextEdited: backend.setHostname(text)
                    }

                    Text {
                        visible: backend.hostnameStatus !== ""
                        text: backend.hostnameStatus
                        color: cErrorRed
                        font.pixelSize: 12
                    }
                }

                ColumnLayout {
                    Layout.fillWidth: true
                    spacing: 6

                    Text {
                        text: RaveUsersModule.Translations.passwordLabel
                        color: "#c7ccd6"
                        font.pixelSize: 14
                        font.weight: Font.Medium
                    }

                    RowLayout {
                        Layout.fillWidth: true
                        spacing: 12

                        PasswordField {
                            Layout.fillWidth: true
                            reveal: showUserPassword
                            onRevealClicked: showUserPassword = !showUserPassword
                            placeholderText: RaveUsersModule.Translations.passwordPlaceholder
                            onTextEdited: backend.setPassword(text)
                        }

                        PasswordField {
                            Layout.fillWidth: true
                            reveal: showUserPassword
                            onRevealClicked: showUserPassword = !showUserPassword
                            placeholderText: RaveUsersModule.Translations.passwordConfirmLabel
                            onTextEdited: backend.setPasswordSecondary(text)
                        }
                    }

                    Text {
                        visible: backend.passwordStatus !== ""
                        text: backend.passwordStatus
                        color: cErrorRed
                        font.pixelSize: 12
                    }
                }

                Rectangle {
                    Layout.fillWidth: true
                    Layout.topMargin: 2
                    Layout.bottomMargin: 2
                    height: 1
                    color: cCardBorder
                    opacity: 0.6
                }

                CheckBox {
                    id: reuseRootCheck
                    Layout.fillWidth: true
                    visible: backend.rootReuseVisible
                    text: RaveUsersModule.Translations.reuseRootLabel
                    checked: backend.reuseRootPassword
                    onToggled: backend.setReuseRootPassword(checked)

                    indicator: Rectangle {
                        implicitWidth: 20
                        implicitHeight: 20
                        x: reuseRootCheck.leftPadding
                        y: parent.height / 2 - height / 2
                        radius: 4
                        color: reuseRootCheck.checked ? cAccentGreen : cInputBg
                        border.color: reuseRootCheck.checked ? cAccentGreen : cInputBorder
                        border.width: 1

                        Text {
                            anchors.centerIn: parent
                            text: "\u2713"
                            font.pixelSize: 14
                            font.bold: true
                            color: "#0f1713"
                            visible: reuseRootCheck.checked
                        }
                    }

                    contentItem: Text {
                        text: reuseRootCheck.text
                        color: "#d7dbe2"
                        font.pixelSize: 14
                        verticalAlignment: Text.AlignVCenter
                        leftPadding: reuseRootCheck.indicator.width + 12
                    }
                }

                ColumnLayout {
                    Layout.fillWidth: true
                    spacing: 6
                    visible: !backend.reuseRootPassword

                    Text {
                        text: RaveUsersModule.Translations.rootPasswordLabel
                        color: "#c7ccd6"
                        font.pixelSize: 14
                        font.weight: Font.Medium
                        Layout.topMargin: 4
                    }

                    RowLayout {
                        Layout.fillWidth: true
                        spacing: 12

                        PasswordField {
                            Layout.fillWidth: true
                            reveal: showRootPassword
                            onRevealClicked: showRootPassword = !showRootPassword
                            placeholderText: RaveUsersModule.Translations.rootPasswordPlaceholder
                            onTextEdited: backend.setRootPasswordText(text)
                        }

                        PasswordField {
                            Layout.fillWidth: true
                            reveal: showRootPassword
                            onRevealClicked: showRootPassword = !showRootPassword
                            placeholderText: RaveUsersModule.Translations.rootPasswordConfirmLabel
                            onTextEdited: backend.setRootPasswordSecondaryText(text)
                        }
                    }

                    Text {
                        visible: backend.rootPasswordStatus !== ""
                        text: backend.rootPasswordStatus
                        color: cErrorRed
                        font.pixelSize: 12
                    }
                }
            }
        }
    }
}