diff options
author | Amr Essam <amr.elsayed@qt.io> | 2022-11-04 11:24:41 +0200 |
---|---|---|
committer | Tim Jenssen <tim.jenssen@qt.io> | 2022-11-04 16:48:27 +0000 |
commit | 91a7db53357aad90b44d78df222081c35b0cad91 (patch) | |
tree | c548bf59027fea8ec735b447ef257e820078b494 /src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp | |
parent | cdc0f72ecfb0f8ccb9cf17222abe9476eda8ce8c (diff) |
QmlDesigner: Show proper warning if .qep file has no componentqds/v3.8.0qds/3.8
When dragging an empty effect, a messagebox shows with an option to open QQEM
(cherry picked from commit f4723ae8856cc011d2026032a85ab7e7c0f0fdd2)
Task-number: QDS-8155
Change-Id: I2afbf7ffb9cb58243f3635fe3a7aee999ab68713
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp')
-rw-r--r-- | src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp index 0e442918da..243510a9f3 100644 --- a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp +++ b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp @@ -69,11 +69,15 @@ #include <projectexplorer/project.h> #include <projectexplorer/projectnodes.h> #include <projectexplorer/projecttree.h> -#include "projectexplorer/session.h" +#include "projectexplorer/target.h" + +#include <qtsupport/baseqtversion.h> +#include <qtsupport/qtkitinformation.h> #include <utils/algorithm.h> #include <utils/fileutils.h> #include <utils/qtcassert.h> +#include "utils/qtcprocess.h" #include <QComboBox> #include <QCoreApplication> @@ -1617,6 +1621,52 @@ void updateImported3DAsset(const SelectionContext &selectionContext) } } +void openEffectMaker(const QString &filePath) +{ + const ProjectExplorer::Target *target = ProjectExplorer::ProjectTree::currentTarget(); + if (!target) { + qWarning() << __FUNCTION__ << "No project open"; + return; + } + + Utils::FilePath projectPath = target->project()->projectDirectory(); + QString effectName = QFileInfo(filePath).baseName(); + QString effectResDir = "asset_imports/Effects/" + effectName; + Utils::FilePath effectResPath = projectPath.resolvePath(effectResDir); + if (!effectResPath.exists()) + QDir(projectPath.toString()).mkpath(effectResDir); + + const QtSupport::QtVersion *baseQtVersion = QtSupport::QtKitAspect::qtVersion(target->kit()); + if (baseQtVersion) { + auto effectMakerPath = baseQtVersion->binPath().pathAppended("QQEffectMaker").withExecutableSuffix(); + if (!effectMakerPath.exists()) { + qWarning() << __FUNCTION__ << "Cannot find EffectMaker app"; + return; + } + + Utils::FilePath effectPath = Utils::FilePath::fromString(filePath); + QString effectContents = QString::fromUtf8(effectPath.fileContents()); + QStringList arguments; + arguments << filePath; + if (effectContents.isEmpty()) + arguments << "--create"; + arguments << "--exportpath" << effectResPath.toString(); + + Utils::Environment env = Utils::Environment::systemEnvironment(); + if (env.osType() == Utils::OsTypeMac) + env.appendOrSet("QSG_RHI_BACKEND", "metal"); + + Utils::QtcProcess *qqemProcess = new Utils::QtcProcess(); + qqemProcess->setEnvironment(env); + qqemProcess->setCommand({ effectMakerPath, arguments }); + qqemProcess->start(); + + QObject::connect(qqemProcess, &Utils::QtcProcess::done, [qqemProcess]() { + qqemProcess->deleteLater(); + }); + } +} + Utils::FilePath getEffectsDirectory() { QString defaultDir = "asset_imports/Effects"; |