Commit b45496ea authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.PropertyEditor: components can provide their own sheets



This patch allows components to provide their own sheets in a
designer subfolder of the component plugin.

Change-Id: Id1393ca73b8806fbf40a813b5e406e9e359cd7aa
Reviewed-by: default avatarMarco Bubke <marco.bubke@digia.com>
parent b069e24a
......@@ -29,6 +29,8 @@
#include "propertyeditor.h"
#include <qmldesignerconstants.h>
#include <nodemetainfo.h>
#include <metainfo.h>
......@@ -87,6 +89,8 @@ const int collapseButtonOffset = 114;
namespace QmlDesigner {
const char resourcePropertyEditorPath[] = ":/propertyeditor";
static QString applicationDirPath()
{
#ifdef Q_OS_WIN
......@@ -385,11 +389,12 @@ static inline QString fixTypeNameForPanes(const QString &typeName)
void PropertyEditor::setupPane(const QString &typeName)
{
NodeMetaInfo metaInfo = model()->metaInfo(typeName);
QUrl qmlFile = fileToUrl(locateQmlFile(QLatin1String("Qt/ItemPane.qml")));
QUrl qmlFile = fileToUrl(locateQmlFile(metaInfo, QLatin1String("Qt/ItemPane.qml")));
QUrl qmlSpecificsFile;
qmlSpecificsFile = fileToUrl(locateQmlFile(fixTypeNameForPanes(typeName) + "Specifics.qml"));
qmlSpecificsFile = fileToUrl(locateQmlFile(metaInfo, fixTypeNameForPanes(typeName) + "Specifics.qml"));
NodeType *type = m_typeHash.value(qmlFile.toString());
if (!type) {
......@@ -756,7 +761,7 @@ void PropertyEditor::resetView()
foreach (const NodeMetaInfo &info, hierarchy) {
if (QFileInfo(qmlSpecificsFile.toLocalFile()).exists())
break;
qmlSpecificsFile = fileToUrl(locateQmlFile(fixTypeNameForPanes(info.typeName()) + "Specifics.qml"));
qmlSpecificsFile = fileToUrl(locateQmlFile(info, fixTypeNameForPanes(info.typeName()) + "Specifics.qml"));
diffClassName = info.typeName();
}
}
......@@ -1061,7 +1066,7 @@ QUrl PropertyEditor::qmlForNode(const ModelNode &modelNode, QString &className)
hierarchy << modelNode.metaInfo().superClasses();
foreach (const NodeMetaInfo &info, hierarchy) {
QUrl fileUrl = fileToUrl(locateQmlFile(qmlFileName(info)));
QUrl fileUrl = fileToUrl(locateQmlFile(info, qmlFileName(info)));
if (fileUrl.isValid()) {
className = info.typeName();
return fileUrl;
......@@ -1071,11 +1076,14 @@ QUrl PropertyEditor::qmlForNode(const ModelNode &modelNode, QString &className)
return fileToUrl(QDir(m_qmlDir).filePath("QtQuick/emptyPane.qml"));
}
QString PropertyEditor::locateQmlFile(const QString &relativePath) const
QString PropertyEditor::locateQmlFile(const NodeMetaInfo &info, const QString &relativePath) const
{
QDir fileSystemDir(m_qmlDir);
static QDir resourcesDir(":/propertyeditor");
static QDir resourcesDir(resourcePropertyEditorPath);
QDir importDir(info.importDirectoryPath() + QLatin1String(Constants::QML_DESIGNER_SUBFOLDER));
if (importDir.exists(relativePath))
return importDir.absoluteFilePath(relativePath);
if (fileSystemDir.exists(relativePath))
return fileSystemDir.absoluteFilePath(relativePath);
if (resourcesDir.exists(relativePath))
......
......@@ -129,7 +129,7 @@ private: //functions
QString qmlFileName(const NodeMetaInfo &nodeInfo) const;
QUrl fileToUrl(const QString &filePath) const;
QUrl qmlForNode(const ModelNode &modelNode, QString &className) const;
QString locateQmlFile(const QString &relativePath) const;
QString locateQmlFile(const NodeMetaInfo &info, const QString &relativePath) const;
void select(const ModelNode& node);
void delayedResetView();
......
......@@ -66,6 +66,8 @@ enum { QML_OPENDESIGNMODE_DEFAULT = 0 }; // 0 for text mode, 1 for design mode
const char SETTINGS_CATEGORY_QML_ICON[] = ":/core/images/category_qml.png";
const char QML_DESIGNER_SUBFOLDER[] = "/designer/";
namespace Internal {
enum { debug = 0 };
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment