Debian Codegraph @

plugins/plugman/example/main.cpp

raw symbols SCIP
1 #include <QGuiApplication>
2 #include <PluginRegistry.h>
3 #include <PluginInfo.h>
4 #include <QScopedPointer>
5 #include <QDebug>
6 #include <QQuickView>
7 #include <ActionRegistry.h>
8 #include <ServiceRegistry.h>
9 #include <ItemRegistry.h>
10 #include "ListenerRegistry.h"
11
12 int main(int argc, char *argv[])
13 {
14 QGuiApplication a(argc, argv);
15
16 QCoreApplication::setApplicationName("pluggy");
17 QCoreApplication::setOrganizationName("dekko");
18
19 // First declare the plugin locations we support
20 PluginRegistry::instance()->setPluginLocations(QStringList()
21 << QStringLiteral("Composer::ToolbarAction")
22 << QStringLiteral("View::Item")
23 << QStringLiteral("Dekko::Service")
24 << QStringLiteral("Dekko::Listener"));
25
26 // Now load all plugins from supported locations, by passing
27 // a list of directories. These can be anywhere you like.
28 // By default the registry will always look for a plugins directory in the same location
29 // as the executable i.e QCoreApplication::applicationDirPath() + "/plugins".
30 // Or alternatively you can also set the DEKKO_PLUGINS environment vairable to a directory
31 // that the registry should search.
32 PluginRegistry::instance()->loadPlugins(QStringList() << QStringLiteral("/tmp/Dekko"));
33
34
35 // Now start any non UI service plugins. These should be run as a qprocess if possibl
36 // but the ServicePlugin just exposes a start() and stop() method so it can be in this
37 // process if required.
38 QScopedPointer<ServiceRegistry> services(new ServiceRegistry);
39 services->setServiceKey(QStringLiteral("Dekko::Service"));
40 services->startServices();
41
42 qmlRegisterType<ActionRegistry>("Plugins", 0, 1, "ActionRegistry");
43 qmlRegisterType<ItemRegistry>("Plugins", 0, 1, "ItemRegistry");
44 qmlRegisterType<ListenerRegistry>("Plugins", 0, 1, "ListenerRegistry");
45
46 QScopedPointer<QQuickView> view(new QQuickView);
47 view->setSource(QUrl(QString("qrc:/qml/Main.qml")));
48 view->show();
49
50 return a.exec();
51 }