File indexing completed on 2024-05-12 16:01:32

0001 /*
0002  *  SPDX-FileCopyrightText: 2014 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "kis_gui_context_command.h"
0008 #include "kis_gui_context_command_p.h"
0009 
0010 
0011 KisGuiContextCommand::KisGuiContextCommand(KUndo2Command *command, QObject *guiObject)
0012     : m_command(command),
0013       m_delegate(new KisGuiContextCommandDelegate(0))
0014 {
0015     /**
0016      * We owe the delegate ourselves, so don't assign a parent to it,
0017      * but just move it to the GUI thread
0018      */
0019     m_delegate->moveToThread(guiObject->thread());
0020 
0021     connect(this, SIGNAL(sigExecuteCommand(KUndo2Command*,bool)),
0022             m_delegate.data(), SLOT(executeCommand(KUndo2Command*,bool)),
0023             Qt::BlockingQueuedConnection);
0024 }
0025 
0026 KisGuiContextCommand::~KisGuiContextCommand()
0027 {
0028 }
0029 
0030 void KisGuiContextCommand::undo()
0031 {
0032     emit sigExecuteCommand(m_command.data(), true);
0033 }
0034 
0035 void KisGuiContextCommand::redo()
0036 {
0037     emit sigExecuteCommand(m_command.data(), false);
0038 }