on xenial help sign in
Added fallback imports to indicators_client
commite6de78926248c408f8bf52b088c23411568113a2 authorNick Dedekind <nicholas.dedekind@gmail.com> dateFri 5 Jul 2013, 17:29 (13 years ago) parent85d3623
1 file changed+17
src/Panel/Indicators/client/indicatorsclient.cpp+17
src/Panel/Indicators/client/indicatorsclient.cpp+17
@@ -35,6 +35,22 @@ void prependImportPaths(QQmlEngine *engine, const QStringList &paths)
3535 engine->setImportPathList(importPathList);
3636}
3737
38+/* When you append and import path to the list of import paths it will be the *last*
39+ place where Qt will search for QML modules.
40+ The usual QQmlEngine::addImportPath() actually prepends the given path.*/
41+void appendImportPaths(QQmlEngine *engine, const QStringList &paths)
42+{
43+ QStringList importPathList = engine->importPathList();
44+ Q_FOREACH(const QString& path, paths) {
45+ // don't duplicate
46+ QStringList::iterator iter = qFind(importPathList.begin(), importPathList.end(), path);
47+ if (iter == importPathList.end()) {
48+ importPathList.append(path);
49+ }
50+ }
51+ engine->setImportPathList(importPathList);
52+}
53+
3854IndicatorsClient::IndicatorsClient(int &argc, char **argv)
3955 : QObject(0),
4056 m_view(0)
@@ -56,6 +72,7 @@ void IndicatorsClient::setupUI()
5672 m_view = new QQuickView;
5773 m_view->engine()->setBaseUrl(QUrl::fromLocalFile(::shellAppDirectory()+"Panel/Indicators/client/"));
5874 prependImportPaths(m_view->engine(), ::overrideImportPaths());
75+ appendImportPaths(m_view->engine(), ::fallbackImportPaths());
5976
6077 m_view->setSource(QUrl("IndicatorsClient.qml"));
6178 m_view->setResizeMode(QQuickView::SizeRootObjectToView);