2019-09-09 15:12:58 +03:00
|
|
|
import QtQuick 2.9
|
2020-05-13 15:08:30 +03:00
|
|
|
import QtQuick.Controls 2.3
|
2019-11-05 18:43:17 +03:00
|
|
|
import QtQuick.Controls.Material 2.2
|
2020-06-15 10:10:33 +03:00
|
|
|
import QtQuick.Layouts 1.2
|
2019-09-09 15:12:58 +03:00
|
|
|
|
|
|
|
Dialog {
|
2020-06-15 10:10:33 +03:00
|
|
|
property var cancelCb
|
|
|
|
property var acceptedCb
|
|
|
|
property bool warning: true
|
|
|
|
property bool buttons: true
|
|
|
|
property string image
|
|
|
|
property string heading
|
|
|
|
property string message
|
|
|
|
property string description
|
|
|
|
property string buttonCancel: qsTr("Cancel")
|
|
|
|
property string buttonAccept: qsTr("Accept")
|
|
|
|
|
2019-10-31 15:34:04 +03:00
|
|
|
padding: 16
|
2019-09-09 15:12:58 +03:00
|
|
|
margins: 0
|
|
|
|
spacing: 0
|
|
|
|
modal: true
|
2019-10-31 15:34:04 +03:00
|
|
|
focus: true
|
2019-09-09 15:12:58 +03:00
|
|
|
x: (parent.width - width) / 2
|
|
|
|
y: (parent.height - height) / 2
|
2019-10-31 15:34:04 +03:00
|
|
|
width: app.width * 0.9 > 600 ? 600 : app.width * 0.9
|
2019-09-09 15:12:58 +03:00
|
|
|
onClosed: {
|
2020-06-15 10:10:33 +03:00
|
|
|
navigator.focus = true;
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
onAccepted: {
|
2020-06-15 10:10:33 +03:00
|
|
|
close();
|
|
|
|
if (acceptedCb)
|
|
|
|
acceptedCb();
|
2019-09-09 15:12:58 +03:00
|
|
|
|
2020-06-15 10:10:33 +03:00
|
|
|
navigator.focus = true;
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
2020-06-15 10:10:33 +03:00
|
|
|
onRejected: {
|
|
|
|
close();
|
|
|
|
if (cancelCb)
|
|
|
|
cancelCb();
|
2019-09-09 15:12:58 +03:00
|
|
|
|
2020-06-15 10:10:33 +03:00
|
|
|
navigator.focus = true;
|
|
|
|
}
|
2020-05-13 15:08:30 +03:00
|
|
|
Component.onCompleted: btnAccept.forceActiveFocus()
|
2019-09-09 15:12:58 +03:00
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
width: parent.width
|
2020-05-13 15:08:30 +03:00
|
|
|
spacing: 0
|
2019-09-09 15:12:58 +03:00
|
|
|
|
|
|
|
Label {
|
|
|
|
text: heading
|
2019-10-09 14:01:47 +03:00
|
|
|
font.pixelSize: 14
|
2019-09-09 15:12:58 +03:00
|
|
|
font.weight: Font.Medium
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
Layout.maximumWidth: parent.width
|
2020-05-14 11:46:02 +03:00
|
|
|
Layout.bottomMargin: 16
|
2020-05-13 15:08:30 +03:00
|
|
|
visible: heading
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
|
2020-05-13 15:08:30 +03:00
|
|
|
RowLayout {
|
|
|
|
spacing: 0
|
2019-10-31 15:34:04 +03:00
|
|
|
width: parent.width
|
2020-05-13 15:08:30 +03:00
|
|
|
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
|
2020-05-14 11:46:02 +03:00
|
|
|
Layout.bottomMargin: 16
|
2020-05-13 15:08:30 +03:00
|
|
|
visible: message
|
|
|
|
|
|
|
|
StyledImage {
|
|
|
|
source: warning ? "../images/warning.svg" : "../images/info.svg"
|
|
|
|
color: warning ? yubicoRed : defaultForeground
|
|
|
|
iconWidth: 32
|
|
|
|
iconHeight: 32
|
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
|
|
|
Layout.maximumWidth: 48
|
|
|
|
visible: message
|
2019-10-31 15:34:04 +03:00
|
|
|
}
|
|
|
|
|
2020-05-13 15:08:30 +03:00
|
|
|
Label {
|
|
|
|
text: message
|
|
|
|
color: primaryColor
|
|
|
|
opacity: highEmphasis
|
|
|
|
font.pixelSize: 13
|
|
|
|
font.weight: Font.Medium
|
|
|
|
lineHeight: 1.2
|
|
|
|
wrapMode: Text.WordWrap
|
2019-10-31 15:34:04 +03:00
|
|
|
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
|
2020-05-13 15:08:30 +03:00
|
|
|
Layout.fillWidth: true
|
|
|
|
visible: message
|
2019-10-31 15:34:04 +03:00
|
|
|
}
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-10-31 15:34:04 +03:00
|
|
|
}
|
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
Label {
|
2019-11-05 18:43:17 +03:00
|
|
|
text: description
|
2019-11-27 16:44:27 +03:00
|
|
|
color: primaryColor
|
2020-05-13 15:08:30 +03:00
|
|
|
opacity: lowEmphasis
|
2019-09-09 15:12:58 +03:00
|
|
|
font.pixelSize: 13
|
|
|
|
lineHeight: 1.2
|
2020-01-14 17:13:35 +03:00
|
|
|
visible: description
|
2020-05-13 15:08:30 +03:00
|
|
|
textFormat: TextEdit.RichText
|
2019-09-09 15:12:58 +03:00
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
Layout.maximumWidth: parent.width
|
|
|
|
}
|
|
|
|
|
2019-11-05 18:43:17 +03:00
|
|
|
DialogButtonBox {
|
|
|
|
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
|
2020-04-20 15:41:21 +03:00
|
|
|
Layout.topMargin: 8
|
|
|
|
Layout.bottomMargin: -8
|
2019-11-05 18:43:17 +03:00
|
|
|
padding: 0
|
2020-01-14 17:13:35 +03:00
|
|
|
visible: buttons
|
2019-09-09 15:12:58 +03:00
|
|
|
|
|
|
|
StyledButton {
|
|
|
|
id: btnAccept
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
text: qsTr(buttonAccept)
|
2020-01-14 17:13:35 +03:00
|
|
|
enabled: true
|
2019-11-05 18:43:17 +03:00
|
|
|
critical: warning
|
2019-09-09 15:12:58 +03:00
|
|
|
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
|
|
|
|
KeyNavigation.tab: btnCancel
|
|
|
|
Keys.onReturnPressed: accept()
|
|
|
|
onClicked: accept()
|
|
|
|
}
|
2019-11-05 18:43:17 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
StyledButton {
|
|
|
|
id: btnCancel
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
text: qsTr(buttonCancel)
|
2019-11-05 18:43:17 +03:00
|
|
|
critical: warning
|
2019-09-09 15:12:58 +03:00
|
|
|
enabled: true
|
|
|
|
DialogButtonBox.buttonRole: DialogButtonBox.RejectRole
|
|
|
|
KeyNavigation.tab: btnAccept
|
|
|
|
Keys.onReturnPressed: reject()
|
|
|
|
onClicked: reject()
|
|
|
|
}
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
2020-06-15 10:10:33 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Overlay.modal: Rectangle {
|
|
|
|
color: "#66000000"
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
2020-06-15 10:10:33 +03:00
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
color: defaultBackground
|
|
|
|
radius: 4
|
|
|
|
}
|
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|