Merge PR #1019: Add a confirmation question when removing a thing

This commit is contained in:
jenkins 2023-05-08 15:58:20 +02:00
commit 29169b293c
10 changed files with 177 additions and 16 deletions

View File

@ -683,6 +683,14 @@
<source>ID</source>
<translation>ID</translation>
</message>
<message>
<source>Remove thing?</source>
<translation>&quot;Thing&quot; entfernen?</translation>
</message>
<message>
<source>Are you sure you want to remove %1 and all associated settings?</source>
<translation>Bist Du sicher, dass %1 und alle zugehörigen Einstellungen entfernt werden sollen?</translation>
</message>
</context>
<context>
<name>ConnectingPage</name>
@ -1726,6 +1734,14 @@
<source>In order for your %1 system to be useful, go ahead and add some things.</source>
<translation>Damit Dein %1 System sich nützlich machen kann, füge einige &quot;Things&quot; hinzu.</translation>
</message>
<message>
<source>Remove thing?</source>
<translation>&quot;Thing&quot; entfernen?</translation>
</message>
<message>
<source>Are you sure you want to remove %1 and all associated settings?</source>
<translation>Bist Du sicher, dass %1 und alle zugehörigen Einstellungen entfernt werden sollen?</translation>
</message>
</context>
<context>
<name>EditTimeEventItemPage</name>

View File

@ -683,6 +683,14 @@
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove thing?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Are you sure you want to remove %1 and all associated settings?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ConnectingPage</name>
@ -1720,6 +1728,14 @@
<source>In order for your %1 system to be useful, go ahead and add some things.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove thing?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Are you sure you want to remove %1 and all associated settings?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EditTimeEventItemPage</name>

View File

@ -683,6 +683,14 @@
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove thing?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Are you sure you want to remove %1 and all associated settings?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ConnectingPage</name>
@ -1720,6 +1728,14 @@
<source>In order for your %1 system to be useful, go ahead and add some things.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove thing?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Are you sure you want to remove %1 and all associated settings?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EditTimeEventItemPage</name>

View File

@ -683,6 +683,14 @@
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove thing?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Are you sure you want to remove %1 and all associated settings?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ConnectingPage</name>
@ -1720,6 +1728,14 @@
<source>In order for your %1 system to be useful, go ahead and add some things.</source>
<translation></translation>
</message>
<message>
<source>Remove thing?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Are you sure you want to remove %1 and all associated settings?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EditTimeEventItemPage</name>

View File

@ -682,6 +682,14 @@
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove thing?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Are you sure you want to remove %1 and all associated settings?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ConnectingPage</name>
@ -1722,6 +1730,14 @@
<source>In order for your %1 system to be useful, go ahead and add some things.</source>
<translation>%1 .</translation>
</message>
<message>
<source>Remove thing?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Are you sure you want to remove %1 and all associated settings?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EditTimeEventItemPage</name>

View File

@ -683,6 +683,14 @@
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove thing?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Are you sure you want to remove %1 and all associated settings?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ConnectingPage</name>
@ -1720,6 +1728,14 @@
<source>In order for your %1 system to be useful, go ahead and add some things.</source>
<translation></translation>
</message>
<message>
<source>Remove thing?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Are you sure you want to remove %1 and all associated settings?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EditTimeEventItemPage</name>

View File

@ -682,6 +682,14 @@
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove thing?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Are you sure you want to remove %1 and all associated settings?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ConnectingPage</name>
@ -1722,6 +1730,14 @@
<source>In order for your %1 system to be useful, go ahead and add some things.</source>
<translation>%1 sisteminizin kullanışlı olması için devam edin ve bazı şeyler ekleyin.</translation>
</message>
<message>
<source>Remove thing?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Are you sure you want to remove %1 and all associated settings?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EditTimeEventItemPage</name>

View File

