mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-20 03:46:11 +00:00
Add PluginManager::getPluginsDirectory()
This commit is contained in:
parent
193fef46df
commit
31a832c34d
@ -30,25 +30,33 @@ PluginManager::~PluginManager()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString PluginManager::getPluginsDirectory() const
|
||||||
|
{
|
||||||
|
QStringList locations = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
|
||||||
|
if (locations.isEmpty()) {
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
QDir pluginsDir(locations.first());
|
||||||
|
pluginsDir.mkpath("plugins");
|
||||||
|
if (!pluginsDir.cd("plugins")) {
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
return pluginsDir.absolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
void PluginManager::loadPlugins()
|
void PluginManager::loadPlugins()
|
||||||
{
|
{
|
||||||
assert(plugins.isEmpty());
|
assert(plugins.isEmpty());
|
||||||
|
|
||||||
QStringList locations = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
|
QString pluginsDirStr = getPluginsDirectory();
|
||||||
if (locations.isEmpty()) {
|
if (pluginsDirStr.isEmpty()) {
|
||||||
qCritical() << "Failed to get a standard path to load plugins from.";
|
qCritical() << "Failed to get a path to load plugins from.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QDir pluginsDir(locations.first());
|
QDir pluginsDir(pluginsDirStr);
|
||||||
pluginsDir.mkpath(".");
|
|
||||||
|
|
||||||
qInfo() << "Plugins are loaded from" << pluginsDir.absolutePath();
|
qInfo() << "Plugins are loaded from" << pluginsDir.absolutePath();
|
||||||
|
|
||||||
pluginsDir.mkdir("plugins");
|
|
||||||
if (!pluginsDir.cd("plugins")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDir nativePluginsDir = pluginsDir;
|
QDir nativePluginsDir = pluginsDir;
|
||||||
nativePluginsDir.mkdir("native");
|
nativePluginsDir.mkdir("native");
|
||||||
if (nativePluginsDir.cd("native")) {
|
if (nativePluginsDir.cd("native")) {
|
||||||
|
@ -29,6 +29,8 @@ public:
|
|||||||
|
|
||||||
const QList<CutterPlugin *> &getPlugins() { return plugins; }
|
const QList<CutterPlugin *> &getPlugins() { return plugins; }
|
||||||
|
|
||||||
|
QString getPluginsDirectory() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<CutterPlugin *> plugins;
|
QList<CutterPlugin *> plugins;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user