Files

94 lines
2.8 KiB
QML
Raw Permalink Normal View History

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Flora
Dialog {
id: root
property string message: ""
property bool doubleConfirm: false
signal confirmed()
title: qsTr("Подтверждение")
modal: true
width: 440
anchors.centerIn: parent
closePolicy: Dialog.NoAutoClose
standardButtons: Dialog.NoButton
background: Rectangle { color: Theme.surface; border.color: Theme.borderStrong; radius: 10 }
property bool armed: false
function resetDialog() {
root.armed = false
deleteButton.text = qsTr("Удалить")
warnLabel.visible = false
warnBox.visible = false
}
onOpened: root.resetDialog()
ColumnLayout {
anchors.fill: parent
spacing: 12
Row {
spacing: 10
Layout.fillWidth: true
Label { text: "\u26A0"; font.pixelSize: 20; color: Theme.warningText; visible: root.doubleConfirm }
Label {
width: parent.width - 30
wrapMode: Text.Wrap
text: root.message
color: Theme.text
font.pixelSize: 13
}
}
Rectangle {
id: warnBox
Layout.fillWidth: true
visible: false
color: Theme.warningBg
border.color: Theme.warningText
radius: 6
height: warnLabel.implicitHeight + 16
Label {
id: warnLabel
anchors.fill: parent
anchors.margins: 8
wrapMode: Text.Wrap
visible: false
color: Theme.warningText
text: qsTr("Внимание: папка содержит файлы. Они будут удалены безвозвратно.\nЕсли вы уверены — нажмите «Точно удалить».")
font.pixelSize: 11
}
}
RowLayout {
Layout.fillWidth: true
Item { Layout.fillWidth: true }
Button { text: qsTr("Отмена"); onClicked: root.reject() }
Button {
id: deleteButton
text: qsTr("Удалить")
highlighted: root.armed
palette.button: root.armed ? Theme.errorText : undefined
onClicked: {
if (root.doubleConfirm && !root.armed) {
root.armed = true
deleteButton.text = qsTr("Точно удалить")
warnLabel.visible = true
warnBox.visible = true
return
}
root.confirmed()
root.accept()
}
}
}
}
}