yubioath-flutter/qml/ConfirmationPopup.qml

148 lines
3.7 KiB
QML
Raw Permalink Normal View History

import QtQuick 2.9
2020-05-13 15:08:30 +03:00
import QtQuick.Controls 2.3
import QtQuick.Controls.Material 2.2
2020-06-15 10:10:33 +03:00
import QtQuick.Layouts 1.2
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")
padding: 16
margins: 0
spacing: 0
modal: true
focus: true
x: (parent.width - width) / 2
y: (parent.height - height) / 2
width: app.width * 0.9 > 600 ? 600 : app.width * 0.9
onClosed: {
2020-06-15 10:10:33 +03:00
navigator.focus = true;
}
onAccepted: {
2020-06-15 10:10:33 +03:00
close();
if (acceptedCb)
acceptedCb();
2020-06-15 10:10:33 +03:00
navigator.focus = true;
}
2020-06-15 10:10:33 +03:00
onRejected: {
close();
if (cancelCb)
cancelCb();
2020-06-15 10:10:33 +03:00
navigator.focus = true;
}
2020-05-13 15:08:30 +03:00
Component.onCompleted: btnAccept.forceActiveFocus()
ColumnLayout {
width: parent.width
2020-05-13 15:08:30 +03:00
spacing: 0
Label {
text: heading
2019-10-09 14:01:47 +03:00
font.pixelSize: 14
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
}
2020-05-13 15:08:30 +03:00
RowLayout {
spacing: 0
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
}
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
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
2020-05-13 15:08:30 +03:00
Layout.fillWidth: true
visible: message
}
2020-06-15 10:10:33 +03:00
}
Label {
text: description
color: primaryColor
2020-05-13 15:08:30 +03:00
opacity: lowEmphasis
font.pixelSize: 13
lineHeight: 1.2
visible: description
2020-05-13 15:08:30 +03:00
textFormat: TextEdit.RichText
wrapMode: Text.WordWrap
Layout.maximumWidth: parent.width
}
DialogButtonBox {
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
Layout.topMargin: 8
Layout.bottomMargin: -8
padding: 0
visible: buttons
StyledButton {
id: btnAccept
2020-06-15 10:10:33 +03:00
text: qsTr(buttonAccept)
enabled: true
critical: warning
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
KeyNavigation.tab: btnCancel
Keys.onReturnPressed: accept()
onClicked: accept()
}
StyledButton {
id: btnCancel
2020-06-15 10:10:33 +03:00
text: qsTr(buttonCancel)
critical: warning
enabled: true
DialogButtonBox.buttonRole: DialogButtonBox.RejectRole
KeyNavigation.tab: btnAccept
Keys.onReturnPressed: reject()
onClicked: reject()
}
2020-06-15 10:10:33 +03:00
}
2020-06-15 10:10:33 +03:00
}
Overlay.modal: Rectangle {
color: "#66000000"
}
2020-06-15 10:10:33 +03:00
background: Rectangle {
color: defaultBackground
radius: 4
}
}