on xenial help sign in
ApplicationPaths singleton
commit95deeb95c39a55db0aa5ed69687efb19fb775848 authorNick Dedekind <nicholas.dedekind@gmail.com> dateWed 3 Jul 2013, 16:15 (13 years ago) parentb8b4e78
3 files changed+17−15
Panel/IndicatorsDataModel.qml+10−12 plugins/Utils/applicationpaths.h−2 plugins/Utils/plugin.cpp+7−1
Panel/IndicatorsDataModel.qml+10−12
@@ -26,43 +26,41 @@ Indicators.IndicatorsModel {
2626
2727 Component.onCompleted: load()
2828
29− property var applicationPaths: ApplicationPaths {}
30−
3129 indicatorData : {
3230 'indicator-messaging' : {
3331 'title': 'Messaging',
3432 'description' : '',
3533 'priority': 10,
36− 'widgetSource' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/MessagingIndicatorWidget.qml',
37− 'pageSource' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/MessagingIndicatorPage.qml'
34+ 'widgetSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/MessagingIndicatorWidget.qml',
35+ 'pageSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/MessagingIndicatorPage.qml'
3836 },
3937 'indicator-sound' : {
4038 'title': 'Sound',
4139 'description' : '',
4240 'priority': 20,
43− 'widgetSource' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/SoundIndicatorWidget.qml',
44− 'pageSource' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/DefaultIndicatorPage.qml'
41+ 'widgetSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/SoundIndicatorWidget.qml',
42+ 'pageSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/DefaultIndicatorPage.qml'
4543 },
4644 'indicator-network' : {
4745 'title': 'Networks',
4846 'description' : '',
4947 'priority': 30,
50− 'widgetSource' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/NetworkIndicatorWidget.qml',
51− 'pageSource' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/NetworkIndicatorPage.qml'
48+ 'widgetSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/NetworkIndicatorWidget.qml',
49+ 'pageSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/NetworkIndicatorPage.qml'
5250 },
5351 'indicator-power' : {
5452 'title': 'Battery',
5553 'description' : '',
5654 'priority': 40,
57− 'widgetSource' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/DefaultIndicatorWidget.qml',
58− 'pageSource' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/DefaultIndicatorPage.qml'
55+ 'widgetSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/DefaultIndicatorWidget.qml',
56+ 'pageSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/DefaultIndicatorPage.qml'
5957 },
6058 'indicator-datetime' : {
6159 'title': 'Date and Time',
6260 'description' : '',
6361 'priority': 100,
64− 'widgetSource' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/DatetimeIndicatorWidget.qml',
65− 'pageSource' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/DatetimeIndicatorPage.qml'
62+ 'widgetSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/DatetimeIndicatorWidget.qml',
63+ 'pageSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/DatetimeIndicatorPage.qml'
6664 }
6765 }
6866}
plugins/Utils/applicationpaths.h−2
@@ -27,8 +27,6 @@ class ApplicationPaths : public QObject
2727{
2828 Q_OBJECT
2929public:
30− ApplicationPaths(QObject*parent=0):QObject(parent) {}
31−
3230 Q_INVOKABLE bool isRunningInstalled() const { return ::isRunningInstalled(); }
3331 Q_INVOKABLE QString shellAppDirectory() const { return ::shellAppDirectory(); }
3432 Q_INVOKABLE QStringList shellImportPaths() const { return ::shellImportPaths(); }
plugins/Utils/plugin.cpp+7−1
@@ -29,6 +29,12 @@
2929#include "qsortfilterproxymodelqml.h"
3030#include "ubuntuwindow.h"
3131
32+static QObject* applicationsPathsSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
33+ Q_UNUSED(engine);
34+ Q_UNUSED(scriptEngine);
35+ return new ApplicationPaths;
36+}
37+
3238void UtilsPlugin::registerTypes(const char *uri)
3339{
3440 Q_ASSERT(uri == QLatin1String("Utils"));
@@ -36,5 +42,5 @@ void UtilsPlugin::registerTypes(const char *uri)
3642 qmlRegisterType<QLimitProxyModelQML>(uri, 0, 1, "LimitProxyModel");
3743 qmlRegisterType<QSortFilterProxyModelQML>(uri, 0, 1, "SortFilterProxyModel");
3844 qmlRegisterExtendedType<QQuickWindow, UbuntuWindow>(uri, 0, 1, "Window");
39− qmlRegisterType<ApplicationPaths>(uri, 0, 1, "ApplicationPaths");
45+ qmlRegisterSingletonType<ApplicationPaths>(uri, 0, 1, "ApplicationPaths", applicationsPathsSingleton);
4046}