forked from qt-creator/qt-creator
QmlDesigner: Change asset import path
The only import path should be project root, so change things that are generated under asset_imports to be generated in new folder GeneratedComponents under project root. GeneratedComponents is prefixed to the type names of generated items as well. If project already contains asset_imports folder, then old location is used. Fixes: QDS-12430 Change-Id: I7a419fe1c5411e3d39bf3c1e659df0043c60ba33 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -94,6 +94,11 @@ bool EffectComposerModel::setData(const QModelIndex &index, const QVariant &valu
|
||||
return true;
|
||||
}
|
||||
|
||||
void EffectComposerModel::setEffectsTypePrefix(const QString &prefix)
|
||||
{
|
||||
m_effectTypePrefix = prefix;
|
||||
}
|
||||
|
||||
void EffectComposerModel::setIsEmpty(bool val)
|
||||
{
|
||||
if (m_isEmpty != val) {
|
||||
@@ -1059,7 +1064,7 @@ void EffectComposerModel::saveResources(const QString &name)
|
||||
Utils::FilePath qmldirPath = effectsResDir.resolvePath(qmldirFileName);
|
||||
QString qmldirContent = QString::fromUtf8(qmldirPath.fileContents().value_or(QByteArray()));
|
||||
if (qmldirContent.isEmpty()) {
|
||||
qmldirContent.append("module Effects\n");
|
||||
qmldirContent.append(QString("module %1\n").arg(m_effectTypePrefix));
|
||||
qmldirPath.writeFileContents(qmldirContent.toUtf8());
|
||||
}
|
||||
|
||||
@@ -1077,7 +1082,7 @@ void EffectComposerModel::saveResources(const QString &name)
|
||||
qmldirPath = effectPath.resolvePath(qmldirFileName);
|
||||
qmldirContent = QString::fromUtf8(qmldirPath.fileContents().value_or(QByteArray()));
|
||||
if (qmldirContent.isEmpty()) {
|
||||
qmldirContent.append("module Effects.");
|
||||
qmldirContent.append(QString("module %1.").arg(m_effectTypePrefix));
|
||||
qmldirContent.append(name);
|
||||
qmldirContent.append('\n');
|
||||
qmldirContent.append(name);
|
||||
@@ -1187,7 +1192,7 @@ void EffectComposerModel::saveResources(const QString &name)
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
emit resourcesSaved(QString("Effects.%1.%1").arg(name).toUtf8(), effectPath);
|
||||
emit resourcesSaved(QString("%1.%2.%2").arg(m_effectTypePrefix, name).toUtf8(), effectPath);
|
||||
}
|
||||
|
||||
void EffectComposerModel::resetEffectError(int type)
|
||||
|
||||
@@ -59,6 +59,8 @@ public:
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
|
||||
void setEffectsTypePrefix(const QString &prefix);
|
||||
|
||||
bool isEmpty() const { return m_isEmpty; }
|
||||
void setIsEmpty(bool val);
|
||||
|
||||
@@ -221,6 +223,7 @@ private:
|
||||
QString m_currentComposition;
|
||||
QTimer m_rebakeTimer;
|
||||
int m_extraMargin = 0;
|
||||
QString m_effectTypePrefix;
|
||||
|
||||
const QRegularExpression m_spaceReg = QRegularExpression("\\s+");
|
||||
};
|
||||
|
||||
@@ -31,6 +31,7 @@ void EffectComposerContext::contextHelp(const HelpCallback &callback) const
|
||||
|
||||
EffectComposerView::EffectComposerView(QmlDesigner::ExternalDependenciesInterface &externalDependencies)
|
||||
: AbstractView{externalDependencies}
|
||||
, m_componentUtils(externalDependencies)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -91,6 +92,7 @@ void EffectComposerView::modelAttached(QmlDesigner::Model *model)
|
||||
if (m_currProjectPath != currProjectPath) { // starting a new project
|
||||
m_widget->effectComposerNodesModel()->loadModel();
|
||||
m_widget->effectComposerModel()->clear(true);
|
||||
m_widget->effectComposerModel()->setEffectsTypePrefix(m_componentUtils.composedEffectsTypePrefix());
|
||||
m_widget->effectComposerModel()->setIsEnabled(
|
||||
!QmlDesigner::DesignerMcuManager::instance().isMCUProject());
|
||||
m_widget->initView();
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "abstractview.h"
|
||||
#include "modelnode.h"
|
||||
|
||||
#include <generatedcomponentutils.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
|
||||
#include <QPointer>
|
||||
@@ -45,6 +46,7 @@ private:
|
||||
|
||||
QPointer<EffectComposerWidget> m_widget;
|
||||
QString m_currProjectPath;
|
||||
QmlDesigner::GeneratedComponentUtils m_componentUtils;
|
||||
};
|
||||
|
||||
} // namespace EffectComposer
|
||||
|
||||
Reference in New Issue
Block a user