Merge "Merge commit '029f926bcfcbb01' (origin/8.0) into 9.0" into 9.0

This commit is contained in:
The Qt Project
2022-10-20 14:05:56 +00:00
14 changed files with 453 additions and 245 deletions

91
dist/changes-8.0.2.md vendored Normal file
View File

@@ -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

View File

@@ -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

View File

@@ -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)
}
}
}

View File

@@ -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()
}
}

View File

@@ -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);
}
}

View File

@@ -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<RewriterView> 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<RewriterView> 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)

View File

@@ -139,10 +139,18 @@ Edit3DWidget::Edit3DWidget(Edit3DView *view)
m_onboardingLabel = new QLabel(this);
QString labelText =
tr("Your file does not import Qt Quick 3D.<br><br>"
"To create a 3D view, add the QtQuick3D module in the Library view. Or click"
" <a href=\"#add_import\"><span style=\"text-decoration:none;color:%1\">here</span></a> "
"to add it immediately.<br><br>"
"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"
" <b>QtQuick3D</b>"
" module in the"
" <b>Components</b>"
" view or click"
" <a href=\"#add_import\"><span style=\"text-decoration:none;color:%1\">here</span></a>"
".<br><br>"
"To import 3D assets, select"
" <b>+</b>"
" in the"
" <b>Assets</b>"
" 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);

View File

@@ -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);

View File

@@ -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();

View File

@@ -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)

View File

@@ -12,8 +12,14 @@
#include <nodelistproperty.h>
#include <nodemetainfo.h>
#include <nodeproperty.h>
#include <plaintexteditmodifier.h>
#include <rewriterview.h>
#include <variantproperty.h>
#include <utils/fileutils.h>
#include <utils/qtcassert.h>
#include <QPlainTextEdit>
#include <QQueue>
#include <QRegularExpression>
@@ -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<RewriterView> 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<RewriterView> 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

View File

@@ -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
}

View File

@@ -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]() {

View File

@@ -7,6 +7,7 @@
#include <QList>
#include <QObject>
#include <QTimer>
#include <memory>
#include <mutex>
@@ -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<ImageCacheData> m_imageCacheData;
std::unique_ptr<PreviewImageCacheData> m_previewImageCacheData;
std::unique_ptr<QmlDesignerProjectManagerProjectData> m_projectData;
QTimer m_previewTimer;
};
} // namespace QmlDesigner