diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-07 12:38:18 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-07 12:38:18 +0100 |
| commit | 3d045076d49ee7cc074f670806a823099ea9fb09 (patch) | |
| tree | 32760f1d5075ad14adc67c182f0df883c9a13e53 /desktop/Snack.qml | |
| parent | af008cbd9f5d8d03eff0aa8ac1c7856bb30412e0 (diff) | |
| download | quickshell-3d045076d49ee7cc074f670806a823099ea9fb09.tar.gz quickshell-3d045076d49ee7cc074f670806a823099ea9fb09.zip | |
settings: one snackbar for every page's messages
Save, apply and upload results went to the page header, one line capped
at 420px and cut with an ellipsis. They now go to a snackbar at the foot
of the settings window, wrapped in full: green fades after 6s, yellow and
red stay until dismissed or replaced, and changing page clears it.
Snack.qml is the singleton pages call (ok, wait, error); Snackbar.qml
draws it once in Settings.qml. SaveBar forwards its notice and error, so
the 24 pages using it change nothing; the header keeps only the draft's
state. The boot logo page calls Snack directly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop/Snack.qml')
| -rw-r--r-- | desktop/Snack.qml | 41 |
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 = ""; } +} |
