2019-09-09 15:12:58 +03:00
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Controls 2.2
|
|
|
|
import QtQuick.Layouts 1.2
|
2019-11-05 18:43:17 +03:00
|
|
|
import QtQuick.Controls.Material 2.2
|
2019-09-09 15:12:58 +03:00
|
|
|
|
|
|
|
Dialog {
|
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
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
color: defaultBackground
|
|
|
|
radius: 4
|
|
|
|
}
|
|
|
|
|
|
|
|
onClosed: {
|
|
|
|
navigator.focus = true
|
|
|
|
}
|
|
|
|
|
|
|
|
onAccepted: {
|
|
|
|
close()
|
2019-11-27 16:44:27 +03:00
|
|
|
acceptedCb()
|
2019-09-09 15:12:58 +03:00
|
|
|
navigator.focus = true
|
|
|
|
}
|
|
|
|
|
|
|
|
onRejected: {
|
|
|
|
close()
|
|
|
|
navigator.focus = true
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: btnCancel.forceActiveFocus()
|
|
|
|
|
|
|
|
property var acceptedCb
|
2019-11-05 18:43:17 +03:00
|
|
|
property bool warning: true
|
|
|
|
property bool buttons: true
|
2019-09-09 15:12:58 +03:00
|
|
|
property string heading
|
2019-11-05 18:43:17 +03:00
|
|
|
property string message
|
|
|
|
property string description
|
2019-09-09 17:59:30 +03:00
|
|
|
property string buttonCancel: qsTr("Cancel")
|
|
|
|
property string buttonAccept: qsTr("Accept")
|
2019-09-09 15:12:58 +03:00
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-10-31 15:34:04 +03:00
|
|
|
Pane {
|
|
|
|
padding: 12
|
|
|
|
rightPadding: 16
|
|
|
|
bottomPadding: 8
|
2020-01-14 17:13:35 +03:00
|
|
|
visible: message
|
2019-10-31 15:34:04 +03:00
|
|
|
width: parent.width
|
2019-11-05 18:43:17 +03:00
|
|
|
Layout.minimumWidth: parent.width
|
2019-10-31 15:34:04 +03:00
|
|
|
Layout.maximumWidth: parent.width
|
2019-11-05 18:43:17 +03:00
|
|
|
Layout.topMargin: 16
|
2019-10-31 15:34:04 +03:00
|
|
|
background: Rectangle {
|
2019-11-05 18:43:17 +03:00
|
|
|
color: warning ? yubicoRed : yubicoGreen
|
|
|
|
radius: 4
|
2019-10-31 15:34:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
spacing: 0
|
|
|
|
width: parent.width
|
|
|
|
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
|
|
|
|
|
|
|
|
StyledImage {
|
2019-11-05 18:43:17 +03:00
|
|
|
source: warning ? "../images/warning.svg" : "../images/info.svg"
|
2019-10-31 15:34:04 +03:00
|
|
|
color: yubicoWhite
|
|
|
|
iconWidth: 32
|
|
|
|
iconHeight: 32
|
|
|
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
|
|
|
Layout.maximumWidth: 32
|
2020-01-14 17:13:35 +03:00
|
|
|
visible: message
|
2019-10-31 15:34:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
2019-11-05 18:43:17 +03:00
|
|
|
text: message
|
2019-10-31 15:34:04 +03:00
|
|
|
color: yubicoWhite
|
|
|
|
font.pixelSize: 13
|
|
|
|
font.weight: Font.Bold
|
|
|
|
lineHeight: 1.2
|
|
|
|
leftPadding: 12
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
|
|
|
|
Layout.fillWidth: true
|
2020-01-14 17:13:35 +03:00
|
|
|
visible: message
|
2019-10-31 15:34:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
Label {
|
2019-10-31 15:34:04 +03:00
|
|
|
Layout.topMargin: 16
|
2019-11-05 18:43:17 +03:00
|
|
|
text: description
|
2019-11-27 16:44:27 +03:00
|
|
|
color: primaryColor
|
|
|
|
opacity: highEmphasis
|
2019-09-09 15:12:58 +03:00
|
|
|
font.pixelSize: 13
|
|
|
|
lineHeight: 1.2
|
2020-01-14 17:13:35 +03:00
|
|
|
visible: description
|
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
|
|
|
|
Layout.topMargin: 0
|
|
|
|
Layout.bottomMargin: -16
|
|
|
|
Layout.rightMargin: -8
|
|
|
|
padding: 0
|
2020-01-14 17:13:35 +03:00
|
|
|
visible: buttons
|
2019-09-09 15:12:58 +03:00
|
|
|
|
|
|
|
StyledButton {
|
|
|
|
id: btnAccept
|
|
|
|
text: qsTr(buttonAccept)
|
|
|
|
flat: true
|
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
|
|
|
|
text: qsTr(buttonCancel)
|
|
|
|
flat: true
|
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()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|