From f21d0b531f46f67ceb0569af08893882ddd506e3 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Fri, 9 Oct 2020 15:46:31 +0200 Subject: [PATCH 01/22] Fix github actions for Qt Creator plugin wizard For Qt Creator 4.13 - rename directory to 'workflows' - use MSVC 2019 for Qt - fix Qt Creator platform names - don't use GitHub's now deprected set-env Fixes: QTCREATORBUG-24412 Change-Id: Ifdd3e95da74fef4ad9f65ae2c084ff82b2ca1972 Reviewed-by: Alessandro Portale --- ...w_README.md => github_workflows_README.md} | 0 ...e.yml => github_workflows_build_qmake.yml} | 22 +++++++------------ .../wizards/qtcreatorplugin/myplugin.pro | 4 ++-- .../wizards/qtcreatorplugin/wizard.json | 8 +++---- 4 files changed, 14 insertions(+), 20 deletions(-) rename share/qtcreator/templates/wizards/qtcreatorplugin/{github_workflow_README.md => github_workflows_README.md} (100%) rename share/qtcreator/templates/wizards/qtcreatorplugin/{github_workflow_build_qmake.yml => github_workflows_build_qmake.yml} (96%) diff --git a/share/qtcreator/templates/wizards/qtcreatorplugin/github_workflow_README.md b/share/qtcreator/templates/wizards/qtcreatorplugin/github_workflows_README.md similarity index 100% rename from share/qtcreator/templates/wizards/qtcreatorplugin/github_workflow_README.md rename to share/qtcreator/templates/wizards/qtcreatorplugin/github_workflows_README.md diff --git a/share/qtcreator/templates/wizards/qtcreatorplugin/github_workflow_build_qmake.yml b/share/qtcreator/templates/wizards/qtcreatorplugin/github_workflows_build_qmake.yml similarity index 96% rename from share/qtcreator/templates/wizards/qtcreatorplugin/github_workflow_build_qmake.yml rename to share/qtcreator/templates/wizards/qtcreatorplugin/github_workflows_build_qmake.yml index 17ffdfe9bf4..5326dfeb9da 100644 --- a/share/qtcreator/templates/wizards/qtcreatorplugin/github_workflow_build_qmake.yml +++ b/share/qtcreator/templates/wizards/qtcreatorplugin/github_workflows_build_qmake.yml @@ -62,11 +62,11 @@ jobs: if ("${{ runner.os }}" STREQUAL "Windows") set(url_os "windows_x86") if ("${{ matrix.config.environment_script }}" MATCHES "vcvars64.bat") - set(qt_package_name "qt.qt5.${qt_version_dotless}.win64_msvc2017_64") - set(qt_dir_prefix "${qt_version}/msvc2017_64") + set(qt_package_name "qt.qt5.${qt_version_dotless}.win64_msvc2019_64") + set(qt_dir_prefix "${qt_version}/msvc2019_64") elseif ("${{ matrix.config.environment_script }}" MATCHES "vcvars32.bat") - set(qt_package_name "qt.qt5.${qt_version_dotless}.win32_msvc2017") - set(qt_dir_prefix "${qt_version}/msvc2017") + set(qt_package_name "qt.qt5.${qt_version_dotless}.win32_msvc2019") + set(qt_dir_prefix "${qt_version}/msvc2019") else() endif() elseif ("${{ runner.os }}" STREQUAL "Linux") @@ -131,14 +131,14 @@ jobs: set(qtc_output_directory "qtcreator/lib/qtcreator/plugins") set(qtc_binary_name "$ENV{PLUGIN_NAME}4.dll") if ("${{ matrix.config.environment_script }}" MATCHES "vcvars64.bat") - set(qtc_platform "windows_msvc2017_x64") + set(qtc_platform "windows_x64") elseif ("${{ matrix.config.environment_script }}" MATCHES "vcvars32.bat") - set(qtc_platform "windows_msvc2017_x86") + set(qtc_platform "windows_x86") endif() elseif ("${{ runner.os }}" STREQUAL "Linux") set(qtc_output_directory "qtcreator/lib/qtcreator/plugins") set(qtc_binary_name "lib$ENV{PLUGIN_NAME}.so") - set(qtc_platform "linux_gcc_64_rhel72") + set(qtc_platform "linux_x64") elseif ("${{ runner.os }}" STREQUAL "macOS") set(qtc_output_directory "qtcreator/bin/Qt Creator.app/Contents/PlugIns") set(qtc_binary_name "lib$ENV{PLUGIN_NAME}.dylib") @@ -167,7 +167,7 @@ jobs: ) endif() - - name: Configure + - name: Build shell: cmake -P {0} run: | if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") @@ -179,9 +179,6 @@ jobs: foreach(line IN LISTS output_lines) if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") - - # Set for other steps - message("::set-env name=${CMAKE_MATCH_1}::${CMAKE_MATCH_2}") endif() endforeach() endif() @@ -200,9 +197,6 @@ jobs: message(FATAL_ERROR "Bad exit status") endif() - - name: Build - shell: cmake -P {0} - run: | if ("${{ runner.os }}" STREQUAL "Windows") set(ENV{PATH} "${{ steps.qt.outputs.qt_dir }}/bin/;$ENV{PATH}") else() diff --git a/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin.pro b/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin.pro index 82328264a7a..34eed0aeeaa 100644 --- a/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin.pro +++ b/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin.pro @@ -11,8 +11,8 @@ HEADERS += \\ %{ConstantsHdrFileName} DISTFILES += \\ - .github/workflow/build_qmake.yml \\ - .github/workflow/README.md + .github/workflows/build_qmake.yml \\ + .github/workflows/README.md # Qt Creator linking diff --git a/share/qtcreator/templates/wizards/qtcreatorplugin/wizard.json b/share/qtcreator/templates/wizards/qtcreatorplugin/wizard.json index cbaca648fe6..443fa25c250 100644 --- a/share/qtcreator/templates/wizards/qtcreatorplugin/wizard.json +++ b/share/qtcreator/templates/wizards/qtcreatorplugin/wizard.json @@ -190,12 +190,12 @@ "openAsProject": true }, { - "source": "github_workflow_build_qmake.yml", - "target": ".github/workflow/build_qmake.yml" + "source": "github_workflows_build_qmake.yml", + "target": ".github/workflows/build_qmake.yml" }, { - "source": "github_workflow_README.md", - "target": ".github/workflow/README.md" + "source": "github_workflows_README.md", + "target": ".github/workflows/README.md" }, { "source": "myplugin.cpp", From b771f400de94edf1d95f2e5ce5827ed226dec914 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 19 Oct 2020 16:37:21 +0200 Subject: [PATCH 02/22] More change log for 4.14 Change-Id: I33de8128e19d530793f9af97f8eedb1ca03fec2a Reviewed-by: Eike Ziller --- dist/changes-4.14.0.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dist/changes-4.14.0.md b/dist/changes-4.14.0.md index 4d5eaa0822d..0f9603fcb3d 100644 --- a/dist/changes-4.14.0.md +++ b/dist/changes-4.14.0.md @@ -14,6 +14,7 @@ General ------- * Added option for asking for confirmation before closing (QTCREATORBUG-7637) +* Improved visibility of controls in dark themes (QTCREATORBUG-23505) Help ---- @@ -39,6 +40,7 @@ Editing * Added action for showing function arguments hint (QTCREATORBUG-19394) * Added option for after how many characters auto-completion may trigger (QTCREATORBUG-19920) * Restricted completion for second argument of `connect` calls to signals (QTCREATORBUG-13558) +* Fixed crash of backend with multiline `Q_PROPERTY` declarations (QTCREATORBUG-24746) * Fixed duplicate items appearing in include completion (QTCREATORBUG-24515) * Fixed missing namespace when generating getters and setters (QTCREATORBUG-14886) * Fixed missing `inline` when generating method definitions in header files @@ -49,6 +51,7 @@ Editing * Fixed that `Insert virtual functions of base class` refactoring action added already implemented operators (QTCREATORBUG-12218) * Fixed that `Complete switch statement` indents unrelated code (QTCREATORBUG-12445) +* Fixed `Complete switch statement` with templates (QTCREATORBUG-24752) * Fixed that `Apply function signature change` removed return values from `std::function` arguments (QTCREATORBUG-13698) * Fixed handling of multiple inheritance in `Insert Virtual Functions` (QTCREATORBUG-12223) @@ -81,6 +84,10 @@ Projects * Fixed `Embedding of the UI Class` option for widget applications (QTCREATORBUG-24422) * Fixed shell used for console applications (QTCREATORBUG-24659) +### qmake + +* Added option to not execute `system` directives (QTCREATORBUG-24551) + ### Wizards * Fixed creation of form editor class with namespace (QTCREATORBUG-24723) @@ -99,6 +106,10 @@ Debugging * Fixed disabling and enabling breakpoints (QTCREATORBUG-24669) +### GDB + +* Fixed loading of symbol files with `Load Core File` (QTCREATORBUG-24541) + Analyzer -------- From aaf564cab7cbb0a79c37098bd9642a72cef9a9ba Mon Sep 17 00:00:00 2001 From: Knud Dollereder Date: Fri, 16 Oct 2020 16:45:44 +0200 Subject: [PATCH 03/22] CurveEditor: Fix bounding rect computation for the graphicsscene MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QDS-2957 Change-Id: I0019d538e7460e923b35024bd02f7186e1935f6b Reviewed-by: Henning Gründl Reviewed-by: Thomas Hartmann --- .../curveeditor/curveeditormodel.cpp | 6 ++--- .../components/curveeditor/curveeditormodel.h | 2 +- .../components/curveeditor/curveeditorstyle.h | 9 ++++++- .../curveeditor/curveeditorview.cpp | 4 +-- .../curveeditor/detail/curveitem.cpp | 10 +++++++ .../curveeditor/detail/graphicsscene.cpp | 27 ++++++++++++++++++- .../curveeditor/detail/graphicsscene.h | 4 +++ .../curveeditor/detail/graphicsview.cpp | 4 +-- 8 files changed, 56 insertions(+), 10 deletions(-) diff --git a/src/plugins/qmldesigner/components/curveeditor/curveeditormodel.cpp b/src/plugins/qmldesigner/components/curveeditor/curveeditormodel.cpp index db58ce4dbb2..56b91d0af65 100644 --- a/src/plugins/qmldesigner/components/curveeditor/curveeditormodel.cpp +++ b/src/plugins/qmldesigner/components/curveeditor/curveeditormodel.cpp @@ -39,10 +39,10 @@ namespace DesignTools { -CurveEditorModel::CurveEditorModel(double minTime, double maxTime, QObject *parent) +CurveEditorModel::CurveEditorModel(QObject *parent) : TreeModel(parent) - , m_minTime(minTime) - , m_maxTime(maxTime) + , m_minTime(CurveEditorStyle::defaultTimeMin) + , m_maxTime(CurveEditorStyle::defaultTimeMax) {} CurveEditorModel::~CurveEditorModel() {} diff --git a/src/plugins/qmldesigner/components/curveeditor/curveeditormodel.h b/src/plugins/qmldesigner/components/curveeditor/curveeditormodel.h index 952dc46c639..cf7575ca5c1 100644 --- a/src/plugins/qmldesigner/components/curveeditor/curveeditormodel.h +++ b/src/plugins/qmldesigner/components/curveeditor/curveeditormodel.h @@ -57,7 +57,7 @@ signals: void curveChanged(PropertyTreeItem *item); public: - CurveEditorModel(double minTime, double maxTime, QObject *parent = nullptr); + CurveEditorModel(QObject *parent = nullptr); ~CurveEditorModel() override; diff --git a/src/plugins/qmldesigner/components/curveeditor/curveeditorstyle.h b/src/plugins/qmldesigner/components/curveeditor/curveeditorstyle.h index 6d6acebc516..854fabff23f 100644 --- a/src/plugins/qmldesigner/components/curveeditor/curveeditorstyle.h +++ b/src/plugins/qmldesigner/components/curveeditor/curveeditorstyle.h @@ -105,6 +105,13 @@ struct Shortcuts struct CurveEditorStyle { + static constexpr double defaultTimeMin = 0.0; + static constexpr double defaultTimeMax = 100.0; + static constexpr double defaultValueMin = -1.0; + static constexpr double defaultValueMax = 1.0; + + static double defaultValueRange() { return std::abs(defaultValueMin - defaultValueMax); } + Shortcuts shortcuts; QBrush backgroundBrush = QBrush(QColor(5, 0, 100)); @@ -124,7 +131,7 @@ struct CurveEditorStyle double valueAxisWidth = 60.0; double valueOffsetTop = 10.0; double valueOffsetBottom = 10.0; - double labelDensityY = 1.5; + double labelDensityY = 2.0; HandleItemStyleOption handleStyle; KeyframeItemStyleOption keyframeStyle; diff --git a/src/plugins/qmldesigner/components/curveeditor/curveeditorview.cpp b/src/plugins/qmldesigner/components/curveeditor/curveeditorview.cpp index 9d858d684c3..b84d386f8e3 100644 --- a/src/plugins/qmldesigner/components/curveeditor/curveeditorview.cpp +++ b/src/plugins/qmldesigner/components/curveeditor/curveeditorview.cpp @@ -42,7 +42,7 @@ namespace QmlDesigner { CurveEditorView::CurveEditorView(QObject *parent) : AbstractView(parent) , m_block(false) - , m_model(new DesignTools::CurveEditorModel(0., 500.)) + , m_model(new DesignTools::CurveEditorModel()) , m_editor(new DesignTools::CurveEditor(m_model)) { Q_UNUSED(parent); @@ -267,7 +267,7 @@ ModelNode getTargetNode1(DesignTools::PropertyTreeItem *item, const QmlTimeline QString targetId = nodeItem->name(); if (timeline.isValid()) { for (auto &&target : timeline.allTargets()) { - if (target.displayName() == targetId) + if (target.isValid() && target.displayName() == targetId) return target; } } diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/curveitem.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/curveitem.cpp index 86aae0b2cc4..90818be74bd 100644 --- a/src/plugins/qmldesigner/components/curveeditor/detail/curveitem.cpp +++ b/src/plugins/qmldesigner/components/curveeditor/detail/curveitem.cpp @@ -87,6 +87,16 @@ QRectF CurveItem::boundingRect() const for (auto *item : m_keyframes) bbox(bounds, item->keyframe()); + if (auto *s = qobject_cast(scene())) { + bounds.setLeft(s->animationRangeMin()); + bounds.setRight(s->animationRangeMax()); + } + + if (qFuzzyCompare(bounds.height(), 0.0)) { + auto tmp = CurveEditorStyle::defaultValueRange() / 2.0; + bounds.adjust(0.0, -tmp, 0.0, tmp); + } + return m_transform.mapRect(bounds); } diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/graphicsscene.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/graphicsscene.cpp index aca41b4d6dd..e9f9050f625 100644 --- a/src/plugins/qmldesigner/components/curveeditor/detail/graphicsscene.cpp +++ b/src/plugins/qmldesigner/components/curveeditor/detail/graphicsscene.cpp @@ -114,9 +114,29 @@ double GraphicsScene::maximumValue() const return limits().top(); } +double GraphicsScene::animationRangeMin() const +{ + if (GraphicsView *gview = graphicsView()) + return gview->minimumTime(); + + return minimumTime(); +} + +double GraphicsScene::animationRangeMax() const +{ + if (GraphicsView *gview = graphicsView()) + return gview->maximumTime(); + + return maximumTime(); +} + QRectF GraphicsScene::rect() const { - return sceneRect(); + QRectF rect; + for (auto *curve : curves()) + rect |= curve->boundingRect(); + + return rect; } QVector GraphicsScene::curves() const @@ -410,6 +430,11 @@ QRectF GraphicsScene::limits() const } m_limits = QRectF(QPointF(min.x(), max.y()), QPointF(max.x(), min.y())); + if (qFuzzyCompare(m_limits.height(), 0.0)) { + auto tmp = CurveEditorStyle::defaultValueRange() / 2.0; + m_limits.adjust(0.0, tmp, 0.0, -tmp); + } + m_dirty = false; } return m_limits; diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/graphicsscene.h b/src/plugins/qmldesigner/components/curveeditor/detail/graphicsscene.h index 9443130b3e2..c19f72b1309 100644 --- a/src/plugins/qmldesigner/components/curveeditor/detail/graphicsscene.h +++ b/src/plugins/qmldesigner/components/curveeditor/detail/graphicsscene.h @@ -67,6 +67,10 @@ public: double maximumValue() const; + double animationRangeMin() const; + + double animationRangeMax() const; + QRectF rect() const; QVector curves() const; diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/graphicsview.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/graphicsview.cpp index 9fec8b2fc54..c162b5fd906 100644 --- a/src/plugins/qmldesigner/components/curveeditor/detail/graphicsview.cpp +++ b/src/plugins/qmldesigner/components/curveeditor/detail/graphicsview.cpp @@ -126,12 +126,12 @@ double GraphicsView::maximumTime() const double GraphicsView::minimumValue() const { - return m_scene->empty() ? -1.0 : m_scene->minimumValue(); + return m_scene->empty() ? CurveEditorStyle::defaultValueMin : m_scene->minimumValue(); } double GraphicsView::maximumValue() const { - return m_scene->empty() ? 1.0 : m_scene->maximumValue(); + return m_scene->empty() ? CurveEditorStyle::defaultValueMax : m_scene->maximumValue(); } double GraphicsView::zoomX() const From f72c2b84f7f84a7bf2fd5886d53e2cedbfb7beb3 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 19 Oct 2020 10:41:13 +0200 Subject: [PATCH 04/22] Unittest: Fix qbs build The image test uses unexported classes from QmlDesigner. Let's just remove it. Change-Id: I42cae90d7333bf1ad7f75839c93eef773cb5fab8 Reviewed-by: Christian Stenger --- tests/unit/unittest/unittest.qbs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/tests/unit/unittest/unittest.qbs b/tests/unit/unittest/unittest.qbs index ac7eb08b822..5ceb723b220 100644 --- a/tests/unit/unittest/unittest.qbs +++ b/tests/unit/unittest/unittest.qbs @@ -333,19 +333,6 @@ Project { "unittests-main.cpp", "usedmacrofilter-test.cpp", "utf8-test.cpp", - "imagecache-test.cpp", - "imagecachegenerator-test.cpp", - "imagecachestorage-test.cpp", - "sqlitedatabasemock.h", - "sqlitereadstatementmock.h", - "sqlitestatementmock.h", - "sqlitetransactionbackendmock.h", - "sqlitewritestatementmock.h", - "notification.h", - "mocktimestampprovider.h", - "imagecachecollectormock.h", - "mockimagecachegenerator.h", - "mockimagecachestorage.h", ] Group { From b0d4414dfcc931b1e93ff4b814b9a9265331b1ea Mon Sep 17 00:00:00 2001 From: David Schulz Date: Mon, 19 Oct 2020 10:15:20 +0200 Subject: [PATCH 05/22] LanguageClient: pass id as a const ref when handling client messages Change-Id: I7ab6a7517d4dd0fe66f601661e7b3f6a7afb338b Reviewed-by: Christian Stenger --- src/libs/languageserverprotocol/icontent.h | 4 ++-- src/libs/languageserverprotocol/jsonrpcmessages.cpp | 4 ++-- src/libs/languageserverprotocol/jsonrpcmessages.h | 4 ++-- src/plugins/languageclient/client.cpp | 6 +++--- src/plugins/languageclient/client.h | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libs/languageserverprotocol/icontent.h b/src/libs/languageserverprotocol/icontent.h index 33ef876510b..e689f500722 100644 --- a/src/libs/languageserverprotocol/icontent.h +++ b/src/libs/languageserverprotocol/icontent.h @@ -90,8 +90,8 @@ public: }; using ResponseHandler = std::function; -using ResponseHandlers = std::function; -using MethodHandler = std::function; +using ResponseHandlers = std::function; +using MethodHandler = std::function; inline uint qHash(const LanguageServerProtocol::MessageId &id) { diff --git a/src/libs/languageserverprotocol/jsonrpcmessages.cpp b/src/libs/languageserverprotocol/jsonrpcmessages.cpp index 466477d7404..e7285b8da9e 100644 --- a/src/libs/languageserverprotocol/jsonrpcmessages.cpp +++ b/src/libs/languageserverprotocol/jsonrpcmessages.cpp @@ -85,8 +85,8 @@ void JsonRpcMessageHandler::registerMessageProvider( void JsonRpcMessageHandler::parseContent(const QByteArray &content, QTextCodec *codec, QString &parseError, - ResponseHandlers responseHandlers, - MethodHandler methodHandler) + const ResponseHandlers &responseHandlers, + const MethodHandler &methodHandler) { const QJsonObject &jsonObject = toJsonObject(content, codec, parseError); if (jsonObject.isEmpty()) diff --git a/src/libs/languageserverprotocol/jsonrpcmessages.h b/src/libs/languageserverprotocol/jsonrpcmessages.h index f97ed803fc6..00caab62f60 100644 --- a/src/libs/languageserverprotocol/jsonrpcmessages.h +++ b/src/libs/languageserverprotocol/jsonrpcmessages.h @@ -76,8 +76,8 @@ public: } static QByteArray jsonRpcMimeType(); static void parseContent(const QByteArray &content, QTextCodec *codec, QString &errorMessage, - ResponseHandlers responseHandlers, - MethodHandler methodHandler); + const ResponseHandlers &responseHandlers, + const MethodHandler &methodHandler); static QJsonObject toJsonObject(const QByteArray &content, QTextCodec *codec, QString &parseError); private: diff --git a/src/plugins/languageclient/client.cpp b/src/plugins/languageclient/client.cpp index c238ba454a3..9f237ea8072 100644 --- a/src/plugins/languageclient/client.cpp +++ b/src/plugins/languageclient/client.cpp @@ -938,10 +938,10 @@ void Client::handleMessage(const BaseMessage &message) if (auto handler = m_contentHandler[message.mimeType]) { QString parseError; handler(message.content, message.codec, parseError, - [this](MessageId id, const QByteArray &content, QTextCodec *codec){ + [this](const MessageId &id, const QByteArray &content, QTextCodec *codec){ this->handleResponse(id, content, codec); }, - [this](const QString &method, MessageId id, const IContent *content){ + [this](const QString &method, const MessageId &id, const IContent *content){ this->handleMethod(method, id, content); }); if (!parseError.isEmpty()) @@ -1072,7 +1072,7 @@ void Client::handleResponse(const MessageId &id, const QByteArray &content, QTex handler(content, codec); } -void Client::handleMethod(const QString &method, MessageId id, const IContent *content) +void Client::handleMethod(const QString &method, const MessageId &id, const IContent *content) { ErrorHierarchy error; auto logError = [&](const JsonObject &content) { diff --git a/src/plugins/languageclient/client.h b/src/plugins/languageclient/client.h index d264898474f..9d8d8487ce8 100644 --- a/src/plugins/languageclient/client.h +++ b/src/plugins/languageclient/client.h @@ -189,7 +189,7 @@ protected: private: void handleResponse(const LanguageServerProtocol::MessageId &id, const QByteArray &content, QTextCodec *codec); - void handleMethod(const QString &method, LanguageServerProtocol::MessageId id, + void handleMethod(const QString &method, const LanguageServerProtocol::MessageId &id, const LanguageServerProtocol::IContent *content); void handleDiagnostics(const LanguageServerProtocol::PublishDiagnosticsParams ¶ms); From a962a08b1ae2d600ec77f8efddb75a8402a8d084 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Mon, 19 Oct 2020 13:47:27 +0200 Subject: [PATCH 06/22] Editor: fix completion character completions Cleanup the proposal after an item is activated even if the proposal widget is not visible anymore. Otherwise we might wrongly cleanup a proposal that was triggered by a completion character while a completion list was already open. Change-Id: Ie95247de09313c5816cffd9a865b05183db02354 Reviewed-by: Christian Stenger --- src/plugins/texteditor/codeassist/codeassistant.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/texteditor/codeassist/codeassistant.cpp b/src/plugins/texteditor/codeassist/codeassistant.cpp index 815be89bbaa..05f3c8ae17b 100644 --- a/src/plugins/texteditor/codeassist/codeassistant.cpp +++ b/src/plugins/texteditor/codeassist/codeassistant.cpp @@ -485,9 +485,10 @@ void CodeAssistantPrivate::destroyContext() if (isWaitingForProposal()) { cancelCurrentRequest(); - } else if (isDisplayingProposal()) { + } else if (m_proposalWidget) { m_editorWidget->keepAutoCompletionHighlight(false); - m_proposalWidget->closeProposal(); + if (m_proposalWidget->isVisible()) + m_proposalWidget->closeProposal(); disconnect(m_proposalWidget, &QObject::destroyed, this, &CodeAssistantPrivate::finalizeProposal); finalizeProposal(); From f220cb0e23729ddccf52c25dae4e4696641bc62d Mon Sep 17 00:00:00 2001 From: David Schulz Date: Thu, 15 Oct 2020 08:52:48 +0200 Subject: [PATCH 07/22] Revert "Editor: Make line spacing adjustable" This does not work with text wrapping since there are multiple QTextLines inside a block but we can not adjust the line hight inside a block. This needs to be addressed inside Qt. This reverts commit dc64f3207bdf6c0d295859e47791cb8193e67f4e. Change-Id: If6c28056da9891eeeb75f5939a42f08360013a80 Reviewed-by: Christian Stenger --- dist/changes-4.14.0.md | 2 - src/plugins/fakevim/fakevimplugin.cpp | 2 +- src/plugins/texteditor/fontsettings.cpp | 80 ++++------- src/plugins/texteditor/fontsettings.h | 7 - src/plugins/texteditor/fontsettingspage.cpp | 16 +-- src/plugins/texteditor/fontsettingspage.ui | 125 ++++++------------ src/plugins/texteditor/textdocumentlayout.cpp | 8 -- src/plugins/texteditor/texteditor.cpp | 45 +++---- 8 files changed, 86 insertions(+), 199 deletions(-) diff --git a/dist/changes-4.14.0.md b/dist/changes-4.14.0.md index 0f9603fcb3d..3cc8c567eca 100644 --- a/dist/changes-4.14.0.md +++ b/dist/changes-4.14.0.md @@ -24,8 +24,6 @@ Help Editing ------- -* Added option to adjust line spacing (QTCREATORBUG-13727) - ### C++ * Added refactoring action that creates getters and setters for all class members diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index aa0976c5242..e3499193725 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -324,7 +324,7 @@ private: { QTextCursor tc = m_editor->textCursor(); m_currentPos = tc.position(); - m_lineSpacing = m_editor->document()->documentLayout()->blockBoundingRect(tc.block()).height(); + m_lineSpacing = m_editor->cursorRect(tc).height(); setFont(m_editor->extraArea()->font()); // Follow geometry of normal line numbers if visible, diff --git a/src/plugins/texteditor/fontsettings.cpp b/src/plugins/texteditor/fontsettings.cpp index 26d3d041942..d74a13b2cc5 100644 --- a/src/plugins/texteditor/fontsettings.cpp +++ b/src/plugins/texteditor/fontsettings.cpp @@ -45,7 +45,6 @@ static const char fontFamilyKey[] = "FontFamily"; static const char fontSizeKey[] = "FontSize"; static const char fontZoomKey[] = "FontZoom"; -static const char lineSpacingKey[] = "LineSpacing"; static const char antialiasKey[] = "FontAntialias"; static const char schemeFileNamesKey[] = "ColorSchemes"; @@ -57,13 +56,11 @@ static const bool DEFAULT_ANTIALIAS = true; namespace TextEditor { // -- FontSettings -FontSettings::FontSettings() - : m_family(defaultFixedFontFamily()) - , m_fontSize(defaultFontSize()) - , m_fontZoom(100) - , m_lineSpacing(100) - , m_antialias(DEFAULT_ANTIALIAS) - , m_lineSpacingCache(0) +FontSettings::FontSettings() : + m_family(defaultFixedFontFamily()), + m_fontSize(defaultFontSize()), + m_fontZoom(100), + m_antialias(DEFAULT_ANTIALIAS) { } @@ -72,10 +69,10 @@ void FontSettings::clear() m_family = defaultFixedFontFamily(); m_fontSize = defaultFontSize(); m_fontZoom = 100; - m_lineSpacing = 100; m_antialias = DEFAULT_ANTIALIAS; m_scheme.clear(); - clearCaches(); + m_formatCache.clear(); + m_textCharFormatCache.clear(); } static QString settingsGroup() @@ -92,12 +89,9 @@ void FontSettings::toSettings(QSettings *s) const if (m_fontSize != defaultFontSize() || s->contains(QLatin1String(fontSizeKey))) s->setValue(QLatin1String(fontSizeKey), m_fontSize); - if (m_fontZoom != 100 || s->contains(QLatin1String(fontZoomKey))) + if (m_fontZoom!= 100 || s->contains(QLatin1String(fontZoomKey))) s->setValue(QLatin1String(fontZoomKey), m_fontZoom); - if (m_lineSpacing != 100 || s->contains(QLatin1String(lineSpacingKey))) - s->setValue(QLatin1String(lineSpacingKey), m_lineSpacing); - if (m_antialias != DEFAULT_ANTIALIAS || s->contains(QLatin1String(antialiasKey))) s->setValue(QLatin1String(antialiasKey), m_antialias); @@ -122,8 +116,7 @@ bool FontSettings::fromSettings(const FormatDescriptions &descriptions, const QS m_family = s->value(group + QLatin1String(fontFamilyKey), defaultFixedFontFamily()).toString(); m_fontSize = s->value(group + QLatin1String(fontSizeKey), m_fontSize).toInt(); - m_fontZoom = s->value(group + QLatin1String(fontZoomKey), m_fontZoom).toInt(); - m_lineSpacing = s->value(group + QLatin1String(lineSpacingKey), m_lineSpacing).toInt(); + m_fontZoom= s->value(group + QLatin1String(fontZoomKey), m_fontZoom).toInt(); m_antialias = s->value(group + QLatin1String(antialiasKey), DEFAULT_ANTIALIAS).toBool(); if (s->contains(group + QLatin1String(schemeFileNamesKey))) { @@ -141,12 +134,11 @@ bool FontSettings::fromSettings(const FormatDescriptions &descriptions, const QS bool FontSettings::equals(const FontSettings &f) const { return m_family == f.m_family - && m_schemeFileName == f.m_schemeFileName - && m_fontSize == f.m_fontSize - && m_lineSpacing == f.m_lineSpacing - && m_fontZoom == f.m_fontZoom - && m_antialias == f.m_antialias - && m_scheme == f.m_scheme; + && m_schemeFileName == f.m_schemeFileName + && m_fontSize == f.m_fontSize + && m_fontZoom == f.m_fontZoom + && m_antialias == f.m_antialias + && m_scheme == f.m_scheme; } uint qHash(const TextStyle &textStyle) @@ -280,13 +272,6 @@ void FontSettings::addMixinStyle(QTextCharFormat &textCharFormat, }; } -void FontSettings::clearCaches() -{ - m_formatCache.clear(); - m_textCharFormatCache.clear(); - m_lineSpacingCache = 0; -} - QTextCharFormat FontSettings::toTextCharFormat(TextStyles textStyles) const { auto textCharFormatIterator = m_textCharFormatCache.find(textStyles); @@ -327,7 +312,8 @@ QString FontSettings::family() const void FontSettings::setFamily(const QString &family) { m_family = family; - clearCaches(); + m_formatCache.clear(); + m_textCharFormatCache.clear(); } /** @@ -341,7 +327,8 @@ int FontSettings::fontSize() const void FontSettings::setFontSize(int size) { m_fontSize = size; - clearCaches(); + m_formatCache.clear(); + m_textCharFormatCache.clear(); } /** @@ -357,28 +344,6 @@ void FontSettings::setFontZoom(int zoom) m_fontZoom = zoom; m_formatCache.clear(); m_textCharFormatCache.clear(); - m_lineSpacingCache = 0; -} - -qreal FontSettings::lineSpacing() const -{ - if (qFuzzyIsNull(m_lineSpacingCache)) { - auto currentFont = font(); - currentFont.setPointSize(m_fontSize * m_fontZoom / 100); - m_lineSpacingCache = QFontMetricsF(currentFont).lineSpacing() / 100 * m_lineSpacing; - } - return m_lineSpacingCache; -} - -int FontSettings::relativeLineSpacing() const -{ - return m_lineSpacing; -} - -void FontSettings::setRelativeLineSpacing(int relativeLineSpacing) -{ - m_lineSpacing = relativeLineSpacing; - m_lineSpacingCache = 0; } QFont FontSettings::font() const @@ -399,7 +364,8 @@ bool FontSettings::antialias() const void FontSettings::setAntialias(bool antialias) { m_antialias = antialias; - clearCaches(); + m_formatCache.clear(); + m_textCharFormatCache.clear(); } /** @@ -436,7 +402,8 @@ void FontSettings::setColorSchemeFileName(const QString &fileName) bool FontSettings::loadColorScheme(const QString &fileName, const FormatDescriptions &descriptions) { - clearCaches(); + m_formatCache.clear(); + m_textCharFormatCache.clear(); bool loaded = true; m_schemeFileName = fileName; @@ -492,7 +459,8 @@ const ColorScheme &FontSettings::colorScheme() const void FontSettings::setColorScheme(const ColorScheme &scheme) { m_scheme = scheme; - clearCaches(); + m_formatCache.clear(); + m_textCharFormatCache.clear(); } static QString defaultFontFamily() diff --git a/src/plugins/texteditor/fontsettings.h b/src/plugins/texteditor/fontsettings.h index 0fbc80e15d4..9447141434c 100644 --- a/src/plugins/texteditor/fontsettings.h +++ b/src/plugins/texteditor/fontsettings.h @@ -75,10 +75,6 @@ public: int fontZoom() const; void setFontZoom(int zoom); - qreal lineSpacing() const; - int relativeLineSpacing() const; - void setRelativeLineSpacing(int relativeLineSpacing); - QFont font() const; bool antialias() const; @@ -104,19 +100,16 @@ public: private: void addMixinStyle(QTextCharFormat &textCharFormat, const MixinTextStyles &mixinStyles) const; - void clearCaches(); private: QString m_family; QString m_schemeFileName; int m_fontSize; int m_fontZoom; - int m_lineSpacing; bool m_antialias; ColorScheme m_scheme; mutable QHash m_formatCache; mutable QHash m_textCharFormatCache; - mutable qreal m_lineSpacingCache; }; inline bool operator==(const FontSettings &f1, const FontSettings &f2) { return f1.equals(f2); } diff --git a/src/plugins/texteditor/fontsettingspage.cpp b/src/plugins/texteditor/fontsettingspage.cpp index 41450ec8cfe..0e35cade04a 100644 --- a/src/plugins/texteditor/fontsettingspage.cpp +++ b/src/plugins/texteditor/fontsettingspage.cpp @@ -31,9 +31,9 @@ #include #include +#include #include #include -#include #include #include @@ -128,11 +128,6 @@ public: m_ui.antialias->setChecked(m_value.antialias()); m_ui.zoomSpinBox->setValue(m_value.fontZoom()); - m_ui.lineSpacingSpinBox->setValue(m_value.relativeLineSpacing()); - m_ui.lineSpacingWarningLabel->setPixmap(Utils::Icons::WARNING.pixmap()); - m_ui.lineSpacingWarningLabel->setToolTip(tr("A line spacing less than 100% can result in " - "overlapping and misaligned graphics.")); - m_ui.lineSpacingWarningLabel->setVisible(m_value.relativeLineSpacing() < 100); m_ui.schemeEdit->setFormatDescriptions(fd); m_ui.schemeEdit->setBaseFont(m_value.font()); @@ -148,8 +143,6 @@ public: this, &FontSettingsPageWidget::fontSizeSelected); connect(m_ui.zoomSpinBox, QOverload::of(&QSpinBox::valueChanged), this, &FontSettingsPageWidget::fontZoomChanged); - connect(m_ui.lineSpacingSpinBox, QOverload::of(&QSpinBox::valueChanged), - this, &FontSettingsPageWidget::lineSpacingChanged); connect(m_ui.antialias, &QCheckBox::toggled, this, &FontSettingsPageWidget::antialiasChanged); connect(m_ui.schemeComboBox, @@ -173,7 +166,6 @@ public: void fontSelected(const QFont &font); void fontSizeSelected(int index); void fontZoomChanged(); - void lineSpacingChanged(const int &value); void antialiasChanged(); void colorSchemeSelected(int index); void openCopyColorSchemeDialog(); @@ -425,12 +417,6 @@ void FontSettingsPageWidget::fontZoomChanged() m_value.setFontZoom(m_ui.zoomSpinBox->value()); } -void FontSettingsPageWidget::lineSpacingChanged(const int &value) -{ - m_value.setRelativeLineSpacing(value); - m_ui.lineSpacingWarningLabel->setVisible(value < 100); -} - void FontSettingsPageWidget::antialiasChanged() { m_value.setAntialias(m_ui.antialias->isChecked()); diff --git a/src/plugins/texteditor/fontsettingspage.ui b/src/plugins/texteditor/fontsettingspage.ui index da8a9fa907e..5c61c007385 100644 --- a/src/plugins/texteditor/fontsettingspage.ui +++ b/src/plugins/texteditor/fontsettingspage.ui @@ -6,7 +6,7 @@ 0 0 - 752 + 639 306 @@ -17,23 +17,40 @@ Font - - + + - 1 + 0 0 - - true + + Size: - - - + + + Zoom: + + + + + + + + 0 + 0 + + + + Family: + + + + Qt::Horizontal @@ -49,7 +66,7 @@ - + Qt::Horizontal @@ -62,19 +79,6 @@ - - - - - 0 - 0 - - - - Size: - - - @@ -82,32 +86,6 @@ - - - - % - - - 10 - - - 3000 - - - 10 - - - 100 - - - - - - - Zoom: - - - @@ -124,61 +102,41 @@ - - + + % - 50 + 10 3000 + + 10 + 100 - - + + + + + - 0 + 1 0 - - Family: + + true - - - - Line spacing: - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 20 - 20 - - - - - - - @@ -242,7 +200,6 @@ fontComboBox sizeComboBox zoomSpinBox - lineSpacingSpinBox antialias schemeComboBox copyButton diff --git a/src/plugins/texteditor/textdocumentlayout.cpp b/src/plugins/texteditor/textdocumentlayout.cpp index 70b63e0303b..a2f292e9c71 100644 --- a/src/plugins/texteditor/textdocumentlayout.cpp +++ b/src/plugins/texteditor/textdocumentlayout.cpp @@ -24,13 +24,8 @@ ****************************************************************************/ #include "textdocumentlayout.h" - -#include "fontsettings.h" #include "textdocument.h" -#include "texteditorsettings.h" - #include - #include namespace TextEditor { @@ -630,9 +625,6 @@ void TextDocumentLayout::updateMarksBlock(const QTextBlock &block) QRectF TextDocumentLayout::blockBoundingRect(const QTextBlock &block) const { QRectF boundingRect = QPlainTextDocumentLayout::blockBoundingRect(block); - if (boundingRect.isNull()) - return boundingRect; - boundingRect.setHeight(TextEditorSettings::fontSettings().lineSpacing()); if (TextBlockUserData *userData = textUserData(block)) boundingRect.adjust(0, 0, 0, userData->additionalAnnotationHeight()); return boundingRect; diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 516b82ac724..ec634b0e85c 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -1107,9 +1107,9 @@ void TextEditorWidget::print(QPrinter *printer) delete dlg; } -static int foldBoxWidth() +static int foldBoxWidth(const QFontMetrics &fm) { - const int lineSpacing = TextEditorSettings::fontSettings().lineSpacing(); + const int lineSpacing = fm.lineSpacing(); return lineSpacing + lineSpacing % 2 + 1; } @@ -3606,9 +3606,9 @@ QRect TextEditorWidgetPrivate::foldBox() QRectF br = q->blockBoundingGeometry(begin).translated(q->contentOffset()); QRectF er = q->blockBoundingGeometry(end).translated(q->contentOffset()); - return QRect(m_extraArea->width() - foldBoxWidth(), + return QRect(m_extraArea->width() - foldBoxWidth(q->fontMetrics()), int(br.top()), - foldBoxWidth(), + foldBoxWidth(q->fontMetrics()), int(er.bottom() - br.top())); } @@ -4089,9 +4089,7 @@ bool TextEditorWidgetPrivate::updateAnnotationBounds(TextBlockUserData *blockUse { const bool additionalHeightNeeded = annotationsVisible && m_displaySettings.m_annotationAlignment == AnnotationAlignment::BetweenLines; - const int additionalHeight = additionalHeightNeeded - ? TextEditorSettings::fontSettings().lineSpacing() - : 0; + const int additionalHeight = additionalHeightNeeded ? q->fontMetrics().lineSpacing() : 0; if (blockUserData->additionalAnnotationHeight() == additionalHeight) return false; blockUserData->setAdditionalAnnotationHeight(additionalHeight); @@ -4132,7 +4130,7 @@ void TextEditorWidgetPrivate::updateLineAnnotation(const PaintEventData &data, return mark1->priority() > mark2->priority(); }); - const qreal itemOffset = blockData.boundingRect.height(); + const qreal itemOffset = q->fontMetrics().lineSpacing(); const qreal initialOffset = m_displaySettings.m_annotationAlignment == AnnotationAlignment::BetweenLines ? itemOffset / 2 : itemOffset * 2; const qreal minimalContentWidth = q->fontMetrics().horizontalAdvance('X') * m_displaySettings.m_minimalAnnotationContent; @@ -5027,7 +5025,7 @@ int TextEditorWidget::extraAreaWidth(int *markWidthPtr) const int markWidth = 0; if (d->m_marksVisible) { - markWidth += documentLayout->maxMarkWidthFactor * TextEditorSettings::fontSettings().lineSpacing() + 2; + markWidth += documentLayout->maxMarkWidthFactor * fm.lineSpacing() + 2; // if (documentLayout->doubleMarkCount) // markWidth += fm.lineSpacing() / 3; @@ -5042,7 +5040,7 @@ int TextEditorWidget::extraAreaWidth(int *markWidthPtr) const space += 4; if (d->m_codeFoldingVisible) - space += foldBoxWidth(); + space += foldBoxWidth(fm); if (viewportMargins() != QMargins{isLeftToRight() ? space : 0, 0, isLeftToRight() ? 0 : space, 0}) d->slotUpdateExtraAreaWidth(space); @@ -5068,9 +5066,9 @@ struct Internal::ExtraAreaPaintEventData , selectionStart(editor->textCursor().selectionStart()) , selectionEnd(editor->textCursor().selectionEnd()) , fontMetrics(d->m_extraArea->font()) - , lineSpacing(TextEditorSettings::fontSettings().lineSpacing()) + , lineSpacing(fontMetrics.lineSpacing()) , markWidth(d->m_marksVisible ? lineSpacing : 0) - , collapseColumnWidth(d->m_codeFoldingVisible ? foldBoxWidth() : 0) + , collapseColumnWidth(d->m_codeFoldingVisible ? foldBoxWidth(fontMetrics) : 0) , extraAreaWidth(d->m_extraArea->width() - collapseColumnWidth) , currentLineNumberFormat( editor->textDocument()->fontSettings().toTextCharFormat(C_CURRENT_LINE_NUMBER)) @@ -5194,7 +5192,7 @@ void TextEditorWidgetPrivate::paintCodeFolding(QPainter &painter, bool hovered = blockNumber >= extraAreaHighlightFoldBlockNumber && blockNumber <= extraAreaHighlightFoldEndBlockNumber; - int boxWidth = foldBoxWidth(); + int boxWidth = foldBoxWidth(data.fontMetrics); if (hovered) { int itop = qRound(blockBoundingRect.top()); int ibottom = qRound(blockBoundingRect.bottom()); @@ -5567,10 +5565,8 @@ void TextEditorWidget::mouseMoveEvent(QMouseEvent *e) if (cursor.positionInBlock() == cursor.block().length()-1) column += (e->pos().x() - cursorRect().center().x()) / QFontMetricsF(font()).horizontalAdvance(QLatin1Char(' ')); int block = cursor.blockNumber(); - if (block == blockCount() - 1) { - block += (e->pos().y() - cursorRect().center().y()) - / TextEditorSettings::fontSettings().lineSpacing(); - } + if (block == blockCount() - 1) + block += (e->pos().y() - cursorRect().center().y()) / QFontMetricsF(font()).lineSpacing(); d->enableBlockSelection(block, column, block, column); } } else { @@ -5620,11 +5616,8 @@ void TextEditorWidget::mousePressEvent(QMouseEvent *e) if (cursor.positionInBlock() == cursor.block().length()-1) column += (e->pos().x() - cursorRect(cursor).center().x()) / QFontMetricsF(font()).horizontalAdvance(QLatin1Char(' ')); int block = cursor.blockNumber(); - if (block == blockCount() - 1) { - block += (e->pos().y() - cursorRect(cursor).center().y()) - / TextEditorSettings::fontSettings().lineSpacing(); - } - + if (block == blockCount() - 1) + block += (e->pos().y() - cursorRect(cursor).center().y()) / QFontMetricsF(font()).lineSpacing(); if (d->m_inBlockSelectionMode) { d->m_blockSelection.positionBlock = block; d->m_blockSelection.positionColumn = column; @@ -5798,7 +5791,7 @@ void TextEditorWidget::updateFoldingHighlight(const QPoint &pos) const int highlightBlockNumber = d->extraAreaHighlightFoldedBlockNumber; d->extraAreaHighlightFoldedBlockNumber = -1; - if (pos.x() > extraArea()->width() - foldBoxWidth()) { + if (pos.x() > extraArea()->width() - foldBoxWidth(fontMetrics())) { d->extraAreaHighlightFoldedBlockNumber = cursor.blockNumber(); } else if (d->m_displaySettings.m_highlightBlocks) { QTextCursor cursor = textCursor(); @@ -5841,7 +5834,7 @@ void TextEditorWidget::extraAreaMouseEvent(QMouseEvent *e) int dist = (e->pos() - d->m_markDragStart).manhattanLength(); if (dist > QApplication::startDragDistance()) { d->m_markDragging = true; - const int height = TextEditorSettings::fontSettings().lineSpacing() - 1; + const int height = fontMetrics().lineSpacing() - 1; const int width = int(.5 + height * d->m_dragMark->widthFactor()); d->m_markDragCursor = QCursor(d->m_dragMark->icon().pixmap({height, width})); d->m_dragMark->setVisible(false); @@ -5859,7 +5852,7 @@ void TextEditorWidget::extraAreaMouseEvent(QMouseEvent *e) if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonDblClick) { if (e->button() == Qt::LeftButton) { - int boxWidth = foldBoxWidth(); + int boxWidth = foldBoxWidth(fontMetrics()); if (d->m_codeFoldingVisible && e->pos().x() > extraArea()->width() - boxWidth) { if (!cursor.block().next().isVisible()) { d->toggleBlockVisible(cursor.block()); @@ -6386,7 +6379,7 @@ void TextEditorWidgetPrivate::adjustScrollBarRanges() { if (!m_highlightScrollBarController) return; - const double lineSpacing = TextEditorSettings::fontSettings().lineSpacing(); + const double lineSpacing = QFontMetricsF(q->font()).lineSpacing(); if (lineSpacing == 0) return; From ab8cda95a6d4f57ade6adc704b89e284e7daaeea Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Mon, 19 Oct 2020 22:41:49 +0200 Subject: [PATCH 08/22] ClangRefactoringBackend: Fix build with Clang 11 Change-Id: Id03b0771e242534943e062dee3e63022ec9d9ce8 Reviewed-by: Eike Ziller --- src/tools/clangrefactoringbackend/source/sourcelocationsutils.h | 1 + src/tools/clangrefactoringbackend/source/symbolsvisitorbase.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/tools/clangrefactoringbackend/source/sourcelocationsutils.h b/src/tools/clangrefactoringbackend/source/sourcelocationsutils.h index 45bc71fdb45..c4fc1bf645b 100644 --- a/src/tools/clangrefactoringbackend/source/sourcelocationsutils.h +++ b/src/tools/clangrefactoringbackend/source/sourcelocationsutils.h @@ -29,6 +29,7 @@ #include #include +#include #include #include #include diff --git a/src/tools/clangrefactoringbackend/source/symbolsvisitorbase.h b/src/tools/clangrefactoringbackend/source/symbolsvisitorbase.h index 7b63cb223ec..d5a609315ec 100644 --- a/src/tools/clangrefactoringbackend/source/symbolsvisitorbase.h +++ b/src/tools/clangrefactoringbackend/source/symbolsvisitorbase.h @@ -34,6 +34,7 @@ #include #include +#include #include #include #include From 05ecdba5d8afac54909d194369c4a1bff76b89ac Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Tue, 20 Oct 2020 07:38:54 +0200 Subject: [PATCH 09/22] Tests: Fix compile and code Change-Id: I2f2a8a4ff9e7bcd3138b93b177e07f2aa3850fcb Reviewed-by: Thomas Hartmann --- tests/auto/qml/qmldesigner/coretests/coretests.pro | 1 + .../auto/qml/qmldesigner/testconnectionmanager.cpp | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/auto/qml/qmldesigner/coretests/coretests.pro b/tests/auto/qml/qmldesigner/coretests/coretests.pro index c179025da59..e94cddbd7d6 100644 --- a/tests/auto/qml/qmldesigner/coretests/coretests.pro +++ b/tests/auto/qml/qmldesigner/coretests/coretests.pro @@ -52,6 +52,7 @@ INCLUDEPATH += $$IDE_SOURCE_TREE/src/plugins/qmldesigner/components/propertyedit INCLUDEPATH += $$IDE_SOURCE_TREE/src/plugins/qmldesigner/components/debugview INCLUDEPATH += $$IDE_SOURCE_TREE/src/plugins/qmldesigner/components/edit3d INCLUDEPATH *= $$IDE_SOURCE_TREE/src/libs/3rdparty +INCLUDEPATH *= $$IDE_SOURCE_TREE/src/libs/sqlite include($$IDE_SOURCE_TREE/src/plugins/qmldesigner/designercore/designercore-lib.pri) diff --git a/tests/auto/qml/qmldesigner/testconnectionmanager.cpp b/tests/auto/qml/qmldesigner/testconnectionmanager.cpp index f637fb1f1ab..03a6d43346c 100644 --- a/tests/auto/qml/qmldesigner/testconnectionmanager.cpp +++ b/tests/auto/qml/qmldesigner/testconnectionmanager.cpp @@ -32,26 +32,26 @@ namespace QmlDesigner { TestConnectionManager::TestConnectionManager() { - m_connections.emplace_back("Editor", "editormode"); + connections().emplace_back("Editor", "editormode"); } void TestConnectionManager::writeCommand(const QVariant &command) { - TestConnectionManager::writeCommand(command); + ConnectionManager::writeCommand(command); - m_writeCommandCounter++; + writeCommandCounter()++; static int synchronizeId = 0; synchronizeId++; SynchronizeCommand synchronizeCommand(synchronizeId); - QLocalSocket *socket = m_connections.front().socket.get(); + QLocalSocket *socket = connections().front().socket.get(); - writeCommandToIODevice(QVariant::fromValue(synchronizeCommand), socket, m_writeCommandCounter); - m_writeCommandCounter++; + writeCommandToIODevice(QVariant::fromValue(synchronizeCommand), socket, writeCommandCounter()); + writeCommandCounter()++; while (socket->waitForReadyRead(100)) { - readDataStream(m_connections.front()); + readDataStream(connections().front()); if (m_synchronizeId == synchronizeId) return; } From 83da45adde46df9c7762dc0004c7b02154876548 Mon Sep 17 00:00:00 2001 From: Mahmoud Badri Date: Mon, 19 Oct 2020 12:03:46 +0300 Subject: [PATCH 10/22] QmlDesigner: Remove AnnotationTool Remove AnnotationTool from FormEditor's selected item's tools. Change-Id: I797ed4002d14c04956aaeb5d779f1cf3f326f849 Fixes: QDS-2970 Reviewed-by: Miikka Heikkinen Reviewed-by: Aleksei German Reviewed-by: Thomas Hartmann --- share/qtcreator/translations/qtcreator_ru.ts | 14 - src/plugins/qmldesigner/CMakeLists.txt | 1 - .../annotationeditor/annotationeditor.pri | 2 - .../annotationeditor/annotationtool.cpp | 259 ------------------ .../annotationeditor/annotationtool.h | 93 ------- src/plugins/qmldesigner/qmldesignerplugin.cpp | 2 - src/plugins/qmldesigner/qmldesignerplugin.qbs | 2 - 7 files changed, 373 deletions(-) delete mode 100644 src/plugins/qmldesigner/components/annotationeditor/annotationtool.cpp delete mode 100644 src/plugins/qmldesigner/components/annotationeditor/annotationtool.h diff --git a/share/qtcreator/translations/qtcreator_ru.ts b/share/qtcreator/translations/qtcreator_ru.ts index 50a2531f9f7..343f1c468e4 100644 --- a/share/qtcreator/translations/qtcreator_ru.ts +++ b/share/qtcreator/translations/qtcreator_ru.ts @@ -2554,13 +2554,6 @@ To hide a sticky splash screen, invoke QtAndroid::hideSplashScreen(). Анимируемые свойства. - - AnnotationToolAction - - Edit Annotation - Изменить аннотацию - - Application @@ -39440,13 +39433,6 @@ Neither the path to the library nor the path to its includes is added to the .pr Аннотация - - QmlDesigner::AnnotationTool - - Annotation Tool - Аннотация - - QmlDesigner::AssetExportDialog diff --git a/src/plugins/qmldesigner/CMakeLists.txt b/src/plugins/qmldesigner/CMakeLists.txt index ca98f2c4242..31d5b74dae9 100644 --- a/src/plugins/qmldesigner/CMakeLists.txt +++ b/src/plugins/qmldesigner/CMakeLists.txt @@ -627,7 +627,6 @@ extend_qtc_plugin(QmlDesigner annotationeditordialog.cpp annotationeditordialog.h annotationeditordialog.ui globalannotationeditordialog.cpp globalannotationeditordialog.h globalannotationeditordialog.ui annotationeditor.cpp annotationeditor.h - annotationtool.cpp annotationtool.h globalannotationeditor.cpp globalannotationeditor.h ) diff --git a/src/plugins/qmldesigner/components/annotationeditor/annotationeditor.pri b/src/plugins/qmldesigner/components/annotationeditor/annotationeditor.pri index e597e6862cd..b1773c2dcf6 100644 --- a/src/plugins/qmldesigner/components/annotationeditor/annotationeditor.pri +++ b/src/plugins/qmldesigner/components/annotationeditor/annotationeditor.pri @@ -1,11 +1,9 @@ -HEADERS += $$PWD/annotationtool.h HEADERS += $$PWD/annotationcommenttab.h HEADERS += $$PWD/annotationeditordialog.h HEADERS += $$PWD/annotationeditor.h HEADERS += $$PWD/globalannotationeditor.h HEADERS += $$PWD/globalannotationeditordialog.h -SOURCES += $$PWD/annotationtool.cpp SOURCES += $$PWD/annotationcommenttab.cpp SOURCES += $$PWD/annotationeditordialog.cpp SOURCES += $$PWD/annotationeditor.cpp diff --git a/src/plugins/qmldesigner/components/annotationeditor/annotationtool.cpp b/src/plugins/qmldesigner/components/annotationeditor/annotationtool.cpp deleted file mode 100644 index 9db5d0d81c3..00000000000 --- a/src/plugins/qmldesigner/components/annotationeditor/annotationtool.cpp +++ /dev/null @@ -1,259 +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. -** -****************************************************************************/ - -#include "annotationtool.h" - -#include "formeditorscene.h" -#include "formeditorview.h" -#include "formeditorwidget.h" -#include "itemutilfunctions.h" -#include "formeditoritem.h" - -#include "nodemetainfo.h" -#include "qmlitemnode.h" -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace QmlDesigner { - -class AnnotationToolAction : public AbstractAction -{ -public: - AnnotationToolAction() : AbstractAction(QCoreApplication::translate("AnnotationToolAction","Edit Annotation")) - { - } - - QByteArray category() const override - { - return QByteArray(); - } - - QByteArray menuId() const override - { - return "AnnotationTool"; - } - - int priority() const override - { - return CustomActionsPriority + 5; - } - - Type type() const override - { - return FormEditorAction; - } - -protected: - bool isVisible(const SelectionContext &selectionContext) const override - { - return selectionContext.singleNodeIsSelected(); - } - - bool isEnabled(const SelectionContext &selectionContext) const override - { - return isVisible(selectionContext); - } -}; - -AnnotationTool::AnnotationTool() -{ - auto annotationToolAction = new AnnotationToolAction; - QmlDesignerPlugin::instance()->designerActionManager().addDesignerAction(annotationToolAction); - connect(annotationToolAction->action(), &QAction::triggered, [=]() { - view()->changeCurrentToolTo(this); - }); -} - -AnnotationTool::~AnnotationTool() = default; - -void AnnotationTool::clear() -{ - if (m_annotationEditor) - m_annotationEditor->deleteLater(); - - AbstractFormEditorTool::clear(); -} - -void AnnotationTool::mousePressEvent(const QList &itemList, - QGraphicsSceneMouseEvent *event) -{ - AbstractFormEditorTool::mousePressEvent(itemList, event); -} - -void AnnotationTool::mouseMoveEvent(const QList & /*itemList*/, - QGraphicsSceneMouseEvent * /*event*/) -{ -} - -void AnnotationTool::hoverMoveEvent(const QList & /*itemList*/, - QGraphicsSceneMouseEvent * /*event*/) -{ -} - -void AnnotationTool::keyPressEvent(QKeyEvent * /*keyEvent*/) -{ -} - -void AnnotationTool::keyReleaseEvent(QKeyEvent * /*keyEvent*/) -{ -} - -void AnnotationTool::dragLeaveEvent(const QList &/*itemList*/, QGraphicsSceneDragDropEvent * /*event*/) -{ -} - -void AnnotationTool::dragMoveEvent(const QList &/*itemList*/, QGraphicsSceneDragDropEvent * /*event*/) -{ -} - -void AnnotationTool::mouseReleaseEvent(const QList &itemList, - QGraphicsSceneMouseEvent *event) -{ - AbstractFormEditorTool::mouseReleaseEvent(itemList, event); -} - - -void AnnotationTool::mouseDoubleClickEvent(const QList &itemList, QGraphicsSceneMouseEvent *event) -{ - AbstractFormEditorTool::mouseDoubleClickEvent(itemList, event); -} - -void AnnotationTool::itemsAboutToRemoved(const QList &removedItemList) -{ - if (m_annotationEditor.isNull()) - return; - - if (removedItemList.contains(m_formEditorItem)) - view()->changeToSelectionTool(); -} - -void AnnotationTool::selectedItemsChanged(const QList &itemList) -{ - if (!itemList.isEmpty()) { - m_formEditorItem = itemList.constFirst(); - - ModelNode itemModelNode = m_formEditorItem->qmlItemNode().modelNode(); - m_oldCustomId = itemModelNode.customId(); - m_oldAnnotation = itemModelNode.annotation(); - - if (m_annotationEditor.isNull()) { - m_annotationEditor = new AnnotationEditorDialog(view()->formEditorWidget()->parentWidget(), - itemModelNode.displayName(), - m_oldCustomId, m_oldAnnotation); - - connect(m_annotationEditor, &AnnotationEditorDialog::accepted, this, &AnnotationTool::annotationDialogAccepted); - connect(m_annotationEditor, &QDialog::rejected, this, &AnnotationTool::annotationDialogRejected); - - m_annotationEditor->show(); - m_annotationEditor->raise(); - } - } else { - view()->changeToSelectionTool(); - } -} - -void AnnotationTool::instancesCompleted(const QList & /*itemList*/) -{ -} - -void AnnotationTool::instancesParentChanged(const QList & /*itemList*/) -{ -} - -void AnnotationTool::instancePropertyChange(const QList > & /*propertyList*/) -{ -} - -void AnnotationTool::formEditorItemsChanged(const QList & /*itemList*/) -{ -} - -int AnnotationTool::wantHandleItem(const ModelNode & /*modelNode*/) const -{ - return 5; -} - -QString AnnotationTool::name() const -{ - return tr("Annotation Tool"); -} - -void AnnotationTool::annotationDialogAccepted() -{ - if (m_annotationEditor) { - saveNewCustomId(m_annotationEditor->customId()); - saveNewAnnotation(m_annotationEditor->annotation()); - - m_annotationEditor->close(); - m_annotationEditor->deleteLater(); - } - - m_annotationEditor = nullptr; - - view()->changeToSelectionTool(); -} - -void AnnotationTool::saveNewCustomId(const QString &customId) -{ - if (m_formEditorItem) { - m_oldCustomId = customId; - m_formEditorItem->qmlItemNode().modelNode().setCustomId(customId); - } -} - -void AnnotationTool::saveNewAnnotation(const Annotation &annotation) -{ - if (m_formEditorItem) { - if (annotation.comments().isEmpty()) - m_formEditorItem->qmlItemNode().modelNode().removeAnnotation(); - else - m_formEditorItem->qmlItemNode().modelNode().setAnnotation(annotation); - - m_oldAnnotation = annotation; - } -} - -void AnnotationTool::annotationDialogRejected() -{ - if (m_annotationEditor) { - m_annotationEditor->close(); - m_annotationEditor->deleteLater(); - } - - m_annotationEditor = nullptr; - - view()->changeToSelectionTool(); -} - -} diff --git a/src/plugins/qmldesigner/components/annotationeditor/annotationtool.h b/src/plugins/qmldesigner/components/annotationeditor/annotationtool.h deleted file mode 100644 index 0073286dd62..00000000000 --- a/src/plugins/qmldesigner/components/annotationeditor/annotationtool.h +++ /dev/null @@ -1,93 +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. -** -****************************************************************************/ - -#pragma once - -#include "annotation.h" -#include "annotationeditordialog.h" -#include "abstractcustomtool.h" -#include "selectionindicator.h" - -#include -#include -#include - -namespace QmlDesigner { - -class AnnotationTool : public QObject, public AbstractCustomTool -{ - Q_OBJECT -public: - AnnotationTool(); - ~AnnotationTool() override; - - void mousePressEvent(const QList &itemList, - QGraphicsSceneMouseEvent *event) override; - void mouseMoveEvent(const QList &itemList, - QGraphicsSceneMouseEvent *event) override; - void mouseReleaseEvent(const QList &itemList, - QGraphicsSceneMouseEvent *event) override; - void mouseDoubleClickEvent(const QList &itemList, - QGraphicsSceneMouseEvent *event) override; - void hoverMoveEvent(const QList &itemList, - QGraphicsSceneMouseEvent *event) override; - void keyPressEvent(QKeyEvent *event) override; - void keyReleaseEvent(QKeyEvent *keyEvent) override; - - void dragLeaveEvent(const QList &itemList, - QGraphicsSceneDragDropEvent * event) override; - void dragMoveEvent(const QList &itemList, - QGraphicsSceneDragDropEvent * event) override; - - void itemsAboutToRemoved(const QList &itemList) override; - - void selectedItemsChanged(const QList &itemList) override; //impl needed - - void instancesCompleted(const QList &itemList) override; - void instancesParentChanged(const QList &itemList) override; - void instancePropertyChange(const QList > &propertyList) override; - - void clear() override; - - void formEditorItemsChanged(const QList &itemList) override; - - int wantHandleItem(const ModelNode &modelNode) const override; - - QString name() const override; - -private: - void annotationDialogAccepted(); - void annotationDialogRejected(); - void saveNewCustomId(const QString &customId); - void saveNewAnnotation(const Annotation &annotation); - -private: - FormEditorItem *m_formEditorItem = nullptr; - QString m_oldCustomId; - Annotation m_oldAnnotation; - QPointer m_annotationEditor; -}; - -} diff --git a/src/plugins/qmldesigner/qmldesignerplugin.cpp b/src/plugins/qmldesigner/qmldesignerplugin.cpp index 3022bd80be5..938a718d7c4 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.cpp +++ b/src/plugins/qmldesigner/qmldesignerplugin.cpp @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -250,7 +249,6 @@ bool QmlDesignerPlugin::delayedInitialize() d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::SourceTool); d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::ColorTool); - d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::AnnotationTool); d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::TextTool); d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::PathTool); d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::TransitionTool); diff --git a/src/plugins/qmldesigner/qmldesignerplugin.qbs b/src/plugins/qmldesigner/qmldesignerplugin.qbs index 8dc09339034..c9b608ea397 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.qbs +++ b/src/plugins/qmldesigner/qmldesignerplugin.qbs @@ -712,8 +712,6 @@ Project { "annotationeditor/globalannotationeditordialog.cpp", "annotationeditor/globalannotationeditordialog.h", "annotationeditor/globalannotationeditordialog.ui", - "annotationeditor/annotationtool.cpp", - "annotationeditor/annotationtool.h", "bindingeditor/bindingeditor.cpp", "bindingeditor/bindingeditor.h", "bindingeditor/actioneditor.cpp", From 08d84a688a2cd2bac6076cef09af04c3f9d29b90 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 20 Oct 2020 09:03:35 +0200 Subject: [PATCH 11/22] Fix compilation of sdktool against old Qt versions Amends 6c5eaed92ca838e68745c71ee27adb754a496b8e Change-Id: Ia664ea16767e9787252ec529061c7d5f5d89a7de Reviewed-by: Christian Stenger --- src/libs/utils/stringutils.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libs/utils/stringutils.cpp b/src/libs/utils/stringutils.cpp index d8483df5525..9d179a9abd2 100644 --- a/src/libs/utils/stringutils.cpp +++ b/src/libs/utils/stringutils.cpp @@ -399,6 +399,9 @@ QString formatElapsedTime(qint64 elapsed) */ QString wildcardToRegularExpression(const QString &original) { +#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) + using qsizetype = int; +#endif const qsizetype wclen = original.size(); QString rx; rx.reserve(wclen + wclen / 16); @@ -455,6 +458,10 @@ QString wildcardToRegularExpression(const QString &original) } } +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) return QRegularExpression::anchoredPattern(rx); +#else + return "\\A" + rx + "\\z"; +#endif } } // namespace Utils From fb0db5c745bc6fe4885afd11750e267f89cf99da Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 19 Oct 2020 18:26:20 +0200 Subject: [PATCH 12/22] ProjectExplorer: Fix sorting predicate to have a strict weak order Fixes random crashes when opening the 'Manage session' dialog. Amends 8c0906e8fb632b82135a843657a1df9216a93c60 Fixes: QTCREATORBUG-24797 Change-Id: Ic3118163d1a9a10eacc1ea1cc90f54c86ac790d9 Reviewed-by: Eike Ziller --- src/plugins/projectexplorer/sessionmodel.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/plugins/projectexplorer/sessionmodel.cpp b/src/plugins/projectexplorer/sessionmodel.cpp index b0d847e7dfe..4cfa95eea54 100644 --- a/src/plugins/projectexplorer/sessionmodel.cpp +++ b/src/plugins/projectexplorer/sessionmodel.cpp @@ -183,10 +183,18 @@ void SessionModel::sort(int column, Qt::SortOrder order) beginResetModel(); const auto cmp = [column, order](const QString &s1, const QString &s2) { bool isLess; - if (column == 0) + if (column == 0) { + if (s1 == s2) + return false; isLess = s1 < s2; - else - isLess = SessionManager::sessionDateTime(s1) < SessionManager::sessionDateTime(s2); + } + else { + const auto s1time = SessionManager::sessionDateTime(s1); + const auto s2time = SessionManager::sessionDateTime(s2); + if (s1time == s2time) + return false; + isLess = s1time < s2time; + } if (order == Qt::DescendingOrder) isLess = !isLess; return isLess; From 3614ab81ce9726b17b0c725ff55e1ae5be3ab7d1 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 20 Oct 2020 11:05:46 +0200 Subject: [PATCH 13/22] QmlDesigner: Fix incorrect conversion between double and int/long And fix macOS build which complained that std::abs with doubles is ambiguous (between int and long and long long). Amends aaf564cab7cbb0a79c37098bd9642a72cef9a9ba Change-Id: I87d4453afa4dda676cc27c219d7dbfc22fcee70a Reviewed-by: Knud Dollereder Reviewed-by: Thomas Hartmann --- .../qmldesigner/components/curveeditor/curveeditorstyle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/qmldesigner/components/curveeditor/curveeditorstyle.h b/src/plugins/qmldesigner/components/curveeditor/curveeditorstyle.h index 854fabff23f..3eda30dfcdc 100644 --- a/src/plugins/qmldesigner/components/curveeditor/curveeditorstyle.h +++ b/src/plugins/qmldesigner/components/curveeditor/curveeditorstyle.h @@ -110,7 +110,7 @@ struct CurveEditorStyle static constexpr double defaultValueMin = -1.0; static constexpr double defaultValueMax = 1.0; - static double defaultValueRange() { return std::abs(defaultValueMin - defaultValueMax); } + static double defaultValueRange() { return std::fabs(defaultValueMin - defaultValueMax); } Shortcuts shortcuts; From 15c9de9251af76fdfd6798ad35d7d912deb99644 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Mon, 12 Oct 2020 19:50:24 +0200 Subject: [PATCH 14/22] Squish: Update tst_codepasting Change-Id: Ie908f0af267f420e107c06ae039bb085462f945d Reviewed-by: Christian Stenger --- tests/system/suite_tools/tst_codepasting/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system/suite_tools/tst_codepasting/test.py b/tests/system/suite_tools/tst_codepasting/test.py index a5441050a94..37b9832c3a1 100644 --- a/tests/system/suite_tools/tst_codepasting/test.py +++ b/tests/system/suite_tools/tst_codepasting/test.py @@ -239,7 +239,7 @@ def main(): clickButton(waitForObject(":*Qt Creator.Clear_QToolButton")) continue test.compare(filenameCombo.currentText, "%s: %s" % (protocol, pasteId), "Verify title of editor") - if protocol in (NAME_PBCOM, NAME_DPCOM) and pastedText.endswith("\n"): + if protocol in (NAME_DPCOM) and pastedText.endswith("\n"): pastedText = pastedText[:-1] test.compare(editor.plainText, pastedText, "Verify that pasted and fetched texts are the same") From 1a8c802f56ba5f701a38c45aff4107ce6a2d1a82 Mon Sep 17 00:00:00 2001 From: Mahmoud Badri Date: Tue, 20 Oct 2020 11:09:04 +0300 Subject: [PATCH 15/22] QmlDesigner: Remove Switchsplittabwidget Removed the unused class Switchsplittabwidget from the codebase. Change-Id: Idb0071d4e6bb54b6a08e6026f8768f9239a5c342 Reviewed-by: Thomas Hartmann --- src/plugins/qmldesigner/CMakeLists.txt | 1 - src/plugins/qmldesigner/designmodewidget.cpp | 1 - src/plugins/qmldesigner/designmodewidget.h | 3 - src/plugins/qmldesigner/qmldesignerplugin.pri | 2 - src/plugins/qmldesigner/qmldesignerplugin.qbs | 2 - .../qmldesigner/switchsplittabwidget.cpp | 212 ------------------ .../qmldesigner/switchsplittabwidget.h | 63 ------ 7 files changed, 284 deletions(-) delete mode 100644 src/plugins/qmldesigner/switchsplittabwidget.cpp delete mode 100644 src/plugins/qmldesigner/switchsplittabwidget.h diff --git a/src/plugins/qmldesigner/CMakeLists.txt b/src/plugins/qmldesigner/CMakeLists.txt index 31d5b74dae9..21b1c9cf647 100644 --- a/src/plugins/qmldesigner/CMakeLists.txt +++ b/src/plugins/qmldesigner/CMakeLists.txt @@ -29,7 +29,6 @@ add_qtc_plugin(QmlDesigner qmldesignerplugin.cpp qmldesignerplugin.h settingspage.cpp settingspage.h settingspage.ui shortcutmanager.cpp shortcutmanager.h - switchsplittabwidget.cpp switchsplittabwidget.h designermcumanager.cpp designermcumanager.h EXPLICIT_MOC components/propertyeditor/propertyeditorvalue.h diff --git a/src/plugins/qmldesigner/designmodewidget.cpp b/src/plugins/qmldesigner/designmodewidget.cpp index 5b75ea7241e..2bb61467a91 100644 --- a/src/plugins/qmldesigner/designmodewidget.cpp +++ b/src/plugins/qmldesigner/designmodewidget.cpp @@ -24,7 +24,6 @@ ****************************************************************************/ #include "designmodewidget.h" -#include "switchsplittabwidget.h" #include diff --git a/src/plugins/qmldesigner/designmodewidget.h b/src/plugins/qmldesigner/designmodewidget.h index 67f8f3d554d..bf348d33006 100644 --- a/src/plugins/qmldesigner/designmodewidget.h +++ b/src/plugins/qmldesigner/designmodewidget.h @@ -50,7 +50,6 @@ namespace QmlDesigner { class ItemLibraryWidget; class CrumbleBar; class DocumentWarningWidget; -class SwitchSplitTabWidget; namespace Internal { @@ -103,8 +102,6 @@ private: // functions void aboutToShowWorkspaces(); private: // variables - SwitchSplitTabWidget* m_centralTabWidget = nullptr; - QPointer m_bottomSideBar; Core::EditorToolBar *m_toolBar; CrumbleBar *m_crumbleBar; diff --git a/src/plugins/qmldesigner/qmldesignerplugin.pri b/src/plugins/qmldesigner/qmldesignerplugin.pri index 8c99395c58d..b11ff7a53b1 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.pri +++ b/src/plugins/qmldesigner/qmldesignerplugin.pri @@ -2,7 +2,6 @@ HEADERS += $$PWD/qmldesignerconstants.h \ $$PWD/shortcutmanager.h \ $$PWD/qmldesignerplugin.h \ $$PWD/designmodewidget.h \ - $$PWD/switchsplittabwidget.h \ $$PWD/designersettings.h \ $$PWD/generateresource.h \ $$PWD/settingspage.h \ @@ -16,7 +15,6 @@ HEADERS += $$PWD/qmldesignerconstants.h \ SOURCES += $$PWD/qmldesignerplugin.cpp \ $$PWD/shortcutmanager.cpp \ $$PWD/designmodewidget.cpp \ - $$PWD/switchsplittabwidget.cpp \ $$PWD/designersettings.cpp \ $$PWD/generateresource.cpp \ $$PWD/settingspage.cpp \ diff --git a/src/plugins/qmldesigner/qmldesignerplugin.qbs b/src/plugins/qmldesigner/qmldesignerplugin.qbs index c9b608ea397..93cf6587cad 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.qbs +++ b/src/plugins/qmldesigner/qmldesignerplugin.qbs @@ -933,8 +933,6 @@ Project { "designmodecontext.h", "designmodewidget.cpp", "designmodewidget.h", - "switchsplittabwidget.cpp", - "switchsplittabwidget.h", "documentmanager.cpp", "documentmanager.h", "documentwarningwidget.cpp", diff --git a/src/plugins/qmldesigner/switchsplittabwidget.cpp b/src/plugins/qmldesigner/switchsplittabwidget.cpp deleted file mode 100644 index e30f4180cfe..00000000000 --- a/src/plugins/qmldesigner/switchsplittabwidget.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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. -** -****************************************************************************/ - -#include "switchsplittabwidget.h" -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace QmlDesigner { -SwitchSplitTabWidget::SwitchSplitTabWidget(QWidget *parent) - : QWidget(parent) - , m_splitter(new QSplitter) - , m_tabBar(new QTabBar) - , m_tabBarBackground(new QWidget) -{ - // setting object names for css - setObjectName("backgroundWidget"); - m_splitter->setObjectName("centralTabWidget"); - m_splitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - m_splitter->setHandleWidth(0); - - QString sheet = QString::fromUtf8(Utils::FileReader::fetchQrc(":/qmldesigner/centerwidget.css")); - m_tabBarBackground->setStyleSheet(Theme::replaceCssColors(sheet)); - - m_tabBar->setObjectName("centralTabBar"); - m_tabBar->setShape(QTabBar::RoundedEast); - m_tabBar->setDocumentMode(false); - // add a faketab to have the possibility to unselect all tabs - m_tabBar->addTab(QString()); - selectFakeTab(); - - m_tabBarBackground->setObjectName("tabBarBackground"); - - connect(m_tabBar, &QTabBar::tabBarClicked, [this] (int index) { - if (index != -1) - updateSplitterSizes(index - fakeTab); - }); - - setLayout(new QHBoxLayout); - layout()->setContentsMargins(0, 0, 0, 0); - layout()->setSpacing(0); - layout()->addWidget(m_splitter); - - m_tabBarBackground->setLayout(new QVBoxLayout); - m_tabBarBackground->layout()->setContentsMargins(0, 0, 0, 0); - m_tabBarBackground->layout()->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); - m_tabBarBackground->layout()->addWidget(m_tabBar); - - auto horizontalButton = new QToolButton; - horizontalButton->setObjectName("centralTabBar"); - horizontalButton->setIcon(Utils::Icon({{QLatin1String(":/qmldesigner/images/spliteditorvertically.png"), - Utils::Theme::IconsBaseColor}}).icon()); - horizontalButton->setIconSize(QSize(8, 16)); - connect(horizontalButton, &QToolButton::clicked, [this] () { - m_splitter->setOrientation(Qt::Vertical); - updateSplitterSizes(); - selectFakeTab(); - }); - auto verticalButton = new QToolButton; - verticalButton->setObjectName("centralTabBar"); - verticalButton->setIcon(Utils::Icon({{QLatin1String(":/qmldesigner/images/spliteditorhorizontally.png"), - Utils::Theme::IconsBaseColor}}).icon()); - verticalButton->setIconSize(QSize(8, 16)); - connect(verticalButton, &QToolButton::clicked, [this] () { - m_splitter->setOrientation(Qt::Horizontal); - updateSplitterSizes(); - selectFakeTab(); - }); - - m_tabBarBackground->layout()->addWidget(horizontalButton); - m_tabBarBackground->layout()->addWidget(verticalButton); - layout()->addWidget(m_tabBarBackground); - updateSplitButtons(); -} - -int SwitchSplitTabWidget::count() const -{ - return m_splitter->count(); -} - -QWidget *SwitchSplitTabWidget::currentWidget() const -{ - QList sizes = m_splitter->sizes(); - for (int i = 0; i < count(); ++i) { - if (sizes.at(i) > 0 && m_splitter->widget(i)->hasFocus()) - return m_splitter->widget(i); - } - return nullptr; -} - -void SwitchSplitTabWidget::updateSplitterSizes(int index) -{ - QVector splitterSizes(m_splitter->count()); - int splitterFullSize = 0; - bool isHorizontal = m_splitter->orientation() == Qt::Horizontal; - for (int i = 0; i < m_splitter->count(); ++i) { - auto widget = m_splitter->widget(i); - splitterFullSize += isHorizontal ? widget->width() : widget->height(); - } - - if (index > -1) { - // collapse all but the one at index - splitterSizes.fill(0); - splitterSizes.replace(index, splitterFullSize); - } else { - // distribute full size among enabled tabs - int divisor = splitterSizes.count(); - for (int i = 0; i < m_splitter->count(); ++i) { - if (!m_tabBar->isTabEnabled(i + fakeTab)) - --divisor; - } - - int splitSize = splitterFullSize / divisor; - for (int i = 0; i < m_splitter->count(); ++i) - splitterSizes.replace(i, m_tabBar->isTabEnabled(i + fakeTab) ? splitSize : 0); - } - - m_splitter->setSizes(splitterSizes.toList()); -} - -int SwitchSplitTabWidget::addTab(QWidget *w, const QString &label) -{ - m_splitter->addWidget(w); - const int newIndex = m_tabBar->addTab(label); - if (mode() == TabMode) { - m_tabBar->setCurrentIndex(newIndex); - updateSplitterSizes(newIndex - fakeTab); - } - if (mode() == SplitMode) - updateSplitterSizes(); - updateSplitButtons(); - return newIndex; -} - -QWidget *SwitchSplitTabWidget::takeTabWidget(const int index) -{ - if (index == -1 || index > count() - 1) - return nullptr; - QWidget *widget = m_splitter->widget(index); - widget->setParent(nullptr); - m_tabBar->removeTab(index + fakeTab); - // TODO: set which mode and tab is the current one - updateSplitButtons(); - return widget; -} - -void SwitchSplitTabWidget::switchTo(QWidget *widget) -{ - if (widget == nullptr || currentWidget() == widget) - return; - const int widgetIndex = m_splitter->indexOf(widget); - Q_ASSERT(widgetIndex != -1); - if (mode() == TabMode) { - updateSplitterSizes(widgetIndex); - m_tabBar->setCurrentIndex(widgetIndex + fakeTab); - } - - widget->setFocus(); -} - -void SwitchSplitTabWidget::updateSplitButtons() -{ - const bool isTabBarNecessary = count() > 1; - m_tabBarBackground->setVisible(isTabBarNecessary); -} - -void SwitchSplitTabWidget::selectFakeTab() -{ - m_tabBar->setCurrentIndex(0); -} - -SwitchSplitTabWidget::Mode SwitchSplitTabWidget::mode() const -{ - const bool isTabBarNecessary = count() > 1; - const int fakeTabPosition = 0; - const int hasSelectedTab = m_tabBar->currentIndex() > fakeTabPosition; - // Note: When splitting the view by dragging from the side of the view, SplitMode is not detected - return (isTabBarNecessary && !hasSelectedTab) ? SplitMode : TabMode; -} - -} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/switchsplittabwidget.h b/src/plugins/qmldesigner/switchsplittabwidget.h deleted file mode 100644 index 72c5cc3e5e8..00000000000 --- a/src/plugins/qmldesigner/switchsplittabwidget.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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. -** -****************************************************************************/ - -#pragma once - -#include - -QT_BEGIN_NAMESPACE -class QTabBar; -class QSplitter; -class QPushButton; -QT_END_NAMESPACE - -namespace QmlDesigner { -class SwitchSplitTabWidget : public QWidget -{ - Q_OBJECT - - enum Mode { SplitMode, TabMode }; - -public: - explicit SwitchSplitTabWidget(QWidget *parent = nullptr); - int count() const; - QWidget *currentWidget() const; - - int addTab(QWidget *widget, const QString &label); - QWidget *takeTabWidget(const int index); - void switchTo(QWidget *widget); - -private: - void updateSplitterSizes(int index = -1); - void updateSplitButtons(); - void selectFakeTab(); - Mode mode() const; - - QSplitter *m_splitter = nullptr; - QTabBar *m_tabBar = nullptr; - QWidget *m_tabBarBackground = nullptr; - const int fakeTab = 1; -}; -} // namespace QmlDesigner From 675a85bef088d9d7f039ffb7054957ee2e90e11e Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Tue, 20 Oct 2020 12:18:10 +0200 Subject: [PATCH 16/22] QmlDesigner: Add missing include Amends 3614ab81ce9726b17b0c725ff55e1ae5be3ab7d1 Change-Id: Ib8a02fe5829462379ae9a665b5c0e8e8832cc090 Reviewed-by: Knud Dollereder Reviewed-by: Eike Ziller --- .../qmldesigner/components/curveeditor/curveeditorstyle.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/qmldesigner/components/curveeditor/curveeditorstyle.h b/src/plugins/qmldesigner/components/curveeditor/curveeditorstyle.h index 3eda30dfcdc..f6c6c378c59 100644 --- a/src/plugins/qmldesigner/components/curveeditor/curveeditorstyle.h +++ b/src/plugins/qmldesigner/components/curveeditor/curveeditorstyle.h @@ -36,6 +36,8 @@ #include #include +#include + namespace DesignTools { struct TreeItemStyleOption From 2b5e1ea62ec084fc4706e2aa8db0ba819b74c4c2 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 16 Oct 2020 16:38:25 +0200 Subject: [PATCH 17/22] CppEditor: Fix some "convert to camel case" edge cases Fixes: QTCREATORBUG-16560 Change-Id: I8573ae6c5dce0956c868addc69a921c62f1d571a Reviewed-by: Christian Stenger --- src/plugins/cppeditor/cppquickfix_test.cpp | 33 ++++++++++++ src/plugins/cppeditor/cppquickfixes.cpp | 54 ++++++++++++------- src/plugins/cppeditor/cppquickfixes.h | 5 ++ .../cpptools/cpprefactoringchanges.cpp | 2 +- src/plugins/cpptools/cpprefactoringchanges.h | 2 +- 5 files changed, 76 insertions(+), 20 deletions(-) diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp index 4da9174b4ff..1dbfeafedf6 100644 --- a/src/plugins/cppeditor/cppquickfix_test.cpp +++ b/src/plugins/cppeditor/cppquickfix_test.cpp @@ -2047,6 +2047,39 @@ void CppEditorPlugin::test_quickfix_data() << CppQuickFixFactoryPtr(new InsertQtPropertyMembers) << _("class C { @Q_PROPERTY(typeid foo READ foo) };\n") << _(); + + QTest::newRow("convert to camel case: normal") + << CppQuickFixFactoryPtr(new ConvertToCamelCase(true)) + << _("void @lower_case_function();\n") + << _("void lowerCaseFunction();\n"); + QTest::newRow("convert to camel case: already camel case") + << CppQuickFixFactoryPtr(new ConvertToCamelCase(true)) + << _("void @camelCaseFunction();\n") + << _(); + QTest::newRow("convert to camel case: no underscores (lower case)") + << CppQuickFixFactoryPtr(new ConvertToCamelCase(true)) + << _("void @lowercasefunction();\n") + << _(); + QTest::newRow("convert to camel case: no underscores (upper case)") + << CppQuickFixFactoryPtr(new ConvertToCamelCase(true)) + << _("void @UPPERCASEFUNCTION();\n") + << _(); + QTest::newRow("convert to camel case: non-applicable underscore") + << CppQuickFixFactoryPtr(new ConvertToCamelCase(true)) + << _("void @m_a_member;\n") + << _("void m_aMember;\n"); + QTest::newRow("convert to camel case: upper case") + << CppQuickFixFactoryPtr(new ConvertToCamelCase(true)) + << _("void @UPPER_CASE_FUNCTION();\n") + << _("void upperCaseFunction();\n"); + QTest::newRow("convert to camel case: partially camel case already") + << CppQuickFixFactoryPtr(new ConvertToCamelCase(true)) + << _("void mixed@_andCamelCase();\n") + << _("void mixedAndCamelCase();\n"); + QTest::newRow("convert to camel case: wild mix") + << CppQuickFixFactoryPtr(new ConvertToCamelCase(true)) + << _("void @WhAt_TODO_hErE();\n") + << _("void WhAtTODOHErE();\n"); } void CppEditorPlugin::test_quickfix() diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index c8929a6ff9c..50d0da5aff8 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -2002,9 +2002,13 @@ namespace { class ConvertToCamelCaseOp: public CppQuickFixOperation { public: - ConvertToCamelCaseOp(const CppQuickFixInterface &interface, const QString &newName) + ConvertToCamelCaseOp(const CppQuickFixInterface &interface, const QString &name, + const AST *nameAst, bool test) : CppQuickFixOperation(interface, -1) - , m_name(newName) + , m_name(name) + , m_nameAst(nameAst) + , m_isAllUpper(name.isUpper()) + , m_test(test) { setDescription(QApplication::translate("CppTools::QuickFix", "Convert to Camel Case")); } @@ -2014,17 +2018,24 @@ public: CppRefactoringChanges refactoring(snapshot()); CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); - for (int i = 1; i < m_name.length(); ++i) { - const QChar c = m_name.at(i); - if (c.isUpper()) { - m_name[i] = c.toLower(); - } else if (i < m_name.length() - 1 - && isConvertibleUnderscore(m_name, i)) { - m_name.remove(i, 1); - m_name[i] = m_name.at(i).toUpper(); + QString newName = m_isAllUpper ? m_name.toLower() : m_name; + for (int i = 1; i < newName.length(); ++i) { + const QChar c = newName.at(i); + if (c.isUpper() && m_isAllUpper) { + newName[i] = c.toLower(); + } else if (i < newName.length() - 1 && isConvertibleUnderscore(newName, i)) { + newName.remove(i, 1); + newName[i] = newName.at(i).toUpper(); } } - editor()->renameUsages(m_name); + if (m_test) { + ChangeSet changeSet; + changeSet.replace(currentFile->range(m_nameAst), newName); + currentFile->setChangeSet(changeSet); + currentFile->apply(); + } else { + editor()->renameUsages(newName); + } } static bool isConvertibleUnderscore(const QString &name, int pos) @@ -2034,7 +2045,10 @@ public: } private: - QString m_name; + const QString m_name; + const AST * const m_nameAst; + const bool m_isAllUpper; + const bool m_test; }; } // anonymous namespace @@ -2048,22 +2062,26 @@ void ConvertToCamelCase::match(const CppQuickFixInterface &interface, QuickFixOp AST * const ast = path.last(); const Name *name = nullptr; + const AST *astForName = nullptr; if (const NameAST * const nameAst = ast->asName()) { - if (nameAst->name && nameAst->name->asNameId()) + if (nameAst->name && nameAst->name->asNameId()) { + astForName = nameAst; name = nameAst->name; + } } else if (const NamespaceAST * const namespaceAst = ast->asNamespace()) { + astForName = namespaceAst; name = namespaceAst->symbol->name(); } if (!name) return; - QString newName = QString::fromUtf8(name->identifier()->chars()); - if (newName.length() < 3) + QString nameString = QString::fromUtf8(name->identifier()->chars()); + if (nameString.length() < 3) return; - for (int i = 1; i < newName.length() - 1; ++i) { - if (ConvertToCamelCaseOp::isConvertibleUnderscore(newName, i)) { - result << new ConvertToCamelCaseOp(interface, newName); + for (int i = 1; i < nameString.length() - 1; ++i) { + if (ConvertToCamelCaseOp::isConvertibleUnderscore(nameString, i)) { + result << new ConvertToCamelCaseOp(interface, nameString, astForName, m_test); return; } } diff --git a/src/plugins/cppeditor/cppquickfixes.h b/src/plugins/cppeditor/cppquickfixes.h index 91bd8c9a624..4a9d1ab3579 100644 --- a/src/plugins/cppeditor/cppquickfixes.h +++ b/src/plugins/cppeditor/cppquickfixes.h @@ -221,7 +221,12 @@ public: class ConvertToCamelCase : public CppQuickFixFactory { public: + ConvertToCamelCase(bool test = false) : CppQuickFixFactory(), m_test(test) {} + void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override; + +private: + const bool m_test; }; /*! diff --git a/src/plugins/cpptools/cpprefactoringchanges.cpp b/src/plugins/cpptools/cpprefactoringchanges.cpp index 509506d5a14..a86dd6451b2 100644 --- a/src/plugins/cpptools/cpprefactoringchanges.cpp +++ b/src/plugins/cpptools/cpprefactoringchanges.cpp @@ -213,7 +213,7 @@ Utils::ChangeSet::Range CppRefactoringFile::range(unsigned tokenIndex) const return {start, start + token.utf16chars()}; } -Utils::ChangeSet::Range CppRefactoringFile::range(AST *ast) const +Utils::ChangeSet::Range CppRefactoringFile::range(const AST *ast) const { return {startOf(ast), endOf(ast)}; } diff --git a/src/plugins/cpptools/cpprefactoringchanges.h b/src/plugins/cpptools/cpprefactoringchanges.h index 3a547a90c5d..58fbf39eeee 100644 --- a/src/plugins/cpptools/cpprefactoringchanges.h +++ b/src/plugins/cpptools/cpprefactoringchanges.h @@ -52,7 +52,7 @@ public: Range range(int start, int end) const; Range range(unsigned tokenIndex) const; - Range range(CPlusPlus::AST *ast) const; + Range range(const CPlusPlus::AST *ast) const; const CPlusPlus::Token &tokenAt(unsigned index) const; From a2aa02acbabdfbcfb358293703b6226e517d31ea Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Tue, 20 Oct 2020 15:40:56 +0200 Subject: [PATCH 18/22] CMake Build: Make sure testplugin target exists before setting property When doing a minimal build, the testplugin might not be created. Change-Id: Ia4f1cbd14cbdad6e81cb7090a7f52aad692175fa Reviewed-by: Eike Ziller --- .../auto/extensionsystem/pluginspec/testplugin/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto/extensionsystem/pluginspec/testplugin/CMakeLists.txt b/tests/auto/extensionsystem/pluginspec/testplugin/CMakeLists.txt index 391c90862fa..d52f1c98d04 100644 --- a/tests/auto/extensionsystem/pluginspec/testplugin/CMakeLists.txt +++ b/tests/auto/extensionsystem/pluginspec/testplugin/CMakeLists.txt @@ -22,4 +22,6 @@ add_qtc_plugin(testplugin ) # The empty string gets removed if I put it above -set_target_properties(testplugin PROPERTIES PREFIX "") +if (TARGET testplugin) + set_target_properties(testplugin PROPERTIES PREFIX "") +endif() From 3c4f7967e32bbef76710b591728b0d8c41e41bd3 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Tue, 20 Oct 2020 14:18:57 +0200 Subject: [PATCH 19/22] CMake Build: Allow building unittests when targets are missing when configuring a minimal build make sure that when querying for target properties like SOURCE_DIR the target actually exists. Change-Id: Ib754b79be6461e3ddd4cdeb1abac123cf4535068 Reviewed-by: Eike Ziller --- cmake/QtCreatorAPIInternal.cmake | 10 +++++++++- tests/unit/unittest/CMakeLists.txt | 27 +++++++++++++-------------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/cmake/QtCreatorAPIInternal.cmake b/cmake/QtCreatorAPIInternal.cmake index 5404680da0f..8e55d4e8a1a 100644 --- a/cmake/QtCreatorAPIInternal.cmake +++ b/cmake/QtCreatorAPIInternal.cmake @@ -386,7 +386,7 @@ endfunction() function(extend_qtc_target target_name) cmake_parse_arguments(_arg "" - "SOURCES_PREFIX;FEATURE_INFO" + "SOURCES_PREFIX;SOURCES_PREFIX_FROM_TARGET;FEATURE_INFO" "CONDITION;DEPENDS;PUBLIC_DEPENDS;DEFINES;PUBLIC_DEFINES;INCLUDES;PUBLIC_INCLUDES;SOURCES;EXPLICIT_MOC;SKIP_AUTOMOC;EXTRA_TRANSLATIONS;PROPERTIES" ${ARGN} ) @@ -411,6 +411,14 @@ function(extend_qtc_target target_name) return() endif() + if (_arg_SOURCES_PREFIX_FROM_TARGET) + if (NOT TARGET ${_arg_SOURCES_PREFIX_FROM_TARGET}) + return() + else() + get_target_property(_arg_SOURCES_PREFIX ${_arg_SOURCES_PREFIX_FROM_TARGET} SOURCES_DIR) + endif() + endif() + add_qtc_depends(${target_name} PRIVATE ${_arg_DEPENDS} PUBLIC ${_arg_PUBLIC_DEPENDS} diff --git a/tests/unit/unittest/CMakeLists.txt b/tests/unit/unittest/CMakeLists.txt index 13741ae4789..86f27616f35 100644 --- a/tests/unit/unittest/CMakeLists.txt +++ b/tests/unit/unittest/CMakeLists.txt @@ -40,7 +40,6 @@ add_qtc_test(unittest GTEST clientserveroutsideprocess-test.cpp commandlinebuilder-test.cpp compare-operators.h - compilationdatabaseutils-test.cpp compileroptionsbuilder-test.cpp conditionally-disabled-tests.h cppprojectfilecategorizer-test.cpp @@ -319,7 +318,7 @@ extend_qtc_test(unittest ) extend_qtc_test(unittest - CONDITION TARGET clangFormat + CONDITION TARGET ClangFormat DEPENDS clangFormat SOURCES clangformat-test.cpp @@ -421,9 +420,8 @@ extend_qtc_test_with_target_sources(CPlusPlus DEFINES CPLUSPLUS_BUILD_STATIC_LIB extend_qtc_test_with_target_sources(3rd_cplusplus DEFINES CPLUSPLUS_BUILD_LIB) extend_qtc_test_with_target_sources(ClangSupport DEFINES CLANGSUPPORT_BUILD_LIB) -get_target_property(ClangCodeModelSourcesDir ClangCodeModel SOURCES_DIR) extend_qtc_test(unittest - SOURCES_PREFIX "${ClangCodeModelSourcesDir}" + SOURCES_PREFIX_FROM_TARGET ClangCodeModel SOURCES clangactivationsequencecontextprocessor.cpp clangactivationsequencecontextprocessor.h clangactivationsequenceprocessor.cpp clangactivationsequenceprocessor.h @@ -436,16 +434,20 @@ extend_qtc_test(unittest clangisdiagnosticrelatedtolocation.h ) -get_target_property(CompilationDatabasePMSourcesDir CompilationDatabaseProjectManager SOURCES_DIR) extend_qtc_test(unittest - SOURCES_PREFIX "${CompilationDatabasePMSourcesDir}" + SOURCES_PREFIX_FROM_TARGET CompilationDatabaseProjectManager SOURCES compilationdatabaseutils.cpp compilationdatabaseutils.h ) -get_target_property(CoreSourcesDir Core SOURCES_DIR) extend_qtc_test(unittest - SOURCES_PREFIX "${CoreSourcesDir}" + CONDITION TARGET CompilationDatabaseProjectManager + SOURCES + compilationdatabaseutils-test.cpp +) + +extend_qtc_test(unittest + SOURCES_PREFIX_FROM_TARGET Core DEFINES CORE_STATIC_LIBRARY SOURCES coreicons.cpp coreicons.h @@ -453,9 +455,8 @@ extend_qtc_test(unittest locator/ilocatorfilter.cpp locator/ilocatorfilter.h ) -get_target_property(CppToolsSourcesDir CppTools SOURCES_DIR) extend_qtc_test(unittest - SOURCES_PREFIX "${CppToolsSourcesDir}" + SOURCES_PREFIX_FROM_TARGET CppTools DEFINES CPPTOOLS_STATIC_LIBRARY SOURCES cppprojectfile.cpp cppprojectfile.h @@ -469,9 +470,8 @@ extend_qtc_test(unittest headerpathfilter.cpp headerpathfilter.h ) -get_target_property(ProjectExplorerSourcesDir ProjectExplorer SOURCES_DIR) extend_qtc_test(unittest - SOURCES_PREFIX "${ProjectExplorerSourcesDir}" + SOURCES_PREFIX_FROM_TARGET ProjectExplorer DEFINES PROJECTEXPLORER_STATIC_LIBRARY SOURCES projectmacro.cpp projectmacro.h @@ -517,9 +517,8 @@ extend_qtc_test(unittest progressmanagerinterface.h ) -get_target_property(ClangFormatSourcesDir ClangFormat SOURCES_DIR) extend_qtc_test(unittest - SOURCES_PREFIX "${ClangFormatSourcesDir}" + SOURCES_PREFIX_FROM_TARGET ClangFormat DEFINES CLANGPCHMANAGER_STATIC_LIB SOURCES clangformatconstants.h From 49a8266d5869d221b16066378ad89ff7cb105e70 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 20 Oct 2020 16:15:00 +0200 Subject: [PATCH 20/22] Update Qbs to HEAD of master Fixes issues when compiling with ccache. Change-Id: I3cb712b84f527eaf35649d207d5750fa698d46b7 Reviewed-by: Ivan Komissarov --- src/shared/qbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/qbs b/src/shared/qbs index 0d5fdcee74b..d870a7a4535 160000 --- a/src/shared/qbs +++ b/src/shared/qbs @@ -1 +1 @@ -Subproject commit 0d5fdcee74b76175e0b03269b12d9bd4b6eee9c4 +Subproject commit d870a7a4535e801e1161ececccd0d85dca0a3408 From 6b8d8e414ac45ed74fd3968da9525c704178eae8 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 8 Oct 2020 10:50:15 +0300 Subject: [PATCH 21/22] QmlDesigner: Port 3D edit view to Qt6 Task-number: QDS-2899 Change-Id: Iedbe5e8561e5ab71ef32922e69da43cd3cc57e90 Reviewed-by: Thomas Hartmann --- .../commands/valueschangedcommand.cpp | 4 + .../qml/qmlpuppet/mockfiles/EditView3D.qml | 28 +- .../qml/qmlpuppet/mockfiles/LightGizmo.qml | 16 +- .../qmlpuppet/mockfiles/LightIconGizmo.qml | 1 + .../qml/qmlpuppet/mockfiles/LightModel.qml | 2 +- .../mockfiles/ModelNode2DImageView.qml | 7 +- .../mockfiles/ModelNode3DImageView.qml | 5 + .../qml2puppet/editor3d/camerageometry.cpp | 22 +- .../qml2puppet/editor3d/camerageometry.h | 15 +- .../qml2puppet/editor3d/editor3d.pri | 5 + .../qml2puppet/editor3d/generalhelper.cpp | 18 +- .../qml2puppet/editor3d/generalhelper.h | 3 + .../qml2puppet/editor3d/gridgeometry.cpp | 13 + .../qml2puppet/editor3d/gridgeometry.h | 15 +- .../qml2puppet/editor3d/lightgeometry.cpp | 13 + .../qml2puppet/editor3d/lightgeometry.h | 15 +- .../qml2puppet/editor3d/linegeometry.cpp | 13 + .../qml2puppet/editor3d/linegeometry.h | 15 +- .../editor3d/qt5compat/qquick3darealight.cpp | 59 +++++ .../editor3d/qt5compat/qquick3darealight_p.h | 66 +++++ .../editor3d/selectionboxgeometry.cpp | 22 +- .../editor3d/selectionboxgeometry.h | 15 +- .../qml2puppet/iconrenderer/iconrenderer.cpp | 161 ++++++++---- .../qml2puppet/iconrenderer/iconrenderer.h | 8 + .../instances/nodeinstanceserver.cpp | 5 +- .../qml2puppet/instances/nodeinstanceserver.h | 1 + .../qt5informationnodeinstanceserver.cpp | 239 +++++++++++++----- .../qt5informationnodeinstanceserver.h | 3 + .../instances/qt5nodeinstanceserver.cpp | 8 + .../instances/qt5rendernodeinstanceserver.cpp | 5 - .../instances/quickitemnodeinstance.cpp | 40 +-- .../qmlpuppet/qml2puppet/qml2puppetmain.cpp | 56 +++- .../components/edit3d/edit3dcanvas.cpp | 2 +- src/tools/qml2puppet/CMakeLists.txt | 8 + src/tools/qml2puppet/qml2puppet.qbs | 16 ++ 35 files changed, 742 insertions(+), 182 deletions(-) create mode 100644 share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight.cpp create mode 100644 share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight_p.h diff --git a/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.cpp index 18370be9fcb..530447cb945 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.cpp +++ b/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.cpp @@ -109,7 +109,11 @@ QDataStream &operator<<(QDataStream &out, const ValuesChangedCommand &command) ++keyCounter; command.m_keyNumber = keyCounter; QByteArray outDataStreamByteArray; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QDataStream temporaryOutDataStream(&outDataStreamByteArray, QIODevice::WriteOnly); +#else + QDataStream temporaryOutDataStream(&outDataStreamByteArray, QDataStream::WriteOnly); +#endif temporaryOutDataStream.setVersion(QDataStream::Qt_4_8); temporaryOutDataStream << propertyValueContainer; diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml index 95245aae5eb..2842d70637c 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml @@ -25,8 +25,6 @@ import QtQuick 2.12 import QtQuick3D 1.15 -import QtQuick.Controls 2.0 -import QtGraphicalEffects 1.0 import MouseArea3D 1.0 Item { @@ -100,6 +98,7 @@ Item { if (editView) { // Destroy is async, so make sure we don't get any more updates for the old editView _generalHelper.enableItemUpdate(editView, false); + editView.visible = false; editView.destroy(); } @@ -299,15 +298,23 @@ Item { function addLightGizmo(scene, obj) { - // Insert into first available gizmo + // Insert into first available gizmo if we don't already have gizmo for this object + var slotFound = -1; for (var i = 0; i < lightIconGizmos.length; ++i) { if (!lightIconGizmos[i].targetNode) { + slotFound = i; + } else if (lightIconGizmos[i].targetNode === obj) { lightIconGizmos[i].scene = scene; - lightIconGizmos[i].targetNode = obj; return; } } + if (slotFound !== -1) { + lightIconGizmos[slotFound].scene = scene; + lightIconGizmos[slotFound].targetNode = obj; + return; + } + // No free gizmos available, create a new one var gizmoComponent = Qt.createComponent("LightIconGizmo.qml"); if (gizmoComponent.status === Component.Ready) { @@ -324,14 +331,23 @@ Item { function addCameraGizmo(scene, obj) { - // Insert into first available gizmo + // Insert into first available gizmo if we don't already have gizmo for this object + var slotFound = -1; for (var i = 0; i < cameraGizmos.length; ++i) { if (!cameraGizmos[i].targetNode) { + slotFound = i; + } else if (cameraGizmos[i].targetNode === obj) { cameraGizmos[i].scene = scene; - cameraGizmos[i].targetNode = obj; return; } } + + if (slotFound !== -1) { + cameraGizmos[slotFound].scene = scene; + cameraGizmos[slotFound].targetNode = obj; + return; + } + // No free gizmos available, create a new one var gizmoComponent = Qt.createComponent("CameraGizmo.qml"); var frustumComponent = Qt.createComponent("CameraFrustum.qml"); diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml index 2e9791dc282..b69884cb7d6 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml @@ -26,7 +26,7 @@ import QtQuick 2.0 import QtQuick3D 1.15 import MouseArea3D 1.0 -import LightGeometry 1.0 +import LightUtils 1.0 Node { id: lightGizmo @@ -35,7 +35,6 @@ Node { property Node targetNode: null property MouseArea3D dragHelper: null property color color: Qt.rgba(1, 1, 0, 1) - property real brightnessScale: targetNode ? Math.max(1.0, 1.0 + targetNode.brightness) : 100 property real fadeScale: { // Value indicates area where intensity is above certain percent of total brightness. if (lightGizmo.targetNode instanceof SpotLight || lightGizmo.targetNode instanceof PointLight) { @@ -64,6 +63,8 @@ Node { || pointLightFadeHandle.dragging property point currentMousePos property string currentLabel + property int brightnessDecimals: _generalHelper.brightnessScaler() > 10. ? 0 : 2; + property real brightnessMultiplier: Math.pow(10, brightnessDecimals); signal propertyValueCommit(string propName) signal propertyValueChange(string propName) @@ -226,7 +227,6 @@ Node { onValueCommit: lightGizmo.propertyValueCommit(propName) } } - Node { id: areaParts visible: lightGizmo.targetNode instanceof AreaLight @@ -305,15 +305,19 @@ Node { active: lightGizmo.visible dragHelper: lightGizmo.dragHelper scale: autoScaler.getScale(Qt.vector3d(5, 5, 5)) - length: (lightGizmo.brightnessScale / 10) + 3 + length: targetNode ? Math.max(1.0, 1.0 + targetNode.brightness / _generalHelper.brightnessScaler() * 10.0) + 3 : 10 property real _startBrightness function updateBrightness(relativeDistance, screenPos) { - var currentValue = Math.round(Math.max(0, _startBrightness + relativeDistance * 10)); + var currentValue = Math.max(0, (_startBrightness + relativeDistance * _generalHelper.brightnessScaler() / 10.0)); + currentValue *= brightnessMultiplier; + currentValue = Math.round(currentValue); + currentValue /= brightnessMultiplier; + var l = Qt.locale(); - lightGizmo.currentLabel = "brightness" + qsTr(": ") + Number(currentValue).toLocaleString(l, 'f', 0); + lightGizmo.currentLabel = "brightness" + qsTr(": ") + Number(currentValue).toLocaleString(l, 'f', brightnessDecimals); lightGizmo.currentMousePos = screenPos; targetNode.brightness = currentValue; } diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/LightIconGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/LightIconGizmo.qml index 6f0d426c1fb..8cbce4d1d91 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/LightIconGizmo.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/LightIconGizmo.qml @@ -25,6 +25,7 @@ import QtQuick 2.0 import QtQuick3D 1.15 +import LightUtils 1.0 IconGizmo { id: lightIconGizmo diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/LightModel.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/LightModel.qml index 9ccb3c49ae1..3e42760ca14 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/LightModel.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/LightModel.qml @@ -25,7 +25,7 @@ import QtQuick 2.0 import QtQuick3D 1.15 -import LightGeometry 1.0 +import LightUtils 1.0 Model { id: lightModel diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/ModelNode2DImageView.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/ModelNode2DImageView.qml index c4bd31d7e7e..23025477157 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/ModelNode2DImageView.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/ModelNode2DImageView.qml @@ -24,6 +24,7 @@ ****************************************************************************/ import QtQuick 2.15 +import QtQuick3D 1.15 Item { id: root @@ -32,8 +33,12 @@ Item { property alias contentItem: contentItem + View3D { + // Dummy view to hold the context in case View3D items are used in the component + // TODO remove when QTBUG-87678 is fixed + } + Item { id: contentItem - anchors.fill: parent } } diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/ModelNode3DImageView.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/ModelNode3DImageView.qml index 277bc8431f9..c09275b32ec 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/ModelNode3DImageView.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/ModelNode3DImageView.qml @@ -122,6 +122,11 @@ Item { } } + View3D { + // Dummy view to hold the context + // TODO remove when QTBUG-87678 is fixed + } + Item { id: contentItem anchors.fill: parent diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp index 9c81fdc9703..0fbc28c6b58 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp @@ -51,6 +51,19 @@ CameraGeometry::~CameraGeometry() { } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +QString CameraGeometry::name() const +{ + return objectName(); +} + +void CameraGeometry::setName(const QString &name) +{ + setObjectName(name); + emit nameChanged(); +} +#endif + QQuick3DCamera *CameraGeometry::camera() const { return m_camera; @@ -173,13 +186,16 @@ void CameraGeometry::fillVertexData(QByteArray &vertexData, QByteArray &indexDat QMatrix4x4 m; QSSGRenderCamera *camera = m_camera->cameraNode(); if (camera) { + QRectF rect = m_viewPortRect; + if (rect.isNull()) + rect = QRectF(0, 0, 1000, 1000); // Let's have some visualization for null viewports if (qobject_cast(m_camera)) { // For some reason ortho cameras show double what projection suggests, // so give them doubled viewport to match visualization to actual camera view - camera->calculateGlobalVariables(QRectF(0, 0, m_viewPortRect.width() * 2.0, - m_viewPortRect.height() * 2.0)); + camera->calculateGlobalVariables(QRectF(0, 0, rect.width() * 2.0, + rect.height() * 2.0)); } else { - camera->calculateGlobalVariables(m_viewPortRect); + camera->calculateGlobalVariables(rect); } m = camera->projection.inverted(); } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.h index 73722cd7a1f..55d31ca389e 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.h @@ -39,6 +39,17 @@ class CameraGeometry : public QQuick3DGeometry Q_PROPERTY(QQuick3DCamera *camera READ camera WRITE setCamera NOTIFY cameraChanged) Q_PROPERTY(QRectF viewPortRect READ viewPortRect WRITE setViewPortRect NOTIFY viewPortRectChanged) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + // Name property was removed in Qt 6, so define it here for compatibility. + // Name maps to object name. + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) +public: + QString name() const; + void setName(const QString &name); +signals: + void nameChanged(); +#endif + public: CameraGeometry(); ~CameraGeometry() override; @@ -46,12 +57,12 @@ public: QQuick3DCamera *camera() const; QRectF viewPortRect() const; -public Q_SLOTS: +public slots: void setCamera(QQuick3DCamera *camera); void setViewPortRect(const QRectF &rect); void handleCameraPropertyChange(); -Q_SIGNALS: +signals: void cameraChanged(); void viewPortRectChanged(); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/editor3d.pri b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/editor3d.pri index 755aef73e25..bcfbc5e12ed 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/editor3d.pri +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/editor3d.pri @@ -15,3 +15,8 @@ SOURCES += $$PWD/generalhelper.cpp \ $$PWD/selectionboxgeometry.cpp \ $$PWD/linegeometry.cpp \ $$PWD/icongizmoimageprovider.cpp + +versionAtLeast(QT_VERSION, 6.0.0) { + HEADERS += $$PWD/qt5compat/qquick3darealight_p.h + SOURCES += $$PWD/qt5compat/qquick3darealight.cpp +} diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp index afa02625d4d..6222c84ce71 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -166,7 +167,12 @@ QVector4D GeneralHelper::focusObjectToCamera(QQuick3DCamera *camera, float defau if (auto renderModel = static_cast(targetPriv->spatialNode)) { QWindow *window = static_cast(viewPort->window()); if (window) { - auto context = QSSGRenderContextInterface::getRenderContextInterface(quintptr(window)); + QSSGRef context; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + context = QSSGRenderContextInterface::getRenderContextInterface(quintptr(window)); +#else + context = targetPriv->sceneManager->rci; +#endif if (!context.isNull()) { QSSGBounds3 bounds; auto geometry = qobject_cast(modelNode->geometry()); @@ -297,6 +303,16 @@ QString GeneralHelper::rootSizeKey() const return _rootSizeKey; } +double GeneralHelper::brightnessScaler() const +{ + // Light brightness was rescaled in Qt6 from 100 -> 1. +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + return 100.; +#else + return 1.; +#endif +} + 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 92893cc546a..f162eb0d30c 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -82,6 +83,8 @@ public: QString lastSceneIdKey() const; QString rootSizeKey() const; + Q_INVOKABLE double brightnessScaler() const; + bool isMacOS() const; signals: diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.cpp index 4b548239ca8..66a2a6b2a5c 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.cpp @@ -41,6 +41,19 @@ GridGeometry::~GridGeometry() { } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +QString GridGeometry::name() const +{ + return objectName(); +} + +void GridGeometry::setName(const QString &name) +{ + setObjectName(name); + emit nameChanged(); +} +#endif + int GridGeometry::lines() const { return m_lines; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.h index 50b41288e2d..6074fb42453 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.h @@ -41,6 +41,17 @@ class GridGeometry : public QQuick3DGeometry Q_PROPERTY(bool isCenterLine READ isCenterLine WRITE setIsCenterLine NOTIFY isCenterLineChanged) Q_PROPERTY(bool isSubdivision MEMBER m_isSubdivision) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + // Name property was removed in Qt 6, so define it here for compatibility. + // Name maps to object name. + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) +public: + QString name() const; + void setName(const QString &name); +signals: + void nameChanged(); +#endif + public: GridGeometry(); ~GridGeometry() override; @@ -49,12 +60,12 @@ public: float step() const; bool isCenterLine() const; -public Q_SLOTS: +public slots: void setLines(int count); void setStep(float step); void setIsCenterLine(bool enabled); -Q_SIGNALS: +signals: void linesChanged(); void stepChanged(); void isCenterLineChanged(); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp index cebf3232f13..2facb771393 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp @@ -45,6 +45,19 @@ LightGeometry::~LightGeometry() { } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +QString LightGeometry::name() const +{ + return objectName(); +} + +void LightGeometry::setName(const QString &name) +{ + setObjectName(name); + emit nameChanged(); +} +#endif + LightGeometry::LightType LightGeometry::lightType() const { return m_lightType; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h index cac375d675e..e9ba7182183 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h @@ -37,6 +37,17 @@ class LightGeometry : public QQuick3DGeometry Q_OBJECT Q_PROPERTY(LightType lightType READ lightType WRITE setLightType NOTIFY lightTypeChanged) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + // Name property was removed in Qt 6, so define it here for compatibility. + // Name maps to object name. + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) +public: + QString name() const; + void setName(const QString &name); +signals: + void nameChanged(); +#endif + public: enum class LightType { Invalid, @@ -52,10 +63,10 @@ public: LightType lightType() const; -public Q_SLOTS: +public slots: void setLightType(LightType lightType); -Q_SIGNALS: +signals: void lightTypeChanged(); protected: diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.cpp index cd2e890f86e..5b6110d2af0 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.cpp @@ -41,6 +41,19 @@ LineGeometry::~LineGeometry() { } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +QString LineGeometry::name() const +{ + return objectName(); +} + +void LineGeometry::setName(const QString &name) +{ + setObjectName(name); + emit nameChanged(); +} +#endif + QVector3D LineGeometry::startPos() const { return m_startPos; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.h index 2e87ff87481..df83f89b258 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.h @@ -39,6 +39,17 @@ class LineGeometry : public QQuick3DGeometry Q_PROPERTY(QVector3D startPos READ startPos WRITE setStartPos NOTIFY startPosChanged) Q_PROPERTY(QVector3D endPos READ endPos WRITE setEndPos NOTIFY endPosChanged) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + // Name property was removed in Qt 6, so define it here for compatibility. + // Name maps to object name. + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) +public: + QString name() const; + void setName(const QString &name); +signals: + void nameChanged(); +#endif + public: LineGeometry(); ~LineGeometry() override; @@ -46,11 +57,11 @@ public: QVector3D startPos() const; QVector3D endPos() const; -public Q_SLOTS: +public slots: void setStartPos(const QVector3D &pos); void setEndPos(const QVector3D &pos); -Q_SIGNALS: +signals: void startPosChanged(); void endPosChanged(); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight.cpp new file mode 100644 index 00000000000..6fcbdcb89e3 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifdef QUICK3D_MODULE + +#include "qquick3darealight_p.h" +#include + +#include + +namespace QmlDesigner::Internal { + +float QQuick3DAreaLight::width() const +{ + return m_width; +} + +float QQuick3DAreaLight::height() const +{ + return m_height; +} + +void QQuick3DAreaLight::setWidth(float width) +{ + m_width = width; + emit widthChanged(); +} + +void QQuick3DAreaLight::setHeight(float height) +{ + m_height = height; + emit heightChanged(); +} + +} + +#endif diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight_p.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight_p.h new file mode 100644 index 00000000000..8db54879600 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight_p.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#pragma once + +#ifdef QUICK3D_MODULE + +// This is a dummy class for Qt 5 compatibility purposes only + +#include + +namespace QmlDesigner::Internal { + +class QQuick3DAreaLight : public QQuick3DAbstractLight +{ + Q_OBJECT + Q_PROPERTY(float width READ width WRITE setWidth NOTIFY widthChanged) + Q_PROPERTY(float height READ height WRITE setHeight NOTIFY heightChanged) + +public: + QQuick3DAreaLight() : QQuick3DAbstractLight() {} + ~QQuick3DAreaLight() override {} + + float width() const; + float height() const; + +public slots: + void setWidth(float width); + void setHeight(float height); + +signals: + void widthChanged(); + void heightChanged(); + +private: + float m_width = 100.0f; + float m_height = 100.0f; +}; + +} + +QML_DECLARE_TYPE(QmlDesigner::Internal::QQuick3DAreaLight) + +#endif diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.cpp index 621508c4997..1e1fe8937cc 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -59,6 +60,19 @@ SelectionBoxGeometry::~SelectionBoxGeometry() m_connections.clear(); } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +QString SelectionBoxGeometry::name() const +{ + return objectName(); +} + +void SelectionBoxGeometry::setName(const QString &name) +{ + setObjectName(name); + emit nameChanged(); +} +#endif + QQuick3DNode *SelectionBoxGeometry::targetNode() const { return m_targetNode; @@ -291,8 +305,12 @@ void SelectionBoxGeometry::getBounds( if (auto renderModel = static_cast(renderNode)) { QWindow *window = static_cast(m_view3D->window()); if (window) { - auto context = QSSGRenderContextInterface::getRenderContextInterface( - quintptr(window)); + QSSGRef context; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + context = QSSGRenderContextInterface::getRenderContextInterface(quintptr(window)); +#else + context = QQuick3DObjectPrivate::get(this)->sceneManager->rci; +#endif if (!context.isNull()) { auto bufferManager = context->bufferManager(); QSSGBounds3 bounds = renderModel->getModelBounds(bufferManager); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.h index 6cf9a153c2e..947ef7d54ab 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.h @@ -43,6 +43,17 @@ class SelectionBoxGeometry : public QQuick3DGeometry Q_PROPERTY(QQuick3DViewport *view3D READ view3D WRITE setView3D NOTIFY view3DChanged) Q_PROPERTY(bool isEmpty READ isEmpty NOTIFY isEmptyChanged) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + // Name property was removed in Qt 6, so define it here for compatibility. + // Name maps to object name. + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) +public: + QString name() const; + void setName(const QString &name); +signals: + void nameChanged(); +#endif + public: SelectionBoxGeometry(); ~SelectionBoxGeometry() override; @@ -54,12 +65,12 @@ public: QSSGBounds3 bounds() const; -public Q_SLOTS: +public slots: void setTargetNode(QQuick3DNode *targetNode); void setRootNode(QQuick3DNode *rootNode); void setView3D(QQuick3DViewport *view); -Q_SIGNALS: +signals: void targetNodeChanged(); void rootNodeChanged(); void view3DChanged(); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.cpp index 54ba6bed07c..cb9d867b0ff 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.cpp @@ -58,96 +58,67 @@ IconRenderer::IconRenderer(int size, const QString &filePath, const QString &sou void IconRenderer::setupRender() { DesignerSupport::activateDesignerMode(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) DesignerSupport::activateDesignerWindowManager(); +#endif m_quickView = new QQuickView; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QSurfaceFormat surfaceFormat = m_quickView->requestedFormat(); surfaceFormat.setVersion(4, 1); surfaceFormat.setProfile(QSurfaceFormat::CoreProfile); m_quickView->setFormat(surfaceFormat); DesignerSupport::createOpenGLContext(m_quickView); +#else + m_quickView->setDefaultAlphaBuffer(true); + m_quickView->setColor(Qt::transparent); + m_ratio = m_quickView->devicePixelRatio(); + m_quickView->installEventFilter(this); +#endif QQmlComponent component(m_quickView->engine()); component.loadUrl(QUrl::fromLocalFile(m_source)); QObject *iconItem = component.create(); if (iconItem) { - QQuickItem *containerItem = nullptr; - bool is3D = false; #ifdef QUICK3D_MODULE if (auto scene = qobject_cast(iconItem)) { qmlRegisterType("SelectionBoxGeometry", 1, 0, "SelectionBoxGeometry"); QQmlComponent component(m_quickView->engine()); component.loadUrl(QUrl("qrc:/qtquickplugin/mockfiles/IconRenderer3D.qml")); - containerItem = qobject_cast(component.create()); - DesignerSupport::setRootItem(m_quickView, containerItem); + m_containerItem = qobject_cast(component.create()); + DesignerSupport::setRootItem(m_quickView, m_containerItem); auto helper = new QmlDesigner::Internal::GeneralHelper(); m_quickView->engine()->rootContext()->setContextProperty("_generalHelper", helper); - m_contentItem = QQmlProperty::read(containerItem, "view3D").value(); + m_contentItem = QQmlProperty::read(m_containerItem, "view3D").value(); auto view3D = qobject_cast(m_contentItem); view3D->setImportScene(scene); - is3D = true; + m_is3D = true; } else #endif if (auto scene = qobject_cast(iconItem)) { m_contentItem = scene; - containerItem = new QQuickItem(); - containerItem->setSize(QSizeF(1024, 1024)); - DesignerSupport::setRootItem(m_quickView, containerItem); - m_contentItem->setParentItem(containerItem); + m_containerItem = new QQuickItem(); + m_containerItem->setSize(QSizeF(1024, 1024)); + DesignerSupport::setRootItem(m_quickView, m_containerItem); + m_contentItem->setParentItem(m_containerItem); } - if (containerItem && m_contentItem) { - m_contentItem->setSize(QSizeF(m_size, m_size)); - if (m_contentItem->width() > containerItem->width()) - containerItem->setWidth(m_contentItem->width()); - if (m_contentItem->height() > containerItem->height()) - containerItem->setHeight(m_contentItem->height()); - - QTimer::singleShot(0, this, [this, is3D, containerItem]() { - m_designerSupport.refFromEffectItem(m_quickView->rootObject(), false); - QQuickDesignerSupportItems::disableNativeTextRendering(m_quickView->rootObject()); - -#ifdef QUICK3D_MODULE - if (is3D) { - // Render once to make sure scene is up to date before we set up the selection box - render({}); - QMetaObject::invokeMethod(containerItem, "setSceneToBox"); - int tries = 0; - while (tries < 10) { - ++tries; - render({}); - QMetaObject::invokeMethod(containerItem, "fitAndHideBox"); - } - } + if (m_containerItem && m_contentItem) { + resizeContent(m_size); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + QTimer::singleShot(0, this, &IconRenderer::createIcon); #else - Q_UNUSED(is3D) - Q_UNUSED(containerItem) + m_quickView->show(); + m_quickView->lower(); + + // Failsafe to exit eventually if window fails to expose + QTimer::singleShot(10000, qGuiApp, &QGuiApplication::quit); #endif - QFileInfo fi(m_filePath); - - // Render regular size image - render(fi.absoluteFilePath()); - - // Render @2x image - m_contentItem->setSize(QSizeF(m_size * 2, m_size * 2)); - - QString saveFile; - saveFile = fi.absolutePath() + '/' + fi.completeBaseName() + "@2x"; - if (!fi.suffix().isEmpty()) - saveFile += '.' + fi.suffix(); - - fi.absoluteDir().mkpath("."); - - render(saveFile); - - // Allow little time for file operations to finish - QTimer::singleShot(1000, qGuiApp, &QGuiApplication::quit); - }); } else { QTimer::singleShot(0, qGuiApp, &QGuiApplication::quit); } @@ -156,6 +127,56 @@ void IconRenderer::setupRender() } } +bool IconRenderer::eventFilter(QObject *watched, QEvent *event) +{ +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + if (watched == m_quickView && event->type() == QEvent::Expose) + QTimer::singleShot(0, this, &IconRenderer::createIcon); +#endif + return false; +} + +void IconRenderer::createIcon() +{ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + m_designerSupport.refFromEffectItem(m_quickView->rootObject(), false); +#endif + QQuickDesignerSupportItems::disableNativeTextRendering(m_quickView->rootObject()); + +#ifdef QUICK3D_MODULE + if (m_is3D) { + // Render once to make sure scene is up to date before we set up the selection box + render({}); + QMetaObject::invokeMethod(m_containerItem, "setSceneToBox"); + int tries = 0; + while (tries < 10) { + ++tries; + render({}); + QMetaObject::invokeMethod(m_containerItem, "fitAndHideBox"); + } + } +#endif + QFileInfo fi(m_filePath); + + // Render regular size image + render(fi.absoluteFilePath()); + + // Render @2x image + resizeContent(m_size * 2); + + QString saveFile; + saveFile = fi.absolutePath() + '/' + fi.completeBaseName() + "@2x"; + if (!fi.suffix().isEmpty()) + saveFile += '.' + fi.suffix(); + + fi.absoluteDir().mkpath("."); + + render(saveFile); + + // Allow little time for file operations to finish + QTimer::singleShot(1000, qGuiApp, &QGuiApplication::quit); +} + void IconRenderer::render(const QString &fileName) { std::function updateNodesRecursive; @@ -163,14 +184,30 @@ void IconRenderer::render(const QString &fileName) const auto childItems = item->childItems(); for (QQuickItem *childItem : childItems) updateNodesRecursive(childItem); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) DesignerSupport::updateDirtyNode(item); +#else + if (item->flags() & QQuickItem::ItemHasContents) + item->update(); +#endif }; updateNodesRecursive(m_quickView->rootObject()); QRect rect(QPoint(), m_contentItem->size().toSize()); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QImage renderImage = m_designerSupport.renderImageForItem(m_quickView->rootObject(), rect, rect.size()); +#else + QImage renderImage = m_quickView->grabWindow(); +#endif if (!fileName.isEmpty()) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + if (m_ratio != 1.) { + rect.setWidth(qRound(rect.size().width() * m_ratio)); + rect.setHeight(qRound(rect.size().height() * m_ratio)); + } + renderImage = renderImage.copy(rect); +#endif QFileInfo fi(fileName); if (fi.suffix().isEmpty()) renderImage.save(fileName, "PNG"); @@ -178,3 +215,17 @@ void IconRenderer::render(const QString &fileName) renderImage.save(fileName); } } + +void IconRenderer::resizeContent(int size) +{ + int theSize = size; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + if (m_ratio != 1.) + theSize = qRound(qreal(size) / m_quickView->devicePixelRatio()); +#endif + m_contentItem->setSize(QSizeF(theSize, theSize)); + if (m_contentItem->width() > m_containerItem->width()) + m_containerItem->setWidth(m_contentItem->width()); + if (m_contentItem->height() > m_containerItem->height()) + m_containerItem->setHeight(m_contentItem->height()); +} diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.h index f7bab0f6fc6..64afed6f8ae 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.h @@ -44,13 +44,21 @@ public: void setupRender(); +protected: + bool eventFilter(QObject *watched, QEvent *event) override; + private: + void createIcon(); void render(const QString &fileName); + void resizeContent(int size); int m_size = 16; + double m_ratio = 1.; QString m_filePath; QString m_source; QQuickView *m_quickView = nullptr; QQuickItem *m_contentItem = nullptr; + QQuickItem *m_containerItem = nullptr; DesignerSupport m_designerSupport; + bool m_is3D = false; }; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp index 183f036bf73..ece608fdc98 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp @@ -78,7 +78,6 @@ #include #include #include -#include #include #include #include @@ -1477,4 +1476,8 @@ void NodeInstanceServer::sheduleRootItemRender() } } +void NodeInstanceServer::initializeAuxiliaryViews() +{ +} + } // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h index d5726a31f6f..78e35d98a92 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h @@ -253,6 +253,7 @@ protected: void setSlowRenderTimerInterval(int timerInterval); virtual void initializeView() = 0; + virtual void initializeAuxiliaryViews(); virtual void setupScene(const CreateSceneCommand &command) = 0; void setTranslationLanguage(const QString &language); void loadDummyDataFiles(const QString& directory); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp index ecd066d16ce..94702ed6099 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp @@ -76,6 +76,7 @@ #include #include +#include #include #include @@ -92,6 +93,9 @@ #include #include #include +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#include "../editor3d/qt5compat/qquick3darealight_p.h" +#endif #endif namespace QmlDesigner { @@ -128,9 +132,14 @@ static bool imageHasContent(const QImage &image) QQuickView *Qt5InformationNodeInstanceServer::createAuxiliaryQuickView(const QUrl &url, QQuickItem *&rootItem) { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) auto view = new QQuickView(quickView()->engine(), quickView()); view->setFormat(quickView()->format()); DesignerSupport::createOpenGLContext(view); +#else + auto view = new QQuickView(quickView()->engine(), nullptr); + view->setFormat(quickView()->format()); +#endif QQmlComponent component(engine()); component.loadUrl(url); rootItem = qobject_cast(component.create()); @@ -151,10 +160,13 @@ void Qt5InformationNodeInstanceServer::createEditView3D() qmlRegisterRevision("MouseArea3D", 1, 0); qmlRegisterType("MouseArea3D", 1, 0, "MouseArea3D"); qmlRegisterType("CameraGeometry", 1, 0, "CameraGeometry"); - qmlRegisterType("LightGeometry", 1, 0, "LightGeometry"); + qmlRegisterType("LightUtils", 1, 0, "LightGeometry"); qmlRegisterType("GridGeometry", 1, 0, "GridGeometry"); qmlRegisterType("SelectionBoxGeometry", 1, 0, "SelectionBoxGeometry"); qmlRegisterType("LineGeometry", 1, 0, "LineGeometry"); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qmlRegisterType("LightUtils", 1, 0, "AreaLight"); +#endif auto helper = new QmlDesigner::Internal::GeneralHelper(); QObject::connect(helper, &QmlDesigner::Internal::GeneralHelper::toolStateChanged, @@ -166,24 +178,8 @@ void Qt5InformationNodeInstanceServer::createEditView3D() m_editView3D = createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/EditView3D.qml"), m_editView3DRootItem); - if (m_editView3DRootItem) { - QObject::connect(m_editView3DRootItem, SIGNAL(selectionChanged(QVariant)), - this, SLOT(handleSelectionChanged(QVariant))); - QObject::connect(m_editView3DRootItem, SIGNAL(commitObjectProperty(QVariant, QVariant)), - this, SLOT(handleObjectPropertyCommit(QVariant, QVariant))); - QObject::connect(m_editView3DRootItem, SIGNAL(changeObjectProperty(QVariant, QVariant)), - this, SLOT(handleObjectPropertyChange(QVariant, QVariant))); - QObject::connect(m_editView3DRootItem, SIGNAL(notifyActiveSceneChange()), - this, SLOT(handleActiveSceneChange())); - QObject::connect(&m_propertyChangeTimer, &QTimer::timeout, - this, &Qt5InformationNodeInstanceServer::handleObjectPropertyChangeTimeout); - QObject::connect(&m_selectionChangeTimer, &QTimer::timeout, - this, &Qt5InformationNodeInstanceServer::handleSelectionChangeTimeout); - QObject::connect(&m_render3DEditViewTimer, &QTimer::timeout, - this, &Qt5InformationNodeInstanceServer::doRender3DEditView); - + if (m_editView3DRootItem) helper->setParent(m_editView3DRootItem); - } #endif } @@ -380,6 +376,9 @@ void Qt5InformationNodeInstanceServer::updateView3DRect(QObject *view3D) void Qt5InformationNodeInstanceServer::updateActiveSceneToEditView3D() { #ifdef QUICK3D_MODULE + if (!m_editView3DSetupDone) + return; + // Active scene change handling on qml side is async, so a deleted importScene would crash // editView when it updates next. Disable/enable edit view update synchronously to avoid this. QVariant activeSceneVar = objectToVariant(m_active3DScene); @@ -431,6 +430,9 @@ void Qt5InformationNodeInstanceServer::removeNode3D(QObject *node) void Qt5InformationNodeInstanceServer::resolveSceneRoots() { #ifdef QUICK3D_MODULE + if (!m_editView3DSetupDone) + return; + const auto oldMap = m_3DSceneMap; m_3DSceneMap.clear(); auto it = oldMap.begin(); @@ -477,16 +479,23 @@ ServerNodeInstance Qt5InformationNodeInstanceServer::active3DSceneInstance() con void Qt5InformationNodeInstanceServer::updateNodesRecursive(QQuickItem *item) { - for (QQuickItem *childItem : item->childItems()) + const auto childItems = item->childItems(); + for (QQuickItem *childItem : childItems) updateNodesRecursive(childItem); - DesignerSupport::updateDirtyNode(item); + if (Internal::QuickItemNodeInstance::unifiedRenderPath()) { + if (item->flags() & QQuickItem::ItemHasContents) + item->update(); + } else { + DesignerSupport::updateDirtyNode(item); + } } QQuickItem *Qt5InformationNodeInstanceServer::getContentItemForRendering(QQuickItem *rootItem) { QQuickItem *contentItem = QQmlProperty::read(rootItem, "contentItem").value(); if (contentItem) { - designerSupport()->refFromEffectItem(contentItem, false); + if (!Internal::QuickItemNodeInstance::unifiedRenderPath()) + designerSupport()->refFromEffectItem(contentItem, false); QmlDesigner::Internal::QmlPrivateGate::disableNativeTextRendering(contentItem); } return contentItem; @@ -502,22 +511,32 @@ void Qt5InformationNodeInstanceServer::render3DEditView(int count) // render the 3D edit view and send the result to creator process void Qt5InformationNodeInstanceServer::doRender3DEditView() { - if (m_editView3DRootItem) { + if (m_editView3DSetupDone) { if (!m_editView3DContentItem) m_editView3DContentItem = getContentItemForRendering(m_editView3DRootItem); + QImage renderImage; + updateNodesRecursive(m_editView3DContentItem); - // Fake render loop signaling to update things like QML items as 3D textures - m_editView3D->beforeSynchronizing(); - m_editView3D->beforeRendering(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + if (Internal::QuickItemNodeInstance::unifiedRenderPath()) { + renderImage = m_editView3D->grabWindow(); + } else { + // Fake render loop signaling to update things like QML items as 3D textures + m_editView3D->beforeSynchronizing(); + m_editView3D->beforeRendering(); - QSizeF size = qobject_cast(m_editView3DContentItem)->size(); - QRectF renderRect(QPointF(0., 0.), size); - QImage renderImage = designerSupport()->renderImageForItem(m_editView3DContentItem, - renderRect, size.toSize()); + QSizeF size = qobject_cast(m_editView3DContentItem)->size(); + QRectF renderRect(QPointF(0., 0.), size); + renderImage = designerSupport()->renderImageForItem(m_editView3DContentItem, + renderRect, size.toSize()); - m_editView3D->afterRendering(); + m_editView3D->afterRendering(); + } +#else + renderImage = m_editView3D->grabWindow(); +#endif // There's no instance related to image, so instance id is -1. // Key number is selected so that it is unlikely to conflict other ImageContainer use. @@ -581,27 +600,42 @@ void Qt5InformationNodeInstanceServer::doRenderModelNode3DImageView() instanceObj = instance.internalObject(); } QSize renderSize = m_modelNodePreviewImageCommand.size(); + if (Internal::QuickItemNodeInstance::unifiedRenderPath()) { + // Requested size is already adjusted for target pixel ratio, so we have to adjust + // back if ratio is not default for our window. + double ratio = m_ModelNode3DImageView->devicePixelRatio(); + renderSize.setWidth(qRound(qreal(renderSize.width()) / ratio)); + renderSize.setHeight(qRound(qreal(renderSize.height()) / ratio)); + } QMetaObject::invokeMethod(m_ModelNode3DImageViewRootItem, "createViewForObject", Q_ARG(QVariant, objectToVariant(instanceObj)), Q_ARG(QVariant, QVariant::fromValue(renderSize.width())), Q_ARG(QVariant, QVariant::fromValue(renderSize.height()))); + bool ready = false; int count = 0; // Ensure we don't ever get stuck in an infinite loop while (!ready && ++count < 10) { updateNodesRecursive(m_ModelNode3DImageViewContentItem); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + if (Internal::QuickItemNodeInstance::unifiedRenderPath()) { + renderImage = m_ModelNode3DImageView->grabWindow(); + } else { + // Fake render loop signaling to update things like QML items as 3D textures + m_ModelNode3DImageView->beforeSynchronizing(); + m_ModelNode3DImageView->beforeRendering(); - // Fake render loop signaling to update things like QML items as 3D textures - m_ModelNode3DImageView->beforeSynchronizing(); - m_ModelNode3DImageView->beforeRendering(); - - QSizeF size = qobject_cast(m_ModelNode3DImageViewContentItem)->size(); - QRectF renderRect(QPointF(0., 0.), size); - renderImage = designerSupport()->renderImageForItem(m_ModelNode3DImageViewContentItem, - renderRect, size.toSize()); - m_ModelNode3DImageView->afterRendering(); + QSizeF size = qobject_cast(m_ModelNode3DImageViewContentItem)->size(); + QRectF renderRect(QPointF(0., 0.), size); + renderImage = designerSupport()->renderImageForItem(m_ModelNode3DImageViewContentItem, + renderRect, size.toSize()); + m_ModelNode3DImageView->afterRendering(); + } +#else + renderImage = m_ModelNode3DImageView->grabWindow(); +#endif QMetaObject::invokeMethod(m_ModelNode3DImageViewRootItem, "afterRender"); ready = QQmlProperty::read(m_ModelNode3DImageViewRootItem, "ready").value(); } @@ -682,12 +716,23 @@ void Qt5InformationNodeInstanceServer::doRenderModelNode2DImageView() if (renderSize.isEmpty()) { renderSize = finalSize; renderRect = QRectF(QPointF(0., 0.), QSizeF(renderSize)); - instanceItem->setSize(renderSize); } + m_ModelNode2DImageView->resize(renderSize); + m_ModelNode2DImageViewRootItem->setSize(renderSize); + m_ModelNode2DImageViewContentItem->setPosition(QPointF(-renderRect.x(), -renderRect.y())); updateNodesRecursive(m_ModelNode2DImageViewContentItem); - renderImage = designerSupport()->renderImageForItem(m_ModelNode2DImageViewContentItem, renderRect, renderSize); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + if (Internal::QuickItemNodeInstance::unifiedRenderPath()) { + renderImage = m_ModelNode2DImageView->grabWindow(); + } else { + renderImage = designerSupport()->renderImageForItem(m_ModelNode2DImageViewContentItem, + renderRect, renderSize); + } +#else + renderImage = m_ModelNode2DImageView->grabWindow(); +#endif if (!imageHasContent(renderImage)) renderImage = nonVisualComponentPreviewImage(); @@ -721,6 +766,12 @@ Qt5InformationNodeInstanceServer::Qt5InformationNodeInstanceServer(NodeInstanceC m_renderModelNodeImageViewTimer.setSingleShot(true); } +Qt5InformationNodeInstanceServer::~Qt5InformationNodeInstanceServer() +{ + for (auto view : qAsConst(m_view3Ds)) + QObject::disconnect(view, nullptr, this, nullptr); +} + void Qt5InformationNodeInstanceServer::sendTokenBack() { foreach (const TokenCommand &command, m_tokenList) @@ -795,7 +846,7 @@ QList Qt5InformationNodeInstanceServer::createInstances( { const auto createdInstances = NodeInstanceServer::createInstances(container); - if (m_editView3DRootItem) { + if (m_editView3DSetupDone) { add3DViewPorts(createdInstances); add3DScenes(createdInstances); createCameraAndLightGizmos(createdInstances); @@ -806,6 +857,37 @@ QList Qt5InformationNodeInstanceServer::createInstances( return createdInstances; } +void Qt5InformationNodeInstanceServer::initializeAuxiliaryViews() +{ +#ifdef QUICK3D_MODULE + if (qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_MODE")) { + createEditView3D(); + m_ModelNode3DImageView = createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/ModelNode3DImageView.qml"), + m_ModelNode3DImageViewRootItem); + } +#endif + + m_ModelNode2DImageView = createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/ModelNode2DImageView.qml"), + m_ModelNode2DImageViewRootItem); + m_ModelNode2DImageView->setDefaultAlphaBuffer(true); + m_ModelNode2DImageView->setColor(Qt::transparent); + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + if (!m_editView3D.isNull()) { + m_editView3D->show(); + m_editView3D->lower(); + } + if (!m_ModelNode3DImageView.isNull()) { + m_ModelNode3DImageView->show(); + m_ModelNode3DImageView->lower(); + } + if (!m_ModelNode2DImageView.isNull()) { + m_ModelNode2DImageView->show(); + m_ModelNode2DImageView->lower(); + } +#endif +} + void Qt5InformationNodeInstanceServer::handleObjectPropertyChangeTimeout() { modifyVariantValue(m_changedNode, m_changedProperty, @@ -1028,14 +1110,28 @@ void Qt5InformationNodeInstanceServer::setup3DEditView(const QList &toolStates) { #ifdef QUICK3D_MODULE + if (!m_editView3DRootItem) + return; + ServerNodeInstance root = rootNodeInstance(); add3DViewPorts(instanceList); add3DScenes(instanceList); - createEditView3D(); - m_ModelNode3DImageView = createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/ModelNode3DImageView.qml"), - m_ModelNode3DImageViewRootItem); + QObject::connect(m_editView3DRootItem, SIGNAL(selectionChanged(QVariant)), + this, SLOT(handleSelectionChanged(QVariant))); + QObject::connect(m_editView3DRootItem, SIGNAL(commitObjectProperty(QVariant, QVariant)), + this, SLOT(handleObjectPropertyCommit(QVariant, QVariant))); + QObject::connect(m_editView3DRootItem, SIGNAL(changeObjectProperty(QVariant, QVariant)), + this, SLOT(handleObjectPropertyChange(QVariant, QVariant))); + QObject::connect(m_editView3DRootItem, SIGNAL(notifyActiveSceneChange()), + this, SLOT(handleActiveSceneChange())); + QObject::connect(&m_propertyChangeTimer, &QTimer::timeout, + this, &Qt5InformationNodeInstanceServer::handleObjectPropertyChangeTimeout); + QObject::connect(&m_selectionChangeTimer, &QTimer::timeout, + this, &Qt5InformationNodeInstanceServer::handleSelectionChangeTimeout); + QObject::connect(&m_render3DEditViewTimer, &QTimer::timeout, + this, &Qt5InformationNodeInstanceServer::doRender3DEditView); QString lastSceneId; auto helper = qobject_cast(m_3dHelper); @@ -1056,7 +1152,7 @@ void Qt5InformationNodeInstanceServer::setup3DEditView(const QList instanceList; - foreach (const InstanceContainer &container, command.instances()) { + const auto instances = command.instances(); + for (const InstanceContainer &container : instances) { if (hasInstanceForId(container.instanceId())) { ServerNodeInstance instance = instanceForId(container.instanceId()); - if (instance.isValid()) { + if (instance.isValid()) instanceList.append(instance); - } } } @@ -1212,8 +1310,6 @@ void Qt5InformationNodeInstanceServer::createScene(const CreateSceneCommand &com if (qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_MODE")) setup3DEditView(instanceList, command.edit3dToolStates()); - m_ModelNode2DImageView = createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/ModelNode2DImageView.qml"), - m_ModelNode2DImageViewRootItem); QObject::connect(&m_renderModelNodeImageViewTimer, &QTimer::timeout, this, &Qt5InformationNodeInstanceServer::doRenderModelNodeImageView); } @@ -1274,7 +1370,7 @@ void QmlDesigner::Qt5InformationNodeInstanceServer::removeSharedMemory(const Qml void Qt5InformationNodeInstanceServer::changeSelection(const ChangeSelectionCommand &command) { - if (!m_editView3DRootItem) + if (!m_editView3DSetupDone) return; m_lastSelectionChangeCommand = command; @@ -1380,7 +1476,7 @@ void Qt5InformationNodeInstanceServer::removeInstances(const RemoveInstancesComm resolveSceneRoots(); } - if (m_editView3DRootItem && (!m_active3DScene || !m_active3DView)) { + if (m_editView3DSetupDone && (!m_active3DScene || !m_active3DView)) { if (!m_active3DScene && !m_3DSceneMap.isEmpty()) m_active3DScene = m_3DSceneMap.begin().key(); m_active3DView = findView3DForSceneRoot(m_active3DScene); @@ -1417,6 +1513,9 @@ void Qt5InformationNodeInstanceServer::inputEvent(const InputEventCommand &comma void Qt5InformationNodeInstanceServer::view3DAction(const View3DActionCommand &command) { + if (!m_editView3DSetupDone) + return; + QVariantMap updatedState; int renderCount = 1; @@ -1486,20 +1585,22 @@ void Qt5InformationNodeInstanceServer::changeIds(const ChangeIdsCommand &command Qt5NodeInstanceServer::changeIds(command); #ifdef QUICK3D_MODULE - ServerNodeInstance sceneInstance = active3DSceneInstance(); - if (m_active3DSceneUpdatePending) { - const QString sceneId = sceneInstance.id(); - if (!sceneId.isEmpty()) - updateActiveSceneToEditView3D(); - } else { - qint32 sceneInstanceId = sceneInstance.instanceId(); - for (const auto &id : command.ids) { - if (sceneInstanceId == id.instanceId()) { - QMetaObject::invokeMethod(m_editView3DRootItem, "handleActiveSceneIdChange", - Qt::QueuedConnection, - Q_ARG(QVariant, QVariant(sceneInstance.id()))); - render3DEditView(); - break; + if (m_editView3DSetupDone) { + ServerNodeInstance sceneInstance = active3DSceneInstance(); + if (m_active3DSceneUpdatePending) { + const QString sceneId = sceneInstance.id(); + if (!sceneId.isEmpty()) + updateActiveSceneToEditView3D(); + } else { + qint32 sceneInstanceId = sceneInstance.instanceId(); + for (const auto &id : command.ids) { + if (sceneInstanceId == id.instanceId()) { + QMetaObject::invokeMethod(m_editView3DRootItem, "handleActiveSceneIdChange", + Qt::QueuedConnection, + Q_ARG(QVariant, QVariant(sceneInstance.id()))); + render3DEditView(); + break; + } } } } @@ -1525,7 +1626,7 @@ void Qt5InformationNodeInstanceServer::update3DViewState(const Update3dViewState { #ifdef QUICK3D_MODULE if (command.type() == Update3dViewStateCommand::SizeChange) { - if (m_editView3DRootItem) { + if (m_editView3DSetupDone) { m_editView3DRootItem->setSize(command.size()); auto helper = qobject_cast(m_3dHelper); if (helper) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h index 881e6769156..8f3af1ccdb4 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h @@ -49,6 +49,7 @@ class Qt5InformationNodeInstanceServer : public Qt5NodeInstanceServer public: explicit Qt5InformationNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient); + ~Qt5InformationNodeInstanceServer() override; void reparentInstances(const ReparentInstancesCommand &command) override; void clearScene(const ClearSceneCommand &command) override; @@ -89,6 +90,7 @@ protected: void selectInstances(const QList &instanceList); void modifyProperties(const QVector &properties); QList createInstances(const QVector &container) override; + void initializeAuxiliaryViews() override; private: void handleObjectPropertyChangeTimeout(); @@ -129,6 +131,7 @@ private: QPointer m_editView3D; QQuickItem *m_editView3DRootItem = nullptr; QQuickItem *m_editView3DContentItem = nullptr; + bool m_editView3DSetupDone = false; QPointer m_ModelNode3DImageView; QQuickItem *m_ModelNode3DImageViewRootItem = nullptr; QQuickItem *m_ModelNode3DImageViewContentItem = nullptr; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp index c2015299c52..3cc541545ea 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp @@ -81,6 +81,14 @@ void Qt5NodeInstanceServer::initializeView() QStringList customSelectors = QString::fromUtf8(qgetenv("QML_FILE_SELECTORS")).split(','); fileSelector->setExtraSelectors(customSelectors); } + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + // View needs to be shown for all puppets before any instances are created in case there is a View3D + quickView()->show(); + quickView()->lower(); +#endif + + initializeAuxiliaryViews(); } QQmlView *Qt5NodeInstanceServer::declarativeView() const diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp index fd3446f3968..9722280dfa9 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp @@ -147,11 +147,6 @@ void Qt5RenderNodeInstanceServer::createScene(const CreateSceneCommand &command) } nodeInstanceClient()->pixmapChanged(createPixmapChangedCommand(instanceList)); - -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -#else - quickView()->show(); -#endif } void Qt5RenderNodeInstanceServer::clearScene(const ClearSceneCommand &command) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp index 1f54bffdbd8..1c08b408e6e 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp @@ -262,10 +262,8 @@ QStringList QuickItemNodeInstance::allStates() const void QuickItemNodeInstance::updateDirtyNode(QQuickItem *item) { - if (s_unifiedRenderPath) { - item->update(); + if (s_unifiedRenderPath) return; - } DesignerSupport::updateDirtyNode(item); } @@ -417,23 +415,24 @@ QImage QuickItemNodeInstance::renderImage() const static double devicePixelRatio = qgetenv("FORMEDITOR_DEVICE_PIXEL_RATIO").toDouble(); size *= devicePixelRatio; - // Fake render loop signaling to update things like QML items as 3D textures - nodeInstanceServer()->quickView()->beforeSynchronizing(); - nodeInstanceServer()->quickView()->beforeRendering(); - QImage renderImage; #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - if (s_unifiedRenderPath) + if (s_unifiedRenderPath) { renderImage = nodeInstanceServer()->quickView()->grabWindow(); - else + } else { + // Fake render loop signaling to update things like QML items as 3D textures + nodeInstanceServer()->quickView()->beforeSynchronizing(); + nodeInstanceServer()->quickView()->beforeRendering(); + renderImage = designerSupport()->renderImageForItem(quickItem(), renderBoundingRect, size); + + nodeInstanceServer()->quickView()->afterRendering(); + } #else renderImage = nodeInstanceServer()->quickView()->grabWindow(); #endif - nodeInstanceServer()->quickView()->afterRendering(); - renderImage.setDevicePixelRatio(devicePixelRatio); return renderImage; @@ -447,27 +446,27 @@ QImage QuickItemNodeInstance::renderPreviewImage(const QSize &previewImageSize) static double devicePixelRatio = qgetenv("FORMEDITOR_DEVICE_PIXEL_RATIO").toDouble(); const QSize size = previewImageSize * devicePixelRatio; if (quickItem()->isVisible()) { - // Fake render loop signaling to update things like QML items as 3D textures - nodeInstanceServer()->quickView()->beforeSynchronizing(); - nodeInstanceServer()->quickView()->beforeRendering(); - QImage image; #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - if (s_unifiedRenderPath) + if (s_unifiedRenderPath) { image = nodeInstanceServer()->quickView()->grabWindow(); - else + } else { + // Fake render loop signaling to update things like QML items as 3D textures + nodeInstanceServer()->quickView()->beforeSynchronizing(); + nodeInstanceServer()->quickView()->beforeRendering(); + image = designerSupport()->renderImageForItem(quickItem(), previewItemBoundingRect, size); + nodeInstanceServer()->quickView()->afterRendering(); + } #else image = nodeInstanceServer()->quickView()->grabWindow(); #endif image = image.scaledToWidth(size.width()); - nodeInstanceServer()->quickView()->afterRendering(); - return image; } else { QImage transparentImage(size, QImage::Format_ARGB32_Premultiplied); @@ -686,7 +685,8 @@ void QuickItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParen if (quickItem()->parentItem()) { refresh(); - DesignerSupport::updateDirtyNode(quickItem()); + + updateDirtyNode(quickItem()); if (instanceIsValidLayoutable(oldParentInstance, oldParentProperty)) oldParentInstance->refreshLayoutable(); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp index 1f94bc3e59e..cd2877a4f52 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp @@ -31,8 +31,11 @@ #include -#include +#include +#include + #include "iconrenderer/iconrenderer.h" +#include #include #include @@ -46,6 +49,54 @@ #endif namespace { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) +{ + QByteArray localMsg = msg.toLocal8Bit(); + switch (type) { + case QtDebugMsg: + fprintf(stderr, + "Debug: %s (%s:%u, %s)\n", + localMsg.constData(), + context.file, + context.line, + context.function); + break; + case QtInfoMsg: + fprintf(stderr, + "Info: %s (%s:%u, %s)\n", + localMsg.constData(), + context.file, + context.line, + context.function); + break; + case QtWarningMsg: + fprintf(stderr, + "Warning: %s (%s:%u, %s)\n", + localMsg.constData(), + context.file, + context.line, + context.function); + break; + case QtCriticalMsg: + fprintf(stderr, + "Critical: %s (%s:%u, %s)\n", + localMsg.constData(), + context.file, + context.line, + context.function); + break; + case QtFatalMsg: + fprintf(stderr, + "Fatal: %s (%s:%u, %s)\n", + localMsg.constData(), + context.file, + context.line, + context.function); + abort(); + } +} +#endif int internalMain(QGuiApplication *application) { @@ -144,6 +195,9 @@ int internalMain(QGuiApplication *application) int main(int argc, char *argv[]) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qInstallMessageHandler(myMessageOutput); +#endif // Since we always render text into an FBO, we need to globally disable // subpixel antialiasing and instead use gray. qputenv("QSG_DISTANCEFIELD_ANTIALIASING", "gray"); diff --git a/src/plugins/qmldesigner/components/edit3d/edit3dcanvas.cpp b/src/plugins/qmldesigner/components/edit3d/edit3dcanvas.cpp index 91aa0062991..de3757e68c7 100644 --- a/src/plugins/qmldesigner/components/edit3d/edit3dcanvas.cpp +++ b/src/plugins/qmldesigner/components/edit3d/edit3dcanvas.cpp @@ -92,7 +92,7 @@ void Edit3DCanvas::paintEvent(QPaintEvent *e) QPainter painter(this); - painter.drawImage(rect(), m_image, rect()); + painter.drawImage(rect(), m_image, QRect(0, 0, m_image.width(), m_image.height())); } void Edit3DCanvas::resizeEvent(QResizeEvent *e) diff --git a/src/tools/qml2puppet/CMakeLists.txt b/src/tools/qml2puppet/CMakeLists.txt index 85809020d8c..1dbdd5b7fa3 100644 --- a/src/tools/qml2puppet/CMakeLists.txt +++ b/src/tools/qml2puppet/CMakeLists.txt @@ -137,6 +137,14 @@ extend_qtc_executable(qml2puppet icongizmoimageprovider.cpp icongizmoimageprovider.h ) +extend_qtc_executable(qml2puppet + CONDITION Qt5_VERSION VERSION_GREATER_EQUAL 6.0.0 + + SOURCES_PREFIX "${SRCDIR}/qml2puppet/editor3d/qt5compat" + SOURCES + qquick3darealight.cpp qquick3darealight_p.h +) + extend_qtc_executable(qml2puppet SOURCES_PREFIX "${SRCDIR}/qml2puppet/iconrenderer" SOURCES diff --git a/src/tools/qml2puppet/qml2puppet.qbs b/src/tools/qml2puppet/qml2puppet.qbs index 742c20406ec..63341b5dc28 100644 --- a/src/tools/qml2puppet/qml2puppet.qbs +++ b/src/tools/qml2puppet/qml2puppet.qbs @@ -19,6 +19,8 @@ QtcTool { property bool useQuick3d: Utilities.versionCompare(Qt.core.version, "5.15") >= 0 && Qt["quick3d-private"].present + property bool useQt5Compat: Utilities.versionCompare(Qt.core.version, "6.0") >= 0 + cpp.defines: { var defines = base.filter(function(d) { return d != "QT_CREATOR"; }); if (useQuick3d) @@ -258,6 +260,20 @@ QtcTool { fileTags: product.useQuick3d ? [] : ["unmocable"] overrideTags: false } + + Group { + name: "puppet2 Qt 5 compatibility sources" + condition: useQt5Compat + files: ["editor3d/qt5compat/qquick3darealight.cpp"] + } + + Group { + name: "puppet2 Qt 5 compatibility headers" + condition: useQt5Compat + files: ["editor3d/qt5compat/qquick3darealight_p.h"] + fileTags: product.useQuick3d ? [] : ["unmocable"] + overrideTags: false + } } Group { From 0ca9ea353c91b9715e1dc9e8533560f94f261e23 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 20 Oct 2020 10:16:33 +0200 Subject: [PATCH 22/22] Editor: Do not use disabled code color for right margin highlight Fixes: QTCREATORBUG-17174 Change-Id: I68729d5a44b23fe46b810054a1dc472ffd63e272 Reviewed-by: Christian Stenger --- src/plugins/texteditor/texteditor.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index ec634b0e85c..6bd05f9b2c0 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -4175,6 +4175,13 @@ void TextEditorWidgetPrivate::updateLineAnnotation(const PaintEventData &data, q->viewport()->update(updateRect); } +QColor blendRightMarginColor(const FontSettings &settings, bool areaColor) +{ + const QColor baseColor = settings.toTextCharFormat(C_TEXT).background().color(); + const QColor col = (baseColor.value() > 128) ? Qt::black : Qt::white; + return blendColors(baseColor, col, areaColor ? 16 : 32); +} + void TextEditorWidgetPrivate::paintRightMarginArea(PaintEventData &data, QPainter &painter) const { if (m_visibleWrapColumn <= 0) @@ -4189,7 +4196,7 @@ void TextEditorWidgetPrivate::paintRightMarginArea(PaintEventData &data, QPainte data.eventRect.top(), data.viewportRect.width() - data.rightMargin, data.eventRect.height()); - painter.fillRect(behindMargin, data.ifdefedOutFormat.background()); + painter.fillRect(behindMargin, blendRightMarginColor(m_document->fontSettings(), true)); } } @@ -4199,11 +4206,8 @@ void TextEditorWidgetPrivate::paintRightMarginLine(const PaintEventData &data, if (m_visibleWrapColumn <= 0 || data.rightMargin >= data.viewportRect.width()) return; - const QBrush background = data.ifdefedOutFormat.background(); - const QColor baseColor = m_document->fontSettings().toTextCharFormat(C_TEXT).background().color(); - const QColor col = (baseColor.value() > 128) ? Qt::black : Qt::white; const QPen pen = painter.pen(); - painter.setPen(blendColors(background.isOpaque() ? background.color() : baseColor, col, 32)); + painter.setPen(blendRightMarginColor(m_document->fontSettings(), false)); painter.drawLine(QPointF(data.rightMargin, data.eventRect.top()), QPointF(data.rightMargin, data.eventRect.bottom())); painter.setPen(pen);