2021-01-20 13:04:18 +01:00
|
|
|
/*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2022-02-03 11:48:21 +01:00
|
|
|
* Copyright (C) 2021 Raspberry Pi Ltd
|
2021-01-20 13:04:18 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Controls 2.2
|
|
|
|
import QtQuick.Layouts 1.0
|
|
|
|
import QtQuick.Controls.Material 2.2
|
2022-02-04 12:32:12 +01:00
|
|
|
import "qmlcomponents"
|
2021-01-20 13:04:18 +01:00
|
|
|
|
|
|
|
Popup {
|
|
|
|
id: msgpopup
|
2023-05-18 15:03:43 +02:00
|
|
|
x: (parent.width-width)/2
|
2021-01-20 13:04:18 +01:00
|
|
|
y: (parent.height-height)/2
|
2023-05-18 15:03:43 +02:00
|
|
|
width: Math.max(buttons.width+10, parent.width-150)
|
2021-01-20 13:04:18 +01:00
|
|
|
height: msgpopupbody.implicitHeight+150
|
|
|
|
padding: 0
|
|
|
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
|
|
|
|
2023-10-17 15:21:49 +01:00
|
|
|
property bool hasSavedSettings: false
|
|
|
|
|
2021-01-20 13:04:18 +01:00
|
|
|
signal yes()
|
|
|
|
signal no()
|
2023-03-24 14:26:43 +01:00
|
|
|
signal noClearSettings()
|
2021-01-20 13:04:18 +01:00
|
|
|
signal editSettings()
|
|
|
|
|
|
|
|
// 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
|
2023-10-16 13:09:34 +01:00
|
|
|
text: qsTr("Use OS customization?")
|
2021-01-20 13:04:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2023-10-11 13:22:32 +01:00
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
|
2021-01-20 13:04:18 +01:00
|
|
|
Accessible.name: text.replace(/<\/?[^>]+(>|$)/g, "")
|
2023-10-16 13:09:34 +01:00
|
|
|
text: qsTr("Would you like to apply OS customization settings?")
|
2021-01-20 13:04:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
Layout.alignment: Qt.AlignCenter | Qt.AlignBottom
|
|
|
|
Layout.bottomMargin: 10
|
|
|
|
spacing: 20
|
2023-05-18 15:03:43 +02:00
|
|
|
id: buttons
|
2021-01-20 13:04:18 +01:00
|
|
|
|
2022-02-04 12:32:12 +01:00
|
|
|
ImButton {
|
2023-10-16 13:09:34 +01:00
|
|
|
text: qsTr("EDIT SETTINGS")
|
2021-01-20 13:04:18 +01:00
|
|
|
onClicked: {
|
|
|
|
msgpopup.close()
|
2023-10-16 13:09:34 +01:00
|
|
|
msgpopup.editSettings()
|
2021-01-20 13:04:18 +01:00
|
|
|
}
|
2022-02-04 12:32:12 +01:00
|
|
|
Material.foreground: activeFocus ? "#d1dcfb" : "#ffffff"
|
2021-01-20 13:04:18 +01:00
|
|
|
Material.background: "#c51a4a"
|
|
|
|
}
|
|
|
|
|
2023-03-24 14:26:43 +01:00
|
|
|
ImButton {
|
2023-10-17 15:21:49 +01:00
|
|
|
id: noAndClearButton
|
2023-03-24 14:26:43 +01:00
|
|
|
text: qsTr("NO, CLEAR SETTINGS")
|
|
|
|
onClicked: {
|
|
|
|
msgpopup.close()
|
|
|
|
msgpopup.noClearSettings()
|
|
|
|
}
|
|
|
|
Material.foreground: activeFocus ? "#d1dcfb" : "#ffffff"
|
|
|
|
Material.background: "#c51a4a"
|
2023-10-17 15:21:49 +01:00
|
|
|
enabled: false
|
2023-03-24 14:26:43 +01:00
|
|
|
}
|
|
|
|
|
2022-02-04 12:32:12 +01:00
|
|
|
ImButton {
|
2023-10-17 15:21:49 +01:00
|
|
|
id: yesButton
|
2021-01-20 13:04:18 +01:00
|
|
|
text: qsTr("YES")
|
|
|
|
onClicked: {
|
|
|
|
msgpopup.close()
|
|
|
|
msgpopup.yes()
|
|
|
|
}
|
2022-02-04 12:32:12 +01:00
|
|
|
Material.foreground: activeFocus ? "#d1dcfb" : "#ffffff"
|
2021-01-20 13:04:18 +01:00
|
|
|
Material.background: "#c51a4a"
|
2023-10-17 15:21:49 +01:00
|
|
|
enabled: false
|
2021-01-20 13:04:18 +01:00
|
|
|
}
|
|
|
|
|
2022-02-04 12:32:12 +01:00
|
|
|
ImButton {
|
2023-10-16 13:09:34 +01:00
|
|
|
text: qsTr("NO")
|
2021-01-20 13:04:18 +01:00
|
|
|
onClicked: {
|
|
|
|
msgpopup.close()
|
2023-10-16 13:09:34 +01:00
|
|
|
msgpopup.no()
|
2021-01-20 13:04:18 +01:00
|
|
|
}
|
2022-02-04 12:32:12 +01:00
|
|
|
Material.foreground: activeFocus ? "#d1dcfb" : "#ffffff"
|
2021-01-20 13:04:18 +01:00
|
|
|
Material.background: "#c51a4a"
|
|
|
|
}
|
|
|
|
|
|
|
|
Text { text: " " }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function openPopup() {
|
|
|
|
open()
|
2023-10-17 15:21:49 +01:00
|
|
|
if (hasSavedSettings) {
|
|
|
|
/* HACK: Bizarrely, the button enabled characteristics are not re-evaluated on open.
|
|
|
|
* So, let's manually _force_ these buttons to be enabled */
|
|
|
|
yesButton.enabled = true
|
|
|
|
noAndClearButton.enabled = true
|
|
|
|
} else {
|
|
|
|
yesButton.enabled = false
|
|
|
|
noAndClearButton.enabled = false
|
|
|
|
}
|
|
|
|
|
2021-01-20 13:04:18 +01:00
|
|
|
// trigger screen reader to speak out message
|
|
|
|
msgpopupbody.forceActiveFocus()
|
|
|
|
}
|
|
|
|
}
|