diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/EditWindow3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/EditWindow3D.qml deleted file mode 100644 index 4ec92e63c35..00000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/EditWindow3D.qml +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -import QtQuick 2.12 -import QtQuick.Window 2.12 - -Window { - id: viewWindow - width: 1024 - height: 768 - visible: true - title: qsTr("3D Edit View [") + sceneId + qsTr("]") - // need all those flags otherwise the title bar disappears after setting WindowStaysOnTopHint flag later - flags: Qt.Window | Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.WindowMinMaxButtonsHint | Qt.WindowCloseButtonHint - - property alias editViewRoot: windowContentItem - - onWidthChanged: _generalHelper.storeWindowState(); - onHeightChanged: _generalHelper.storeWindowState(); - onXChanged: _generalHelper.storeWindowState(); - onYChanged: _generalHelper.storeWindowState(); - onWindowStateChanged: _generalHelper.storeWindowState(); - - EditView3D { - id: windowContentItem - anchors.fill: parent - } -} diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp index 30c2e3a2ec5..8fe5395a6a5 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp @@ -43,7 +43,6 @@ #include #include #include -#include namespace QmlDesigner { namespace Internal { @@ -259,61 +258,6 @@ void GeneralHelper::initToolStates(const QString &sceneId, const QVariantMap &to m_toolStates[sceneId] = toolStates; } -void GeneralHelper::storeWindowState() -{ - if (!m_edit3DWindow) - return; - - QVariantMap windowState; - const QRect geometry = m_edit3DWindow->geometry(); - const bool maximized = m_edit3DWindow->windowState() == Qt::WindowMaximized; - windowState.insert("maximized", maximized); - windowState.insert("geometry", geometry); - - storeToolState(globalStateId(), "windowState", windowState, 500); -} - -void GeneralHelper::restoreWindowState() -{ - if (!m_edit3DWindow) - return; - - if (m_toolStates.contains(globalStateId())) { - const QVariantMap &globalStateMap = m_toolStates[globalStateId()]; - const QString stateKey = QStringLiteral("windowState"); - if (globalStateMap.contains(stateKey)) { - QVariantMap windowState = globalStateMap[stateKey].value(); - - doRestoreWindowState(windowState); - - // If the mouse cursor at puppet launch time is in a different screen than the one where the - // view geometry was saved on, the initial position and size can be incorrect, but if - // we reset the geometry again asynchronously, it should end up with correct geometry. - QTimer::singleShot(0, [this, windowState]() { - doRestoreWindowState(windowState); - QTimer::singleShot(0, [this]() { - // Make sure that the window is at least partially visible on the screen - QRect geo = m_edit3DWindow->geometry(); - QRect sRect = m_edit3DWindow->screen()->geometry(); - if (geo.left() > sRect.right() - 150) - geo.moveRight(sRect.right()); - if (geo.right() < sRect.left() + 150) - geo.moveLeft(sRect.left()); - if (geo.top() > sRect.bottom() - 150) - geo.moveBottom(sRect.bottom()); - if (geo.bottom() < sRect.top() + 150) - geo.moveTop(sRect.top()); - if (geo.width() > sRect.width()) - geo.setWidth(sRect.width()); - if (geo.height() > sRect.height()) - geo.setHeight(sRect.height()); - m_edit3DWindow->setGeometry(geo); - }); - }); - } - } -} - void GeneralHelper::enableItemUpdate(QQuickItem *item, bool enable) { if (item) @@ -328,33 +272,11 @@ QVariantMap GeneralHelper::getToolStates(const QString &sceneId) return {}; } -void GeneralHelper::setEdit3DWindow(QQuickWindow *w) -{ - m_edit3DWindow = w; -} - QString GeneralHelper::globalStateId() const { return _globalStateId; } -void GeneralHelper::doRestoreWindowState(const QVariantMap &windowState) -{ - const QString geoKey = QStringLiteral("geometry"); - if (windowState.contains(geoKey)) { - bool maximized = false; - const QString maxKey = QStringLiteral("maximized"); - if (windowState.contains(maxKey)) - maximized = windowState[maxKey].toBool(); - - QRect rect = windowState[geoKey].value(); - - m_edit3DWindow->setGeometry(rect); - if (maximized) - m_edit3DWindow->showMaximized(); - } -} - bool GeneralHelper::isMacOS() const { #ifdef Q_OS_MACOS diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h index f36e7458173..e9d8e525458 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h @@ -38,7 +38,6 @@ QT_BEGIN_NAMESPACE class QQuick3DCamera; class QQuick3DNode; class QQuick3DViewport; -class QQuickWindow; class QQuickItem; QT_END_NAMESPACE @@ -75,11 +74,8 @@ public: Q_INVOKABLE void storeToolState(const QString &sceneId, const QString &tool, const QVariant &state, int delayEmit = 0); void initToolStates(const QString &sceneId, const QVariantMap &toolStates); - Q_INVOKABLE void storeWindowState(); - void restoreWindowState(); Q_INVOKABLE void enableItemUpdate(QQuickItem *item, bool enable); Q_INVOKABLE QVariantMap getToolStates(const QString &sceneId); - void setEdit3DWindow(QQuickWindow *w); QString globalStateId() const; bool isMacOS() const; @@ -88,9 +84,6 @@ signals: void overlayUpdateNeeded(); void toolStateChanged(const QString &sceneId, const QString &tool, const QVariant &toolState); -private slots: - void doRestoreWindowState(const QVariantMap &windowState); - private: void handlePendingToolStateUpdate(); @@ -98,7 +91,6 @@ private: QTimer m_toolStateUpdateTimer; QHash m_toolStates; QHash m_toolStatesPending; - QPointer m_edit3DWindow; }; } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp index 36c42222be9..eaea9911dbf 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp @@ -812,7 +812,6 @@ void Qt5InformationNodeInstanceServer::setup3DEditView(const QListinitToolStates(it.key(), it.value()); ++it; } - helper->restoreWindowState(); if (toolStates.contains(helper->globalStateId()) && toolStates[helper->globalStateId()].contains("rootSize")) { m_editView3DRootItem->setSize(toolStates[helper->globalStateId()]["rootSize"].value()); diff --git a/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc b/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc index ce71153ecc6..5d30e496910 100644 --- a/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc +++ b/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc @@ -8,7 +8,6 @@ mockfiles/GenericBackend.qml mockfiles/Dialog.qml mockfiles/EditView3D.qml - mockfiles/EditWindow3D.qml mockfiles/EditCameraController.qml mockfiles/Arrow.qml mockfiles/AutoScaleHelper.qml