summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/command_base.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-03-30 18:39:27 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-12 18:19:07 +0300
commit58f2e5f77c2faaf4c2f75767ee8fde67cc0931ac (patch)
tree9f76fbf3ccb1cb17c516f077af08810f11fcb40d /desktop-widgets/command_base.cpp
parent837ab6c90b7952095c0dadf2de18db883b0f5ecf (diff)
downloadsubsurface-58f2e5f77c2faaf4c2f75767ee8fde67cc0931ac.tar.gz
Undo: use QUndoStack::isClean() to determine unsaved changes
Properly implement the unsaved-changes flag(s). Since we currently have two kinds of changes, there are two flags: 1) dive_list_changed in divelist.c marks non-undoable changes. This flag is only cleared on save or load. 2) QUndoStack::isClean() is used to determine the state of undoable changes. Every time the user returns to the state where they saved, this flag is cleared. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/command_base.cpp')
-rw-r--r--desktop-widgets/command_base.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/desktop-widgets/command_base.cpp b/desktop-widgets/command_base.cpp
index 24ce81225..26a587f7c 100644
--- a/desktop-widgets/command_base.cpp
+++ b/desktop-widgets/command_base.cpp
@@ -1,17 +1,33 @@
// SPDX-License-Identifier: GPL-2.0
#include "command_base.h"
+#include "core/qthelper.h" // for updateWindowTitle()
namespace Command {
static QUndoStack undoStack;
// General commands
+void init()
+{
+ QObject::connect(&undoStack, &QUndoStack::cleanChanged, &updateWindowTitle);
+}
+
void clear()
{
undoStack.clear();
}
+void setClean()
+{
+ undoStack.setClean();
+}
+
+bool isClean()
+{
+ return undoStack.isClean();
+}
+
QAction *undoAction(QObject *parent)
{
return undoStack.createUndoAction(parent, QCoreApplication::translate("Command", "&Undo"));