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 #ifndef __KIS_GUI_CONTEXT_COMMAND_H
0008 #define __KIS_GUI_CONTEXT_COMMAND_H
0009 
0010 #include <QObject>
0011 #include "kundo2command.h"
0012 
0013 class KisGuiContextCommandDelegate;
0014 
0015 /**
0016  * KisGuiContextCommand is a special command-wrapper which ensures
0017  * that the holding command is executed in the GUI thread only. Please
0018  * note that any activity done by the containing command must *not*
0019  * lead to the blocking on the image, otherwise you'll get a deadlock!
0020  */
0021 class KisGuiContextCommand : public QObject, public KUndo2Command
0022 {
0023     Q_OBJECT
0024 public:
0025     KisGuiContextCommand(KUndo2Command *command, QObject *guiObject);
0026     ~KisGuiContextCommand() override;
0027 
0028     void undo() override;
0029     void redo() override;
0030 
0031 Q_SIGNALS:
0032     void sigExecuteCommand(KUndo2Command *command, bool undo);
0033 
0034 private:
0035     QScopedPointer<KUndo2Command> m_command;
0036     QScopedPointer<KisGuiContextCommandDelegate> m_delegate;
0037 };
0038 
0039 #endif /* __KIS_GUI_CONTEXT_COMMAND_H */