diff options
author | Mahmoud Badri <mahmoud.badri@qt.io> | 2023-11-22 15:28:54 +0200 |
---|---|---|
committer | Mahmoud Badri <mahmoud.badri@qt.io> | 2023-11-23 10:36:17 +0000 |
commit | c14dc9d2baa2b7813be5fd5d02905b0ecd89309c (patch) | |
tree | 0a28937861c134b26ab880b1cd3477ecb88aa98d | |
parent | 3930deff2914c0440768bc81a109131e9a34f880 (diff) |
EffectMaker: Focus view upon open, and correctly open new effects
Also don't open old effect maker when creating a new effect
Fixes: QDS-11359
Fixes: QDS-11364
Change-Id: Ie9659af991f10cafac29dc53cbe7163eb8995b2a
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
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; |