dtkComposer.cpp 1.74 KB
Newer Older
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
1
/* dtkComposer.cpp ---
2
 *
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
3 4 5 6 7
 * Author: Thibaud Kloczko
 * Created: Tue Apr  9 12:49:06 2013 (+0200)
 */

/* Change Log:
8
 *
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
9 10 11
 */

#include "dtkComposer.h"
12 13 14

#include <dtkConfig.h>

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
15
#include "dtkComposerNodeFactory.h"
16 17
#include "dtkComposerFactory.h"
#include "dtkComposerExtension.h"
18
#include "dtkComposerSettings.h"
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
19 20 21

namespace dtkComposer
{
22
    namespace node
23 24 25 26 27 28 29
    {
        dtkComposerNodeFactory *factory(void) {
            return dtkComposerFactory::instance();
        }
    }

    namespace extension
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
30
    {
31
        namespace _private {
32 33 34 35 36 37
            dtkComposerExtensionPluginFactory factory;
            dtkComposerExtensionPluginManager manager;
        }

        dtkComposerExtensionPluginFactory& pluginFactory(void) {
            return _private::factory;
38
        }
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
39

40 41 42 43
        dtkComposerExtensionPluginManager& pluginManager(void) {
            return _private::manager;
        }
        void initialize(const QString& path) {
44 45 46 47 48 49 50 51 52 53 54 55
            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 ;
                }
56
                pluginManager().setVerboseLoading(true);
57
                pluginManager().initialize(realpath);
58 59 60 61
            } else {
                dtkDebug() << "initialize composer plugins using path:" << path ;
                pluginManager().initialize(path);
            }
62
        }
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
63 64
    }
}