Commit 3737d47e authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

add settings for composer. handle multiple directories for plugins initialization

parent 8ed9b47a
......@@ -117,6 +117,7 @@ set(${PROJECT_NAME}_HEADERS
dtkComposerScenePort.h
dtkComposerSceneView.h
dtkComposerSearchDialog.h
dtkComposerSettings.h
dtkComposerStack.h
dtkComposerStackCommand.h
dtkComposerStackUtils.h
......@@ -230,6 +231,7 @@ set(${PROJECT_NAME}_SOURCES
dtkComposerScenePort.cpp
dtkComposerSceneView.cpp
dtkComposerSearchDialog.cpp
dtkComposerSettings.cpp
dtkComposerStack.cpp
dtkComposerStackCommand.cpp
dtkComposerStackUtils.cpp
......
......@@ -57,6 +57,7 @@
#include "dtkComposerScenePort.h"
#include "dtkComposerSceneView.h"
#include "dtkComposerSearchDialog.h"
#include "dtkComposerSettings.h"
#include "dtkComposerStack.h"
#include "dtkComposerStackCommand.h"
#include "dtkComposerStackUtils.h"
......
......@@ -15,6 +15,7 @@
#include "dtkComposerNodeFactory.h"
#include "dtkComposerFactory.h"
#include "dtkComposerExtension.h"
#include "dtkComposerSettings.h"
namespace dtkComposer
{
......@@ -40,11 +41,20 @@ namespace dtkComposer
return _private::manager;
}
void initialize(const QString& path) {
if (path.isEmpty()) {
QString default_path = QDir(DTK_INSTALL_PREFIX).filePath("plugins/dtkComposer");
dtkDebug() << "no composer plugin path configured, use default:" << default_path ;
QString realpath = path;
if (realpath.isEmpty()) {
dtkComposerSettings composer_settings;
composer_settings.beginGroup("extension");
realpath = composer_settings.value("plugins").toString();
composer_settings.endGroup();
if (realpath.isEmpty()) {
realpath = QDir(DTK_INSTALL_PREFIX).filePath("plugins/dtkComposer");
dtkDebug() << "no composer plugin path configured, use default:" << realpath ;
}
pluginManager().setVerboseLoading(true);
pluginManager().initialize(default_path);
pluginManager().initialize(realpath);
} else {
dtkDebug() << "initialize composer plugins using path:" << path ;
pluginManager().initialize(path);
......
/* dtkComposerSettings.cpp ---
*
* Author: Nicolas Niclausse
* Copyright (C) 2016 - Nicolas Niclausse, Inria.
* Created: 2016/02/15 12:39:05
*/
/* Commentary:
*
*/
/* Change log:
*
*/
#include "dtkComposerSettings.h"
#include <dtkLog>
dtkComposerSettings::dtkComposerSettings(void) : QSettings(QSettings::IniFormat, QSettings::UserScope, "inria", "dtk-composer")
{
this->beginGroup("extension");
if(!this->allKeys().contains("plugins")){
this->setValue("plugins", QString());
}
this->sync();
this->endGroup();
}
dtkComposerSettings::~dtkComposerSettings(void)
{
}
//
// dtkComposerSettings.cpp ends here
/* @(#)dtkComposerSettings.h ---
*
* Author: Nicolas Niclausse
* Copyright (C) 2016 - Nicolas Niclausse, Inria.
* Created: 2016/02/15 12:38:05
*/
/* Commentary:
*
*/
/* Change log:
*
*/
#pragma once
#include "dtkComposerExport.h"
#include <QtCore>
class DTKCOMPOSER_EXPORT dtkComposerSettings : public QSettings
{
public:
dtkComposerSettings(void);
~dtkComposerSettings(void);
};
......@@ -155,16 +155,19 @@ template <typename T> void dtkCorePluginManager<T>::loadFromName(const QString &
template <typename T> void dtkCorePluginManager<T>::initialize(const QString& path)
{
QDir dir(path);
foreach(QFileInfo info, dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot))
this->scan(info.absoluteFilePath());
if(d->autoLoading) {
foreach(QString path2, path.split(":",QString::SkipEmptyParts )) {
QDir dir(path2);
dtkTrace() << "scanning directory for plugins:" << path2;
foreach(QFileInfo info, dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot))
this->load(info.absoluteFilePath());
this->scan(info.absoluteFilePath());
if(d->autoLoading) {
foreach(QFileInfo info, dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot))
this->load(info.absoluteFilePath());
}
}
}
}
template <typename T> void dtkCorePluginManager<T>::uninitialize(void)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment