[utilities/powerplant] src/qml: Cleaned up, fixed slider gradient, add toast notification
Carl Schwan <[email protected]> Wed, 5 Aug 2026 11:30:12 +0000 (UTC)
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 60f4c4414548705162013dff416e4d3382be7023 by Carl Schwan, on behalf of Michael Rostom.
Committed on 05/08/2026 at 11:30.
Pushed by carlschwan into branch 'master'.
Cleaned up, fixed slider gradient, add toast notification
* Ran qmlint fixed some unqualified access in NavigationBar and HeathSlider
* Cleaned up Main
* Added toast notification for watering/fertilizing/health record to indicate the user that the action is done
* Fixed Broken Gradient because of a typo
M +4 -4 src/qml/HealthSlider.qml
M +3 -6 src/qml/Main.qml
M +11 -8 src/qml/NavigationBar.qml
M +15 -9 src/qml/PlantDetailPage.qml
https://invent.kde.org/utilities/powerplant/-/commit/60f4c4414548705162013dff416e4d3382be7023
diff --git a/src/qml/HealthSlider.qml b/src/qml/HealthSlider.qml
index e8310e1..43e7cb2 100644
--- a/src/qml/HealthSlider.qml
+++ b/src/qml/HealthSlider.qml
@@ -45,7 +45,7 @@ Controls.Slider {
background: Rectangle {
id: background
x: root.leftPadding
- y: root.topPadding + weirdNumber - height / 2
+ y: root.topPadding + root.weirdNumber - height / 2
implicitWidth: 200
implicitHeight: 15
width: root.availableWidth
@@ -76,7 +76,7 @@ Controls.Slider {
GradientStop {
id: gradientStop3
- position: root.gradient[1].position
+ position: root.gradient[2].position
color: root.gradient[2].color
}
}
@@ -98,14 +98,14 @@ Controls.Slider {
height: 10
width: 10
radius: 5
- color: healthColor
+ color: root.healthColor
border.color: root.hovered || root.activeFocus ? Kirigami.Theme.hoverColor : Kirigami.ColorUtils.linearInterpolation(Kirigami.Theme.backgroundColor, Kirigami.Theme.textColor, 0.3)
border.width: 1
x: -4.5
y: -5
}
x: root.leftPadding + root.visualPosition * (root.availableWidth)
- y: root.topPadding + weirdNumber - height / 2
+ y: root.topPadding + root.weirdNumber - height / 2
implicitWidth: 26
implicitHeight: 26
antialiasing: true
diff --git a/src/qml/Main.qml b/src/qml/Main.qml
index 9fda5a2..896c7ea 100644
--- a/src/qml/Main.qml
+++ b/src/qml/Main.qml
@@ -2,8 +2,6 @@
// SPDX-FileCopyrightText: 2023 Mathis BrĂ¼chert <[email protected]>
import QtQuick
-import QtQuick.Controls as Controls
-import QtQuick.Layouts
import org.kde.kirigami as Kirigami
import org.kde.config as KConfig
import org.kde.powerplant
@@ -21,16 +19,15 @@ Kirigami.ApplicationWindow {
globalToolBar {
style: Kirigami.ApplicationHeaderStyle.ToolBar
showNavigationButtons: {
- if (applicationWindow().pageStack.currentIndex > 0 || applicationWindow().pageStack.currentIndex > 0) {
+ if (pageStack.currentIndex > 0) {
Kirigami.ApplicationHeaderStyle.ShowBackButton;
- } else {
- 0;
}
}
}
}
footer: NavigationBar {
- id: navigationbar
+ id: navigationBar
+ pageStack: root.pageStack
}
KConfig.WindowStateSaver {
diff --git a/src/qml/NavigationBar.qml b/src/qml/NavigationBar.qml
index 9934d6d..b971b63 100644
--- a/src/qml/NavigationBar.qml
+++ b/src/qml/NavigationBar.qml
@@ -6,18 +6,21 @@ import org.kde.kirigami as Kirigami
import org.kde.powerplant
Kirigami.NavigationTabBar {
- id: root
+ id: navigationBar
+
+ property var pageStack
visible: pageStack.layers.depth < 2
+
actions: [
Kirigami.Action {
- text: i18n("Plants")
+ text: i18nc("@action Navigation bar element", "Plants")
icon.name: "battery-profile-powersave-symbolic"
onTriggered: {
- while (pageStack.depth > 1) {
- pageStack.pop();
+ while (navigationBar.pageStack.depth > 1) {
+ navigationBar.pageStack.pop();
}
- pageStack.replace(Qt.resolvedUrl("PlantsPage.qml"));
+ navigationBar.pageStack.replace(Qt.resolvedUrl("PlantsPage.qml"));
}
Component.onCompleted: trigger()
},
@@ -25,10 +28,10 @@ Kirigami.NavigationTabBar {
text: i18n("Tasks")
icon.name: "view-calendar-tasks-symbolic"
onTriggered: {
- while (pageStack.depth > 1) {
- pageStack.pop();
+ while (navigationBar.pageStack.depth > 1) {
+ navigationBar.pageStack.pop();
}
- pageStack.replace(Qt.resolvedUrl("TaskPage.qml"));
+ navigationBar.pageStack.replace(Qt.resolvedUrl("TaskPage.qml"));
}
}
]
diff --git a/src/qml/PlantDetailPage.qml b/src/qml/PlantDetailPage.qml
index ff71239..b685bec 100644
--- a/src/qml/PlantDetailPage.qml
+++ b/src/qml/PlantDetailPage.qml
@@ -267,7 +267,10 @@ Kirigami.ScrollablePage {
Controls.Button {
text: i18n("Watered")
icon.name: "answer-correct-symbolic"
- onClicked: waterEvents.waterPlant()
+ onClicked: {
+ applicationWindow().showPassiveNotification("Plant Watered", "short");
+ waterEvents.waterPlant();
+ }
}
}
}
@@ -303,22 +306,23 @@ Kirigami.ScrollablePage {
Controls.Button {
text: i18n("Fertilized")
icon.name: "answer-correct-symbolic"
- onClicked: fertilizerEvents.fertilizePlant()
+ onClicked: {
+ applicationWindow().showPassiveNotification("Plant Fertilized", "short");
+ fertilizerEvents.fertilizePlant();
+ }
}
}
}
}
FormCard.FormHeader {
- title: i18n("Health")
+ title: i18nc("@title:row", "Health")
}
FormCard.FormCard {
FormCard.AbstractFormDelegate {
id: health
-
- background: null
- text: i18n("How healthy is your plant today?")
+ text: i18nc("@label:slider","How healthy is your plant today?")
contentItem: ColumnLayout {
Controls.Label {
@@ -334,15 +338,17 @@ Kirigami.ScrollablePage {
from: 0
to: 100
}
-
Item {
Layout.fillWidth: true
}
Controls.Button {
- text: i18n("Add")
+ text: i18nc("@action:button","Record")
icon.name: "list-add-symbolic"
- onClicked: healthEvents.addHealthEvent(healthSlider.value)
+ onClicked: {
+ applicationWindow().showPassiveNotification("Added Health Entry", "short");
+ healthEvents.addHealthEvent(healthSlider.value);
+ }
}
}
}