mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-31 08:37:26 +00:00
Load Plugins from QStandardPaths::AppDataLocation
This commit is contained in:
parent
986041380c
commit
ea6dea3cc1
@ -11,6 +11,7 @@
|
||||
#include <QDir>
|
||||
#include <QCoreApplication>
|
||||
#include <QPluginLoader>
|
||||
#include <QStandardPaths>
|
||||
|
||||
Q_GLOBAL_STATIC(PluginManager, uniqueInstance)
|
||||
|
||||
@ -31,27 +32,26 @@ void PluginManager::loadPlugins()
|
||||
{
|
||||
assert(plugins.isEmpty());
|
||||
|
||||
QDir pluginsDir(qApp->applicationDirPath());
|
||||
#if defined(Q_OS_WIN)
|
||||
if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release")
|
||||
pluginsDir.cdUp();
|
||||
#elif defined(Q_OS_MAC)
|
||||
if (pluginsDir.dirName() == "MacOS") {
|
||||
pluginsDir.cdUp();
|
||||
pluginsDir.cdUp();
|
||||
pluginsDir.cdUp();
|
||||
QStringList locations = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
|
||||
if (locations.isEmpty()) {
|
||||
qCritical() << "Failed to get a standard path to load plugins from.";
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
QDir pluginsDir(locations.first());
|
||||
|
||||
pluginsDir.mkdir("plugins");
|
||||
if (!pluginsDir.cd("plugins")) {
|
||||
return;
|
||||
}
|
||||
|
||||
QDir nativePluginsDir = pluginsDir;
|
||||
nativePluginsDir.mkdir("native");
|
||||
if (nativePluginsDir.cd("native")) {
|
||||
loadNativePlugins(nativePluginsDir);
|
||||
}
|
||||
|
||||
QDir pythonPluginsDir = pluginsDir;
|
||||
pythonPluginsDir.mkdir("python");
|
||||
if (pythonPluginsDir.cd("python")) {
|
||||
loadPythonPlugins(pythonPluginsDir.absolutePath());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user