diff --git a/include/ui/eventfilters.h b/include/ui/eventfilters.h index 984ce23a..851c344b 100644 --- a/include/ui/eventfilters.h +++ b/include/ui/eventfilters.h @@ -3,6 +3,7 @@ +/// Prevent wheel scroll class WheelFilter : public QObject { Q_OBJECT public: @@ -10,3 +11,18 @@ public: virtual ~WheelFilter() {} bool eventFilter(QObject *obj, QEvent *event) override; }; + + + +/// Ctrl+Wheel = zoom +class MapSceneEventFilter : public QObject { + Q_OBJECT +protected: + bool eventFilter(QObject *obj, QEvent *event) override; +public: + explicit MapSceneEventFilter(QObject *parent = nullptr) : QObject(parent) {} + +signals: + void wheelZoom(int delta); +public slots: +}; diff --git a/include/ui/mapsceneeventfilter.h b/include/ui/mapsceneeventfilter.h deleted file mode 100644 index 7de427e3..00000000 --- a/include/ui/mapsceneeventfilter.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef MAPSCENEEVENTFILTER_H -#define MAPSCENEEVENTFILTER_H - -#include - -class MapSceneEventFilter : public QObject -{ - Q_OBJECT -protected: - bool eventFilter(QObject *obj, QEvent *event) override; -public: - explicit MapSceneEventFilter(QObject *parent = nullptr); - -signals: - void wheelZoom(int delta); -public slots: -}; - -#endif // MAPSCENEEVENTFILTER_H diff --git a/porymap.pro b/porymap.pro index 04fc6e00..bf9a200f 100644 --- a/porymap.pro +++ b/porymap.pro @@ -66,7 +66,6 @@ SOURCES += src/core/block.cpp \ src/ui/prefabcreationdialog.cpp \ src/ui/regionmappixmapitem.cpp \ src/ui/citymappixmapitem.cpp \ - src/ui/mapsceneeventfilter.cpp \ src/ui/metatilelayersitem.cpp \ src/ui/metatileselector.cpp \ src/ui/movablerect.cpp \ @@ -158,7 +157,6 @@ HEADERS += include/core/block.h \ include/ui/prefabcreationdialog.h \ include/ui/regionmappixmapitem.h \ include/ui/citymappixmapitem.h \ - include/ui/mapsceneeventfilter.h \ include/ui/metatilelayersitem.h \ include/ui/metatileselector.h \ include/ui/movablerect.h \ diff --git a/src/editor.cpp b/src/editor.cpp index fc77b2b6..48b8ce4e 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -4,7 +4,7 @@ #include "log.h" #include "mapconnection.h" #include "currentselectedmetatilespixmapitem.h" -#include "mapsceneeventfilter.h" +#include "eventfilters.h" #include "metatile.h" #include "montabwidget.h" #include "encountertablemodel.h" diff --git a/src/project.cpp b/src/project.cpp index 245f3fb8..f2615ebf 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -1376,12 +1376,6 @@ void Project::updateLayout(Layout *layout) { mapLayoutsTableMaster.append(layout->id); } - // !TODO: why is[was] this a deep copy?? - // Deep copy - // Layout *layout = mapLayouts.value(map->layoutId); - // Layout *newLayout = new Layout(); - // *newLayout = *layout; - // mapLayoutsMaster.insert(map->layoutId, newLayout); if (mapLayoutsMaster.contains(layout->id)) { mapLayoutsMaster[layout->id]->copyFrom(layout); } diff --git a/src/ui/eventfilters.cpp b/src/ui/eventfilters.cpp index 24f2e0bd..1e7b2b80 100644 --- a/src/ui/eventfilters.cpp +++ b/src/ui/eventfilters.cpp @@ -1,5 +1,7 @@ #include "eventfilters.h" +#include + bool WheelFilter::eventFilter(QObject *, QEvent *event) { @@ -8,3 +10,17 @@ bool WheelFilter::eventFilter(QObject *, QEvent *event) { } return false; } + + + +bool MapSceneEventFilter::eventFilter(QObject*, QEvent *event) { + if (event->type() == QEvent::GraphicsSceneWheel) { + QGraphicsSceneWheelEvent *wheelEvent = static_cast(event); + if (wheelEvent->modifiers() & Qt::ControlModifier) { + emit wheelZoom(wheelEvent->delta() > 0 ? 1 : -1); + event->accept(); + return true; + } + } + return false; +} diff --git a/src/ui/mapsceneeventfilter.cpp b/src/ui/mapsceneeventfilter.cpp deleted file mode 100644 index f8ae14cb..00000000 --- a/src/ui/mapsceneeventfilter.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "mapsceneeventfilter.h" -#include -#include - -MapSceneEventFilter::MapSceneEventFilter(QObject *parent) : QObject(parent) -{ - -} - -bool MapSceneEventFilter::eventFilter(QObject*, QEvent *event) -{ - if (event->type() == QEvent::GraphicsSceneWheel) - { - QGraphicsSceneWheelEvent *wheelEvent = static_cast(event); - if (wheelEvent->modifiers() & Qt::ControlModifier) - { - emit wheelZoom(wheelEvent->delta() > 0 ? 1 : -1); - event->accept(); - return true; - } - } - return false; -}