aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/command_base.cpp
blob: 24ce81225f30d111d766b8c3eec32211db70a8fa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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