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
|
import QtQuick 2.12
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.3
import FishUI 1.0 as FishUI
Item {
id: root
property var heightValue: mainLayout.implicitHeight + FishUI.Units.largeSpacing * 2
width: 450
height: heightValue
Connections {
target: confirmation
function onFailure() {
doneButton.enabled = true
passwordInput.enabled = true
}
}
onHeightValueChanged: {
rootWindow.height = heightValue
rootWindow.maximumHeight = heightValue
rootWindow.minimumHeight = heightValue
rootWindow.maximumWidth = root.width
rootWindow.minimumWidth = root.width
}
Keys.enabled: true
Keys.onEscapePressed: {
confirmation.setConfirmationResult("")
}
Rectangle {
id: _background
anchors.fill: parent
radius: FishUI.Theme.bigRadius
color: FishUI.Theme.secondBackgroundColor
}
DragHandler {
target: null
acceptedDevices: PointerDevice.GenericPointer
grabPermissions: TapHandler.CanTakeOverFromAnything
onActiveChanged: if (active) { windowHelper.startSystemMove(rootWindow) }
}
FishUI.WindowHelper {
id: windowHelper
}
FishUI.WindowShadow {
view: rootWindow
geometry: Qt.rect(root.x, root.y, root.width, root.height)
radius: _background.radius
}
FontMetrics {
id: fontMetrics
}
RowLayout {
id: mainLayout
anchors.fill: parent
anchors.margins: FishUI.Units.largeSpacing
Image {
id: icon
source: "qrc:/svg/emblem-warning.svg"
sourceSize.width: 64
sourceSize.height: 64
smooth: true
Layout.alignment: Qt.AlignTop
visible: !iconImage
}
Image {
id: iconImage
source: "image://icontheme/" + confirmation.iconName
sourceSize.width: 64
sourceSize.height: 64
Layout.alignment: Qt.AlignTop
visible: state !== Image.Ready
}
Item {
width: FishUI.Units.largeSpacing
}
ColumnLayout {
id: column
spacing: FishUI.Units.largeSpacing
Text {
text: confirmation.message
font.bold: false
Layout.fillWidth: true
Layout.fillHeight: true
maximumLineCount: 2
wrapMode: Text.Wrap
elide: Text.ElideRight
color: FishUI.Theme.textColor
}
TextField {
id: userTextField
text: confirmation.identity
enabled: false
Layout.fillWidth: true
}
TextField {
id: passwordInput
placeholderText: qsTr("Password")
echoMode: TextField.Password
Layout.fillWidth: true
selectByMouse: true
focus: true
onAccepted: {
if (passwordInput.text)
confirmation.setConfirmationResult(passwordInput.text)
}
Keys.onEscapePressed: {
confirmation.setConfirmationResult("")
}
}
RowLayout {
spacing: FishUI.Units.largeSpacing
Button {
text: qsTr("Cancel")
Layout.fillWidth: true
height: 50
onClicked: confirmation.rejected()
}
Button {
id: doneButton
text: qsTr("Done")
Layout.fillWidth: true
flat: true
height: 50
onClicked: {
doneButton.enabled = false
passwordInput.enabled = false
confirmation.setConfirmationResult(passwordInput.text)
}
}
}
}
}
}
|