Krita Source Code Documentation
Loading...
Searching...
No Matches
KisUndoActionsUpdateManager.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2018 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
9#include <QAction>
10#include <kundo2stack.h>
11
12#include <KisDocument.h>
13
14
15KisUndoActionsUpdateManager::KisUndoActionsUpdateManager(QAction *undoAction, QAction *redoAction, QObject *parent)
16 : QObject(parent),
17 m_undoAction(undoAction),
18 m_redoAction(redoAction)
19{
20
21}
22
24{
26
27 if (document) {
28
29 KUndo2Stack *stack = document->undoStack();
30
31 m_documentConnections.addConnection(stack, SIGNAL(undoTextChanged(QString)), this, SLOT(slotUndoTextChanged(QString)));
32 m_documentConnections.addConnection(stack, SIGNAL(redoTextChanged(QString)), this, SLOT(slotRedoTextChanged(QString)));
33
36
37 m_undoAction->setEnabled(stack->canUndo());
38 m_redoAction->setEnabled(stack->canRedo());
39 }
40}
41
43{
44 m_undoAction->setText(i18n("Undo %1", text));
45}
46
48{
49 m_redoAction->setText(i18n("Redo %1", text));
50}
51
QString redoText() const
QString undoText() const
bool canUndo() const
bool canRedo() const
void addConnection(Sender sender, Signal signal, Receiver receiver, Method method, Qt::ConnectionType type=Qt::AutoConnection)
void slotRedoTextChanged(const QString &text)
KisSignalAutoConnectionsStore m_documentConnections
void slotUndoTextChanged(const QString &text)
KisUndoActionsUpdateManager(QAction *undoAction, QAction *redoAction, QObject *parent=0)
void setCurrentDocument(KisDocument *document)