diff --git a/dist/changes-8.0.2.md b/dist/changes-8.0.2.md new file mode 100644 index 00000000000..7dc343604d1 --- /dev/null +++ b/dist/changes-8.0.2.md @@ -0,0 +1,91 @@ +Qt Creator 8.0.2 +================ + +Qt Creator version 8.0.2 contains bug fixes. + +The most important changes are listed in this document. For a complete list of +changes, see the Git log for the Qt Creator sources that you can check out from +the public Git repository. For example: + + git clone git://code.qt.io/qt-creator/qt-creator.git + git log --cherry-pick --pretty=oneline origin/v8.0.1..v8.0.2 + +Editing +------- + +* Fixed importing color schemes +* Fixed moving text between editors by drag & drop (QTCREATORBUG-28125, + QTCREATORBUG-28126) +* Fixed that the default font could be blurry (QTCREATORBUG-28106, + QTCREATORBUG-28139) + +### C++ + +* Re-added non-Clangd version of `Extract Function` (QTCREATORBUG-28030) + +### Language Client + +* Fixed issues after resetting server (QTCREATORBUG-27596) + +### SCXML + +* Fixed crash when closing document (QTCREATORBUG-28027) + +Version Control +--------------- + +* Fixed handling of `\r` in tool output (QTCREATORBUG-27615) + +Test Integration +---------------- + +* GTest + * Fixed running selected tests (QTCREATORBUG-28153) +* Catch2 + * Fixed crash when running tests (QTCREATORBUG-28269) + +Platforms +--------- + +### Android + +* Fixed deployment in release mode (QTCREATORBUG-28163) + +### Remote Linux + +* Fixed issue with deployment (QTCREATORBUG-28167) +* Fixed key deployment on Windows (QTCREATORBUG-28092) +* Fixed killing remote processes (QTCREATORBUG-28072) + +Credits for these changes go to: +-------------------------------- +Aleksei German +Ali Kianian +André Pönitz +Antti Määttä +Brook Cronin +Christian Kandeler +Christian Stenger +Cristian Adam +David Schulz +Eike Ziller +Fawzi Mohamed +Henning Gruendl +Ivan Komissarov +Jaroslaw Kobus +Knud Dollereder +Leena Miettinen +Mahmoud Badri +Marco Bubke +Marcus Tillmanns +Mats Honkamaa +Miikka Heikkinen +Petri Virkkunen +Pranta Dastider +Robert Löhning +Samuel Ghinet +Sivert Krøvel +Sona Kurazyan +Thomas Hartmann +Tim Jenssen +Vikas Pachdha diff --git a/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-effects.qdoc b/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-effects.qdoc index a7a91ee8ee1..158932dff8a 100644 --- a/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-effects.qdoc +++ b/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-effects.qdoc @@ -11,8 +11,8 @@ \QDS provides a set of 3D effects, which are visible in the \l {2D} view. To apply a visual effect to a scene, drag-and-drop an effect from \uicontrol Components > \uicontrol {Qt Quick 3D} > - \uicontrol {Qt Quick 3D Effects} to a \uicontrol View3D component in - \l Navigator. + \uicontrol {Qt Quick 3D Effects} to a \uicontrol SceneEnvironment component + in \l Navigator. You can use the \l Effect component available in \uicontrol Components > \uicontrol {Qt Quick 3D} > \uicontrol {Qt Quick 3D} as the base diff --git a/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowser.qml b/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowser.qml index f60f4f150b1..abe06210433 100644 --- a/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowser.qml +++ b/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowser.qml @@ -2,7 +2,6 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 import QtQuick 2.15 -import QtQuick.Layouts 1.15 import QtQuickDesignerTheme 1.0 import HelperWidgets 2.0 import StudioControls 1.0 as StudioControls @@ -14,12 +13,7 @@ Item { readonly property int cellWidth: 100 readonly property int cellHeight: 120 - property var currentMaterial: null - property int currentMaterialIdx: 0 - property var currentBundleMaterial: null - property int copiedMaterialInternalId: -1 - - property var matSectionsModel: [] + property var currMaterialItem: null // Called also from C++ to close context menu on focus out function closeContextMenu() @@ -54,10 +48,9 @@ Item { var userMatsSecBottom = mapFromItem(userMaterialsSection, 0, userMaterialsSection.y).y + userMaterialsSection.height; - if (!materialBrowserModel.hasMaterialRoot && (!materialBrowserBundleModel.matBundleExists - || mouse.y < userMatsSecBottom)) { - root.currentMaterial = null - ctxMenu.popup() + if (!materialBrowserModel.hasMaterialRoot && materialBrowserModel.hasQuick3DImport + && (!materialBrowserBundleModel.matBundleExists || mouse.y < userMatsSecBottom)) { + ctxMenu.popupMenu() } } } @@ -67,11 +60,23 @@ Item { function onSelectedIndexChanged() { // commit rename upon changing selection - var item = gridRepeater.itemAt(currentMaterialIdx); - if (item) - item.commitRename(); + if (root.currMaterialItem) + root.currMaterialItem.commitRename(); - currentMaterialIdx = materialBrowserModel.selectedIndex; + root.currMaterialItem = gridRepeater.itemAt(materialBrowserModel.selectedIndex); + } + } + + MaterialBrowserContextMenu { + id: ctxMenu + } + + MaterialBundleContextMenu { + id: ctxMenuBundle + + onUnimport: (bundleMat) => { + unimportBundleMaterialDialog.targetBundleMaterial = bundleMat + unimportBundleMaterialDialog.open() } } @@ -79,152 +84,6 @@ Item { id: unimportBundleMaterialDialog } - StudioControls.Menu { - id: ctxMenu - - closePolicy: StudioControls.Menu.CloseOnEscape | StudioControls.Menu.CloseOnPressOutside - - StudioControls.MenuItem { - text: qsTr("Apply to selected (replace)") - enabled: root.currentMaterial && materialBrowserModel.hasModelSelection - onTriggered: materialBrowserModel.applyToSelected(root.currentMaterial.materialInternalId, false) - } - - StudioControls.MenuItem { - text: qsTr("Apply to selected (add)") - enabled: root.currentMaterial && materialBrowserModel.hasModelSelection - onTriggered: materialBrowserModel.applyToSelected(root.currentMaterial.materialInternalId, true) - } - - StudioControls.MenuSeparator { - height: StudioTheme.Values.border - } - - StudioControls.Menu { - title: qsTr("Copy properties") - enabled: root.currentMaterial - - width: parent.width - - onAboutToShow: { - if (root.currentMaterial.hasDynamicProperties) - root.matSectionsModel = ["All", "Custom"]; - else - root.matSectionsModel = ["All"]; - - switch (root.currentMaterial.materialType) { - case "DefaultMaterial": - root.matSectionsModel = root.matSectionsModel.concat(materialBrowserModel.defaultMaterialSections); - break; - - case "PrincipledMaterial": - root.matSectionsModel = root.matSectionsModel.concat(materialBrowserModel.principledMaterialSections); - break; - - case "CustomMaterial": - root.matSectionsModel = root.matSectionsModel.concat(materialBrowserModel.customMaterialSections); - break; - } - } - - Repeater { - model: root.matSectionsModel - - StudioControls.MenuItem { - text: modelData - enabled: root.currentMaterial - onTriggered: { - root.copiedMaterialInternalId = root.currentMaterial.materialInternalId - materialBrowserModel.copyMaterialProperties(root.currentMaterialIdx, modelData) - } - } - } - } - - StudioControls.MenuItem { - text: qsTr("Paste properties") - enabled: root.currentMaterial - && root.copiedMaterialInternalId !== root.currentMaterial.materialInternalId - && root.currentMaterial.materialType === materialBrowserModel.copiedMaterialType - && materialBrowserModel.isCopiedMaterialValid() - onTriggered: materialBrowserModel.pasteMaterialProperties(root.currentMaterialIdx) - } - - StudioControls.MenuSeparator { - height: StudioTheme.Values.border - } - - StudioControls.MenuItem { - text: qsTr("Duplicate") - enabled: root.currentMaterial - onTriggered: materialBrowserModel.duplicateMaterial(root.currentMaterialIdx) - } - - StudioControls.MenuItem { - text: qsTr("Rename") - enabled: root.currentMaterial - onTriggered: { - var item = gridRepeater.itemAt(root.currentMaterialIdx); - if (item) - item.startRename(); - } - } - - StudioControls.MenuItem { - text: qsTr("Delete") - enabled: root.currentMaterial - - onTriggered: materialBrowserModel.deleteMaterial(root.currentMaterialIdx) - } - - StudioControls.MenuSeparator {} - - StudioControls.MenuItem { - text: qsTr("Create New Material") - - onTriggered: materialBrowserModel.addNewMaterial() - } - } - - StudioControls.Menu { - id: ctxMenuBundle - - closePolicy: StudioControls.Menu.CloseOnEscape | StudioControls.Menu.CloseOnPressOutside - - StudioControls.MenuItem { - text: qsTr("Apply to selected (replace)") - enabled: root.currentBundleMaterial && materialBrowserModel.hasModelSelection - onTriggered: materialBrowserBundleModel.applyToSelected(root.currentBundleMaterial, false) - } - - StudioControls.MenuItem { - text: qsTr("Apply to selected (add)") - enabled: root.currentBundleMaterial && materialBrowserModel.hasModelSelection - onTriggered: materialBrowserBundleModel.applyToSelected(root.currentBundleMaterial, true) - } - - StudioControls.MenuSeparator {} - - StudioControls.MenuItem { - enabled: !materialBrowserBundleModel.importerRunning - text: qsTr("Add an instance to project") - - onTriggered: { - materialBrowserBundleModel.addToProject(root.currentBundleMaterial) - } - } - - StudioControls.MenuItem { - enabled: !materialBrowserBundleModel.importerRunning && root.currentBundleMaterial.bundleMaterialImported - text: qsTr("Remove from project") - - onTriggered: { - unimportBundleMaterialDialog.targetBundleMaterial = root.currentBundleMaterial - unimportBundleMaterialDialog.open() - } - } - } - Column { id: col y: 5 @@ -266,6 +125,7 @@ Item { anchors.verticalCenter: parent.verticalCenter buttonSize: searchBox.height onClicked: materialBrowserModel.addNewMaterial() + enabled: materialBrowserModel.hasQuick3DImport } } @@ -324,8 +184,7 @@ Item { height: root.cellHeight onShowContextMenu: { - root.currentMaterial = model - ctxMenu.popup() + ctxMenu.popupMenu(this, model) } } } @@ -387,8 +246,7 @@ Item { height: root.cellHeight onShowContextMenu: { - root.currentBundleMaterial = modelData - ctxMenuBundle.popup() + ctxMenuBundle.popupMenu(modelData) } } } diff --git a/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowserContextMenu.qml b/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowserContextMenu.qml new file mode 100644 index 00000000000..d1e9f1ab1f4 --- /dev/null +++ b/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowserContextMenu.qml @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +import QtQuick +import HelperWidgets +import StudioControls as StudioControls +import StudioTheme as StudioTheme + +StudioControls.Menu { + id: root + + property var targetMaterial: null + property var targetItem: null + property int copiedMaterialInternalId: -1 + property var matSectionsModel: [] + + function popupMenu(targetItem = null, targetMaterial = null) + { + this.targetItem = targetItem + this.targetMaterial = targetMaterial + popup() + } + + closePolicy: StudioControls.Menu.CloseOnEscape | StudioControls.Menu.CloseOnPressOutside + + StudioControls.MenuItem { + text: qsTr("Apply to selected (replace)") + enabled: root.targetMaterial && materialBrowserModel.hasModelSelection + onTriggered: materialBrowserModel.applyToSelected(root.targetMaterial.materialInternalId, false) + } + + StudioControls.MenuItem { + text: qsTr("Apply to selected (add)") + enabled: root.targetMaterial && materialBrowserModel.hasModelSelection + onTriggered: materialBrowserModel.applyToSelected(root.targetMaterial.materialInternalId, true) + } + + StudioControls.MenuSeparator {} + + StudioControls.Menu { + title: qsTr("Copy properties") + enabled: root.targetMaterial + + width: parent.width + + onAboutToShow: { + if (root.targetMaterial.hasDynamicProperties) + root.matSectionsModel = ["All", "Custom"]; + else + root.matSectionsModel = ["All"]; + + switch (root.targetMaterial.materialType) { + case "DefaultMaterial": + root.matSectionsModel = root.matSectionsModel.concat(materialBrowserModel.defaultMaterialSections); + break; + + case "PrincipledMaterial": + root.matSectionsModel = root.matSectionsModel.concat(materialBrowserModel.principledMaterialSections); + break; + + case "CustomMaterial": + root.matSectionsModel = root.matSectionsModel.concat(materialBrowserModel.customMaterialSections); + break; + } + } + + Repeater { + model: root.matSectionsModel + + StudioControls.MenuItem { + text: modelData + enabled: root.targetMaterial + onTriggered: { + root.copiedMaterialInternalId = root.targetMaterial.materialInternalId + materialBrowserModel.copyMaterialProperties(materialBrowserModel.selectedIndex, modelData) + } + } + } + } + + StudioControls.MenuItem { + text: qsTr("Paste properties") + enabled: root.targetMaterial + && root.copiedMaterialInternalId !== root.targetMaterial.materialInternalId + && root.targetMaterial.materialType === materialBrowserModel.copiedMaterialType + && materialBrowserModel.isCopiedMaterialValid() + onTriggered: materialBrowserModel.pasteMaterialProperties(materialBrowserModel.selectedIndex) + } + + StudioControls.MenuSeparator {} + + StudioControls.MenuItem { + text: qsTr("Duplicate") + enabled: root.targetMaterial + onTriggered: materialBrowserModel.duplicateMaterial(materialBrowserModel.selectedIndex) + } + + StudioControls.MenuItem { + text: qsTr("Rename") + enabled: root.targetItem + onTriggered: root.targetItem.startRename(); + } + + StudioControls.MenuItem { + text: qsTr("Delete") + enabled: root.targetMaterial + + onTriggered: materialBrowserModel.deleteMaterial(materialBrowserModel.selectedIndex) + } + + StudioControls.MenuSeparator {} + + StudioControls.MenuItem { + text: qsTr("Create New Material") + + onTriggered: materialBrowserModel.addNewMaterial() + } +} diff --git a/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBundleContextMenu.qml b/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBundleContextMenu.qml new file mode 100644 index 00000000000..eb698d69932 --- /dev/null +++ b/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBundleContextMenu.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +import QtQuick 2.15 +import HelperWidgets 2.0 +import StudioControls 1.0 as StudioControls +import StudioTheme 1.0 as StudioTheme + +StudioControls.Menu { + id: root + + property var targetMaterial: null + signal unimport(var bundleMat); + + function popupMenu(targetMaterial = null) + { + this.targetMaterial = targetMaterial + popup() + } + + closePolicy: StudioControls.Menu.CloseOnEscape | StudioControls.Menu.CloseOnPressOutside + + StudioControls.MenuItem { + text: qsTr("Apply to selected (replace)") + enabled: root.targetMaterial && materialBrowserModel.hasModelSelection + onTriggered: materialBrowserBundleModel.applyToSelected(root.targetMaterial, false) + } + + StudioControls.MenuItem { + text: qsTr("Apply to selected (add)") + enabled: root.targetMaterial && materialBrowserModel.hasModelSelection + onTriggered: materialBrowserBundleModel.applyToSelected(root.targetMaterial, true) + } + + StudioControls.MenuSeparator {} + + StudioControls.MenuItem { + enabled: !materialBrowserBundleModel.importerRunning + text: qsTr("Add an instance to project") + + onTriggered: { + materialBrowserBundleModel.addToProject(root.targetMaterial) + } + } + + StudioControls.MenuItem { + enabled: !materialBrowserBundleModel.importerRunning && root.targetMaterial.bundleMaterialImported + text: qsTr("Remove from project") + + onTriggered: root.unimport(root.targetMaterial); + } +} diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp index 31c3303a54f..d21d6abcc46 100644 --- a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp +++ b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp @@ -1500,68 +1500,6 @@ QString getTemplateDialog(const Utils::FilePath &projectPath) return result; } -void styleMerge(const SelectionContext &selectionContext, const QString &templateFile) -{ - Model *parentModel = selectionContext.view()->model(); - - QTC_ASSERT(parentModel, return); - - auto templateModel(Model::create("QtQuick.Item", 2, 1, parentModel)); - Q_ASSERT(templateModel.get()); - - templateModel->setFileUrl(QUrl::fromLocalFile(templateFile)); - - QPlainTextEdit textEditTemplate; - Utils::FileReader reader; - - QTC_ASSERT(reader.fetch(Utils::FilePath::fromString(templateFile)), return); - QString qmlTemplateString = QString::fromUtf8(reader.data()); - QString imports; - - for (const Import &import : parentModel->imports()) - imports += QStringLiteral("import ") + import.toString(true) + QLatin1Char(';') + QLatin1Char('\n'); - - textEditTemplate.setPlainText(imports + qmlTemplateString); - NotIndentingTextEditModifier textModifierTemplate(&textEditTemplate); - - QScopedPointer templateRewriterView(new RewriterView(RewriterView::Amend)); - templateRewriterView->setTextModifier(&textModifierTemplate); - templateModel->attachView(templateRewriterView.data()); - templateRewriterView->setCheckSemanticErrors(false); - - ModelNode templateRootNode = templateRewriterView->rootModelNode(); - QTC_ASSERT(templateRootNode.isValid(), return); - - auto styleModel(Model::create("QtQuick.Item", 2, 1, parentModel)); - Q_ASSERT(styleModel.get()); - - styleModel->setFileUrl(QUrl::fromLocalFile(templateFile)); - - QPlainTextEdit textEditStyle; - RewriterView *parentRewriterView = selectionContext.view()->model()->rewriterView(); - QTC_ASSERT(parentRewriterView, return); - textEditStyle.setPlainText(parentRewriterView->textModifierContent()); - NotIndentingTextEditModifier textModifierStyle(&textEditStyle); - - QScopedPointer styleRewriterView(new RewriterView(RewriterView::Amend)); - styleRewriterView->setTextModifier(&textModifierStyle); - styleModel->attachView(styleRewriterView.data()); - - StylesheetMerger merger(templateRewriterView.data(), styleRewriterView.data()); - - try { - merger.merge(); - } catch (Exception &e) { - e.showException(); - } - - try { - parentRewriterView->textModifier()->textDocument()->setPlainText(templateRewriterView->textModifierContent()); - } catch (Exception &e) { - e.showException(); - } -} - void mergeWithTemplate(const SelectionContext &selectionContext) { const Utils::FilePath projectPath = Utils::FilePath::fromString(baseDirectory(selectionContext.view()->model()->fileUrl())); @@ -1569,7 +1507,7 @@ void mergeWithTemplate(const SelectionContext &selectionContext) const QString templateFile = getTemplateDialog(projectPath); if (QFileInfo::exists(templateFile)) - styleMerge(selectionContext, templateFile); + StylesheetMerger::styleMerge(selectionContext.view()->model(), templateFile); } void removeGroup(const SelectionContext &selectionContext) diff --git a/src/plugins/qmldesigner/components/edit3d/edit3dwidget.cpp b/src/plugins/qmldesigner/components/edit3d/edit3dwidget.cpp index b41a3165130..22cfe0d8db3 100644 --- a/src/plugins/qmldesigner/components/edit3d/edit3dwidget.cpp +++ b/src/plugins/qmldesigner/components/edit3d/edit3dwidget.cpp @@ -139,10 +139,18 @@ Edit3DWidget::Edit3DWidget(Edit3DView *view) m_onboardingLabel = new QLabel(this); QString labelText = tr("Your file does not import Qt Quick 3D.

