From 5493e21f4092cf496ae0644824a0f35d73573116 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Sat, 18 Feb 2023 21:04:13 +0100 Subject: [PATCH] Removing device types now asks for confirmation --- DeviceTypesSettingsPage.qml | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/DeviceTypesSettingsPage.qml b/DeviceTypesSettingsPage.qml index eb235b8..280aa54 100644 --- a/DeviceTypesSettingsPage.qml +++ b/DeviceTypesSettingsPage.qml @@ -1,4 +1,5 @@ import QtQuick +import QtQuick.Controls import QtQuick.Controls.Material import QtQuick.Layouts @@ -21,8 +22,38 @@ ColumnLayout { model: deviceTypesModel - onAddClicked: (index) => deviceTypesModel.insertRow(index < 0 ? 0 : index + 1); - onRemoveClicked: (index) => deviceTypesModel.removeRow(index) + onAddClicked: (index) => { const newIndex = index < 0 ? 0 : index + 1; if (deviceTypesModel.insertRow(newIndex)) currentIndex = newIndex; else console.warn('failed'); } + onRemoveClicked: (index) => { + const dialog = dialogComponent.createObject(Overlay.overlay); + dialog.index = index; + dialog.open(); + } + + Component { + id: dialogComponent + + Dialog { + property int index + + anchors.centerIn: parent + standardButtons: DialogButtonBox.Yes | DialogButtonBox.Cancel + modal: true + title: qsTr('Confirmation') + + onAccepted: deviceTypesModel.removeRow(index) + + Label { + id: textContainer + + anchors.fill: parent + + horizontalAlignment: Qt.AlignLeft + verticalAlignment: Qt.AlignTop + + text: qsTr('Are you sure you want to remove row %0').arg(index) + } + } + } } ColumnLayout {