diff options
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"; |