forked from qt-creator/qt-creator
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:
@@ -1,6 +1,9 @@
|
||||
// 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
|
||||
#include "navigation2d.h"
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <designersettings.h>
|
||||
#include <qmldesignerplugin.h>
|
||||
|
||||
#include <QGestureEvent>
|
||||
#include <QScrollBar>
|
||||
@@ -73,15 +76,24 @@ bool Navigation2dFilter::wheelEvent(QWheelEvent *event)
|
||||
bool zoomChangedConnected = QObject::isSignalConnected(zoomChangedSignal);
|
||||
|
||||
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()) {
|
||||
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();
|
||||
return true;
|
||||
} 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();
|
||||
dist = dist / (8*15);
|
||||
emit zoomChanged(dist/200.0, event->position());
|
||||
dist = dist / (stepCount*degreePerStep);
|
||||
emit zoomChanged(dist * speed, event->position());
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
#include "formeditoritem.h"
|
||||
#include "formeditorwidget.h"
|
||||
#include "navigation2d.h"
|
||||
#include <utils/hostosinfo.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QCoreApplication>
|
||||
@@ -44,9 +45,11 @@ FormEditorGraphicsView::FormEditorGraphicsView(QWidget *parent)
|
||||
connect(filter, &Navigation2dFilter::zoomIn, this, &FormEditorGraphicsView::zoomIn);
|
||||
connect(filter, &Navigation2dFilter::zoomOut, this, &FormEditorGraphicsView::zoomOut);
|
||||
|
||||
connect(filter, &Navigation2dFilter::panChanged, [this](const QPointF &direction) {
|
||||
Navigation2dFilter::scroll(direction, horizontalScrollBar(), verticalScrollBar());
|
||||
});
|
||||
if (Utils::HostOsInfo::isMacHost()) {
|
||||
connect(filter, &Navigation2dFilter::panChanged, [this](const QPointF &direction) {
|
||||
Navigation2dFilter::scroll(direction, horizontalScrollBar(), verticalScrollBar());
|
||||
});
|
||||
}
|
||||
|
||||
auto zoomChanged = &Navigation2dFilter::zoomChanged;
|
||||
connect(filter, zoomChanged, [this](double s, const QPointF &/*pos*/) {
|
||||
|
@@ -86,6 +86,7 @@ void DesignerSettings::fromSettings(QSettings *settings)
|
||||
restoreValue(settings, DesignerSettingsKey::SMOOTH_RENDERING, false);
|
||||
restoreValue(settings, DesignerSettingsKey::SHOW_DEBUG_SETTINGS, false);
|
||||
restoreValue(settings, DesignerSettingsKey::OLD_STATES_EDITOR, false);
|
||||
restoreValue(settings, DesignerSettingsKey::EDITOR_ZOOM_FACTOR, 1.0);
|
||||
|
||||
settings->endGroup();
|
||||
settings->endGroup();
|
||||
|
@@ -54,6 +54,7 @@ const char DISABLE_ITEM_LIBRARY_UPDATE_TIMER[] = "DisableItemLibraryUpdateTimer"
|
||||
const char ASK_BEFORE_DELETING_ASSET[] = "AskBeforeDeletingAsset";
|
||||
const char SMOOTH_RENDERING[] = "SmoothRendering";
|
||||
const char OLD_STATES_EDITOR[] = "ForceOldStatesEditor";
|
||||
const char EDITOR_ZOOM_FACTOR[] = "EditorZoomFactor";
|
||||
}
|
||||
|
||||
class QMLDESIGNERUTILS_EXPORT DesignerSettings
|
||||
|
Reference in New Issue
Block a user