Commit 34e7a3db authored by Dimitris Kardarakos's avatar Dimitris Kardarakos

Provide a confirmation dialog before calendar deletion

parent ab2192b9
...@@ -27,6 +27,8 @@ Kirigami.Action { ...@@ -27,6 +27,8 @@ Kirigami.Action {
property bool isCalendar: true property bool isCalendar: true
property var configuration property var configuration
signal deleteCalendar
checked: (text == configuration.activeCalendar) checked: (text == configuration.activeCalendar)
Kirigami.Action { Kirigami.Action {
...@@ -42,16 +44,6 @@ Kirigami.Action { ...@@ -42,16 +44,6 @@ Kirigami.Action {
text: "Delete" text: "Delete"
iconName: "delete" iconName: "delete"
onTriggered: { onTriggered: (configuration.activeCalendar == parent.text) ? showPassiveNotification("Active calendar cannot be deleted") : deleteCalendar()
if (configuration.activeCalendar == parent.text) {
showPassiveNotification("Active calendar cannot be deleted");
}
else {
var toRemoveCalendarComponent = Qt.createQmlObject("import org.kde.phone.calindori 0.1 as Calindori; Calindori.LocalCalendar { name: \"" + parent.text + "\"}",root);
toRemoveCalendarComponent.deleteCalendar();
configuration.removeCalendar(parent.text);
showPassiveNotification("Calendar " + parent.text + " has been deleted");
}
}
} }
} }
/*
* Copyright 2019 Dimitris Kardarakos <dimkard@posteo.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.0
import QtQuick.Controls 2.4 as Controls2
import QtQuick.Layouts 1.11
import org.kde.kirigami 2.4 as Kirigami
import org.kde.phone.calindori 0.1 as Calindori
Kirigami.OverlaySheet {
id: deleteSheet
property string calendar
property var configuration
contentItem: Controls2.Label {
Layout.fillWidth: true
wrapMode: Text.WordWrap
text: "All data included in this calendar will be deleted. Proceed with deletion?"
}
parent: applicationWindow().overlay
footer: RowLayout {
Item {
Layout.fillWidth: true
}
Controls2.ToolButton {
text: qsTr("Delete")
onClicked: {
var toRemoveCalendarComponent = Qt.createQmlObject("import org.kde.phone.calindori 0.1 as Calindori; Calindori.LocalCalendar { name: \"" + deleteSheet.calendar + "\"}",root);
toRemoveCalendarComponent.deleteCalendar();
configuration.removeCalendar(deleteSheet.calendar);
showPassiveNotification("Calendar " + deleteSheet.calendar + " has been deleted");
deleteSheet.close();
}
}
Controls2.ToolButton {
text: qsTr("Cancel")
onClicked: deleteSheet.close()
}
}
}
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
import QtQuick 2.1 import QtQuick 2.1
import QtQuick.Layouts 1.2 import QtQuick.Layouts 1.2
import org.kde.kirigami 2.0 as Kirigami import org.kde.kirigami 2.0 as Kirigami
import QtQuick.Controls 2.4 as Controls2
import org.kde.phone.calindori 0.1 as Calindori import org.kde.phone.calindori 0.1 as Calindori
import "Utils.js" as Utils import "Utils.js" as Utils
...@@ -89,6 +90,11 @@ Kirigami.ApplicationWindow { ...@@ -89,6 +90,11 @@ Kirigami.ApplicationWindow {
CalendarAction { CalendarAction {
configuration: calindoriConfig configuration: calindoriConfig
onDeleteCalendar: {
deleteSheet.calendar = text;
deleteSheet.open();
}
} }
} }
...@@ -217,5 +223,11 @@ Kirigami.ApplicationWindow { ...@@ -217,5 +223,11 @@ Kirigami.ApplicationWindow {
} }
} }
ConfirmationSheet {
id: deleteSheet
configuration: calindoriConfig
}
} }
...@@ -13,5 +13,6 @@ ...@@ -13,5 +13,6 @@
<file alias="CalendarInputPage.qml">contents/ui/CalendarInputPage.qml</file> <file alias="CalendarInputPage.qml">contents/ui/CalendarInputPage.qml</file>
<file alias="Utils.js">contents/code/Utils.js</file> <file alias="Utils.js">contents/code/Utils.js</file>
<file alias="CalendarAction.qml">contents/ui/CalendarAction.qml</file> <file alias="CalendarAction.qml">contents/ui/CalendarAction.qml</file>
<file alias="ConfirmationSheet.qml">contents/ui/ConfirmationSheet.qml</file>
</qresource> </qresource>
</RCC> </RCC>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment