diff options
Diffstat (limited to 'desktop-widgets/command_base.cpp')
-rw-r--r-- | desktop-widgets/command_base.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/desktop-widgets/command_base.cpp b/desktop-widgets/command_base.cpp new file mode 100644 index 000000000..24ce81225 --- /dev/null +++ b/desktop-widgets/command_base.cpp @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include "command_base.h" + +namespace Command { + +static QUndoStack undoStack; + +// General commands +void clear() +{ + undoStack.clear(); +} + +QAction *undoAction(QObject *parent) +{ + return undoStack.createUndoAction(parent, QCoreApplication::translate("Command", "&Undo")); +} + +QAction *redoAction(QObject *parent) +{ + return undoStack.createRedoAction(parent, QCoreApplication::translate("Command", "&Redo")); +} + +void execute(Base *cmd) +{ + if (cmd->workToBeDone()) + undoStack.push(cmd); + else + delete cmd; +} + +} // namespace Command + + |