diff --git a/mainwidget.cpp b/mainwidget.cpp index 8cae394..aed8b58 100644 --- a/mainwidget.cpp +++ b/mainwidget.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -560,6 +561,8 @@ LevelOneScene::LevelOneScene(QWidget *levelOneWidget, QObject *parent) : QGraphi m_sidePanelGridItemGroup[c]->addToGroup(gridPiece); } } + + installEventFilter(this); } void LevelOneScene::setBorderDimensions(int sceneWidth, int sceneHeight, int widgetWidth, int leftSidePanelColumns, int rightSidePanelColumns) @@ -637,6 +640,22 @@ void LevelOneScene::toggleGrid(bool gridOn) m_sidePanelGridItemGroup[i]->setVisible(gridOn); } +bool LevelOneScene::eventFilter(QObject *object, QEvent *event) +{ + Q_UNUSED(object); + + if (event->type() == QEvent::GraphicsSceneWheel && static_cast(event)->modifiers() == Qt::ControlModifier) { + if (static_cast(event)->delta() > 0) + emit mouseZoomIn(); + else if (static_cast(event)->delta() < 0) + emit mouseZoomOut(); + + event->accept(); + return true; + } + return false; +} + void LevelOneScene::setFullScreenColour(const QColor &newColor) { m_fullScreenTopRectItem->setBrush(QBrush(newColor)); diff --git a/mainwidget.h b/mainwidget.h index 2971534..e195b25 100644 --- a/mainwidget.h +++ b/mainwidget.h @@ -121,7 +121,13 @@ public slots: void setFullScreenColour(const QColor &); void setFullRowColour(int, const QColor &); +signals: + void mouseZoomIn(); + void mouseZoomOut(); + private: + bool eventFilter(QObject *, QEvent *); + QGraphicsRectItem *m_fullScreenTopRectItem, *m_fullScreenBottomRectItem; QGraphicsRectItem *m_fullRowLeftRectItem[25], *m_fullRowRightRectItem[25]; QGraphicsProxyWidget *m_levelOneProxyWidget; diff --git a/mainwindow.cpp b/mainwindow.cpp index cdd32cc..6e7eef4 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -181,6 +181,9 @@ void MainWindow::init() connect(m_textWidget->pageRender(), &TeletextPageRender::fullRowColourChanged, m_textScene, &LevelOneScene::setFullRowColour); connect(m_textWidget, &TeletextWidget::insertKeyPressed, this, &MainWindow::toggleInsertMode); + connect(m_textScene, &LevelOneScene::mouseZoomIn, this, &MainWindow::zoomIn); + connect(m_textScene, &LevelOneScene::mouseZoomOut, this, &MainWindow::zoomOut); + QShortcut *blockShortCut = new QShortcut(QKeySequence(Qt::Key_Escape, Qt::Key_J), m_textView); connect(blockShortCut, &QShortcut::activated, [=]() { m_textWidget->setCharacter(0x7f); });