forked from qt-creator/qt-creator
QmlDesigner: Fix loading of .metainfo for versioned folders
This fixes a regression introduced by 7ea6492a17
.
Since we actually check if import folders exist,
we did not take versioned folders into account. e.g. 'MyPlugin.1'
Extended and cleaned up the manual test case.
Task-number: QDS-6078
Change-Id: I3235d8fe498745903c5ca897e25e3d43222c119f
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
@@ -69,10 +69,38 @@ SubComponentManager::SubComponentManager(Model *model, QObject *parent)
|
|||||||
this, [this](const QString &path) { parseDirectory(path); });
|
this, [this](const QString &path) { parseDirectory(path); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString findFolderForImport(const QStringList &importPaths, const QString &url)
|
||||||
|
{
|
||||||
|
if (url.isEmpty())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
QString folderUrl = url;
|
||||||
|
folderUrl.replace('.', '/');
|
||||||
|
|
||||||
|
for (const QString &path : importPaths) {
|
||||||
|
QFileInfo dirInfo = QFileInfo(path + QLatin1Char('/') + folderUrl);
|
||||||
|
|
||||||
|
if (dirInfo.exists() && dirInfo.isDir())
|
||||||
|
return dirInfo.canonicalFilePath();
|
||||||
|
|
||||||
|
const QDir parentDir = dirInfo.dir();
|
||||||
|
if (parentDir.exists()) {
|
||||||
|
const QStringList parts = url.split('.');
|
||||||
|
const QString lastFolder = parts.last();
|
||||||
|
|
||||||
|
const QStringList candidates = parentDir.entryList({lastFolder + ".*"}, QDir::Dirs);
|
||||||
|
if (!candidates.isEmpty())
|
||||||
|
return parentDir.canonicalPath() + "/" + candidates.first();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
bool SubComponentManager::addImport(const Import &import, int index)
|
bool SubComponentManager::addImport(const Import &import, int index)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug) {
|
||||||
qDebug() << Q_FUNC_INFO << index << import.file().toUtf8();
|
qDebug() << Q_FUNC_INFO << index << import.file().toUtf8();
|
||||||
|
qDebug() << Q_FUNC_INFO << index << import.url();
|
||||||
|
}
|
||||||
|
|
||||||
bool importExists = false;
|
bool importExists = false;
|
||||||
if (import.isFileImport()) {
|
if (import.isFileImport()) {
|
||||||
@@ -85,19 +113,11 @@ bool SubComponentManager::addImport(const Import &import, int index)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QString url = import.url();
|
QString url = import.url();
|
||||||
|
const QString result = findFolderForImport(importPaths(), url);
|
||||||
url.replace(QLatin1Char('.'), QLatin1Char('/'));
|
if (!result.isEmpty()) {
|
||||||
|
m_watcher.addPath(result);
|
||||||
foreach (const QString &path, importPaths()) {
|
importExists = true;
|
||||||
QFileInfo dirInfo = QFileInfo(path + QLatin1Char('/') + url);
|
|
||||||
if (dirInfo.exists() && dirInfo.isDir()) {
|
|
||||||
const QString canonicalDirPath = dirInfo.canonicalFilePath();
|
|
||||||
m_watcher.addPath(canonicalDirPath);
|
|
||||||
importExists = true;
|
|
||||||
//m_dirToQualifier.insertMulti(canonicalDirPath, import.qualifier()); ### todo: proper support for import as
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// TODO: QDeclarativeDomImport::Library
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (importExists) {
|
if (importExists) {
|
||||||
|
@@ -0,0 +1,38 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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.0
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
width: 60
|
||||||
|
height: 60
|
||||||
|
color: "green"
|
||||||
|
property alias text: textItem.text
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: textItem
|
||||||
|
anchors.centerIn: parent
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,43 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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.0
|
||||||
|
|
||||||
|
Item {
|
||||||
|
property alias text: textItem.text
|
||||||
|
property alias color: rect.color
|
||||||
|
property alias radius: rect.radius
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: rect
|
||||||
|
anchors.fill: parent
|
||||||
|
color: "green"
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: textItem
|
||||||
|
anchors.centerIn: parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,84 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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.0
|
||||||
|
import HelperWidgets 2.0
|
||||||
|
import QtQuick.Layouts 1.0
|
||||||
|
|
||||||
|
Column {
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
|
||||||
|
Section {
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
caption: qsTr("Color")
|
||||||
|
|
||||||
|
ColorEditor {
|
||||||
|
caption: qsTr("Color")
|
||||||
|
backendValue: backendValues.color
|
||||||
|
supportGradient: true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Section {
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
caption: "Rectangle"
|
||||||
|
|
||||||
|
SectionLayout {
|
||||||
|
rows: 2
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr("Text")
|
||||||
|
}
|
||||||
|
|
||||||
|
SecondColumnLayout {
|
||||||
|
LineEdit {
|
||||||
|
backendValue: backendValues.text
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr("Radius")
|
||||||
|
}
|
||||||
|
SecondColumnLayout {
|
||||||
|
SpinBox {
|
||||||
|
backendValue: backendValues.radius
|
||||||
|
hasSlider: true
|
||||||
|
Layout.preferredWidth: 80
|
||||||
|
minimumValue: 0
|
||||||
|
maximumValue: Math.min(backendValues.height.value, backendValues.width.value) / 2
|
||||||
|
}
|
||||||
|
ExpandingSpacer {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,44 @@
|
|||||||
|
MetaInfo {
|
||||||
|
Type {
|
||||||
|
name: "MyPlugin2.MyComponent"
|
||||||
|
icon: ":/qtquickplugin/images/item-icon16.png"
|
||||||
|
|
||||||
|
ItemLibraryEntry {
|
||||||
|
name: "My Component"
|
||||||
|
category: "My Test Plugin 2"
|
||||||
|
libraryIcon: ":/qtquickplugin/images/item-icon.png"
|
||||||
|
version: "1.0"
|
||||||
|
requiredImport: "MyPlugin2"
|
||||||
|
|
||||||
|
Property {
|
||||||
|
name: "text"
|
||||||
|
type: "binding"
|
||||||
|
value: "qsTr(\"This is text\")"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Type {
|
||||||
|
name: "MyPlugin2.MyComponent2"
|
||||||
|
icon: ":/qtquickplugin/images/item-icon16.png"
|
||||||
|
|
||||||
|
ItemLibraryEntry {
|
||||||
|
name: "My Component 2"
|
||||||
|
category: "My Test Plugin 2"
|
||||||
|
libraryIcon: ":/qtquickplugin/images/item-icon.png"
|
||||||
|
version: "1.0"
|
||||||
|
requiredImport: "MyPlugin2"
|
||||||
|
|
||||||
|
Property {
|
||||||
|
name: "text"
|
||||||
|
type: "binding"
|
||||||
|
value: "qsTr(\"This is text\")"
|
||||||
|
}
|
||||||
|
|
||||||
|
Property { name: "width"; type: "int"; value: 200; }
|
||||||
|
Property { name: "height"; type: "int"; value: 200; }
|
||||||
|
Property { name: "color"; type: "QColor"; value: "red"; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,2 @@
|
|||||||
|
MyComponent 1.0 MyComponent.qml
|
||||||
|
MyComponent2 1.0 MyComponent2.qml
|
@@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
** Copyright (C) 2022 The Qt Company Ltd.
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of Qt Creator.
|
** This file is part of Qt Creator.
|
||||||
@@ -23,13 +23,10 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
import QtQuick 2.3
|
import QtQuick
|
||||||
import QtQuick.Controls 1.2
|
|
||||||
import QtQuick.Window 2.2
|
|
||||||
import MyPlugin 1.0
|
import MyPlugin 1.0
|
||||||
|
|
||||||
ApplicationWindow {
|
Rectangle {
|
||||||
title: qsTr("Hello World")
|
|
||||||
width: 640
|
width: 640
|
||||||
height: 480
|
height: 480
|
||||||
|
|
||||||
@@ -38,3 +35,9 @@ ApplicationWindow {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*##^##
|
||||||
|
Designer {
|
||||||
|
D{i:0;autoSize:true;height:480;width:640}
|
||||||
|
}
|
||||||
|
##^##*/
|
||||||
|
38
tests/manual/qml/testprojects/plugins/plugins2.qml
Normal file
38
tests/manual/qml/testprojects/plugins/plugins2.qml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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.3
|
||||||
|
import MyPlugin2 1.0
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
|
||||||
|
width: 640
|
||||||
|
height: 480
|
||||||
|
|
||||||
|
MyComponent {
|
||||||
|
text: qsTr("Some Text")
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user