forked from raspberrypi/rpi-imager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUseSavedSettingsPopup.qml
163 lines (144 loc) · 4.43 KB
/
UseSavedSettingsPopup.qml
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
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright (C) 2021 Raspberry Pi Ltd
*/
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.0
import QtQuick.Controls.Material 2.2
import "qmlcomponents"
Popup {
id: msgpopup
x: (parent.width-width)/2
y: (parent.height-height)/2
width: Math.max(buttons.width+10, parent.width-150)
height: msgpopupbody.implicitHeight+150
padding: 0
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
modal: true
property bool hasSavedSettings: false
signal yes()
signal no()
signal noClearSettings()
signal editSettings()
signal closeSettings()
// background of title
Rectangle {
color: "#f5f5f5"
anchors.right: parent.right
anchors.top: parent.top
height: 35
width: parent.width
}
// line under title
Rectangle {
color: "#afafaf"
width: parent.width
y: 35
implicitHeight: 1
}
Text {
id: msgx
text: "X"
anchors.right: parent.right
anchors.top: parent.top
anchors.rightMargin: 25
anchors.topMargin: 10
font.family: roboto.name
font.bold: true
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
msgpopup.close()
}
}
}
ColumnLayout {
spacing: 20
anchors.fill: parent
Text {
id: msgpopupheader
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
Layout.fillWidth: true
Layout.topMargin: 10
font.family: roboto.name
font.bold: true
text: qsTr("Use OS customization?")
}
Text {
id: msgpopupbody
font.pointSize: 12
wrapMode: Text.Wrap
textFormat: Text.StyledText
font.family: roboto.name
Layout.maximumWidth: msgpopup.width-50
Layout.fillHeight: true
Layout.leftMargin: 25
Layout.topMargin: 25
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
Accessible.name: text.replace(/<\/?[^>]+(>|$)/g, "")
text: qsTr("Would you like to apply OS customization settings?")
}
RowLayout {
Layout.alignment: Qt.AlignCenter | Qt.AlignBottom
Layout.bottomMargin: 10
spacing: 20
id: buttons
ImButtonRed {
text: qsTr("EDIT SETTINGS")
onClicked: {
// Don't close this dialog when "edit settings" is
// clicked, as we don't want the user to fall back to the
// start of the flow. After editing the settings we want
// then to once again have the choice about whether to use
// customisation or not.
msgpopup.editSettings()
}
}
ImButtonRed {
id: noAndClearButton
text: qsTr("NO, CLEAR SETTINGS")
onClicked: {
msgpopup.close()
msgpopup.noClearSettings()
}
enabled: hasSavedSettings
}
ImButtonRed {
id: yesButton
text: qsTr("YES")
onClicked: {
msgpopup.close()
msgpopup.yes()
}
enabled: hasSavedSettings
}
ImButtonRed {
text: qsTr("NO")
onClicked: {
msgpopup.close()
msgpopup.no()
}
}
Text { text: " " }
}
}
function openPopup() {
open()
if (imageWriter.hasSavedCustomizationSettings()) {
/* HACK: Bizarrely, the button enabled characteristics are not re-evaluated on open.
* So, let's manually _force_ these buttons to be enabled */
hasSavedSettings = true
}
// trigger screen reader to speak out message
msgpopupbody.forceActiveFocus()
}
onClosed: {
// Close the advanced options window if this msgbox is dismissed,
// in order to prevent the user from starting writing while the
// advanced options window is open.
closeSettings()
}
}