forked from qt-creator/qt-creator
SCXML: fix magnifier not hiding
Fixes: QTCREATORBUG-24463 Change-Id: I835550e32467992ea7ad2555c546d810e6e0bbad Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -63,12 +63,16 @@ void Magnifier::showEvent(QShowEvent *e)
|
||||
{
|
||||
QWidget::showEvent(e);
|
||||
grabMouse();
|
||||
qApp->installEventFilter(this);
|
||||
emit visibilityChanged(true);
|
||||
}
|
||||
|
||||
void Magnifier::hideEvent(QHideEvent *e)
|
||||
{
|
||||
QWidget::hideEvent(e);
|
||||
releaseMouse();
|
||||
qApp->removeEventFilter(this);
|
||||
emit visibilityChanged(false);
|
||||
}
|
||||
|
||||
void Magnifier::mousePressEvent(QMouseEvent *e)
|
||||
@@ -98,6 +102,20 @@ void Magnifier::wheelEvent(QWheelEvent *e)
|
||||
m_ui.m_graphicsView->centerOn(m_mainView->mapToScene(pos() - m_topLeft + rect().center()));
|
||||
}
|
||||
|
||||
bool Magnifier::eventFilter(QObject * /*obj*/, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::KeyRelease
|
||||
&& static_cast<QKeyEvent *>(event)->key() == Qt::Key_Alt) {
|
||||
setVisible(false);
|
||||
}
|
||||
if (event->type() == QEvent::ApplicationStateChange
|
||||
&& QGuiApplication::applicationState() != Qt::ApplicationActive) {
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Magnifier::moveEvent(QMoveEvent *e)
|
||||
{
|
||||
QWidget::moveEvent(e);
|
||||
|
@@ -51,8 +51,11 @@ public:
|
||||
void setCurrentScene(PluginInterface::GraphicsScene *scene);
|
||||
void setTopLeft(const QPoint &topLeft);
|
||||
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
|
||||
signals:
|
||||
void clicked(double zoomLevel);
|
||||
void visibilityChanged(bool hidden);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
|
@@ -513,6 +513,7 @@ void MainWidget::addStateView(BaseItem *item)
|
||||
});
|
||||
connect(view->view(), &GraphicsView::panningChanged, m_actionHandler->action(ActionPan), &QAction::setChecked);
|
||||
connect(view->view(), &GraphicsView::magnifierChanged, m_actionHandler->action(ActionMagnifier), &QAction::setChecked);
|
||||
connect(m_magnifier, &Magnifier::visibilityChanged, m_actionHandler->action(ActionMagnifier), &QAction::setChecked);
|
||||
connect(view->scene(), &GraphicsScene::openStateView, this, &MainWidget::addStateView, Qt::QueuedConnection);
|
||||
connect(view->scene(), &GraphicsScene::selectedStateCountChanged, this, [this](int count) {
|
||||
bool currentView = sender() == m_views.last()->scene();
|
||||
|
Reference in New Issue
Block a user