diff --git a/3rdparty/3rdparty.pro b/3rdparty/3rdparty.pro index 76f1311f..a12fe5fc 100644 --- a/3rdparty/3rdparty.pro +++ b/3rdparty/3rdparty.pro @@ -1,4 +1,3 @@ TEMPLATE = subdirs SUBDIRS += \ - pickawinner \ - qt-undo + pickawinner diff --git a/3rdparty/qt-undo b/3rdparty/qt-undo deleted file mode 160000 index 2e07c4d2..00000000 --- a/3rdparty/qt-undo +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2e07c4d239158d9e699342361fb10e403cde22fa diff --git a/README.md b/README.md index 50e355bd..cbe6e59f 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,6 @@ See the [releases](https://github.com/mitchcurtis/slate/releases) page for the a ### Dependencies ### * Qt >= 5.11 -* https://github.com/mitchcurtis/qt-undo * https://github.com/mitchcurtis/pickawinner ### Cloning ### @@ -41,7 +40,7 @@ See the [releases](https://github.com/mitchcurtis/slate/releases) page for the a ### Building ### -qt-undo and pickawinner can be cloned and built separately, but they are also available as submodules of Slate's repo, and can therefore be built automatically when +pickawinner can be cloned and built separately, but it is also available as a submodule of Slate's repo, and can therefore be built automatically when Slate is built, by first running the following commands: cd /path/to/slate-source-dir diff --git a/app/addguidecommand.cpp b/app/addguidecommand.cpp index 207cd758..47195495 100644 --- a/app/addguidecommand.cpp +++ b/app/addguidecommand.cpp @@ -25,8 +25,8 @@ Q_LOGGING_CATEGORY(lcAddGuideCommand, "app.undo.addGuideCommand") -AddGuideCommand::AddGuideCommand(Project *project, const Guide &guide, UndoCommand *parent) : - UndoCommand(parent), +AddGuideCommand::AddGuideCommand(Project *project, const Guide &guide, QUndoCommand *parent) : + QUndoCommand(parent), mProject(project), mGuide(guide) { diff --git a/app/addguidecommand.h b/app/addguidecommand.h index f639a655..5c5753d5 100644 --- a/app/addguidecommand.h +++ b/app/addguidecommand.h @@ -21,18 +21,16 @@ #define ADDGUIDECOMMAND_H #include -#include +#include #include "guide.h" class Project; -class AddGuideCommand : public UndoCommand +class AddGuideCommand : public QUndoCommand { - Q_OBJECT - public: - AddGuideCommand(Project *project, const Guide &guide, UndoCommand *parent = nullptr); + AddGuideCommand(Project *project, const Guide &guide, QUndoCommand *parent = nullptr); void undo() override; void redo() override; diff --git a/app/addlayercommand.cpp b/app/addlayercommand.cpp index bce1d7e8..830bd94d 100644 --- a/app/addlayercommand.cpp +++ b/app/addlayercommand.cpp @@ -26,11 +26,12 @@ Q_LOGGING_CATEGORY(lcAddLayerCommand, "app.undo.addLayerCommand") -AddLayerCommand::AddLayerCommand(LayeredImageProject *project, ImageLayer *layer, int index, UndoCommand *parent) : - UndoCommand(parent), +AddLayerCommand::AddLayerCommand(LayeredImageProject *project, ImageLayer *layer, int index, QUndoCommand *parent) : + QUndoCommand(parent), mProject(project), mIndex(index), - mLayer(layer) + mLayer(layer), + mLayerGuard(layer) { qCDebug(lcAddLayerCommand) << "constructed" << this; } @@ -39,14 +40,16 @@ void AddLayerCommand::undo() { qCDebug(lcAddLayerCommand) << "undoing" << this; mProject->takeLayer(mIndex); + // Prevent leaks. - mLayer->setParent(this); + Q_ASSERT(mLayerGuard.isNull()); + mLayerGuard.reset(mLayer); } void AddLayerCommand::redo() { qCDebug(lcAddLayerCommand) << "redoing" << this; - mProject->addLayer(mLayer, mIndex); + mProject->addLayer(mLayerGuard.take(), mIndex); } int AddLayerCommand::id() const diff --git a/app/addlayercommand.h b/app/addlayercommand.h index d25c491f..bd67f259 100644 --- a/app/addlayercommand.h +++ b/app/addlayercommand.h @@ -21,17 +21,16 @@ #define ADDLAYERCOMMAND_H #include -#include +#include +#include class ImageLayer; class LayeredImageProject; -class AddLayerCommand : public UndoCommand +class AddLayerCommand : public QUndoCommand { - Q_OBJECT - public: - AddLayerCommand(LayeredImageProject *project, ImageLayer *layer, int index, UndoCommand *parent = nullptr); + AddLayerCommand(LayeredImageProject *project, ImageLayer *layer, int index, QUndoCommand *parent = nullptr); void undo() override; void redo() override; @@ -44,6 +43,7 @@ class AddLayerCommand : public UndoCommand LayeredImageProject *mProject; int mIndex; ImageLayer *mLayer; + QScopedPointer mLayerGuard; }; diff --git a/app/app.pri b/app/app.pri index ead351dd..82e7ada4 100644 --- a/app/app.pri +++ b/app/app.pri @@ -1,4 +1,4 @@ -QT += widgets qml quick undo +QT += widgets qml quick CONFIG += c++11 INCLUDEPATH += $$PWD diff --git a/app/application.cpp b/app/application.cpp index b92063d1..470cbff1 100644 --- a/app/application.cpp +++ b/app/application.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "canvaspane.h" #include "filevalidator.h" @@ -101,9 +102,13 @@ Application::Application(int &argc, char **argv, const QString &applicationName) qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); + + // For some reason, only when debugging, I get + // QMetaProperty::read: Unable to handle unregistered datatype 'QUndoStack*' for property 'Project_QML_108::undoStack' + // if I don't do this. + qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); - qRegisterMetaType(); if (QFontDatabase::addApplicationFont(":/fonts/FontAwesome.otf") == -1) { qWarning() << "Failed to load FontAwesome font"; diff --git a/app/applygreedypixelfillcommand.cpp b/app/applygreedypixelfillcommand.cpp index 3eba3e78..619fc09d 100644 --- a/app/applygreedypixelfillcommand.cpp +++ b/app/applygreedypixelfillcommand.cpp @@ -27,8 +27,8 @@ Q_LOGGING_CATEGORY(lcApplyGreedyPixelFillCommand, "app.undo.applyGreedyPixelFillCommand") ApplyGreedyPixelFillCommand::ApplyGreedyPixelFillCommand(ImageCanvas *canvas, int layerIndex, const QImage &previousImage, - const QImage &newImage, UndoCommand *parent) : - UndoCommand(parent), + const QImage &newImage, QUndoCommand *parent) : + QUndoCommand(parent), mCanvas(canvas), mLayerIndex(layerIndex), mPreviousImage(previousImage), diff --git a/app/applygreedypixelfillcommand.h b/app/applygreedypixelfillcommand.h index 7186dbfb..e96a422d 100644 --- a/app/applygreedypixelfillcommand.h +++ b/app/applygreedypixelfillcommand.h @@ -22,17 +22,15 @@ #include #include -#include +#include class ImageCanvas; -class ApplyGreedyPixelFillCommand : public UndoCommand +class ApplyGreedyPixelFillCommand : public QUndoCommand { - Q_OBJECT - public: ApplyGreedyPixelFillCommand(ImageCanvas *canvas, int layerIndex,const QImage &previousImage, - const QImage &newImage, UndoCommand *parent = nullptr); + const QImage &newImage, QUndoCommand *parent = nullptr); void undo() override; void redo() override; diff --git a/app/applylayeredimagepixelfillcommand.h b/app/applylayeredimagepixelfillcommand.h index 7637fa3d..52519484 100644 --- a/app/applylayeredimagepixelfillcommand.h +++ b/app/applylayeredimagepixelfillcommand.h @@ -28,8 +28,6 @@ class LayeredImageProject; class ApplyLayeredImagePixelFillCommand : public UndoCommand { - Q_OBJECT - public: ApplyLayeredImagePixelFillCommand(LayeredImageProject *project, const QImage &previousImage, const QImage &newImage, UndoCommand *parent = nullptr); diff --git a/app/applypixelerasercommand.cpp b/app/applypixelerasercommand.cpp index 94448c80..9ea2f50f 100644 --- a/app/applypixelerasercommand.cpp +++ b/app/applypixelerasercommand.cpp @@ -26,8 +26,8 @@ Q_LOGGING_CATEGORY(lcApplyPixelEraserCommand, "app.undo.applyPixelEraserCommand") ApplyPixelEraserCommand::ApplyPixelEraserCommand(ImageCanvas *canvas, int layerIndex, const QVector &scenePositions, - const QVector &previousColours, UndoCommand *parent) : - UndoCommand(parent), + const QVector &previousColours, QUndoCommand *parent) : + QUndoCommand(parent), mCanvas(canvas), mLayerIndex(layerIndex) { @@ -58,9 +58,9 @@ int ApplyPixelEraserCommand::id() const return ApplyPixelEraserCommandId; } -bool ApplyPixelEraserCommand::mergeWith(const UndoCommand *other) +bool ApplyPixelEraserCommand::mergeWith(const QUndoCommand *other) { - const ApplyPixelEraserCommand *otherCommand = qobject_cast(other); + const ApplyPixelEraserCommand *otherCommand = dynamic_cast(other); if (!otherCommand) { return false; } diff --git a/app/applypixelerasercommand.h b/app/applypixelerasercommand.h index da20247a..7c06d016 100644 --- a/app/applypixelerasercommand.h +++ b/app/applypixelerasercommand.h @@ -24,23 +24,21 @@ #include #include #include -#include +#include #include "imagecanvas.h" -class ApplyPixelEraserCommand : public UndoCommand +class ApplyPixelEraserCommand : public QUndoCommand { - Q_OBJECT - public: ApplyPixelEraserCommand(ImageCanvas *canvas, int layerIndex, const QVector &scenePositions, const QVector &previousColours, - UndoCommand *parent = nullptr); + QUndoCommand *parent = nullptr); void undo() override; void redo() override; int id() const override; - bool mergeWith(const UndoCommand *other) override; + bool mergeWith(const QUndoCommand *other) override; private: friend QDebug operator<<(QDebug debug, const ApplyPixelEraserCommand *command); diff --git a/app/applypixelfillcommand.cpp b/app/applypixelfillcommand.cpp index cdf489a1..ecd950e5 100644 --- a/app/applypixelfillcommand.cpp +++ b/app/applypixelfillcommand.cpp @@ -26,8 +26,8 @@ Q_LOGGING_CATEGORY(lcApplyPixelFillCommand, "app.undo.applyPixelFillCommand") ApplyPixelFillCommand::ApplyPixelFillCommand(ImageCanvas *canvas, int layerIndex, - const QImage &previousImage, const QImage &newImage, UndoCommand *parent) : - UndoCommand(parent), + const QImage &previousImage, const QImage &newImage, QUndoCommand *parent) : + QUndoCommand(parent), mCanvas(canvas), mLayerIndex(layerIndex), mPreviousImage(previousImage), diff --git a/app/applypixelfillcommand.h b/app/applypixelfillcommand.h index 3aa49501..ba232967 100644 --- a/app/applypixelfillcommand.h +++ b/app/applypixelfillcommand.h @@ -22,17 +22,15 @@ #include #include -#include +#include class ImageCanvas; -class ApplyPixelFillCommand : public UndoCommand +class ApplyPixelFillCommand : public QUndoCommand { - Q_OBJECT - public: ApplyPixelFillCommand(ImageCanvas *canvas, int layerIndex, const QImage &previousImage, - const QImage &newImage, UndoCommand *parent = nullptr); + const QImage &newImage, QUndoCommand *parent = nullptr); void undo() override; void redo() override; diff --git a/app/applypixellinecommand.cpp b/app/applypixellinecommand.cpp index bb0e1987..20381327 100644 --- a/app/applypixellinecommand.cpp +++ b/app/applypixellinecommand.cpp @@ -27,8 +27,8 @@ Q_LOGGING_CATEGORY(lcApplyPixelLineCommand, "app.undo.applyPixelLineCommand") ApplyPixelLineCommand::ApplyPixelLineCommand(ImageCanvas *canvas, int layerIndex, const QImage &imageWithLine, const QImage &imageWithoutLine, const QRect &lineRect, - const QPoint &newLastPixelPenReleaseScenePos, const QPoint &oldLastPixelPenReleaseScenePos, UndoCommand *parent) : - UndoCommand(parent), + const QPoint &newLastPixelPenReleaseScenePos, const QPoint &oldLastPixelPenReleaseScenePos, QUndoCommand *parent) : + QUndoCommand(parent), mCanvas(canvas), mLayerIndex(layerIndex), mImageWithLine(imageWithLine), @@ -62,7 +62,7 @@ int ApplyPixelLineCommand::id() const return ApplyPixelLineCommandId; } -bool ApplyPixelLineCommand::mergeWith(const UndoCommand *) +bool ApplyPixelLineCommand::mergeWith(const QUndoCommand *) { return false; } diff --git a/app/applypixellinecommand.h b/app/applypixellinecommand.h index b2e44992..7d067073 100644 --- a/app/applypixellinecommand.h +++ b/app/applypixellinecommand.h @@ -22,25 +22,23 @@ #include #include -#include +#include #include "imagecanvas.h" -class ApplyPixelLineCommand : public UndoCommand +class ApplyPixelLineCommand : public QUndoCommand { - Q_OBJECT - public: ApplyPixelLineCommand(ImageCanvas *canvas, int layerIndex, const QImage &imageWithLine, const QImage &imageWithoutLine, const QRect &lineRect, const QPoint &newLastPixelPenReleaseScenePos, - const QPoint &oldLastPixelPenReleaseScenePos, UndoCommand *parent = nullptr); + const QPoint &oldLastPixelPenReleaseScenePos, QUndoCommand *parent = nullptr); ~ApplyPixelLineCommand(); void undo() override; void redo() override; int id() const override; - bool mergeWith(const UndoCommand *other) override; + bool mergeWith(const QUndoCommand *other) override; private: friend QDebug operator<<(QDebug debug, const ApplyPixelLineCommand *command); diff --git a/app/applypixelpencommand.cpp b/app/applypixelpencommand.cpp index 53b3c4c3..bb2d53cf 100644 --- a/app/applypixelpencommand.cpp +++ b/app/applypixelpencommand.cpp @@ -26,8 +26,8 @@ Q_LOGGING_CATEGORY(lcApplyPixelPenCommand, "app.undo.applyPixelPenCommand") ApplyPixelPenCommand::ApplyPixelPenCommand(ImageCanvas *canvas, int layerIndex, const QVector &scenePositions, - const QVector &previousColours, const QColor &colour, UndoCommand *parent) : - UndoCommand(parent), + const QVector &previousColours, const QColor &colour, QUndoCommand *parent) : + QUndoCommand(parent), mCanvas(canvas), mLayerIndex(layerIndex), mColour(colour) @@ -59,9 +59,9 @@ int ApplyPixelPenCommand::id() const return ApplyPixelPenCommandId; } -bool ApplyPixelPenCommand::mergeWith(const UndoCommand *other) +bool ApplyPixelPenCommand::mergeWith(const QUndoCommand *other) { - const ApplyPixelPenCommand *otherCommand = qobject_cast(other); + const ApplyPixelPenCommand *otherCommand = dynamic_cast(other); if (!otherCommand) { return false; } diff --git a/app/applypixelpencommand.h b/app/applypixelpencommand.h index ead820dc..72d54579 100644 --- a/app/applypixelpencommand.h +++ b/app/applypixelpencommand.h @@ -24,23 +24,21 @@ #include #include #include -#include +#include #include "imagecanvas.h" -class ApplyPixelPenCommand : public UndoCommand +class ApplyPixelPenCommand : public QUndoCommand { - Q_OBJECT - public: ApplyPixelPenCommand(ImageCanvas *canvas, int layerIndex, const QVector &scenePositions, const QVector &previousColours, - const QColor &colour, UndoCommand *parent = nullptr); + const QColor &colour, QUndoCommand *parent = nullptr); void undo() override; void redo() override; int id() const override; - bool mergeWith(const UndoCommand *other) override; + bool mergeWith(const QUndoCommand *other) override; private: friend QDebug operator<<(QDebug debug, const ApplyPixelPenCommand *command); diff --git a/app/applytilecanvaspixelfillcommand.cpp b/app/applytilecanvaspixelfillcommand.cpp index 7ab7a065..fc897cad 100644 --- a/app/applytilecanvaspixelfillcommand.cpp +++ b/app/applytilecanvaspixelfillcommand.cpp @@ -27,8 +27,8 @@ Q_LOGGING_CATEGORY(lcApplyTileCanvasPixelFillCommand, "app.undo.applyTileCanvasPixelFillCommand") ApplyTileCanvasPixelFillCommand::ApplyTileCanvasPixelFillCommand(TileCanvas *canvas, const QVector &scenePositions, - const QColor &previousColour, const QColor &colour, UndoCommand *parent) : - UndoCommand(parent), + const QColor &previousColour, const QColor &colour, QUndoCommand *parent) : + QUndoCommand(parent), mCanvas(canvas), mColour(colour) { diff --git a/app/applytilecanvaspixelfillcommand.h b/app/applytilecanvaspixelfillcommand.h index d4639ff3..525b6ecc 100644 --- a/app/applytilecanvaspixelfillcommand.h +++ b/app/applytilecanvaspixelfillcommand.h @@ -23,18 +23,16 @@ #include #include #include +#include #include -#include class TileCanvas; -class ApplyTileCanvasPixelFillCommand : public UndoCommand +class ApplyTileCanvasPixelFillCommand : public QUndoCommand { - Q_OBJECT - public: ApplyTileCanvasPixelFillCommand(TileCanvas *canvas, const QVector &scenePositions, const QColor &previousColour, - const QColor &colour, UndoCommand *parent = nullptr); + const QColor &colour, QUndoCommand *parent = nullptr); void undo() override; void redo() override; diff --git a/app/applytileerasercommand.cpp b/app/applytileerasercommand.cpp index d5ea7348..b223fbf8 100644 --- a/app/applytileerasercommand.cpp +++ b/app/applytileerasercommand.cpp @@ -27,8 +27,8 @@ Q_LOGGING_CATEGORY(lcApplyTileEraserCommand, "app.undo.applyTileEraserCommand") ApplyTileEraserCommand::ApplyTileEraserCommand(TileCanvas *canvas, const QPoint &tilePos, - int previousId, UndoCommand *parent) : - UndoCommand(parent), + int previousId, QUndoCommand *parent) : + QUndoCommand(parent), mCanvas(canvas) { mTilePositions.append(tilePos); @@ -58,9 +58,9 @@ int ApplyTileEraserCommand::id() const return ApplyTileEraserCommandId; } -bool ApplyTileEraserCommand::mergeWith(const UndoCommand *other) +bool ApplyTileEraserCommand::mergeWith(const QUndoCommand *other) { - const ApplyTileEraserCommand *otherCommand = qobject_cast(other); + const ApplyTileEraserCommand *otherCommand = dynamic_cast(other); if (!otherCommand) { return false; } diff --git a/app/applytileerasercommand.h b/app/applytileerasercommand.h index cc9335a9..c5249bd4 100644 --- a/app/applytileerasercommand.h +++ b/app/applytileerasercommand.h @@ -24,23 +24,21 @@ #include #include #include -#include +#include #include "tilecanvas.h" -class ApplyTileEraserCommand : public UndoCommand +class ApplyTileEraserCommand : public QUndoCommand { - Q_OBJECT - public: ApplyTileEraserCommand(TileCanvas *canvas, const QPoint &tilePos, int previousId, - UndoCommand *parent = nullptr); + QUndoCommand *parent = nullptr); void undo() override; void redo() override; int id() const override; - bool mergeWith(const UndoCommand *other) override; + bool mergeWith(const QUndoCommand *other) override; private: friend QDebug operator<<(QDebug debug, const ApplyTileEraserCommand *command); diff --git a/app/applytilefillcommand.cpp b/app/applytilefillcommand.cpp index 4875c990..fd136d6e 100644 --- a/app/applytilefillcommand.cpp +++ b/app/applytilefillcommand.cpp @@ -26,8 +26,8 @@ Q_LOGGING_CATEGORY(lcApplyTileFillCommand, "app.undo.applyTileFillCommand") ApplyTileFillCommand::ApplyTileFillCommand(TileCanvas *canvas, const QVector &tilePositions, - int previousTile, int tile, UndoCommand *parent) : - UndoCommand(parent), + int previousTile, int tile, QUndoCommand *parent) : + QUndoCommand(parent), mCanvas(canvas), mPreviousTile(previousTile), mTile(tile) @@ -59,7 +59,7 @@ int ApplyTileFillCommand::id() const return ApplyTileFillCommandId; } -bool ApplyTileFillCommand::mergeWith(const UndoCommand *) +bool ApplyTileFillCommand::mergeWith(const QUndoCommand *) { return false; } diff --git a/app/applytilefillcommand.h b/app/applytilefillcommand.h index b066cc1c..73718f87 100644 --- a/app/applytilefillcommand.h +++ b/app/applytilefillcommand.h @@ -24,23 +24,21 @@ #include #include #include -#include +#include #include "tilecanvas.h" -class ApplyTileFillCommand : public UndoCommand +class ApplyTileFillCommand : public QUndoCommand { - Q_OBJECT - public: ApplyTileFillCommand(TileCanvas *canvas, const QVector &tilePositions, int previousTile, - int tile, UndoCommand *parent = nullptr); + int tile, QUndoCommand *parent = nullptr); void undo() override; void redo() override; int id() const override; - bool mergeWith(const UndoCommand *other) override; + bool mergeWith(const QUndoCommand *other) override; private: friend QDebug operator<<(QDebug debug, const ApplyTileFillCommand *command); diff --git a/app/applytilepencommand.cpp b/app/applytilepencommand.cpp index 2d6e403c..8f40ceab 100644 --- a/app/applytilepencommand.cpp +++ b/app/applytilepencommand.cpp @@ -26,8 +26,8 @@ Q_LOGGING_CATEGORY(lcApplyTilePenCommand, "app.undo.applyTilePenCommand") ApplyTilePenCommand::ApplyTilePenCommand(TileCanvas *canvas, const QPoint &tilePos, - int previousId, int id, UndoCommand *parent) : - UndoCommand(parent), + int previousId, int id, QUndoCommand *parent) : + QUndoCommand(parent), mCanvas(canvas), mId(id) { @@ -58,9 +58,9 @@ int ApplyTilePenCommand::id() const return ApplyTilePenCommandId; } -bool ApplyTilePenCommand::mergeWith(const UndoCommand *other) +bool ApplyTilePenCommand::mergeWith(const QUndoCommand *other) { - const ApplyTilePenCommand *otherCommand = qobject_cast(other); + const ApplyTilePenCommand *otherCommand = dynamic_cast(other); if (!otherCommand) { return false; } diff --git a/app/applytilepencommand.h b/app/applytilepencommand.h index 4c93ac52..b404caa5 100644 --- a/app/applytilepencommand.h +++ b/app/applytilepencommand.h @@ -24,23 +24,21 @@ #include #include #include -#include +#include #include "tilecanvas.h" -class ApplyTilePenCommand : public UndoCommand +class ApplyTilePenCommand : public QUndoCommand { - Q_OBJECT - public: ApplyTilePenCommand(TileCanvas *canvas, const QPoint &tilePos, int previousId, - int id, UndoCommand *parent = nullptr); + int id, QUndoCommand *parent = nullptr); void undo() override; void redo() override; int id() const override; - bool mergeWith(const UndoCommand *other) override; + bool mergeWith(const QUndoCommand *other) override; private: friend QDebug operator<<(QDebug debug, const ApplyTilePenCommand *command); diff --git a/app/changeimagecanvassizecommand.cpp b/app/changeimagecanvassizecommand.cpp index ba31750d..51a41dfc 100644 --- a/app/changeimagecanvassizecommand.cpp +++ b/app/changeimagecanvassizecommand.cpp @@ -26,8 +26,8 @@ Q_LOGGING_CATEGORY(lcChangeImageCanvasSizeCommand, "app.undo.changeImageCanvasSizeCommand") ChangeImageCanvasSizeCommand::ChangeImageCanvasSizeCommand(ImageProject *project, const QImage &previousImage, - const QImage &newImage, UndoCommand *parent) : - UndoCommand(parent), + const QImage &newImage, QUndoCommand *parent) : + QUndoCommand(parent), mProject(project), mPreviousImage(previousImage), mNewImage(newImage) diff --git a/app/changeimagecanvassizecommand.h b/app/changeimagecanvassizecommand.h index 852d1e7a..601a3d41 100644 --- a/app/changeimagecanvassizecommand.h +++ b/app/changeimagecanvassizecommand.h @@ -22,17 +22,15 @@ #include #include -#include +#include class ImageProject; -class ChangeImageCanvasSizeCommand : public UndoCommand +class ChangeImageCanvasSizeCommand : public QUndoCommand { - Q_OBJECT - public: ChangeImageCanvasSizeCommand(ImageProject *project, const QImage &previousImage, const QImage &newImage, - UndoCommand *parent = nullptr); + QUndoCommand *parent = nullptr); void undo() override; void redo() override; diff --git a/app/changeimagesizecommand.cpp b/app/changeimagesizecommand.cpp index 3bd3dd14..0f038f58 100644 --- a/app/changeimagesizecommand.cpp +++ b/app/changeimagesizecommand.cpp @@ -26,8 +26,8 @@ Q_LOGGING_CATEGORY(lcChangeImageSizeCommand, "app.undo.ChangeImageSizeCommand") ChangeImageSizeCommand::ChangeImageSizeCommand(ImageProject *project, const QImage &previousImage, - const QImage &newImage, UndoCommand *parent) : - UndoCommand(parent), + const QImage &newImage, QUndoCommand *parent) : + QUndoCommand(parent), mProject(project), mPreviousImage(previousImage), mNewImage(newImage) diff --git a/app/changeimagesizecommand.h b/app/changeimagesizecommand.h index cd57a6de..5485830b 100644 --- a/app/changeimagesizecommand.h +++ b/app/changeimagesizecommand.h @@ -22,17 +22,15 @@ #include #include -#include +#include class ImageProject; -class ChangeImageSizeCommand : public UndoCommand +class ChangeImageSizeCommand : public QUndoCommand { - Q_OBJECT - public: ChangeImageSizeCommand(ImageProject *project, const QImage &previousImage, const QImage &newImage, - UndoCommand *parent = nullptr); + QUndoCommand *parent = nullptr); void undo() override; void redo() override; diff --git a/app/changelayeredimagecanvassizecommand.cpp b/app/changelayeredimagecanvassizecommand.cpp index 071497d7..f6769bc5 100644 --- a/app/changelayeredimagecanvassizecommand.cpp +++ b/app/changelayeredimagecanvassizecommand.cpp @@ -26,8 +26,8 @@ Q_LOGGING_CATEGORY(lcChangeLayeredImageCanvasSizeCommand, "app.undo.changeLayeredImageCanvasSizeCommand") ChangeLayeredImageCanvasSizeCommand::ChangeLayeredImageCanvasSizeCommand(LayeredImageProject *project, - const QVector &previousImages, const QVector &newImages, UndoCommand *parent) : - UndoCommand(parent), + const QVector &previousImages, const QVector &newImages, QUndoCommand *parent) : + QUndoCommand(parent), mProject(project), mPreviousImages(previousImages), mNewImages(newImages) diff --git a/app/changelayeredimagecanvassizecommand.h b/app/changelayeredimagecanvassizecommand.h index 39245ef0..651b1ec9 100644 --- a/app/changelayeredimagecanvassizecommand.h +++ b/app/changelayeredimagecanvassizecommand.h @@ -22,18 +22,16 @@ #include #include -#include +#include #include class LayeredImageProject; -class ChangeLayeredImageCanvasSizeCommand : public UndoCommand +class ChangeLayeredImageCanvasSizeCommand : public QUndoCommand { - Q_OBJECT - public: ChangeLayeredImageCanvasSizeCommand(LayeredImageProject *project, const QVector &previousImages, - const QVector &newImages, UndoCommand *parent = nullptr); + const QVector &newImages, QUndoCommand *parent = nullptr); void undo() override; void redo() override; diff --git a/app/changelayeredimagesizecommand.cpp b/app/changelayeredimagesizecommand.cpp index 75aeedf6..a2b0bc06 100644 --- a/app/changelayeredimagesizecommand.cpp +++ b/app/changelayeredimagesizecommand.cpp @@ -26,8 +26,8 @@ Q_LOGGING_CATEGORY(lcChangeLayeredImageSizeCommand, "app.undo.changeLayeredImageSizeCommand") ChangeLayeredImageSizeCommand::ChangeLayeredImageSizeCommand(LayeredImageProject *project, - const QVector &previousImages, const QVector &newImages, UndoCommand *parent) : - UndoCommand(parent), + const QVector &previousImages, const QVector &newImages, QUndoCommand *parent) : + QUndoCommand(parent), mProject(project), mPreviousImages(previousImages), mNewImages(newImages) diff --git a/app/changelayeredimagesizecommand.h b/app/changelayeredimagesizecommand.h index cc729696..808d3949 100644 --- a/app/changelayeredimagesizecommand.h +++ b/app/changelayeredimagesizecommand.h @@ -22,18 +22,16 @@ #include #include -#include +#include #include class LayeredImageProject; -class ChangeLayeredImageSizeCommand : public UndoCommand +class ChangeLayeredImageSizeCommand : public QUndoCommand { - Q_OBJECT - public: ChangeLayeredImageSizeCommand(LayeredImageProject *project, const QVector &previousImages, - const QVector &newImages, UndoCommand *parent = nullptr); + const QVector &newImages, QUndoCommand *parent = nullptr); void undo() override; void redo() override; diff --git a/app/changelayernamecommand.cpp b/app/changelayernamecommand.cpp index dd405130..3935a399 100644 --- a/app/changelayernamecommand.cpp +++ b/app/changelayernamecommand.cpp @@ -27,8 +27,8 @@ Q_LOGGING_CATEGORY(lcChangeLayerNameCommand, "app.undo.changeLayerNameCommand") ChangeLayerNameCommand::ChangeLayerNameCommand(LayeredImageProject *project, int layerIndex, const QString &previousName, - const QString &newName, UndoCommand *parent) : - UndoCommand(parent), + const QString &newName, QUndoCommand *parent) : + QUndoCommand(parent), mProject(project), mLayerIndex(layerIndex), mPreviousName(previousName), diff --git a/app/changelayernamecommand.h b/app/changelayernamecommand.h index 7de7a271..cc868606 100644 --- a/app/changelayernamecommand.h +++ b/app/changelayernamecommand.h @@ -21,17 +21,15 @@ #define CHANGELAYERNAMECOMMAND_H #include -#include +#include class LayeredImageProject; -class ChangeLayerNameCommand : public UndoCommand +class ChangeLayerNameCommand : public QUndoCommand { - Q_OBJECT - public: ChangeLayerNameCommand(LayeredImageProject *project, int layerIndex, const QString &previousName, - const QString &newName, UndoCommand *parent = nullptr); + const QString &newName, QUndoCommand *parent = nullptr); void undo() override; void redo() override; diff --git a/app/changelayeropacitycommand.cpp b/app/changelayeropacitycommand.cpp index c1f0fc0f..9610fb98 100644 --- a/app/changelayeropacitycommand.cpp +++ b/app/changelayeropacitycommand.cpp @@ -27,8 +27,8 @@ Q_LOGGING_CATEGORY(lcChangeLayerOpacityCommand, "app.undo.changeLayerOpacityCommand") ChangeLayerOpacityCommand::ChangeLayerOpacityCommand(LayeredImageProject *project, int layerIndex, qreal previousOpacity, - qreal newOpacity, UndoCommand *parent) : - UndoCommand(parent), + qreal newOpacity, QUndoCommand *parent) : + QUndoCommand(parent), mProject(project), mLayerIndex(layerIndex), mPreviousOpacity(previousOpacity), diff --git a/app/changelayeropacitycommand.h b/app/changelayeropacitycommand.h index d456daf6..f6549384 100644 --- a/app/changelayeropacitycommand.h +++ b/app/changelayeropacitycommand.h @@ -21,17 +21,15 @@ #define CHANGELAYEROPACITYCOMMAND_H #include -#include +#include class LayeredImageProject; -class ChangeLayerOpacityCommand : public UndoCommand +class ChangeLayerOpacityCommand : public QUndoCommand { - Q_OBJECT - public: ChangeLayerOpacityCommand(LayeredImageProject *project, int layerIndex, qreal previousOpacity, - qreal newOpacity, UndoCommand *parent = nullptr); + qreal newOpacity, QUndoCommand *parent = nullptr); void undo() override; void redo() override; diff --git a/app/changelayerordercommand.cpp b/app/changelayerordercommand.cpp index 367f5373..fe093b41 100644 --- a/app/changelayerordercommand.cpp +++ b/app/changelayerordercommand.cpp @@ -26,8 +26,8 @@ Q_LOGGING_CATEGORY(lcChangeLayerOrderCommand, "app.undo.changeLayerOrderCommand") ChangeLayerOrderCommand::ChangeLayerOrderCommand(LayeredImageProject *project, int previousIndex, int newIndex, - UndoCommand *parent) : - UndoCommand(parent), + QUndoCommand *parent) : + QUndoCommand(parent), mProject(project), mPreviousIndex(previousIndex), mNewIndex(newIndex) diff --git a/app/changelayerordercommand.h b/app/changelayerordercommand.h index e9b55702..53e73b99 100644 --- a/app/changelayerordercommand.h +++ b/app/changelayerordercommand.h @@ -22,18 +22,16 @@ #include #include +#include #include -#include class LayeredImageProject; -class ChangeLayerOrderCommand : public UndoCommand +class ChangeLayerOrderCommand : public QUndoCommand { - Q_OBJECT - public: ChangeLayerOrderCommand(LayeredImageProject *project, int previousIndex, int newIndex, - UndoCommand *parent = nullptr); + QUndoCommand *parent = nullptr); void undo() override; void redo() override; diff --git a/app/changelayervisiblecommand.cpp b/app/changelayervisiblecommand.cpp index 7589dd8c..1fbc4dc8 100644 --- a/app/changelayervisiblecommand.cpp +++ b/app/changelayervisiblecommand.cpp @@ -27,8 +27,8 @@ Q_LOGGING_CATEGORY(lcChangeLayerVisibleCommand, "app.undo.changeLayerVisibleCommand") ChangeLayerVisibleCommand::ChangeLayerVisibleCommand(LayeredImageProject *project, int layerIndex, bool previousVisible, - bool newVisible, UndoCommand *parent) : - UndoCommand(parent), + bool newVisible, QUndoCommand *parent) : + QUndoCommand(parent), mProject(project), mLayerIndex(layerIndex), mPreviousVisible(previousVisible), diff --git a/app/changelayervisiblecommand.h b/app/changelayervisiblecommand.h index 012e3dde..6a71acce 100644 --- a/app/changelayervisiblecommand.h +++ b/app/changelayervisiblecommand.h @@ -21,17 +21,15 @@ #define CHANGELAYERVISIBLECOMMAND_H #include -#include +#include class LayeredImageProject; -class ChangeLayerVisibleCommand : public UndoCommand +class ChangeLayerVisibleCommand : public QUndoCommand { - Q_OBJECT - public: ChangeLayerVisibleCommand(LayeredImageProject *project, int layerIndex, bool previousVisible, - bool newVisible, UndoCommand *parent = nullptr); + bool newVisible, QUndoCommand *parent = nullptr); void undo() override; void redo() override; diff --git a/app/changetilecanvassizecommand.cpp b/app/changetilecanvassizecommand.cpp index 367a1fdd..77a8f44b 100644 --- a/app/changetilecanvassizecommand.cpp +++ b/app/changetilecanvassizecommand.cpp @@ -26,8 +26,8 @@ Q_LOGGING_CATEGORY(lcChangeTileCanvasSizeCommand, "app.undo.changeTileCanvasSizeCommand") ChangeTileCanvasSizeCommand::ChangeTileCanvasSizeCommand(TilesetProject *project, const QSize &previousSize, - const QSize &size, UndoCommand *parent) : - UndoCommand(parent), + const QSize &size, QUndoCommand *parent) : + QUndoCommand(parent), mProject(project), mPreviousSize(previousSize), mSize(size) diff --git a/app/changetilecanvassizecommand.h b/app/changetilecanvassizecommand.h index 3472cdbc..eb2c3504 100644 --- a/app/changetilecanvassizecommand.h +++ b/app/changetilecanvassizecommand.h @@ -23,17 +23,15 @@ #include #include #include -#include +#include class TilesetProject; -class ChangeTileCanvasSizeCommand : public UndoCommand +class ChangeTileCanvasSizeCommand : public QUndoCommand { - Q_OBJECT - public: ChangeTileCanvasSizeCommand(TilesetProject *project, const QSize &previousSize, const QSize &size, - UndoCommand *parent = nullptr); + QUndoCommand *parent = nullptr); void undo() override; void redo() override; diff --git a/app/deleteguidecommand.cpp b/app/deleteguidecommand.cpp index 45b0058e..1138a17c 100644 --- a/app/deleteguidecommand.cpp +++ b/app/deleteguidecommand.cpp @@ -25,8 +25,8 @@ Q_LOGGING_CATEGORY(lcDeleteGuideCommand, "app.undo.deleteGuideCommand") -DeleteGuideCommand::DeleteGuideCommand(Project *project, const Guide &guide, UndoCommand *parent) : - UndoCommand(parent), +DeleteGuideCommand::DeleteGuideCommand(Project *project, const Guide &guide, QUndoCommand *parent) : + QUndoCommand(parent), mProject(project), mGuide(guide) { diff --git a/app/deleteguidecommand.h b/app/deleteguidecommand.h index 1b90f4b7..f1fac2a5 100644 --- a/app/deleteguidecommand.h +++ b/app/deleteguidecommand.h @@ -21,18 +21,16 @@ #define DELETEGUIDECOMMAND_H #include -#include +#include #include "guide.h" class Project; -class DeleteGuideCommand : public UndoCommand +class DeleteGuideCommand : public QUndoCommand { - Q_OBJECT - public: - DeleteGuideCommand(Project *project, const Guide &guide, UndoCommand *parent = nullptr); + DeleteGuideCommand(Project *project, const Guide &guide, QUndoCommand *parent = nullptr); void undo() override; void redo() override; diff --git a/app/deleteimagecanvasselectioncommand.cpp b/app/deleteimagecanvasselectioncommand.cpp index 5db65b00..7c4bd04a 100644 --- a/app/deleteimagecanvasselectioncommand.cpp +++ b/app/deleteimagecanvasselectioncommand.cpp @@ -24,8 +24,8 @@ Q_LOGGING_CATEGORY(lcDeleteImageCanvasSelectionCommand, "app.undo.deleteImageCanvasSelectionCommand") -DeleteImageCanvasSelectionCommand::DeleteImageCanvasSelectionCommand(ImageCanvas *canvas, const QRect &area, UndoCommand *parent) : - UndoCommand(parent), +DeleteImageCanvasSelectionCommand::DeleteImageCanvasSelectionCommand(ImageCanvas *canvas, const QRect &area, QUndoCommand *parent) : + QUndoCommand(parent), mCanvas(canvas), mDeletedArea(area), mDeletedAreaImagePortion(canvas->currentProjectImage()->copy(area)) diff --git a/app/deleteimagecanvasselectioncommand.h b/app/deleteimagecanvasselectioncommand.h index 3ddf746d..eec83dd9 100644 --- a/app/deleteimagecanvasselectioncommand.h +++ b/app/deleteimagecanvasselectioncommand.h @@ -23,17 +23,15 @@ #include #include #include -#include +#include class ImageCanvas; -class DeleteImageCanvasSelectionCommand : public UndoCommand +class DeleteImageCanvasSelectionCommand : public QUndoCommand { - Q_OBJECT - public: DeleteImageCanvasSelectionCommand(ImageCanvas *canvas, const QRect &area, - UndoCommand *parent = nullptr); + QUndoCommand *parent = nullptr); void undo() override; void redo() override; diff --git a/app/deletelayercommand.cpp b/app/deletelayercommand.cpp index d84ac0ef..9e9a2262 100644 --- a/app/deletelayercommand.cpp +++ b/app/deletelayercommand.cpp @@ -26,8 +26,8 @@ Q_LOGGING_CATEGORY(lcDeleteLayerCommand, "app.undo.deleteLayerCommand") -DeleteLayerCommand::DeleteLayerCommand(LayeredImageProject *project, int index, UndoCommand *parent) : - UndoCommand(parent), +DeleteLayerCommand::DeleteLayerCommand(LayeredImageProject *project, int index, QUndoCommand *parent) : + QUndoCommand(parent), mProject(project), mIndex(index), mLayer(project->layerAt(index)) @@ -38,7 +38,7 @@ DeleteLayerCommand::DeleteLayerCommand(LayeredImageProject *project, int index, void DeleteLayerCommand::undo() { qCDebug(lcDeleteLayerCommand) << "undoing" << this; - mProject->addLayer(mLayer, mIndex); + mProject->addLayer(mLayerGuard.take(), mIndex); // If it was deleted, it was also current, as layers can't be deleted without being current. mProject->setCurrentLayerIndex(mIndex); } @@ -48,7 +48,7 @@ void DeleteLayerCommand::redo() qCDebug(lcDeleteLayerCommand) << "redoing" << this; mProject->takeLayer(mIndex); // Prevent leaks. - mLayer->setParent(this); + mLayerGuard.reset(mLayer); } int DeleteLayerCommand::id() const diff --git a/app/deletelayercommand.h b/app/deletelayercommand.h index 18755888..23f7f984 100644 --- a/app/deletelayercommand.h +++ b/app/deletelayercommand.h @@ -21,17 +21,16 @@ #define DELETELAYERCOMMAND_H #include -#include +#include +#include class ImageLayer; class LayeredImageProject; -class DeleteLayerCommand : public UndoCommand +class DeleteLayerCommand : public QUndoCommand { - Q_OBJECT - public: - DeleteLayerCommand(LayeredImageProject *project, int index, UndoCommand *parent = nullptr); + DeleteLayerCommand(LayeredImageProject *project, int index, QUndoCommand *parent = nullptr); void undo() override; void redo() override; @@ -44,6 +43,7 @@ class DeleteLayerCommand : public UndoCommand LayeredImageProject *mProject; int mIndex; ImageLayer *mLayer; + QScopedPointer mLayerGuard; }; diff --git a/app/flipimagecanvasselectioncommand.cpp b/app/flipimagecanvasselectioncommand.cpp index 45b13c04..a38395ae 100644 --- a/app/flipimagecanvasselectioncommand.cpp +++ b/app/flipimagecanvasselectioncommand.cpp @@ -24,8 +24,8 @@ Q_LOGGING_CATEGORY(lcFlipImageCanvasSelectionCommand, "app.undo.flipImageCanvasSelectionCommand") FlipImageCanvasSelectionCommand::FlipImageCanvasSelectionCommand(ImageCanvas *canvas, - const QRect &area, Qt::Orientation orientation, UndoCommand *parent) : - UndoCommand(parent), + const QRect &area, Qt::Orientation orientation, QUndoCommand *parent) : + QUndoCommand(parent), mCanvas(canvas), mOrientation(orientation), mArea(area) diff --git a/app/flipimagecanvasselectioncommand.h b/app/flipimagecanvasselectioncommand.h index c04b999d..59e3072f 100644 --- a/app/flipimagecanvasselectioncommand.h +++ b/app/flipimagecanvasselectioncommand.h @@ -22,17 +22,15 @@ #include #include -#include +#include class ImageCanvas; -class FlipImageCanvasSelectionCommand : public UndoCommand +class FlipImageCanvasSelectionCommand : public QUndoCommand { - Q_OBJECT - public: FlipImageCanvasSelectionCommand(ImageCanvas *canvas, const QRect &area, - Qt::Orientation orientation, UndoCommand *parent = nullptr); + Qt::Orientation orientation, QUndoCommand *parent = nullptr); void undo() override; void redo() override; diff --git a/app/imagecanvas.h b/app/imagecanvas.h index c934b314..d47ea4a4 100644 --- a/app/imagecanvas.h +++ b/app/imagecanvas.h @@ -25,10 +25,9 @@ #include #include #include +#include #include -#include - #include "canvaspane.h" #include "ruler.h" #include "splitter.h" diff --git a/app/layeredimagecanvas.h b/app/layeredimagecanvas.h index 423fe4a4..38f9b7a8 100644 --- a/app/layeredimagecanvas.h +++ b/app/layeredimagecanvas.h @@ -20,8 +20,6 @@ #ifndef LAYEREDIMAGECANVAS_H #define LAYEREDIMAGECANVAS_H -#include - #include "imagecanvas.h" class LayeredImageProject; diff --git a/app/mergelayerscommand.cpp b/app/mergelayerscommand.cpp index 9fc7b5a1..f548560a 100644 --- a/app/mergelayerscommand.cpp +++ b/app/mergelayerscommand.cpp @@ -28,8 +28,8 @@ Q_LOGGING_CATEGORY(lcMergeLayersCommand, "app.undo.mergeLayersCommand") MergeLayersCommand::MergeLayersCommand(LayeredImageProject *project, int sourceIndex, ImageLayer *sourceLayer, int targetIndex, ImageLayer *targetLayer, - UndoCommand *parent) : - UndoCommand(parent), + QUndoCommand *parent) : + QUndoCommand(parent), mProject(project), mSourceIndex(sourceIndex), mSourceLayer(sourceLayer), @@ -44,7 +44,7 @@ void MergeLayersCommand::undo() { qCDebug(lcMergeLayersCommand) << "undoing" << this; // Restore the source layer.. - mProject->addLayer(mSourceLayer, mSourceIndex); + mProject->addLayer(mSourceLayerGuard.take(), mSourceIndex); // .. and then restore the target layer. mProject->setLayerImage(mTargetIndex, mPreviousTargetLayerImage); } @@ -53,8 +53,8 @@ void MergeLayersCommand::redo() { qCDebug(lcMergeLayersCommand) << "redoing" << this; mProject->mergeLayers(mSourceIndex, mTargetIndex); - // The source layer loses its QObject parent, so parent it to us to prevent leaks. - mSourceLayer->setParent(this); + // The source layer loses its QObject parent, so manage it to prevent leaks. + mSourceLayerGuard.reset(mSourceLayer); } int MergeLayersCommand::id() const diff --git a/app/mergelayerscommand.h b/app/mergelayerscommand.h index 0147c22b..82d335ef 100644 --- a/app/mergelayerscommand.h +++ b/app/mergelayerscommand.h @@ -22,19 +22,18 @@ #include #include -#include +#include +#include class ImageLayer; class LayeredImageProject; -class MergeLayersCommand : public UndoCommand +class MergeLayersCommand : public QUndoCommand { - Q_OBJECT - public: MergeLayersCommand(LayeredImageProject *project, int sourceIndex, ImageLayer *sourceLayer, - int targetIndex, ImageLayer *targetLayer, UndoCommand *parent = nullptr); + int targetIndex, ImageLayer *targetLayer, QUndoCommand *parent = nullptr); void undo() override; void redo() override; @@ -47,6 +46,7 @@ class MergeLayersCommand : public UndoCommand LayeredImageProject *mProject; int mSourceIndex; ImageLayer *mSourceLayer; + QScopedPointer mSourceLayerGuard; int mTargetIndex; ImageLayer *mTargetLayer; QImage mPreviousTargetLayerImage; diff --git a/app/moveguidecommand.cpp b/app/moveguidecommand.cpp index 727a93df..6ae61b3d 100644 --- a/app/moveguidecommand.cpp +++ b/app/moveguidecommand.cpp @@ -25,8 +25,8 @@ Q_LOGGING_CATEGORY(lcMoveGuideCommand, "app.undo.moveGuideCommand") -MoveGuideCommand::MoveGuideCommand(Project *project, const Guide &guide, int newPosition, UndoCommand *parent) : - UndoCommand(parent), +MoveGuideCommand::MoveGuideCommand(Project *project, const Guide &guide, int newPosition, QUndoCommand *parent) : + QUndoCommand(parent), mProject(project), mGuide(guide), mPreviousPosition(guide.position()), diff --git a/app/moveguidecommand.h b/app/moveguidecommand.h index 9e48abfb..e079a054 100644 --- a/app/moveguidecommand.h +++ b/app/moveguidecommand.h @@ -21,18 +21,16 @@ #define MOVEGUIDECOMMAND_H #include -#include +#include #include "guide.h" class Project; -class MoveGuideCommand : public UndoCommand +class MoveGuideCommand : public QUndoCommand { - Q_OBJECT - public: - MoveGuideCommand(Project *project, const Guide &guide, int newPosition, UndoCommand *parent = nullptr); + MoveGuideCommand(Project *project, const Guide &guide, int newPosition, QUndoCommand *parent = nullptr); void undo() override; void redo() override; diff --git a/app/moveimagecanvasselectioncommand.cpp b/app/moveimagecanvasselectioncommand.cpp index b497b587..5e589c83 100644 --- a/app/moveimagecanvasselectioncommand.cpp +++ b/app/moveimagecanvasselectioncommand.cpp @@ -26,8 +26,8 @@ Q_LOGGING_CATEGORY(lcMoveImageCanvasSelectionCommand, "app.undo.moveImageCanvasS MoveImageCanvasSelectionCommand::MoveImageCanvasSelectionCommand(ImageCanvas *canvas, const QRect &previousArea, const QImage &previousAreaImagePortion, - const QRect &newArea, bool fromPaste, const QImage &pasteContents, UndoCommand *parent) : - UndoCommand(parent), + const QRect &newArea, bool fromPaste, const QImage &pasteContents, QUndoCommand *parent) : + QUndoCommand(parent), mCanvas(canvas), mPreviousArea(previousArea), mPreviousAreaImagePortion(previousAreaImagePortion), diff --git a/app/moveimagecanvasselectioncommand.h b/app/moveimagecanvasselectioncommand.h index a6ebd237..e5f76279 100644 --- a/app/moveimagecanvasselectioncommand.h +++ b/app/moveimagecanvasselectioncommand.h @@ -23,18 +23,16 @@ #include #include #include -#include +#include class ImageCanvas; -class MoveImageCanvasSelectionCommand : public UndoCommand +class MoveImageCanvasSelectionCommand : public QUndoCommand { - Q_OBJECT - public: MoveImageCanvasSelectionCommand(ImageCanvas *canvas, const QRect &previousArea, const QImage &previousAreaImagePortion, const QRect &newArea, - bool fromPaste, const QImage &pasteContents, UndoCommand *parent = nullptr); + bool fromPaste, const QImage &pasteContents, QUndoCommand *parent = nullptr); void undo() override; void redo() override; diff --git a/app/movelayeredimagecontentscommand.cpp b/app/movelayeredimagecontentscommand.cpp index dbf5a997..524e8e05 100644 --- a/app/movelayeredimagecontentscommand.cpp +++ b/app/movelayeredimagecontentscommand.cpp @@ -26,8 +26,8 @@ Q_LOGGING_CATEGORY(lcMoveLayeredImageContentsCommand, "app.undo.moveLayeredImageContentsCommand") MoveLayeredImageContentsCommand::MoveLayeredImageContentsCommand(LayeredImageProject *project, - const QVector &previousImages, const QVector &newImages, UndoCommand *parent) : - UndoCommand(parent), + const QVector &previousImages, const QVector &newImages, QUndoCommand *parent) : + QUndoCommand(parent), mProject(project), mPreviousImages(previousImages), mNewImages(newImages) diff --git a/app/movelayeredimagecontentscommand.h b/app/movelayeredimagecontentscommand.h index d69360e6..0d5da3fc 100644 --- a/app/movelayeredimagecontentscommand.h +++ b/app/movelayeredimagecontentscommand.h @@ -22,18 +22,16 @@ #include #include -#include +#include #include class LayeredImageProject; -class MoveLayeredImageContentsCommand : public UndoCommand +class MoveLayeredImageContentsCommand : public QUndoCommand { - Q_OBJECT - public: MoveLayeredImageContentsCommand(LayeredImageProject *project, const QVector &previousImages, - const QVector &newImages, UndoCommand *parent = nullptr); + const QVector &newImages, QUndoCommand *parent = nullptr); void undo() override; void redo() override; diff --git a/app/pasteimagecanvascommand.cpp b/app/pasteimagecanvascommand.cpp index bda75d2e..68840786 100644 --- a/app/pasteimagecanvascommand.cpp +++ b/app/pasteimagecanvascommand.cpp @@ -25,8 +25,8 @@ Q_LOGGING_CATEGORY(lcPasteImageCanvasCommand, "app.undo.pasteImageCanvasCommand") PasteImageCanvasCommand::PasteImageCanvasCommand(ImageCanvas *canvas, const QImage &image, - const QPoint &position, UndoCommand *parent) : - UndoCommand(parent), + const QPoint &position, QUndoCommand *parent) : + QUndoCommand(parent), mCanvas(canvas), mNewImage(image), mPreviousImage(canvas->currentProjectImage()->copy(QRect(position, image.size()))), diff --git a/app/pasteimagecanvascommand.h b/app/pasteimagecanvascommand.h index efd86a3e..14fcc081 100644 --- a/app/pasteimagecanvascommand.h +++ b/app/pasteimagecanvascommand.h @@ -23,17 +23,15 @@ #include #include #include -#include +#include class ImageCanvas; -class PasteImageCanvasCommand : public UndoCommand +class PasteImageCanvasCommand : public QUndoCommand { - Q_OBJECT - public: PasteImageCanvasCommand(ImageCanvas *canvas, const QImage &image, const QPoint &position, - UndoCommand *parent = nullptr); + QUndoCommand *parent = nullptr); void undo() override; void redo() override; diff --git a/app/project.cpp b/app/project.cpp index 2642955c..fefe0fe3 100644 --- a/app/project.cpp +++ b/app/project.cpp @@ -313,7 +313,7 @@ QSize Project::size() const return QSize(0, 0); } -UndoStack *Project::undoStack() +QUndoStack *Project::undoStack() { return &mUndoStack; } @@ -356,13 +356,13 @@ void Project::endMacro() } } -QDebug operator<<(QDebug debug, const UndoCommand &command) +QDebug operator<<(QDebug debug, const QUndoCommand &command) { debug << &command; return debug; } -void Project::addChange(UndoCommand *undoCommand) +void Project::addChange(QUndoCommand *undoCommand) { qCDebug(lcProject) << "adding change" << *undoCommand; mUndoStack.push(undoCommand); diff --git a/app/project.h b/app/project.h index 3f37fed7..804f9e82 100644 --- a/app/project.h +++ b/app/project.h @@ -28,7 +28,7 @@ #include #include -#include +#include #include "guide.h" @@ -50,7 +50,7 @@ class Project : public QObject Q_PROPERTY(QUrl dirUrl READ dirUrl NOTIFY urlChanged) Q_PROPERTY(QString displayUrl READ displayUrl NOTIFY urlChanged) Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY sizeChanged) - Q_PROPERTY(UndoStack *undoStack READ undoStack CONSTANT) + Q_PROPERTY(QUndoStack *undoStack READ undoStack CONSTANT) Q_PROPERTY(ApplicationSettings *settings READ settings WRITE setSettings NOTIFY settingsChanged) public: @@ -96,12 +96,12 @@ class Project : public QObject // and MoveContentsDialog. Q_INVOKABLE virtual QImage exportedImage() const; - UndoStack *undoStack(); + QUndoStack *undoStack(); bool isComposingMacro() const; void beginMacro(const QString &text); void endMacro(); - void addChange(UndoCommand *undoCommand); + void addChange(QUndoCommand *undoCommand); void clearChanges(); ApplicationSettings *settings() const; @@ -154,7 +154,7 @@ public slots: // who may be interested) a chance to save data specific to the project. QJsonObject mCachedProjectJson; - UndoStack mUndoStack; + QUndoStack mUndoStack; bool mComposingMacro; bool mHadUnsavedChangesBeforeMacroBegan; diff --git a/app/tilecanvas.h b/app/tilecanvas.h index aff31d0b..e366ab96 100644 --- a/app/tilecanvas.h +++ b/app/tilecanvas.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include "imagecanvas.h" diff --git a/app/tilesetproject.cpp b/app/tilesetproject.cpp index eccf90ee..15ecd81c 100644 --- a/app/tilesetproject.cpp +++ b/app/tilesetproject.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "changetilecanvassizecommand.h" #include "jsonutils.h" diff --git a/app/tilesetproject.h b/app/tilesetproject.h index 20ccf1e7..7d982d00 100644 --- a/app/tilesetproject.h +++ b/app/tilesetproject.h @@ -27,8 +27,6 @@ #include #include -#include - #include "project.h" #include "tile.h" #include "tileset.h"