Implement zooming with Control key and mousewheel
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include <QGraphicsItemGroup>
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsSceneEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QMenu>
|
||||
#include <QMimeData>
|
||||
@@ -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<QGraphicsSceneWheelEvent *>(event)->modifiers() == Qt::ControlModifier) {
|
||||
if (static_cast<QGraphicsSceneWheelEvent *>(event)->delta() > 0)
|
||||
emit mouseZoomIn();
|
||||
else if (static_cast<QGraphicsSceneWheelEvent *>(event)->delta() < 0)
|
||||
emit mouseZoomOut();
|
||||
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void LevelOneScene::setFullScreenColour(const QColor &newColor)
|
||||
{
|
||||
m_fullScreenTopRectItem->setBrush(QBrush(newColor));
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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); });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user