diff options
3 files changed, 16 insertions, 9 deletions
diff --git a/src/plugins/effectmakernew/effectmakermodel.cpp b/src/plugins/effectmakernew/effectmakermodel.cpp index d52e8858ca..32fa88d7eb 100644 --- a/src/plugins/effectmakernew/effectmakermodel.cpp +++ b/src/plugins/effectmakernew/effectmakermodel.cpp @@ -558,6 +558,9 @@ void EffectMakerModel::openComposition(const QString &path) { clear(); + const QString effectName = QFileInfo(path).baseName(); + setCurrentComposition(effectName); + QFile compFile(path); if (!compFile.open(QIODevice::ReadOnly)) { QString error = QString("Couldn't open composition file: '%1'").arg(path); @@ -567,6 +570,10 @@ void EffectMakerModel::openComposition(const QString &path) } QByteArray data = compFile.readAll(); + + if (data.isEmpty()) + return; + QJsonParseError parseError; QJsonDocument jsonDoc(QJsonDocument::fromJson(data, &parseError)); if (parseError.error != QJsonParseError::NoError) { @@ -597,7 +604,6 @@ void EffectMakerModel::openComposition(const QString &path) } // Get effects dir - const QString effectName = QFileInfo(path).baseName(); const Utils::FilePath effectsResDir = QmlDesigner::ModelNodeOperations::getEffectsImportDirectory(); const QString effectsResPath = effectsResDir.pathAppended(effectName).toString(); @@ -613,8 +619,6 @@ void EffectMakerModel::openComposition(const QString &path) setIsEmpty(m_nodes.isEmpty()); bakeShaders(); } - - setCurrentComposition(effectName); } void EffectMakerModel::exportResources(const QString &name) diff --git a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp index a141c69697..a785fea76f 100644 --- a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp +++ b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp @@ -8,6 +8,7 @@ #include "assetslibrarymodel.h" #include "assetslibraryview.h" #include "designeractionmanager.h" +#include "designmodewidget.h" #include "modelnodeoperations.h" #include "qmldesignerconstants.h" #include "qmldesignerplugin.h" @@ -192,12 +193,12 @@ QString AssetsLibraryWidget::getUniqueEffectPath(const QString &parentFolder, co return path; } -bool AssetsLibraryWidget::createNewEffect(const QString &effectPath, bool openEffectMaker) +bool AssetsLibraryWidget::createNewEffect(const QString &effectPath, bool openInEffectMaker) { bool created = QFile(effectPath).open(QIODevice::WriteOnly); - if (created && openEffectMaker) { - ModelNodeOperations::openEffectMaker(effectPath); + if (created && openInEffectMaker) { + openEffectMaker(effectPath); emit directoryCreated(QFileInfo(effectPath).absolutePath()); } @@ -379,10 +380,12 @@ bool isEffectMakerActivated() void AssetsLibraryWidget::openEffectMaker(const QString &filePath) { - if (isEffectMakerActivated()) + if (isEffectMakerActivated()) { // new effect maker m_assetsView->emitCustomNotification("open_effectmaker_composition", {}, {filePath}); - else + QmlDesignerPlugin::instance()->mainWidget()->showDockWidget("Effect Maker", true); + } else { // old effect maker ModelNodeOperations::openEffectMaker(filePath); + } } QString AssetsLibraryWidget::qmlSourcesPath() diff --git a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.h b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.h index 33ad100c0b..4b3976ebae 100644 --- a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.h +++ b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.h @@ -92,7 +92,7 @@ public: Q_INVOKABLE void updateContextMenuActionsEnableState(); Q_INVOKABLE QString getUniqueEffectPath(const QString &parentFolder, const QString &effectName); - Q_INVOKABLE bool createNewEffect(const QString &effectPath, bool openEffectMaker = true); + Q_INVOKABLE bool createNewEffect(const QString &effectPath, bool openInEffectMaker = true); Q_INVOKABLE bool canCreateEffects() const; |