on xenial help sign in
ApplicationPaths singleton
95deeb9Nick Dedekind
Panel/IndicatorsDataModel.qml+10−12
@@ -26,43 +26,41 @@ Indicators.IndicatorsModel {
26
26
27 Component.onCompleted: load()
27 Component.onCompleted: load()
28
28
29− property var applicationPaths: ApplicationPaths {}
30−
31 indicatorData : {
29 indicatorData : {
32 'indicator-messaging' : {
30 'indicator-messaging' : {
33 'title': 'Messaging',
31 'title': 'Messaging',
34 'description' : '',
32 'description' : '',
35 'priority': 10,
33 'priority': 10,
36− 'widgetSource' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/MessagingIndicatorWidget.qml',
34+ 'widgetSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/MessagingIndicatorWidget.qml',
37− 'pageSource' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/MessagingIndicatorPage.qml'
35+ 'pageSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/MessagingIndicatorPage.qml'
38 },
36 },
39 'indicator-sound' : {
37 'indicator-sound' : {
40 'title': 'Sound',
38 'title': 'Sound',
41 'description' : '',
39 'description' : '',
42 'priority': 20,
40 'priority': 20,
43− 'widgetSource' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/SoundIndicatorWidget.qml',
41+ 'widgetSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/SoundIndicatorWidget.qml',
44− 'pageSource' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/DefaultIndicatorPage.qml'
42+ 'pageSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/DefaultIndicatorPage.qml'
45 },
43 },
46 'indicator-network' : {
44 'indicator-network' : {
47 'title': 'Networks',
45 'title': 'Networks',
48 'description' : '',
46 'description' : '',
49 'priority': 30,
47 'priority': 30,
50− 'widgetSource' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/NetworkIndicatorWidget.qml',
48+ 'widgetSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/NetworkIndicatorWidget.qml',
51− 'pageSource' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/NetworkIndicatorPage.qml'
49+ 'pageSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/NetworkIndicatorPage.qml'
52 },
50 },
53 'indicator-power' : {
51 'indicator-power' : {
54 'title': 'Battery',
52 'title': 'Battery',
55 'description' : '',
53 'description' : '',
56 'priority': 40,
54 'priority': 40,
57− 'widgetSource' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/DefaultIndicatorWidget.qml',
55+ 'widgetSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/DefaultIndicatorWidget.qml',
58− 'pageSource' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/DefaultIndicatorPage.qml'
56+ 'pageSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/DefaultIndicatorPage.qml'
59 },
57 },
60 'indicator-datetime' : {
58 'indicator-datetime' : {
61 'title': 'Date and Time',
59 'title': 'Date and Time',
62 'description' : '',
60 'description' : '',
63 'priority': 100,
61 'priority': 100,
64− 'widgetSource' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/DatetimeIndicatorWidget.qml',
62+ 'widgetSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/DatetimeIndicatorWidget.qml',
65− 'pageSource' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/DatetimeIndicatorPage.qml'
63+ 'pageSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/DatetimeIndicatorPage.qml'
66 }
64 }
67 }
65 }
68}
66}
plugins/Utils/applicationpaths.h−2
@@ -27,8 +27,6 @@ class ApplicationPaths : public QObject
27{
27{
28 Q_OBJECT
28 Q_OBJECT
29public:
29public:
30− ApplicationPaths(QObject*parent=0):QObject(parent) {}
31−
32 Q_INVOKABLE bool isRunningInstalled() const { return ::isRunningInstalled(); }
30 Q_INVOKABLE bool isRunningInstalled() const { return ::isRunningInstalled(); }
33 Q_INVOKABLE QString shellAppDirectory() const { return ::shellAppDirectory(); }
31 Q_INVOKABLE QString shellAppDirectory() const { return ::shellAppDirectory(); }
34 Q_INVOKABLE QStringList shellImportPaths() const { return ::shellImportPaths(); }
32 Q_INVOKABLE QStringList shellImportPaths() const { return ::shellImportPaths(); }
plugins/Utils/plugin.cpp+7−1
@@ -29,6 +29,12 @@
29#include "qsortfilterproxymodelqml.h"
29#include "qsortfilterproxymodelqml.h"
30#include "ubuntuwindow.h"
30#include "ubuntuwindow.h"
31
31
32+static QObject* applicationsPathsSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
33+ Q_UNUSED(engine);
34+ Q_UNUSED(scriptEngine);
35+ return new ApplicationPaths;
36+}
37+
32void UtilsPlugin::registerTypes(const char *uri)
38void UtilsPlugin::registerTypes(const char *uri)
33{
39{
34 Q_ASSERT(uri == QLatin1String("Utils"));
40 Q_ASSERT(uri == QLatin1String("Utils"));
@@ -36,5 +42,5 @@ void UtilsPlugin::registerTypes(const char *uri)
36 qmlRegisterType<QLimitProxyModelQML>(uri, 0, 1, "LimitProxyModel");
42 qmlRegisterType<QLimitProxyModelQML>(uri, 0, 1, "LimitProxyModel");
37 qmlRegisterType<QSortFilterProxyModelQML>(uri, 0, 1, "SortFilterProxyModel");
43 qmlRegisterType<QSortFilterProxyModelQML>(uri, 0, 1, "SortFilterProxyModel");
38 qmlRegisterExtendedType<QQuickWindow, UbuntuWindow>(uri, 0, 1, "Window");
44 qmlRegisterExtendedType<QQuickWindow, UbuntuWindow>(uri, 0, 1, "Window");
39− qmlRegisterType<ApplicationPaths>(uri, 0, 1, "ApplicationPaths");
45+ qmlRegisterSingletonType<ApplicationPaths>(uri, 0, 1, "ApplicationPaths", applicationsPathsSingleton);
40}
46}