" - "To create a 3D view, add the QtQuick3D module in the Library view. Or click" - " here " - "to add it immediately.

" - "To import 3D assets from another tool, click the \"Add New Assets...\" button in the Assets tab of the Library view."); + "To create a 3D view, add the" + " QtQuick3D" + " module in the" + " Components" + " view or click" + " here" + ".

" + "To import 3D assets, select" + " +" + " in the" + " Assets" + " view."); m_onboardingLabel->setText(labelText.arg(Utils::creatorTheme()->color(Utils::Theme::TextColorLink).name())); m_onboardingLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); connect(m_onboardingLabel, &QLabel::linkActivated, this, &Edit3DWidget::linkActivated); diff --git a/src/plugins/qmldesigner/designercore/include/stylesheetmerger.h b/src/plugins/qmldesigner/designercore/include/stylesheetmerger.h index e4dc67cd5d8..937dd876364 100644 --- a/src/plugins/qmldesigner/designercore/include/stylesheetmerger.h +++ b/src/plugins/qmldesigner/designercore/include/stylesheetmerger.h @@ -26,6 +26,8 @@ class QMLDESIGNERCORE_EXPORT StylesheetMerger public: StylesheetMerger(AbstractView*, AbstractView*); void merge(); + static void styleMerge(Model *model, const QString &templateFile); + private: void preprocessStyleSheet(); bool idExistsInBothModels(const QString& id); diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp index 5d63b8bebc4..610d8ebfb20 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp @@ -785,6 +785,8 @@ NodeMetaInfoPrivate::NodeMetaInfoPrivate(Model *model, TypeName type, int maj, i if (importInfo.type() == ImportType::Library) { m_majorVersion = importInfo.version().majorVersion(); m_minorVersion = importInfo.version().minorVersion(); + } else { + m_isFileComponent = true; } m_qualfiedTypeName = getUnqualifiedName(m_qualfiedTypeName); @@ -793,6 +795,8 @@ NodeMetaInfoPrivate::NodeMetaInfoPrivate(Model *model, TypeName type, int maj, i || importInfo.type() == ImportType::Directory); if (prepandName) m_qualfiedTypeName.prepend(importInfo.name().toUtf8() + '.'); + + m_qualfiedTypeName.replace("/", "."); } m_objectValue = getObjectValue(); diff --git a/src/plugins/qmldesigner/designercore/model/model.cpp b/src/plugins/qmldesigner/designercore/model/model.cpp index 927d66e5140..66c9fcb3025 100644 --- a/src/plugins/qmldesigner/designercore/model/model.cpp +++ b/src/plugins/qmldesigner/designercore/model/model.cpp @@ -703,10 +703,15 @@ void ModelPrivate::setAuxiliaryData(const InternalNodePointer &node, void ModelPrivate::resetModelByRewriter(const QString &description) { - if (rewriterView()) + if (rewriterView()) { rewriterView()->resetToLastCorrectQml(); - throw RewritingException(__LINE__, __FUNCTION__, __FILE__, description.toUtf8(), rewriterView()->textModifierContent()); + throw RewritingException(__LINE__, + __FUNCTION__, + __FILE__, + description.toUtf8(), + rewriterView()->textModifierContent()); + } } void ModelPrivate::attachView(AbstractView *view) diff --git a/src/plugins/qmldesigner/designercore/model/stylesheetmerger.cpp b/src/plugins/qmldesigner/designercore/model/stylesheetmerger.cpp index 564bbb64ac7..a1e87c9ae03 100644 --- a/src/plugins/qmldesigner/designercore/model/stylesheetmerger.cpp +++ b/src/plugins/qmldesigner/designercore/model/stylesheetmerger.cpp @@ -12,8 +12,14 @@ #include #include #include +#include +#include #include +#include +#include + +#include #include #include @@ -508,4 +514,69 @@ void StylesheetMerger::merge() } } } + +void StylesheetMerger::styleMerge(Model *model, const QString &templateFile) +{ + Model *parentModel = model; + + QTC_ASSERT(parentModel, return); + + auto templateModel(Model::create("QtQuick.Item", 2, 1, parentModel)); + Q_ASSERT(templateModel.get()); + + templateModel->setFileUrl(parentModel->fileUrl()); + + QPlainTextEdit textEditTemplate; + Utils::FileReader reader; + + QTC_ASSERT(reader.fetch(Utils::FilePath::fromString(templateFile)), return); + QString qmlTemplateString = QString::fromUtf8(reader.data()); + QString imports; + + for (const Import &import : parentModel->imports()) { + imports += QStringLiteral("import ") + import.toString(true) + QLatin1Char(';') + + QLatin1Char('\n'); + } + + textEditTemplate.setPlainText(imports + qmlTemplateString); + NotIndentingTextEditModifier textModifierTemplate(&textEditTemplate); + + QScopedPointer templateRewriterView(new RewriterView(RewriterView::Amend)); + templateRewriterView->setTextModifier(&textModifierTemplate); + templateModel->attachView(templateRewriterView.data()); + templateRewriterView->setCheckSemanticErrors(false); + + ModelNode templateRootNode = templateRewriterView->rootModelNode(); + QTC_ASSERT(templateRootNode.isValid(), return); + + auto styleModel(Model::create("QtQuick.Item", 2, 1, parentModel)); + Q_ASSERT(styleModel.get()); + + styleModel->setFileUrl(parentModel->fileUrl()); + + QPlainTextEdit textEditStyle; + RewriterView *parentRewriterView = parentModel->rewriterView(); + QTC_ASSERT(parentRewriterView, return); + textEditStyle.setPlainText(parentRewriterView->textModifierContent()); + NotIndentingTextEditModifier textModifierStyle(&textEditStyle); + + QScopedPointer styleRewriterView(new RewriterView(RewriterView::Amend)); + styleRewriterView->setTextModifier(&textModifierStyle); + styleModel->attachView(styleRewriterView.data()); + + StylesheetMerger merger(templateRewriterView.data(), styleRewriterView.data()); + + try { + merger.merge(); + } catch (Exception &e) { + e.showException(); + } + + try { + parentRewriterView->textModifier()->textDocument()->setPlainText( + templateRewriterView->textModifierContent()); + } catch (Exception &e) { + e.showException(); + } } +} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp index 656a772620b..51cfdfd6acd 100644 --- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp +++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp @@ -510,7 +510,7 @@ public: if (metaInfo.isValid()) qDebug() << metaInfo.superClasses().front().typeName(); - if (!typeName.startsWith("...") && m_model == m_model->metaInfoProxyModel() + if (!metaInfo.isFileComponent() && m_model == m_model->metaInfoProxyModel() && metaInfo.isValid()) throw RewritingException(__LINE__, __FUNCTION__, __FILE__, "test", "test"); } @@ -1355,6 +1355,7 @@ void TextToModelMerger::syncNode(ModelNode &modelNode, } syncSignalDeclarationProperty(modelProperty, signature, differenceHandler); + modelPropertyNames.remove(astName.toUtf8()); continue; // Done } diff --git a/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp b/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp index 4e4ab0ea23f..8376a9b83a0 100644 --- a/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp +++ b/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp @@ -163,7 +163,7 @@ public: ImageCacheCollector collector{connectionManager, QSize{300, 300}, QSize{1000, 1000}, - ImageCacheCollectorNullImageHandling::DontCaptureNullImage}; + ImageCacheCollectorNullImageHandling::CaptureNullImage}; PreviewTimeStampProvider timeStampProvider; AsynchronousImageFactory factory; ProjectStorageData projectStorageData; @@ -193,6 +193,11 @@ QmlDesignerProjectManager::QmlDesignerProjectManager() QObject::connect(sessionManager, &::ProjectExplorer::SessionManager::projectRemoved, [&](auto *project) { projectRemoved(project); }); + + QObject::connect(&m_previewTimer, + &QTimer::timeout, + this, + &QmlDesignerProjectManager::generatePreview); } QmlDesignerProjectManager::~QmlDesignerProjectManager() = default; @@ -222,13 +227,7 @@ void QmlDesignerProjectManager::currentEditorChanged(::Core::IEditor *) if (!m_projectData || !m_projectData->activeTarget) return; - ::QmlProjectManager::QmlBuildSystem *qmlBuildSystem = getQmlBuildSystem( - m_projectData->activeTarget); - - if (qmlBuildSystem) { - m_previewImageCacheData->collector.setTarget(m_projectData->activeTarget); - m_previewImageCacheData->factory.generate(qmlBuildSystem->mainFilePath().toString().toUtf8()); - } + m_previewTimer.start(10000); } void QmlDesignerProjectManager::editorsClosed(const QList<::Core::IEditor *> &) {} @@ -382,6 +381,20 @@ void QmlDesignerProjectManager::aboutToRemoveProject(::ProjectExplorer::Project void QmlDesignerProjectManager::projectRemoved(::ProjectExplorer::Project *) {} +void QmlDesignerProjectManager::generatePreview() +{ + if (!m_projectData || !m_projectData->activeTarget) + return; + + ::QmlProjectManager::QmlBuildSystem *qmlBuildSystem = getQmlBuildSystem( + m_projectData->activeTarget); + + if (qmlBuildSystem) { + m_previewImageCacheData->collector.setTarget(m_projectData->activeTarget); + m_previewImageCacheData->factory.generate(qmlBuildSystem->mainFilePath().toString().toUtf8()); + } +} + QmlDesignerProjectManager::ImageCacheData *QmlDesignerProjectManager::imageCacheData() { std::call_once(imageCacheFlag, [this]() { diff --git a/src/plugins/qmldesigner/qmldesignerprojectmanager.h b/src/plugins/qmldesigner/qmldesignerprojectmanager.h index b4cc14309ba..e9bc8fc2f2a 100644 --- a/src/plugins/qmldesigner/qmldesignerprojectmanager.h +++ b/src/plugins/qmldesigner/qmldesignerprojectmanager.h @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -48,6 +49,7 @@ private: void projectAdded(::ProjectExplorer::Project *project); void aboutToRemoveProject(::ProjectExplorer::Project *project); void projectRemoved(::ProjectExplorer::Project *project); + void generatePreview(); ImageCacheData *imageCacheData(); void fileListChanged(); @@ -64,5 +66,6 @@ private: std::unique_ptr m_imageCacheData; std::unique_ptr m_previewImageCacheData; std::unique_ptr m_projectData; + QTimer m_previewTimer; }; } // namespace QmlDesigner