QmlDesigner: Fix zoom speed for windows

Fixes: QDS-7835
Change-Id: I4ba76f9b7bf7be2472a073515891d50dbe7213c8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Knud Dollereder
2022-11-30 16:36:21 +01:00
parent 06b40d0aaa
commit 16ec1ab67f
4 changed files with 23 additions and 6 deletions

View File

@@ -1,6 +1,9 @@
// Copyright (C) 2020 The Qt Company Ltd. // Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#include "navigation2d.h" #include "navigation2d.h"
#include <utils/hostosinfo.h>
#include <designersettings.h>
#include <qmldesignerplugin.h>
#include <QGestureEvent> #include <QGestureEvent>
#include <QScrollBar> #include <QScrollBar>
@@ -73,15 +76,24 @@ bool Navigation2dFilter::wheelEvent(QWheelEvent *event)
bool zoomChangedConnected = QObject::isSignalConnected(zoomChangedSignal); bool zoomChangedConnected = QObject::isSignalConnected(zoomChangedSignal);
if (zoomChangedConnected) { if (zoomChangedConnected) {
const double globalMouseSpeed =
QmlDesignerPlugin::settings().value(DesignerSettingsKey::EDITOR_ZOOM_FACTOR).toDouble();
double speed = globalMouseSpeed/20.;
if (Utils::HostOsInfo::isMacHost())
speed = 1.0/200.;
if (QPointF delta = event->pixelDelta(); !delta.isNull()) { if (QPointF delta = event->pixelDelta(); !delta.isNull()) {
double dist = std::abs(delta.x()) > std::abs(delta.y()) ? -delta.x() : delta.y(); double dist = std::abs(delta.x()) > std::abs(delta.y()) ? -delta.x() : delta.y();
emit zoomChanged(dist/200.0, event->position()); emit zoomChanged(dist * speed, event->position());
event->accept(); event->accept();
return true; return true;
} else if (QPointF delta = event->angleDelta(); !delta.isNull()) { } else if (QPointF delta = event->angleDelta(); !delta.isNull()) {
constexpr double degreePerStep = 15.;
constexpr double stepCount = 8.;
double dist = std::abs(delta.x()) > std::abs(delta.y()) ? -delta.x() : delta.y(); double dist = std::abs(delta.x()) > std::abs(delta.y()) ? -delta.x() : delta.y();
dist = dist / (8*15); dist = dist / (stepCount*degreePerStep);
emit zoomChanged(dist/200.0, event->position()); emit zoomChanged(dist * speed, event->position());
event->accept(); event->accept();
return true; return true;
} }

View File

@@ -5,6 +5,7 @@
#include "formeditoritem.h" #include "formeditoritem.h"
#include "formeditorwidget.h" #include "formeditorwidget.h"
#include "navigation2d.h" #include "navigation2d.h"
#include <utils/hostosinfo.h>
#include <QAction> #include <QAction>
#include <QCoreApplication> #include <QCoreApplication>
@@ -44,9 +45,11 @@ FormEditorGraphicsView::FormEditorGraphicsView(QWidget *parent)
connect(filter, &Navigation2dFilter::zoomIn, this, &FormEditorGraphicsView::zoomIn); connect(filter, &Navigation2dFilter::zoomIn, this, &FormEditorGraphicsView::zoomIn);
connect(filter, &Navigation2dFilter::zoomOut, this, &FormEditorGraphicsView::zoomOut); connect(filter, &Navigation2dFilter::zoomOut, this, &FormEditorGraphicsView::zoomOut);
if (Utils::HostOsInfo::isMacHost()) {
connect(filter, &Navigation2dFilter::panChanged, [this](const QPointF &direction) { connect(filter, &Navigation2dFilter::panChanged, [this](const QPointF &direction) {
Navigation2dFilter::scroll(direction, horizontalScrollBar(), verticalScrollBar()); Navigation2dFilter::scroll(direction, horizontalScrollBar(), verticalScrollBar());
}); });
}
auto zoomChanged = &Navigation2dFilter::zoomChanged; auto zoomChanged = &Navigation2dFilter::zoomChanged;
connect(filter, zoomChanged, [this](double s, const QPointF &/*pos*/) { connect(filter, zoomChanged, [this](double s, const QPointF &/*pos*/) {

View File

@@ -86,6 +86,7 @@ void DesignerSettings::fromSettings(QSettings *settings)
restoreValue(settings, DesignerSettingsKey::SMOOTH_RENDERING, false); restoreValue(settings, DesignerSettingsKey::SMOOTH_RENDERING, false);
restoreValue(settings, DesignerSettingsKey::SHOW_DEBUG_SETTINGS, false); restoreValue(settings, DesignerSettingsKey::SHOW_DEBUG_SETTINGS, false);
restoreValue(settings, DesignerSettingsKey::OLD_STATES_EDITOR, false); restoreValue(settings, DesignerSettingsKey::OLD_STATES_EDITOR, false);
restoreValue(settings, DesignerSettingsKey::EDITOR_ZOOM_FACTOR, 1.0);
settings->endGroup(); settings->endGroup();
settings->endGroup(); settings->endGroup();

View File

@@ -54,6 +54,7 @@ const char DISABLE_ITEM_LIBRARY_UPDATE_TIMER[] = "DisableItemLibraryUpdateTimer"
const char ASK_BEFORE_DELETING_ASSET[] = "AskBeforeDeletingAsset"; const char ASK_BEFORE_DELETING_ASSET[] = "AskBeforeDeletingAsset";
const char SMOOTH_RENDERING[] = "SmoothRendering"; const char SMOOTH_RENDERING[] = "SmoothRendering";
const char OLD_STATES_EDITOR[] = "ForceOldStatesEditor"; const char OLD_STATES_EDITOR[] = "ForceOldStatesEditor";
const char EDITOR_ZOOM_FACTOR[] = "EditorZoomFactor";
} }
class QMLDESIGNERUTILS_EXPORT DesignerSettings class QMLDESIGNERUTILS_EXPORT DesignerSettings