mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-11 03:21:29 +00:00
a20c22d907
When a different field is edited, hide any old multi-dive-edit warning message. The reason is that we might want to add an "undo" button to the message. But this will undo the wrong command if we don't hide the message. Sadly, this means that we can't use animated show / hide, because an animatedHide() followed immediately by an animatedShow() does not necessarily show the message. In other words, and animatedShow() does not interupt a started animatedHide()!? Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
56 lines
940 B
C++
56 lines
940 B
C++
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include "command_base.h"
|
|
#include "core/qthelper.h" // for updateWindowTitle()
|
|
#include "core/subsurface-qt/DiveListNotifier.h"
|
|
|
|
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"));
|
|
}
|
|
|
|
QAction *redoAction(QObject *parent)
|
|
{
|
|
return undoStack.createRedoAction(parent, QCoreApplication::translate("Command", "&Redo"));
|
|
}
|
|
|
|
bool execute(Base *cmd)
|
|
{
|
|
if (cmd->workToBeDone()) {
|
|
undoStack.push(cmd);
|
|
emit diveListNotifier.commandExecuted();
|
|
return true;
|
|
} else {
|
|
delete cmd;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
} // namespace Command
|
|
|
|
|