[utilities/powerplant] src/qml: Dynamic Greating to time & Delete confirmation

Carl Schwan <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 97752798e6ed03fb45be57a70dfe0d0cc73cf673 by Carl Schwan, on behalf of Michael Rostom.
Committed on 22/07/2026 at 06:26.
Pushed by carlschwan into branch 'master'.

Dynamic Greating to time & Delete confirmation

* Made greeting dynamic: morning/evening/night etc

![Screenshot_20260721_192952.png](/uploads/001a18ec32c47bc1c943643d5d60ffe0/Screenshot_20260721_192952.png){width=199 height=205}![Screenshot_20260721_233126.png](/uploads/4584889829e6f70930860f6982e82f36/Screenshot_20260721_233126.png){width=196 height=202}

* Added a confirmation dialogue when deleting a plant

  ![Screenshot_20260721_192938.png](/uploads/19698f7a7fdd3a35b10fc75439e4d2d8/Screenshot_20260721_192938.png){width=350 height=359}

M  +12   -4    src/qml/PlantDetailPage.qml
M  +14   -1    src/qml/PlantsPage.qml

https://invent.kde.org/utilities/powerplant/-/commit/97752798e6ed03fb45be57a70dfe0d0cc73cf673

diff --git a/src/qml/PlantDetailPage.qml b/src/qml/PlantDetailPage.qml
index 0307887..ff71239 100644
--- a/src/qml/PlantDetailPage.qml
+++ b/src/qml/PlantDetailPage.qml
@@ -20,6 +20,17 @@ Kirigami.ScrollablePage {
     required property int plantId
     property bool wideScreen: applicationWindow().width >= 800
 
+    Kirigami.PromptDialog {
+        id: confirmDeleteDialog
+        title: i18nc("@title:window %1 is plantName", "Delete %1?", plant.name)
+        subtitle: i18nc("@info", "Are you sure you want to delete this plant?")
+        standardButtons: Kirigami.Dialog.Yes | Kirigami.Dialog.No
+        onAccepted: {
+            root.plantsModel.deletePlant(plant.plantId);
+            applicationWindow().pageStack.pop();
+        }
+    }
+
     Plant {
         id: plant
         plantId: root.plantId
@@ -64,10 +75,7 @@ Kirigami.ScrollablePage {
         Kirigami.Action {
             icon.name: "delete-symbolic"
             text: i18nc("@action:button", "Delete")
-            onTriggered: {
-                plantsModel.deletePlant(plant.plantId);
-                applicationWindow().pageStack.pop();
-            }
+            onTriggered: confirmDeleteDialog.open()
         }
     ]
 
diff --git a/src/qml/PlantsPage.qml b/src/qml/PlantsPage.qml
index a37a482..8c61330 100644
--- a/src/qml/PlantsPage.qml
+++ b/src/qml/PlantsPage.qml
@@ -49,6 +49,19 @@ Kirigami.ScrollablePage {
             height: Kirigami.Units.gridUnit * 35
         })
     }
+    property date currentDate: new Date()
+
+    function greetingForHour(hour) {
+        if (hour >= 5 && hour < 12) {
+            return i18nc("@title", "Good morning!");
+        } else if (hour < 17) {
+            return i18nc("@title", "Good afternoon!");
+        } else if (hour < 21) {
+            return i18nc("@title", "Good evening!");
+        } else {
+            return i18nc("@title", "Good night!");
+        }
+    }
 
     GridView {
         id: grid
@@ -67,7 +80,7 @@ Kirigami.ScrollablePage {
                 spacing: 0
 
                 Controls.Label {
-                    text: i18n("Good Morning!")
+                    text: greetingForHour(root.currentDate.getHours())
                     font {
                         bold: true
                         pixelSize: 30
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.