diff --git a/src/engine/gameplay.cpp b/src/engine/gameplay.cpp --- a/src/engine/gameplay.cpp +++ b/src/engine/gameplay.cpp @@ -41,13 +41,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include // Use this because comma in type is not possible in foreach macro. typedef QPair DoubleIntPair; @@ -508,7 +508,7 @@ // Discard the *.save file. static const QString pathTemplate = QString::fromLatin1("collection/%1.save"); - QFile(KStandardDirs::locateLocal("appdata", + QFile(QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, pathTemplate.arg(m_puzzle->identifier()))).remove(); // Load the puzzle and re-shuffle the pieces. loadPuzzle(); @@ -726,7 +726,7 @@ // Is there a saved game? static const QString pathTemplate = QString::fromLatin1("collection/%1.save"); - KConfig savedConfig(KStandardDirs::locateLocal("appdata", + KConfig savedConfig(QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, pathTemplate.arg(m_puzzle->identifier()))); if (savedConfig.hasGroup(AppearanceSaveGroup)) { // Get settings for background, shadows, etc. in this puzzle. @@ -827,7 +827,7 @@ // Is there a saved game? static const QString pathTemplate = QString::fromLatin1("collection/%1.save"); - KConfig savedConfig(KStandardDirs::locateLocal("appdata", + KConfig savedConfig(QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, pathTemplate.arg(m_puzzle->identifier()))); bool oldFormat = false; m_restoredGame = false; @@ -1192,7 +1192,7 @@ { static const QString pathTemplate = QString::fromLatin1("collection/%1.save"); - KConfig savedConfig(KStandardDirs::locateLocal("appdata", + KConfig savedConfig(QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, pathTemplate.arg(m_puzzle->identifier()))); savePuzzleSettings(&savedConfig); diff --git a/src/engine/texturehelper.h b/src/engine/texturehelper.h --- a/src/engine/texturehelper.h +++ b/src/engine/texturehelper.h @@ -42,7 +42,7 @@ void removeScene(QObject* object); private: TextureHelper(); - static QPixmap render(const QString& fileName); + static QPixmap render(const QString& filePath); QList m_scenes; int m_currentIndex; diff --git a/src/engine/texturehelper.cpp b/src/engine/texturehelper.cpp --- a/src/engine/texturehelper.cpp +++ b/src/engine/texturehelper.cpp @@ -19,12 +19,11 @@ #include "texturehelper.h" #include "settings.h" +#include #include #include #include -#include #include -#include #include const QSize Palapeli::TextureHelper::DefaultThumbnailSize(32, 32); @@ -36,21 +35,20 @@ return &instance; } -QPixmap Palapeli::TextureHelper::render(const QString& fileName) +QPixmap Palapeli::TextureHelper::render(const QString& filePath) { - const QString path = KStandardDirs::locate("appdata", "backgrounds/" + fileName); QPixmap pixmap; - if (fileName.contains(".svg")) + if (filePath.endsWith(QLatin1String(".svg"))) { - QSvgRenderer renderer(path); + QSvgRenderer renderer(filePath); pixmap = QPixmap(DefaultPixmapSize); pixmap.fill(Qt::transparent); QPainter painter(&pixmap); renderer.render(&painter); painter.end(); } else - pixmap.load(path); + pixmap.load(filePath); return pixmap; } @@ -66,19 +64,24 @@ colorItem->setData(i18nc("@item:inlistbox", "Single color"), Qt::DisplayRole); appendRow(colorItem); //fetch backgrounds, and create menu items - const QStringList backgroundFiles = KGlobal::dirs()->findAllResources("appdata", "backgrounds/*"); - foreach (const QString& path, backgroundFiles) + const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::AppLocalDataLocation, + "backgrounds", + QStandardPaths::LocateDirectory); + foreach (const QString& dir, dirs) { - //get file name and find selected or default backgrounds - const QString fileName = QFileInfo(path).fileName(); - //create item for this brush - const QPixmap pixmap = render(fileName); - QStandardItem* item = new QStandardItem; - item->setData(pixmap, BrushRole); - item->setData(fileName, IdentifierRole); - item->setData(pixmap.scaled(DefaultThumbnailSize, Qt::KeepAspectRatio), Qt::DecorationRole); - item->setData(fileName, Qt::DisplayRole); - appendRow(item); + const QStringList fileNames = QDir(dir).entryList(QStringList() << QStringLiteral("*"), QDir::Files); + Q_FOREACH (const QString& fileName, fileNames) + { + const QString filePath = dir + QLatin1Char('/') + fileName; + //create item for this brush + const QPixmap pixmap = render(filePath); + QStandardItem* item = new QStandardItem; + item->setData(pixmap, BrushRole); + item->setData(fileName, IdentifierRole); + item->setData(pixmap.scaled(DefaultThumbnailSize, Qt::KeepAspectRatio), Qt::DecorationRole); + item->setData(fileName, Qt::DisplayRole); + appendRow(item); + } } //select initial brush readSettings(); diff --git a/src/file-io/collection.cpp b/src/file-io/collection.cpp --- a/src/file-io/collection.cpp +++ b/src/file-io/collection.cpp @@ -25,10 +25,10 @@ #include #include #include +#include #include #include #include -#include //BEGIN Palapeli::Collection::Item @@ -82,9 +82,9 @@ QString path(path_); path.remove(QRegExp("^palapeli:/*")); if (local) - return KStandardDirs::locateLocal("appdata", path); + return QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, path); else - return KStandardDirs::locate("appdata", path); + return QStandardPaths::locate(QStandardPaths::AppDataLocation, path); } else return path_; @@ -150,7 +150,7 @@ //determine new location const QString id = puzzle->identifier(); const QString fileName = QString::fromLatin1("collection/%1.puzzle").arg(id); - puzzle->setLocation(KStandardDirs::locateLocal("appdata", fileName)); + puzzle->setLocation(QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, fileName)); //store puzzle puzzle->get(Palapeli::PuzzleComponent::ArchiveStorage).waitForFinished(); //create the config group for this puzzle (use pseudo-URL to avoid problems