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

« back to all changes in this revision

Viewing changes to plugins/background/background.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:
53
53
        return filename;
54
54
}
55
55
 
56
 
void Background::setBackgroundFile(QUrl backgroundFile)
 
56
void Background::setBackgroundFile(const QUrl &backgroundFile)
57
57
{
58
58
    if (!backgroundFile.isLocalFile())
59
59
        return;
72
72
    // delete our copy.  We don't need it anymore.
73
73
    if (oldBackgroundFile.contains(getCopiedSystemBackgroundFolder().path())) {
74
74
        QString fileName = QUrl(oldBackgroundFile).fileName();
75
 
        if (QFile::exists(SYSTEM_BACKGROUND_DIR "/" + fileName)) {
 
75
        if (QFile::exists(qgetenv("SNAP") + SYSTEM_BACKGROUND_DIR "/" + fileName)) {
76
76
            rmFile(oldBackgroundFile);
77
77
        }
78
78
    }
116
116
        // with it.
117
117
        // So scan the copied backgrounds.
118
118
        QFileInfoList copyList = getCopiedSystemBackgroundFolder().entryInfoList(QDir::Files | QDir::NoSymLinks);
119
 
        QDir systemDir = QDir(SYSTEM_BACKGROUND_DIR);
 
119
        QDir systemDir = QDir(qgetenv("SNAP") + SYSTEM_BACKGROUND_DIR);
120
120
        foreach (QFileInfo f, copyList) {
121
121
            if (!systemDir.exists(f.fileName()))
122
122
                tmpList << f;
213
213
        dir = QDir(envDir);
214
214
        copiedBackgroundDir = dir;
215
215
    } else {
216
 
        dir = QDir(SYSTEM_BACKGROUND_DIR);
 
216
        dir = QDir(qgetenv("SNAP") + SYSTEM_BACKGROUND_DIR);
217
217
        copiedBackgroundDir = getCopiedSystemBackgroundFolder();
218
218
    }
219
219
 
229
229
        // Prefer copied versions.
230
230
        if (copiedBackgroundDir.exists(f.fileName()))
231
231
            absPath = copiedBackgroundDir.absoluteFilePath(f.fileName());
232
 
        
 
232
 
233
233
        m_ubuntuArt.append(QUrl::fromLocalFile(absPath).toString());
234
234
    }
235
235
 
271
271
QString Background::defaultBackgroundFile() const
272
272
{
273
273
    /* TODO: For now hardcoded path, later we'll use GSettings */
274
 
    return SYSTEM_BACKGROUND_DIR "/warty-final-ubuntu.png";
 
274
    return qgetenv("SNAP") + SYSTEM_BACKGROUND_DIR "/warty-final-ubuntu.png";
275
275
}
276
276
 
277
277
Background::~Background() {