~ci-train-bot/ubuntu-system-settings/ubuntu-system-settings-ubuntu-zesty-2066

« back to all changes in this revision

Viewing changes to src/plugin-manager.cpp

  • Committer: Bileto Bot
  • Author(s): Jonas G. Drange
  • Date: 2016-09-30 13:48:06 UTC
  • mfrom: (1720.3.7 path-fixes)
  • Revision ID: ci-train-bot@canonical.com-20160930134806-tir714ireb8xzaau
uses XDG_DATA_DIRS where applicable to enable USS to find files and folders on snappy-based systems (LP: #1629009)

Approved by: Alberto Mardegan, Ken VanDine, Lukáš Tinkl, system-apps-ci-bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include <QProcessEnvironment>
29
29
#include <QQmlContext>
30
30
#include <QQmlEngine>
 
31
#include <QStandardPaths>
31
32
#include <QStringList>
32
33
 
33
34
using namespace SystemSettings;
34
35
 
35
 
static const QLatin1String baseDir{PLUGIN_MANIFEST_DIR};
 
36
static const QLatin1String baseDir{MANIFEST_DIR};
36
37
 
37
38
namespace SystemSettings {
38
39
 
80
81
{
81
82
    Q_Q(PluginManager);
82
83
    clear();
83
 
    QDir path(baseDir, "*.settings");
 
84
 
 
85
    /* Create a list of search paths (e.g. /usr/share, /usr/local/share) and
 
86
     * append the baseDir. The reason for not using locateAll is that locateAll
 
87
     * does not seem to work with a dir and file pattern, which means it will
 
88
     * look for all .settings files, not just those in well-known locations. */
 
89
    QStandardPaths::StandardLocation loc = QStandardPaths::GenericDataLocation;
 
90
    QFileInfoList searchPaths;
 
91
    Q_FOREACH(const QString &path, QStandardPaths::standardLocations(loc)) {
 
92
        QDir dir(QStringLiteral("%1/%2").arg(path, baseDir), "*.settings");
 
93
        searchPaths.append(dir.entryInfoList());
 
94
    }
84
95
 
85
96
    /* Use an environment variable USS_SHOW_ALL_UI to show unfinished / beta /
86
97
     * deferred components or panels */
95
106
    if (ctx)
96
107
        ctx->engine()->rootContext()->setContextProperty("showAllUI", showAll);
97
108
 
98
 
    Q_FOREACH(QFileInfo fileInfo, path.entryInfoList()) {
 
109
    Q_FOREACH(const QFileInfo &fileInfo, searchPaths) {
99
110
        Plugin *plugin = new Plugin(fileInfo);
100
111
        QQmlEngine::setContextForObject(plugin, ctx);
101
112
        QMap<QString, Plugin*> &pluginList = m_plugins[plugin->category()];