forked from qt-creator/qt-creator
QmlDesigner: Load effect maker nodes from path
...instead of from Qt SDK Change-Id: I10d3104477b7cd7c729121175c66a7402ea49651 Reviewed-by: Amr Elsayed <amr.elsayed@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
@@ -3,13 +3,9 @@
|
|||||||
|
|
||||||
#include "effectmakernodesmodel.h"
|
#include "effectmakernodesmodel.h"
|
||||||
|
|
||||||
#include <projectexplorer/kit.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <projectexplorer/projecttree.h>
|
|
||||||
#include <projectexplorer/target.h>
|
|
||||||
|
|
||||||
#include <qtsupport/qtkitinformation.h>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
#include <utils/filepath.h>
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
@@ -42,29 +38,42 @@ QVariant EffectMakerNodesModel::data(const QModelIndex &index, int role) const
|
|||||||
return m_categories.at(index.row())->property(roleNames().value(role));
|
return m_categories.at(index.row())->property(roleNames().value(role));
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
void EffectMakerNodesModel::findNodesPath()
|
||||||
Utils::FilePath EffectMakerNodesModel::getQmlEffectNodesPath()
|
|
||||||
{
|
{
|
||||||
const ProjectExplorer::Target *target = ProjectExplorer::ProjectTree::currentTarget();
|
if (m_nodesPath.exists() || m_probeNodesDir)
|
||||||
if (!target) {
|
return;
|
||||||
qWarning() << __FUNCTION__ << "No project open";
|
|
||||||
return "";
|
QDir nodesDir;
|
||||||
|
|
||||||
|
if (!qEnvironmentVariable("EFFECT_MAKER_NODES_PATH").isEmpty())
|
||||||
|
nodesDir.setPath(qEnvironmentVariable("EFFECT_MAKER_NODES_PATH"));
|
||||||
|
else if (Utils::HostOsInfo::isMacHost())
|
||||||
|
nodesDir.setPath(QCoreApplication::applicationDirPath() + "/../Resources/effect_maker_nodes");
|
||||||
|
|
||||||
|
// search for nodesDir from exec dir and up
|
||||||
|
if (nodesDir.dirName() == ".") {
|
||||||
|
m_probeNodesDir = true; // probe only once
|
||||||
|
nodesDir.setPath(QCoreApplication::applicationDirPath());
|
||||||
|
while (!nodesDir.cd("effect_maker_nodes") && nodesDir.cdUp())
|
||||||
|
; // do nothing
|
||||||
|
|
||||||
|
if (nodesDir.dirName() != "effect_maker_nodes") // bundlePathDir not found
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QtSupport::QtVersion *baseQtVersion = QtSupport::QtKitAspect::qtVersion(target->kit());
|
m_nodesPath = Utils::FilePath::fromString(nodesDir.path());
|
||||||
return baseQtVersion->qmlPath().pathAppended("QtQuickEffectMaker/defaultnodes");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectMakerNodesModel::loadModel()
|
void EffectMakerNodesModel::loadModel()
|
||||||
{
|
{
|
||||||
const Utils::FilePath effectsPath = getQmlEffectNodesPath();
|
findNodesPath();
|
||||||
|
|
||||||
if (!effectsPath.exists()) {
|
if (!m_nodesPath.exists()) {
|
||||||
qWarning() << __FUNCTION__ << "Effects not found.";
|
qWarning() << __FUNCTION__ << "Effects not found.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDirIterator itCategories(effectsPath.toString(), QDir::Dirs | QDir::NoDotAndDotDot);
|
QDirIterator itCategories(m_nodesPath.toString(), QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
while (itCategories.hasNext()) {
|
while (itCategories.hasNext()) {
|
||||||
itCategories.next();
|
itCategories.next();
|
||||||
|
|
||||||
@@ -72,7 +81,7 @@ void EffectMakerNodesModel::loadModel()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
QList<EffectNode *> effects = {};
|
QList<EffectNode *> effects = {};
|
||||||
Utils::FilePath categoryPath = effectsPath.resolvePath(itCategories.fileName());
|
Utils::FilePath categoryPath = m_nodesPath.resolvePath(itCategories.fileName());
|
||||||
QDirIterator itEffects(categoryPath.toString(), QDir::Files | QDir::NoDotAndDotDot);
|
QDirIterator itEffects(categoryPath.toString(), QDir::Files | QDir::NoDotAndDotDot);
|
||||||
while (itEffects.hasNext()) {
|
while (itEffects.hasNext()) {
|
||||||
itEffects.next();
|
itEffects.next();
|
||||||
|
@@ -3,13 +3,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QStandardItemModel>
|
|
||||||
|
|
||||||
#include "effectnodescategory.h"
|
#include "effectnodescategory.h"
|
||||||
|
|
||||||
namespace Utils {
|
#include <utils/filepath.h>
|
||||||
class FilePath;
|
|
||||||
}
|
#include <QStandardItemModel>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
@@ -35,9 +33,11 @@ public:
|
|||||||
QList<EffectNodesCategory *> categories() const { return m_categories; }
|
QList<EffectNodesCategory *> categories() const { return m_categories; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Utils::FilePath getQmlEffectNodesPath();
|
void findNodesPath();
|
||||||
|
|
||||||
QList<EffectNodesCategory *> m_categories;
|
QList<EffectNodesCategory *> m_categories;
|
||||||
|
Utils::FilePath m_nodesPath;
|
||||||
|
bool m_probeNodesDir = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
Reference in New Issue
Block a user