Files
Flora/qml/dialogs/ConfirmDialog.qml
T

76 lines
2.2 KiB
QML

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
// Подтверждение удаления. Для непустой папки требуется двойное подтверждение:
// первое нажатие показывает предупреждение, второе — удаляет.
Dialog {
id: root
property string message: ""
property bool doubleConfirm: false
signal confirmed()
title: qsTr("Подтверждение")
modal: true
width: 420
anchors.centerIn: parent
closePolicy: Dialog.NoAutoClose
standardButtons: Dialog.NoButton
property bool armed: false
function resetDialog() {
root.armed = false
deleteButton.text = qsTr("Удалить")
warnLabel.visible = false
}
onOpened: root.resetDialog()
ColumnLayout {
anchors.fill: parent
spacing: 12
Label {
Layout.fillWidth: true
wrapMode: Text.Wrap
text: root.message
}
Label {
id: warnLabel
Layout.fillWidth: true
wrapMode: Text.Wrap
visible: false
color: "#b00020"
text: qsTr("Внимание: папка содержит файлы. Они будут удалены безвозвратно.\n"
+ "Если вы уверены — нажмите «Точно удалить».")
}
RowLayout {
Layout.fillWidth: true
Item { Layout.fillWidth: true }
Button {
text: qsTr("Отмена")
onClicked: root.reject()
}
Button {
id: deleteButton
text: qsTr("Удалить")
highlighted: root.armed
onClicked: {
if (root.doubleConfirm && !root.armed) {
root.armed = true
deleteButton.text = qsTr("Точно удалить")
warnLabel.visible = true
return
}
root.confirmed()
root.accept()
}
}
}
}
}