diff options
Diffstat (limited to 'share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp')
-rw-r--r-- | share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp index f99d219c5c..ae2f235673 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp @@ -48,6 +48,8 @@ namespace QmlDesigner { namespace Internal { const QString _globalStateId = QStringLiteral("@GTS"); // global tool state +const QString _lastSceneIdKey = QStringLiteral("lastSceneId"); +const QString _rootSizeKey = QStringLiteral("rootSize"); GeneralHelper::GeneralHelper() : QObject() @@ -64,8 +66,9 @@ GeneralHelper::GeneralHelper() void GeneralHelper::requestOverlayUpdate() { - if (!m_overlayUpdateTimer.isActive()) - m_overlayUpdateTimer.start(); + // Restart the timer on each request in attempt to ensure there's one frame between the last + // request and actual update. + m_overlayUpdateTimer.start(); } QString GeneralHelper::generateUniqueName(const QString &nameRoot) @@ -148,7 +151,7 @@ float GeneralHelper::zoomCamera(QQuick3DCamera *camera, float distance, float de // Return value contains new lookAt point (xyz) and zoom factor (w) QVector4D GeneralHelper::focusObjectToCamera(QQuick3DCamera *camera, float defaultLookAtDistance, QQuick3DNode *targetObject, QQuick3DViewport *viewPort, - float oldZoom, bool updateZoom) + float oldZoom, bool updateZoom, bool closeUp) { if (!camera) return QVector4D(0.f, 0.f, 0.f, 1.f); @@ -200,7 +203,9 @@ QVector4D GeneralHelper::focusObjectToCamera(QQuick3DCamera *camera, float defau camera->setPosition(lookAt + newLookVector); - float newZoomFactor = updateZoom ? qBound(.01f, float(maxExtent / 900.), 100.f) : oldZoom; + qreal divisor = closeUp ? 900. : 725.; + + float newZoomFactor = updateZoom ? qBound(.01f, float(maxExtent / divisor), 100.f) : oldZoom; float cameraZoomFactor = zoomCamera(camera, 0, defaultLookAtDistance, lookAt, newZoomFactor, false); return QVector4D(lookAt, cameraZoomFactor); @@ -277,6 +282,16 @@ QString GeneralHelper::globalStateId() const return _globalStateId; } +QString GeneralHelper::lastSceneIdKey() const +{ + return _lastSceneIdKey; +} + +QString GeneralHelper::rootSizeKey() const +{ + return _rootSizeKey; +} + bool GeneralHelper::isMacOS() const { #ifdef Q_OS_MACOS |