@ -682,6 +682,14 @@
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove thing?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Are you sure you want to remove %1 and all associated settings?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ConnectingPage</name>
@ -1719,6 +1727,14 @@
<source>In order for your %1 system to be useful, go ahead and add some things.</source>
<translation></translation>
</message>
<message>
<source>Remove thing?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Are you sure you want to remove %1 and all associated settings?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EditTimeEventItemPage</name>

View File

@ -38,6 +38,7 @@ import "../delegates"
SettingsPageBase {
id: root
property Thing thing: null
busy: d.pendingCommand != -1
header: NymeaHeader {
text: root.thing.name
@ -80,7 +81,8 @@ SettingsPageBase {
}
function deleteThing() {
engine.thingManager.removeThing(root.thing.id)
var popup = removeDialogComponent.createObject(root)
popup.open()
}
function reconfigureThing() {
@ -101,15 +103,16 @@ SettingsPageBase {
Connections {
target: engine.thingManager
onRemoveThingReply: {
if (d.pendingCommand != commandId) {
return;
}
d.pendingCommand = -1
switch (thingError) {
case Thing.ThingErrorNoError:
pageStack.pop();
return;
case Thing.ThingErrorThingInRule:
var removeMethodComponent = Qt.createComponent(Qt.resolvedUrl("../components/RemoveThingMethodDialog.qml"))
var popup = removeMethodComponent.createObject(root, {thing: root.thing, rulesList: ruleIds});
popup.open();
return;
default:
var popup = errorDialog.createObject(root, {error: thingError})
popup.open();
@ -117,6 +120,11 @@ SettingsPageBase {
}
}
QtObject {
id: d
property int pendingCommand: -1
}
SettingsPageSectionHeader {
text: qsTr("Information")
}
@ -289,6 +297,20 @@ SettingsPageBase {
ErrorDialog { }
}
Component {
id: removeDialogComponent
NymeaDialog {
id: removeDialog
title: qsTr("Remove thing?")
text: qsTr("Are you sure you want to remove %1 and all associated settings?").arg(root.thing.name)
standardButtons: Dialog.Yes | Dialog.No
onAccepted: {
d.pendingCommand = engine.thingManager.removeThing(root.thing.id)
}
}
}
Component {
id: renameDialog
Dialog {

View File

@ -56,24 +56,20 @@ Page {
QtObject {
id: d
property var thingToRemove: null
property int pendingCommandId: -1
}
Connections {
target: engine.thingManager
onRemoveThingReply: {
if (!d.thingToRemove) {
if (commandId != d.pendingCommandId) {
return;
}
d.pendingCommandId = -1
switch (thingError) {
case Thing.ThingErrorNoError:
d.thingToRemove = null;
return;
case Thing.ThingErrorThingInRule:
var removeMethodComponent = Qt.createComponent(Qt.resolvedUrl("../components/RemoveThingMethodDialog.qml"))
var popup = removeMethodComponent.createObject(root, {thing: d.thingToRemove, rulesList: ruleIds});
popup.open();
return;
default:
var errorDialog = Qt.createComponent(Qt.resolvedUrl("../components/ErrorDialog.qml"))
@ -112,13 +108,28 @@ Page {
pageStack.push(Qt.resolvedUrl("ConfigureThingPage.qml"), {thing: thing})
}
onDeleteClicked: {
d.thingToRemove = thing;
engine.thingManager.removeThing(d.thingToRemove.id)
var popup = removeDialogComponent.createObject(root, {thing: thing})
popup.open()
}
}
}
}
Component {
id: removeDialogComponent
NymeaDialog {
id: removeDialog
title: qsTr("Remove thing?")
text: qsTr("Are you sure you want to remove %1 and all associated settings?").arg(thing.name)
standardButtons: Dialog.Yes | Dialog.No
property Thing thing: null
onAccepted: {
d.pendingCommand = engine.thingManager.removeThing(thing.id)
}
}
}
EmptyViewPlaceholder {
anchors { left: parent.left; right: parent.right; margins: app.margins }