forked from qt-creator/qt-creator
ExtensionSystem: FilePath'ify
Change IPlugin::fileName() and IPlugin::location to use FilePath instead of QString. Change-Id: If473ab1e258951735f93221cbd62c505f0727eb2 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -765,7 +765,7 @@ int main(int argc, char **argv)
|
|||||||
// Load
|
// Load
|
||||||
const QStringList pluginPaths = getPluginPaths() + installPluginPaths
|
const QStringList pluginPaths = getPluginPaths() + installPluginPaths
|
||||||
+ options.customPluginPaths;
|
+ options.customPluginPaths;
|
||||||
PluginManager::setPluginPaths(pluginPaths);
|
PluginManager::setPluginPaths(Utils::transform(pluginPaths, &Utils::FilePath::fromUserInput));
|
||||||
QMap<QString, QString> foundAppOptions;
|
QMap<QString, QString> foundAppOptions;
|
||||||
if (pluginArguments.size() > 1) {
|
if (pluginArguments.size() > 1) {
|
||||||
QMap<QString, bool> appOptions;
|
QMap<QString, bool> appOptions;
|
||||||
|
@@ -146,7 +146,7 @@ void PluginDetailsView::update(PluginSpec *spec)
|
|||||||
d->vendor->setText(spec->vendor());
|
d->vendor->setText(spec->vendor());
|
||||||
d->component->setText(spec->category().isEmpty() ? Tr::tr("None") : spec->category());
|
d->component->setText(spec->category().isEmpty() ? Tr::tr("None") : spec->category());
|
||||||
d->url->setText(QString::fromLatin1("<a href=\"%1\">%1</a>").arg(spec->url()));
|
d->url->setText(QString::fromLatin1("<a href=\"%1\">%1</a>").arg(spec->url()));
|
||||||
d->location->setText(QDir::toNativeSeparators(spec->filePath()));
|
d->location->setText(spec->filePath().toUserOutput());
|
||||||
const QString pattern = spec->platformSpecification().pattern();
|
const QString pattern = spec->platformSpecification().pattern();
|
||||||
const QString platform = pattern.isEmpty() ? Tr::tr("All") : pattern;
|
const QString platform = pattern.isEmpty() ? Tr::tr("All") : pattern;
|
||||||
const QString platformString = Tr::tr("%1 (current: \"%2\")")
|
const QString platformString = Tr::tr("%1 (current: \"%2\")")
|
||||||
|
@@ -443,7 +443,7 @@ FutureSynchronizer *PluginManager::futureSynchronizer()
|
|||||||
|
|
||||||
\sa setPluginPaths()
|
\sa setPluginPaths()
|
||||||
*/
|
*/
|
||||||
QStringList PluginManager::pluginPaths()
|
FilePaths PluginManager::pluginPaths()
|
||||||
{
|
{
|
||||||
return d->pluginPaths;
|
return d->pluginPaths;
|
||||||
}
|
}
|
||||||
@@ -455,7 +455,7 @@ QStringList PluginManager::pluginPaths()
|
|||||||
\sa pluginPaths()
|
\sa pluginPaths()
|
||||||
\sa loadPlugins()
|
\sa loadPlugins()
|
||||||
*/
|
*/
|
||||||
void PluginManager::setPluginPaths(const QStringList &paths)
|
void PluginManager::setPluginPaths(const FilePaths &paths)
|
||||||
{
|
{
|
||||||
d->setPluginPaths(paths);
|
d->setPluginPaths(paths);
|
||||||
}
|
}
|
||||||
@@ -1732,7 +1732,7 @@ void PluginManagerPrivate::loadPlugin(PluginSpec *spec, PluginSpec::State destSt
|
|||||||
/*!
|
/*!
|
||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
void PluginManagerPrivate::setPluginPaths(const QStringList &paths)
|
void PluginManagerPrivate::setPluginPaths(const FilePaths &paths)
|
||||||
{
|
{
|
||||||
qCDebug(pluginLog) << "Plugin search paths:" << paths;
|
qCDebug(pluginLog) << "Plugin search paths:" << paths;
|
||||||
qCDebug(pluginLog) << "Required IID:" << pluginIID;
|
qCDebug(pluginLog) << "Required IID:" << pluginIID;
|
||||||
@@ -1741,17 +1741,18 @@ void PluginManagerPrivate::setPluginPaths(const QStringList &paths)
|
|||||||
readPluginPaths();
|
readPluginPaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
static const QStringList pluginFiles(const QStringList &pluginPaths)
|
static const FilePaths pluginFiles(const FilePaths &pluginPaths)
|
||||||
{
|
{
|
||||||
QStringList pluginFiles;
|
FilePaths pluginFiles;
|
||||||
QStringList searchPaths = pluginPaths;
|
FilePaths searchPaths = pluginPaths;
|
||||||
while (!searchPaths.isEmpty()) {
|
while (!searchPaths.isEmpty()) {
|
||||||
const QDir dir(searchPaths.takeFirst());
|
const FilePath dir = searchPaths.takeFirst().absoluteFilePath();
|
||||||
const QFileInfoList files = dir.entryInfoList(QDir::Files | QDir::NoSymLinks);
|
const FilePaths files = dir.dirEntries(QDir::Files | QDir::NoSymLinks);
|
||||||
const QStringList absoluteFilePaths = Utils::transform(files, &QFileInfo::absoluteFilePath);
|
pluginFiles += Utils::filtered(files, [](const FilePath &path) {
|
||||||
pluginFiles += Utils::filtered(absoluteFilePaths, [](const QString &path) { return QLibrary::isLibrary(path); });
|
return QLibrary::isLibrary(path.toFSPathString());
|
||||||
const QFileInfoList dirs = dir.entryInfoList(QDir::Dirs|QDir::NoDotAndDotDot);
|
});
|
||||||
searchPaths += Utils::transform(dirs, &QFileInfo::absoluteFilePath);
|
const FilePaths dirs = dir.dirEntries(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
|
searchPaths += dirs;
|
||||||
}
|
}
|
||||||
return pluginFiles;
|
return pluginFiles;
|
||||||
}
|
}
|
||||||
@@ -1793,11 +1794,12 @@ void PluginManagerPrivate::readPluginPaths()
|
|||||||
QVector<PluginSpec *> newSpecs;
|
QVector<PluginSpec *> newSpecs;
|
||||||
|
|
||||||
// from the file system
|
// from the file system
|
||||||
for (const QString &pluginFile : pluginFiles(pluginPaths)) {
|
for (const FilePath &pluginFile : pluginFiles(pluginPaths)) {
|
||||||
expected_str<PluginSpec *> spec = readCppPluginSpec(pluginFile);
|
expected_str<PluginSpec *> spec = readCppPluginSpec(pluginFile);
|
||||||
if (!spec) {
|
if (!spec) {
|
||||||
qCInfo(pluginLog).noquote()
|
qCInfo(pluginLog).noquote() << QString("Ignoring plugin \"%1\" because: %2")
|
||||||
<< QString("Ignoring plugin \"%1\" because: %2").arg(pluginFile).arg(spec.error());
|
.arg(pluginFile.toUserOutput())
|
||||||
|
.arg(spec.error());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
newSpecs.append(*spec);
|
newSpecs.append(*spec);
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
#include "extensionsystem_global.h"
|
#include "extensionsystem_global.h"
|
||||||
|
|
||||||
#include <aggregation/aggregate.h>
|
#include <aggregation/aggregate.h>
|
||||||
|
#include <utils/filepath.h>
|
||||||
#include <utils/qtcsettings.h>
|
#include <utils/qtcsettings.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@@ -69,8 +70,8 @@ public:
|
|||||||
static QVector<PluginSpec *> loadQueue();
|
static QVector<PluginSpec *> loadQueue();
|
||||||
static void loadPlugins();
|
static void loadPlugins();
|
||||||
static void loadPluginsAtRuntime(const QSet<PluginSpec *> &plugins);
|
static void loadPluginsAtRuntime(const QSet<PluginSpec *> &plugins);
|
||||||
static QStringList pluginPaths();
|
static Utils::FilePaths pluginPaths();
|
||||||
static void setPluginPaths(const QStringList &paths);
|
static void setPluginPaths(const Utils::FilePaths &paths);
|
||||||
static QString pluginIID();
|
static QString pluginIID();
|
||||||
static void setPluginIID(const QString &iid);
|
static void setPluginIID(const QString &iid);
|
||||||
static const QVector<PluginSpec *> plugins();
|
static const QVector<PluginSpec *> plugins();
|
||||||
|
@@ -53,7 +53,7 @@ public:
|
|||||||
void addPlugins(const QVector<PluginSpec *> &specs);
|
void addPlugins(const QVector<PluginSpec *> &specs);
|
||||||
|
|
||||||
void shutdown();
|
void shutdown();
|
||||||
void setPluginPaths(const QStringList &paths);
|
void setPluginPaths(const Utils::FilePaths &paths);
|
||||||
const QVector<ExtensionSystem::PluginSpec *> loadQueue();
|
const QVector<ExtensionSystem::PluginSpec *> loadQueue();
|
||||||
void loadPlugin(PluginSpec *spec, PluginSpec::State destState);
|
void loadPlugin(PluginSpec *spec, PluginSpec::State destState);
|
||||||
void resolveDependencies();
|
void resolveDependencies();
|
||||||
@@ -91,7 +91,7 @@ public:
|
|||||||
QHash<QString, QVector<PluginSpec *>> pluginCategories;
|
QHash<QString, QVector<PluginSpec *>> pluginCategories;
|
||||||
QVector<PluginSpec *> pluginSpecs;
|
QVector<PluginSpec *> pluginSpecs;
|
||||||
std::vector<TestSpec> testSpecs;
|
std::vector<TestSpec> testSpecs;
|
||||||
QStringList pluginPaths;
|
Utils::FilePaths pluginPaths;
|
||||||
QString pluginIID;
|
QString pluginIID;
|
||||||
QVector<QObject *> allObjects; // ### make this a QVector<QPointer<QObject> > > ?
|
QVector<QObject *> allObjects; // ### make this a QVector<QPointer<QObject> > > ?
|
||||||
QStringList defaultDisabledPlugins; // Plugins/Ignored from install settings
|
QStringList defaultDisabledPlugins; // Plugins/Ignored from install settings
|
||||||
|
@@ -201,8 +201,8 @@ public:
|
|||||||
QVector<ExtensionSystem::PluginDependency> dependencies;
|
QVector<ExtensionSystem::PluginDependency> dependencies;
|
||||||
|
|
||||||
PluginSpec::PluginArgumentDescriptions argumentDescriptions;
|
PluginSpec::PluginArgumentDescriptions argumentDescriptions;
|
||||||
QString location;
|
FilePath location;
|
||||||
QString filePath;
|
FilePath filePath;
|
||||||
|
|
||||||
bool experimental{false};
|
bool experimental{false};
|
||||||
bool deprecated{false};
|
bool deprecated{false};
|
||||||
@@ -491,7 +491,7 @@ PluginSpec::PluginArgumentDescriptions PluginSpec::argumentDescriptions() const
|
|||||||
/*!
|
/*!
|
||||||
Returns the absolute path to the directory containing the plugin.
|
Returns the absolute path to the directory containing the plugin.
|
||||||
*/
|
*/
|
||||||
QString PluginSpec::location() const
|
FilePath PluginSpec::location() const
|
||||||
{
|
{
|
||||||
return d->location;
|
return d->location;
|
||||||
}
|
}
|
||||||
@@ -499,7 +499,7 @@ QString PluginSpec::location() const
|
|||||||
/*!
|
/*!
|
||||||
Returns the absolute path to the plugin.
|
Returns the absolute path to the plugin.
|
||||||
*/
|
*/
|
||||||
QString PluginSpec::filePath() const
|
FilePath PluginSpec::filePath() const
|
||||||
{
|
{
|
||||||
return d->filePath;
|
return d->filePath;
|
||||||
}
|
}
|
||||||
@@ -692,19 +692,20 @@ namespace {
|
|||||||
\internal
|
\internal
|
||||||
Returns false if the file does not represent a Qt Creator plugin.
|
Returns false if the file does not represent a Qt Creator plugin.
|
||||||
*/
|
*/
|
||||||
expected_str<PluginSpec *> readCppPluginSpec(const QString &fileName)
|
expected_str<PluginSpec *> readCppPluginSpec(const FilePath &fileName)
|
||||||
{
|
{
|
||||||
auto spec = new CppPluginSpec;
|
auto spec = new CppPluginSpec;
|
||||||
|
|
||||||
QFileInfo fileInfo(fileName);
|
const FilePath absPath = fileName.absoluteFilePath();
|
||||||
spec->setLocation(fileInfo.absolutePath());
|
|
||||||
spec->setFilePath(fileInfo.absoluteFilePath());
|
spec->setLocation(absPath.parentDir());
|
||||||
|
spec->setFilePath(absPath);
|
||||||
spec->d->loader.emplace();
|
spec->d->loader.emplace();
|
||||||
|
|
||||||
if (Utils::HostOsInfo::isMacHost())
|
if (Utils::HostOsInfo::isMacHost())
|
||||||
spec->d->loader->setLoadHints(QLibrary::ExportExternalSymbolsHint);
|
spec->d->loader->setLoadHints(QLibrary::ExportExternalSymbolsHint);
|
||||||
|
|
||||||
spec->d->loader->setFileName(fileInfo.absoluteFilePath());
|
spec->d->loader->setFileName(absPath.toFSPathString());
|
||||||
if (spec->d->loader->fileName().isEmpty())
|
if (spec->d->loader->fileName().isEmpty())
|
||||||
return make_unexpected(::ExtensionSystem::Tr::tr("Cannot open file"));
|
return make_unexpected(::ExtensionSystem::Tr::tr("Cannot open file"));
|
||||||
|
|
||||||
@@ -1110,12 +1111,12 @@ void PluginSpec::setState(State state)
|
|||||||
d->state = state;
|
d->state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginSpec::setLocation(const QString &location)
|
void PluginSpec::setLocation(const FilePath &location)
|
||||||
{
|
{
|
||||||
d->location = location;
|
d->location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginSpec::setFilePath(const QString &filePath)
|
void PluginSpec::setFilePath(const FilePath &filePath)
|
||||||
{
|
{
|
||||||
d->filePath = filePath;
|
d->filePath = filePath;
|
||||||
}
|
}
|
||||||
@@ -1142,8 +1143,7 @@ bool CppPluginSpec::loadLibrary()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (d->loader && !d->loader->load()) {
|
if (d->loader && !d->loader->load()) {
|
||||||
setError(QDir::toNativeSeparators(filePath()) + QString::fromLatin1(": ")
|
setError(filePath().toUserOutput() + QString::fromLatin1(": ") + d->loader->errorString());
|
||||||
+ d->loader->errorString());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto *pluginObject = d->loader ? qobject_cast<IPlugin *>(d->loader->instance())
|
auto *pluginObject = d->loader ? qobject_cast<IPlugin *>(d->loader->instance())
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
#include "iplugin.h"
|
#include "iplugin.h"
|
||||||
|
|
||||||
#include <utils/expected.h>
|
#include <utils/expected.h>
|
||||||
|
#include <utils/filepath.h>
|
||||||
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QStaticPlugin>
|
#include <QStaticPlugin>
|
||||||
@@ -120,8 +121,8 @@ public:
|
|||||||
virtual QJsonObject metaData() const;
|
virtual QJsonObject metaData() const;
|
||||||
virtual PerformanceData &performanceData() const;
|
virtual PerformanceData &performanceData() const;
|
||||||
virtual PluginArgumentDescriptions argumentDescriptions() const;
|
virtual PluginArgumentDescriptions argumentDescriptions() const;
|
||||||
virtual QString location() const;
|
virtual Utils::FilePath location() const;
|
||||||
virtual QString filePath() const;
|
virtual Utils::FilePath filePath() const;
|
||||||
virtual QStringList arguments() const;
|
virtual QStringList arguments() const;
|
||||||
virtual void setArguments(const QStringList &arguments);
|
virtual void setArguments(const QStringList &arguments);
|
||||||
virtual void addArgument(const QString &argument);
|
virtual void addArgument(const QString &argument);
|
||||||
@@ -160,8 +161,8 @@ protected:
|
|||||||
protected:
|
protected:
|
||||||
virtual void setState(State state);
|
virtual void setState(State state);
|
||||||
|
|
||||||
virtual void setLocation(const QString &location);
|
virtual void setLocation(const Utils::FilePath &location);
|
||||||
virtual void setFilePath(const QString &filePath);
|
virtual void setFilePath(const Utils::FilePath &filePath);
|
||||||
virtual Utils::expected_str<void> readMetaData(const QJsonObject &metaData);
|
virtual Utils::expected_str<void> readMetaData(const QJsonObject &metaData);
|
||||||
Utils::expected_str<void> reportError(const QString &error);
|
Utils::expected_str<void> reportError(const QString &error);
|
||||||
|
|
||||||
@@ -169,14 +170,15 @@ private:
|
|||||||
std::unique_ptr<Internal::PluginSpecPrivate> d;
|
std::unique_ptr<Internal::PluginSpecPrivate> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
EXTENSIONSYSTEM_EXPORT Utils::expected_str<PluginSpec *> readCppPluginSpec(const QString &filePath);
|
EXTENSIONSYSTEM_EXPORT Utils::expected_str<PluginSpec *> readCppPluginSpec(
|
||||||
|
const Utils::FilePath &filePath);
|
||||||
EXTENSIONSYSTEM_EXPORT Utils::expected_str<PluginSpec *> readCppPluginSpec(
|
EXTENSIONSYSTEM_EXPORT Utils::expected_str<PluginSpec *> readCppPluginSpec(
|
||||||
const QStaticPlugin &plugin);
|
const QStaticPlugin &plugin);
|
||||||
|
|
||||||
class EXTENSIONSYSTEM_TEST_EXPORT CppPluginSpec : public PluginSpec
|
class EXTENSIONSYSTEM_TEST_EXPORT CppPluginSpec : public PluginSpec
|
||||||
{
|
{
|
||||||
friend EXTENSIONSYSTEM_EXPORT Utils::expected_str<PluginSpec *> readCppPluginSpec(
|
friend EXTENSIONSYSTEM_EXPORT Utils::expected_str<PluginSpec *> readCppPluginSpec(
|
||||||
const QString &filePath);
|
const Utils::FilePath &filePath);
|
||||||
friend EXTENSIONSYSTEM_EXPORT Utils::expected_str<PluginSpec *> readCppPluginSpec(
|
friend EXTENSIONSYSTEM_EXPORT Utils::expected_str<PluginSpec *> readCppPluginSpec(
|
||||||
const QStaticPlugin &plugin);
|
const QStaticPlugin &plugin);
|
||||||
|
|
||||||
|
@@ -119,7 +119,7 @@ public:
|
|||||||
toolTip = Tr::tr("Path: %1\nPlugin is disabled by command line argument.");
|
toolTip = Tr::tr("Path: %1\nPlugin is disabled by command line argument.");
|
||||||
else
|
else
|
||||||
toolTip = Tr::tr("Path: %1");
|
toolTip = Tr::tr("Path: %1");
|
||||||
return toolTip.arg(QDir::toNativeSeparators(m_spec->filePath()));
|
return toolTip.arg(m_spec->filePath().toUserOutput());
|
||||||
}
|
}
|
||||||
if (role == Qt::DecorationRole) {
|
if (role == Qt::DecorationRole) {
|
||||||
bool ok = !m_spec->hasError();
|
bool ok = !m_spec->hasError();
|
||||||
|
@@ -154,7 +154,7 @@ void checkContents(QPromise<ArchiveIssue> &promise, const FilePath &tempDir)
|
|||||||
if (promise.isCanceled())
|
if (promise.isCanceled())
|
||||||
return;
|
return;
|
||||||
it.next();
|
it.next();
|
||||||
expected_str<PluginSpec *> spec = readCppPluginSpec(it.filePath());
|
expected_str<PluginSpec *> spec = readCppPluginSpec(FilePath::fromUserInput(it.filePath()));
|
||||||
if (spec) {
|
if (spec) {
|
||||||
// Is a Qt Creator plugin. Let's see if we find a Core dependency and check the
|
// Is a Qt Creator plugin. Let's see if we find a Core dependency and check the
|
||||||
// version
|
// version
|
||||||
|
@@ -153,7 +153,7 @@ void ExtensionManagerWidget::updateView(const QModelIndex ¤t,
|
|||||||
"of the extensions that are part of pack ") + data.name
|
"of the extensions that are part of pack ") + data.name
|
||||||
: extension->longDescription();
|
: extension->longDescription();
|
||||||
longDescription.replace("\n", "<br/>");
|
longDescription.replace("\n", "<br/>");
|
||||||
const QString location = isPack ? extension->location() : extension->filePath();
|
const FilePath location = isPack ? extension->location() : extension->filePath();
|
||||||
|
|
||||||
QString description = htmlStart;
|
QString description = htmlStart;
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ void ExtensionManagerWidget::updateView(const QModelIndex ¤t,
|
|||||||
.arg(Tr::tr("Version"))
|
.arg(Tr::tr("Version"))
|
||||||
.arg(extension->version())
|
.arg(extension->version())
|
||||||
.arg(Tr::tr("Location"))
|
.arg(Tr::tr("Location"))
|
||||||
.arg(location));
|
.arg(location.toUserOutput()));
|
||||||
|
|
||||||
description.append(htmlEnd);
|
description.append(htmlEnd);
|
||||||
m_primaryDescription->setText(description);
|
m_primaryDescription->setText(description);
|
||||||
|
@@ -135,8 +135,7 @@ expected_str<void> LuaEngine::prepareSetup(
|
|||||||
sol::lib::table,
|
sol::lib::table,
|
||||||
sol::lib::utf8);
|
sol::lib::utf8);
|
||||||
|
|
||||||
const QString searchPath
|
const QString searchPath = (pluginSpec.location() / "?.lua").toUserOutput();
|
||||||
= (FilePath::fromUserInput(pluginSpec.filePath()).parentDir() / "?.lua").toUserOutput();
|
|
||||||
lua["package"]["path"] = searchPath.toStdString();
|
lua["package"]["path"] = searchPath.toStdString();
|
||||||
|
|
||||||
// TODO: only register what the plugin requested
|
// TODO: only register what the plugin requested
|
||||||
|
@@ -62,8 +62,8 @@ public:
|
|||||||
|
|
||||||
bool delayedInitialize() final
|
bool delayedInitialize() final
|
||||||
{
|
{
|
||||||
scanForPlugins(transform(PluginManager::pluginPaths(), [](const QString &path) -> FilePath {
|
scanForPlugins(transform(PluginManager::pluginPaths(), [](const FilePath &path) {
|
||||||
return FilePath::fromUserInput(path) / "lua-plugins";
|
return path / "lua-plugins";
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@@ -71,8 +71,8 @@ expected_str<LuaPluginSpec *> LuaPluginSpec::create(const FilePath &filePath,
|
|||||||
if (!r)
|
if (!r)
|
||||||
return make_unexpected(r.error());
|
return make_unexpected(r.error());
|
||||||
|
|
||||||
pluginSpec->setFilePath(filePath.toUserOutput());
|
pluginSpec->setFilePath(filePath);
|
||||||
pluginSpec->setLocation(filePath.parentDir().toUserOutput());
|
pluginSpec->setLocation(filePath.parentDir());
|
||||||
|
|
||||||
pluginSpec->d->pluginScriptPath = filePath;
|
pluginSpec->d->pluginScriptPath = filePath;
|
||||||
|
|
||||||
|
@@ -584,7 +584,7 @@ FilePaths &JsonWizardFactory::searchPaths()
|
|||||||
// add paths from enabled plugin meta data
|
// add paths from enabled plugin meta data
|
||||||
for (PluginSpec *plugin : PluginManager::plugins()) {
|
for (PluginSpec *plugin : PluginManager::plugins()) {
|
||||||
if (plugin->state() == PluginSpec::Running) {
|
if (plugin->state() == PluginSpec::Running) {
|
||||||
const auto base = FilePath::fromString(plugin->filePath()).parentDir();
|
const auto base = plugin->location();
|
||||||
const auto values = plugin->metaData().value("JsonWizardPaths").toArray();
|
const auto values = plugin->metaData().value("JsonWizardPaths").toArray();
|
||||||
for (const QJsonValue &v : values) {
|
for (const QJsonValue &v : values) {
|
||||||
const auto path = FilePath::fromString(v.toString());
|
const auto path = FilePath::fromString(v.toString());
|
||||||
|
@@ -625,11 +625,13 @@ void QmlDesignerPlugin::enforceDelayedInitialize()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// adding default path to item library plugins
|
// adding default path to item library plugins
|
||||||
const QString postfix = Utils::HostOsInfo::isMacHost() ? QString("/QmlDesigner")
|
const QString postfix = Utils::HostOsInfo::isMacHost()
|
||||||
: QString("/qmldesigner");
|
? QString("QmlDesigner")
|
||||||
const QStringList pluginPaths = Utils::transform(ExtensionSystem::PluginManager::pluginPaths(),
|
: QString("qmldesigner");
|
||||||
[postfix](const QString &p) {
|
const QStringList pluginPaths =
|
||||||
return QString(p + postfix);
|
Utils::transform(ExtensionSystem::PluginManager::pluginPaths(),
|
||||||
|
[postfix](const Utils::FilePath &p) {
|
||||||
|
return (p / postfix).toFSPathString();
|
||||||
});
|
});
|
||||||
|
|
||||||
#ifndef QDS_USE_PROJECTSTORAGE
|
#ifndef QDS_USE_PROJECTSTORAGE
|
||||||
|
@@ -47,9 +47,9 @@ class MyClass11 : public MyClass1
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
};
|
};
|
||||||
|
|
||||||
static QString pluginFolder(const QLatin1String &folder)
|
static Utils::FilePath pluginFolder(const QLatin1String &folder)
|
||||||
{
|
{
|
||||||
return QLatin1String(PLUGINMANAGER_TESTS_DIR) + QLatin1String("/") + folder;
|
return Utils::FilePath::fromUserInput(QLatin1String(PLUGINMANAGER_TESTS_DIR)) / folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_PluginManager::init()
|
void tst_PluginManager::init()
|
||||||
@@ -138,7 +138,7 @@ void tst_PluginManager::getObject()
|
|||||||
|
|
||||||
void tst_PluginManager::circularPlugins()
|
void tst_PluginManager::circularPlugins()
|
||||||
{
|
{
|
||||||
PluginManager::setPluginPaths(QStringList() << pluginFolder(QLatin1String("circularplugins")));
|
PluginManager::setPluginPaths({pluginFolder(QLatin1String("circularplugins"))});
|
||||||
PluginManager::loadPlugins();
|
PluginManager::loadPlugins();
|
||||||
const QVector<PluginSpec *> plugins = PluginManager::plugins();
|
const QVector<PluginSpec *> plugins = PluginManager::plugins();
|
||||||
QCOMPARE(plugins.count(), 3);
|
QCOMPARE(plugins.count(), 3);
|
||||||
@@ -160,7 +160,7 @@ void tst_PluginManager::circularPlugins()
|
|||||||
|
|
||||||
void tst_PluginManager::correctPlugins1()
|
void tst_PluginManager::correctPlugins1()
|
||||||
{
|
{
|
||||||
PluginManager::setPluginPaths(QStringList() << pluginFolder(QLatin1String("correctplugins1")));
|
PluginManager::setPluginPaths({pluginFolder(QLatin1String("correctplugins1"))});
|
||||||
PluginManager::loadPlugins();
|
PluginManager::loadPlugins();
|
||||||
bool specError = false;
|
bool specError = false;
|
||||||
bool runError = false;
|
bool runError = false;
|
||||||
|
@@ -5,7 +5,7 @@ add_qtc_test(tst_pluginspec
|
|||||||
PLUGIN_DIR="${CMAKE_CURRENT_BINARY_DIR}"
|
PLUGIN_DIR="${CMAKE_CURRENT_BINARY_DIR}"
|
||||||
PLUGINSPEC_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
|
PLUGINSPEC_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
DLL_INFIX="$<$<CONFIG:Debug>:d>"
|
DLL_INFIX="$<$<CONFIG:Debug>:d>"
|
||||||
DEPENDS ExtensionSystem
|
DEPENDS ExtensionSystem Utils
|
||||||
SOURCES
|
SOURCES
|
||||||
tst_pluginspec.cpp
|
tst_pluginspec.cpp
|
||||||
)
|
)
|
||||||
|
@@ -4,6 +4,8 @@ QtcAutotest {
|
|||||||
name: "ExtensionSystem pluginspec autotest"
|
name: "ExtensionSystem pluginspec autotest"
|
||||||
Depends { name: "Aggregation" }
|
Depends { name: "Aggregation" }
|
||||||
Depends { name: "ExtensionSystem" }
|
Depends { name: "ExtensionSystem" }
|
||||||
|
Depends { name: "Utils" }
|
||||||
|
|
||||||
Group {
|
Group {
|
||||||
name: "Sources"
|
name: "Sources"
|
||||||
files: "tst_pluginspec.cpp"
|
files: "tst_pluginspec.cpp"
|
||||||
|
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
using namespace ExtensionSystem;
|
using namespace ExtensionSystem;
|
||||||
|
|
||||||
|
static const Utils::FilePath PLUGIN_DIR_PATH = Utils::FilePath::fromUserInput(PLUGIN_DIR);
|
||||||
|
|
||||||
static QJsonObject metaData(const QString &fileName)
|
static QJsonObject metaData(const QString &fileName)
|
||||||
{
|
{
|
||||||
QFile f(fileName);
|
QFile f(fileName);
|
||||||
@@ -221,14 +223,11 @@ void tst_PluginSpec::experimental()
|
|||||||
void tst_PluginSpec::locationAndPath()
|
void tst_PluginSpec::locationAndPath()
|
||||||
{
|
{
|
||||||
Utils::expected_str<PluginSpec *> ps = readCppPluginSpec(
|
Utils::expected_str<PluginSpec *> ps = readCppPluginSpec(
|
||||||
QLatin1String(PLUGIN_DIR) + QLatin1String("/testplugin/")
|
PLUGIN_DIR_PATH / "testplugin" / libraryName(QLatin1String("test")));
|
||||||
+ libraryName(QLatin1String("test")));
|
|
||||||
QVERIFY(ps);
|
QVERIFY(ps);
|
||||||
CppPluginSpec *spec = static_cast<CppPluginSpec *>(ps.value());
|
CppPluginSpec *spec = static_cast<CppPluginSpec *>(ps.value());
|
||||||
QCOMPARE(spec->location(), QString(QLatin1String(PLUGIN_DIR) + QLatin1String("/testplugin")));
|
QCOMPARE(spec->location(), PLUGIN_DIR_PATH / "testplugin");
|
||||||
QCOMPARE(spec->filePath(),
|
QCOMPARE(spec->filePath(), PLUGIN_DIR_PATH / "testplugin" / libraryName(QLatin1String("test")));
|
||||||
QString(QLatin1String(PLUGIN_DIR) + QLatin1String("/testplugin/")
|
|
||||||
+ libraryName(QLatin1String("test"))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_PluginSpec::resolveDependencies()
|
void tst_PluginSpec::resolveDependencies()
|
||||||
@@ -272,8 +271,7 @@ void tst_PluginSpec::resolveDependencies()
|
|||||||
void tst_PluginSpec::loadLibrary()
|
void tst_PluginSpec::loadLibrary()
|
||||||
{
|
{
|
||||||
Utils::expected_str<PluginSpec *> ps = readCppPluginSpec(
|
Utils::expected_str<PluginSpec *> ps = readCppPluginSpec(
|
||||||
QLatin1String(PLUGIN_DIR) + QLatin1String("/testplugin/")
|
PLUGIN_DIR_PATH / "testplugin" / libraryName(QLatin1String("test")));
|
||||||
+ libraryName(QLatin1String("test")));
|
|
||||||
|
|
||||||
QVERIFY(ps);
|
QVERIFY(ps);
|
||||||
CppPluginSpec *spec = static_cast<CppPluginSpec *>(ps.value());
|
CppPluginSpec *spec = static_cast<CppPluginSpec *>(ps.value());
|
||||||
@@ -292,8 +290,7 @@ void tst_PluginSpec::loadLibrary()
|
|||||||
void tst_PluginSpec::initializePlugin()
|
void tst_PluginSpec::initializePlugin()
|
||||||
{
|
{
|
||||||
Utils::expected_str<PluginSpec *> ps = readCppPluginSpec(
|
Utils::expected_str<PluginSpec *> ps = readCppPluginSpec(
|
||||||
QLatin1String(PLUGIN_DIR) + QLatin1String("/testplugin/")
|
PLUGIN_DIR_PATH / "testplugin" / libraryName(QLatin1String("test")));
|
||||||
+ libraryName(QLatin1String("test")));
|
|
||||||
QVERIFY(ps);
|
QVERIFY(ps);
|
||||||
CppPluginSpec *spec = static_cast<CppPluginSpec *>(ps.value());
|
CppPluginSpec *spec = static_cast<CppPluginSpec *>(ps.value());
|
||||||
QVERIFY(spec->resolveDependencies(QVector<PluginSpec *>()));
|
QVERIFY(spec->resolveDependencies(QVector<PluginSpec *>()));
|
||||||
@@ -317,8 +314,7 @@ void tst_PluginSpec::initializePlugin()
|
|||||||
void tst_PluginSpec::initializeExtensions()
|
void tst_PluginSpec::initializeExtensions()
|
||||||
{
|
{
|
||||||
Utils::expected_str<PluginSpec *> ps = readCppPluginSpec(
|
Utils::expected_str<PluginSpec *> ps = readCppPluginSpec(
|
||||||
QLatin1String(PLUGIN_DIR) + QLatin1String("/testplugin/")
|
PLUGIN_DIR_PATH / "testplugin" / libraryName(QLatin1String("test")));
|
||||||
+ libraryName(QLatin1String("test")));
|
|
||||||
QVERIFY(ps);
|
QVERIFY(ps);
|
||||||
CppPluginSpec *spec = static_cast<CppPluginSpec *>(ps.value());
|
CppPluginSpec *spec = static_cast<CppPluginSpec *>(ps.value());
|
||||||
QVERIFY(spec->resolveDependencies(QVector<PluginSpec *>()));
|
QVERIFY(spec->resolveDependencies(QVector<PluginSpec *>()));
|
||||||
|
@@ -114,7 +114,7 @@ int main(int argc, char *argv[])
|
|||||||
QObject::connect(&app, &QCoreApplication::aboutToQuit,
|
QObject::connect(&app, &QCoreApplication::aboutToQuit,
|
||||||
&manager, &ExtensionSystem::PluginManager::shutdown);
|
&manager, &ExtensionSystem::PluginManager::shutdown);
|
||||||
PluginDialog dialog;
|
PluginDialog dialog;
|
||||||
manager.setPluginPaths(QStringList() << app.applicationDirPath() + "/plugins");
|
manager.setPluginPaths({FilePath::fromUserInput(app.applicationDirPath()) / "plugins"});
|
||||||
manager.loadPlugins();
|
manager.loadPlugins();
|
||||||
dialog.show();
|
dialog.show();
|
||||||
app.exec();
|
app.exec();
|
||||||
|
Reference in New Issue
Block a user