diff options
Diffstat (limited to 'desktop/SaveBar.qml')
| -rw-r--r-- | desktop/SaveBar.qml | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/desktop/SaveBar.qml b/desktop/SaveBar.qml new file mode 100644 index 0000000..aa64868 --- /dev/null +++ b/desktop/SaveBar.qml @@ -0,0 +1,43 @@ +// 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. + +import QtQuick + +// Save and Discard for a settings page that edits a draft: its fields change +// the draft, and nothing reaches the file until Save. Sits in the Page header +// through Page.actions. note says what is wrong when Save is held back. +Row { + id: bar + property bool dirty: false + property bool valid: true + property string note: "" + signal save + signal discard + spacing: 8 + + Text { + anchors.verticalCenter: parent.verticalCenter + visible: bar.dirty + text: !bar.valid ? (bar.note || "fix the fields marked red") : "unsaved changes" + color: bar.valid ? Theme.yellow : Theme.red + font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 } + } + Button { + text: "Discard" + enabled: bar.dirty + onClicked: bar.discard() + } + Button { + text: "Save" + enabled: bar.dirty && bar.valid + onClicked: bar.save() + } +} |
