Disable showing/hiding magnifier by pressing Alt modifier

The Alt modifier doesn't work well with mouse wheel
as it causes the horizontal wheel to be triggered.
Disable the Alt modifier as a shortcut for activating
the Magnifier. When Magnifier is shown by activating
the toolbar action, the magnification works by simple
mouse wheel without any modifier.

Fixes: QTCREATORBUG-25612
Change-Id: Idb7c40dbf92ed135a796c9623cc46b6b1e80e9e6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Jarek Kobus
2022-01-17 12:08:08 +01:00
parent 8f98ac4120
commit 1ba6faeea0
3 changed files with 1 additions and 7 deletions

View File

@@ -168,14 +168,12 @@ QImage GraphicsView::grabView()
void GraphicsView::keyReleaseEvent(QKeyEvent *event) void GraphicsView::keyReleaseEvent(QKeyEvent *event)
{ {
emit panningChanged(event->modifiers() == Qt::ShiftModifier); emit panningChanged(event->modifiers() == Qt::ShiftModifier);
emit magnifierChanged(event->modifiers() == Qt::AltModifier);
QGraphicsView::keyReleaseEvent(event); QGraphicsView::keyReleaseEvent(event);
} }
void GraphicsView::keyPressEvent(QKeyEvent *event) void GraphicsView::keyPressEvent(QKeyEvent *event)
{ {
emit panningChanged(event->modifiers() == Qt::ShiftModifier); emit panningChanged(event->modifiers() == Qt::ShiftModifier);
emit magnifierChanged(event->modifiers() == Qt::AltModifier);
QGraphicsView::keyPressEvent(event); QGraphicsView::keyPressEvent(event);
} }

View File

@@ -104,10 +104,6 @@ void Magnifier::wheelEvent(QWheelEvent *e)
bool Magnifier::eventFilter(QObject * /*obj*/, QEvent *event) 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 if (event->type() == QEvent::ApplicationStateChange
&& QGuiApplication::applicationState() != Qt::ApplicationActive) { && QGuiApplication::applicationState() != Qt::ApplicationActive) {
setVisible(false); setVisible(false);

View File

@@ -47,7 +47,7 @@ ActionHandler::ActionHandler(QObject *parent)
{Utils::Icons::FITTOVIEW_TOOLBAR, tr("Fit to View"), tr("Fit to View (F11)"), "F11", false}, {Utils::Icons::FITTOVIEW_TOOLBAR, tr("Fit to View"), tr("Fit to View (F11)"), "F11", false},
{Utils::Icons::PAN_TOOLBAR, tr("Panning"), tr("Panning (Shift)"), "Shift", true}, {Utils::Icons::PAN_TOOLBAR, tr("Panning"), tr("Panning (Shift)"), "Shift", true},
{Utils::Icons::ZOOM_TOOLBAR, tr("Magnifier"), tr("Magnifier Tool (Alt)"), "Alt", true}, {Utils::Icons::ZOOM_TOOLBAR, tr("Magnifier"), tr("Magnifier Tool"), "", true},
{Utils::Icon(":/scxmleditor/images/navigator.png"), tr("Navigator"), tr("Navigator (Ctrl+E)"), "Ctrl+E", true}, {Utils::Icon(":/scxmleditor/images/navigator.png"), tr("Navigator"), tr("Navigator (Ctrl+E)"), "Ctrl+E", true},
{Utils::Icons::COPY_TOOLBAR, tr("Copy"), tr("Copy (Ctrl + C)"), "Ctrl+C", false}, {Utils::Icons::COPY_TOOLBAR, tr("Copy"), tr("Copy (Ctrl + C)"), "Ctrl+C", false},