1 #include "asemantoolsplugin.h"
2 #include "asemanquickview.h"
3 #include "asemandesktoptools.h"
4 #include "asemanqtlogger.h"
5 #include "asemandevices.h"
6 #include "asemantools.h"
7 #include "asemanapplication.h"
8 #include "asemanhashobject.h"
9 #include "asemandownloader.h"
10 #include "asemanlistobject.h"
11 #include "asemancalendarconverter.h"
12 #include "asemanimagecoloranalizor.h"
13 #include "asemanmimedata.h"
14 #include "asemandragobject.h"
15 #include "asemanbackhandler.h"
16 #include "aseman_macros.h"
17 #include "asemancountriesmodel.h"
18 #include "asemanautostartmanager.h"
19 #ifdef Q_OS_ANDROID
20 #include "asemanjavalayer.h"
21 #endif
22 #ifdef DESKTOP_LINUX
23 #include "asemanmimeapps.h"
24 #endif
25 #ifdef ASEMAN_SENSORS
26 #include "asemansensors.h"
27 #endif
28 #ifdef ASEMAN_NOTIFICATION
29 #include "asemannotification.h"
30 #endif
31
32 #include <qqml.h>
33
34 #define SINGLETON_PROVIDER(TYPE, FNC_NAME, ...) \
35 SINGLETON_PROVIDER_PRO(TYPE, FNC_NAME, new TYPE(__VA_ARGS__))
36
37 #define SINGLETON_PROVIDER_PRO(TYPE, FNC_NAME, NEW_CREATOR) \
38 static QObject *FNC_NAME(QQmlEngine *engine, QJSEngine *scriptEngine) { \
39 Q_UNUSED(engine) \
40 Q_UNUSED(scriptEngine) \
41 static TYPE *singleton = NEW_CREATOR; \
42 return singleton; \
43 }
44
SINGLETON_PROVIDER(AsemanDevices,aseman_devices_singleton)45 SINGLETON_PROVIDER(AsemanDevices, aseman_devices_singleton)
46 SINGLETON_PROVIDER(AsemanTools, aseman_tools_singleton)
47 SINGLETON_PROVIDER(AsemanDesktopTools, aseman_desktoptools_singleton)
48 SINGLETON_PROVIDER(AsemanCalendarConverter, aseman_calendarconv_singleton)
49 SINGLETON_PROVIDER(AsemanBackHandler, aseman_backhandler_singleton)
50 SINGLETON_PROVIDER(AsemanApplication, aseman_app_singleton)
51 SINGLETON_PROVIDER_PRO(AsemanQuickView, aseman_qview_singleton, new AsemanQuickView(engine))
52 SINGLETON_PROVIDER_PRO(AsemanQtLogger, aseman_logger_singleton, new AsemanQtLogger(AsemanApplication::logPath()))
53
54 void AsemanToolsPlugin::registerTypes(const char *uri)
55 {
56 qRegisterMetaType<AsemanMimeData*>("AsemanMimeData*");
57
58 qmlRegisterType<AsemanMimeData>(uri, 1, 0, "MimeData");
59 qmlRegisterType<AsemanDragObject>(uri, 1, 0, "DragObject");
60 qmlRegisterType<AsemanListObject>(uri, 1, 0, "ListObject");
61 qmlRegisterType<AsemanHashObject>(uri, 1, 0, "HashObject");
62 qmlRegisterType<AsemanDownloader>(uri, 1,0, "Downloader");
63 qmlRegisterType<AsemanImageColorAnalizor>(uri, 1,0, "ImageColorAnalizor");
64 qmlRegisterType<AsemanCountriesModel>(uri, 1,0, "CountriesModel");
65 qmlRegisterType<AsemanAutoStartManager>(uri, 1,0, "AutoStartManager");
66 #ifdef DESKTOP_LINUX
67 qmlRegisterType<AsemanMimeApps>(uri, 1,0, "MimeApps");
68 #endif
69 #ifdef ASEMAN_SENSORS
70 qmlRegisterType<AsemanSensors>(uri, 1,0, "AsemanSensors");
71 #endif
72 #ifdef ASEMAN_NOTIFICATION
73 qmlRegisterType<AsemanNotification>(uri, 1,0, "Notification");
74 #endif
75
76 qmlRegisterSingletonType<AsemanDevices>(uri, 1, 0, "Devices", aseman_devices_singleton);
77 qmlRegisterSingletonType<AsemanTools>(uri, 1, 0, "Tools", aseman_tools_singleton);
78 qmlRegisterSingletonType<AsemanDesktopTools>(uri, 1, 0, "Desktop", aseman_desktoptools_singleton);
79 qmlRegisterSingletonType<AsemanCalendarConverter>(uri, 1, 0, "CalendarConv", aseman_calendarconv_singleton);
80 qmlRegisterSingletonType<AsemanBackHandler>(uri, 1, 0, "BackHandler", aseman_backhandler_singleton);
81 qmlRegisterSingletonType<AsemanApplication>(uri, 1, 0, "AsemanApp", aseman_app_singleton);
82 qmlRegisterSingletonType<AsemanQtLogger>(uri, 1, 0, "Logger", aseman_logger_singleton);
83 qmlRegisterSingletonType<AsemanQuickView>(uri, 1, 0, "View", aseman_qview_singleton);
84 }
85