aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/Snack.qml
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/Snack.qml')
-rw-r--r--desktop/Snack.qml41
1 files changed, 41 insertions, 0 deletions
diff --git a/desktop/Snack.qml b/desktop/Snack.qml
new file mode 100644
index 0000000..b955ad2
--- /dev/null
+++ b/desktop/Snack.qml
@@ -0,0 +1,41 @@
+// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// 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 General Public License for more details.
+
+pragma Singleton
+
+import Quickshell
+import QtQuick
+
+// The settings window's one message, shown by Snackbar.qml at the foot of the
+// window: what a save, an apply or an upload said. A page calls ok(), wait()
+// or error(); a new message replaces the last. ok() fades by itself, wait()
+// and error() stay until dismissed or replaced. SaveBar forwards its notice
+// and error here, so a page using it needs nothing more.
+Singleton {
+ id: root
+
+ property string text: ""
+ property color color: Theme.green
+ property bool sticky: false
+ // Bumped on every show, so the same text twice restarts the fade.
+ property int serial: 0
+
+ function show(text, color, sticky) {
+ root.text = text;
+ root.color = color;
+ root.sticky = !!sticky;
+ root.serial++;
+ }
+ function ok(text) { root.show(text, Theme.green, false); }
+ function wait(text) { root.show(text, Theme.yellow, true); }
+ function error(text) { root.show(text, Theme.red, true); }
+ function clear() { root.text = ""; }
+}