From 00d507b7ff8dfd440b10de2aa4d201fb6590f27c Mon Sep 17 00:00:00 2001 From: "Anselmo L. S. Melo" Date: Sat, 3 Aug 2013 17:34:58 -0300 Subject: [PATCH] Porting kcmkwin to Qt5/KF5: QStandardPaths REVIEW: 111975 --- kcmkwin/kwindecoration/decorationmodel.cpp | 18 +++++++++++------- kcmkwin/kwindecoration/kwindecoration.cpp | 10 +++++----- kcmkwin/kwinscreenedges/monitor.cpp | 1 - kcmkwin/kwinscripts/module.cpp | 1 - kcmkwin/kwintabbox/layoutpreview.cpp | 6 +++--- kcmkwin/kwintabbox/main.cpp | 6 ++++-- kcmkwin/kwintabbox/thumbnailitem.cpp | 10 +++++----- 7 files changed, 28 insertions(+), 24 deletions(-) diff --git a/kcmkwin/kwindecoration/decorationmodel.cpp b/kcmkwin/kwindecoration/decorationmodel.cpp index 822258fea4..301e7806b7 100644 --- a/kcmkwin/kwindecoration/decorationmodel.cpp +++ b/kcmkwin/kwindecoration/decorationmodel.cpp @@ -28,6 +28,7 @@ along with this program. If not, see . #include #include #include +#include // KDE #include #include @@ -35,7 +36,6 @@ along with this program. If not, see . #include #include #include -#include #include #include "kwindecoration.h" @@ -92,7 +92,7 @@ void DecorationModel::reload() void DecorationModel::findDecorations() { beginResetModel(); - const QStringList dirList = KGlobal::dirs()->findDirs("data", "kwin"); + const QStringList dirList = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "kwin", QStandardPaths::LocateDirectory); foreach (const QString & dir, dirList) { QDir d(dir); @@ -132,7 +132,7 @@ void DecorationModel::findDecorations() data.type = DecorationModelData::QmlDecoration; data.auroraeName = service->property("X-KDE-PluginInfo-Name").toString(); QString scriptName = service->property("X-Plasma-MainScript").toString(); - data.qmlPath = KStandardDirs::locate("data", "kwin/decorations/" + data.auroraeName + "/contents/" + scriptName); + data.qmlPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kwin/decorations/" + data.auroraeName + "/contents/" + scriptName); if (data.qmlPath.isEmpty()) { // not a valid QML theme continue; @@ -156,10 +156,14 @@ void DecorationModel::findDecorations() void DecorationModel::findAuroraeThemes() { - // get all desktop themes - QStringList themes = KGlobal::dirs()->findAllResources("data", - "aurorae/themes/*/metadata.desktop", - KStandardDirs::NoDuplicates); + // get all destop themes + QStringList themes; + const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "aurorae/themes", QStandardPaths::LocateDirectory); + Q_FOREACH (const QString & dir, dirs) { + Q_FOREACH (const QString & file, QDir(dir).entryList(QStringList() << QStringLiteral("metadata.desktop"))) { + themes.append(dir + '/' + file); + } + } foreach (const QString & theme, themes) { int themeSepIndex = theme.lastIndexOf('/', -1); QString themeRoot = theme.left(themeSepIndex); diff --git a/kcmkwin/kwindecoration/kwindecoration.cpp b/kcmkwin/kwindecoration/kwindecoration.cpp index f402d0ae7b..79d456b7ae 100644 --- a/kcmkwin/kwindecoration/kwindecoration.cpp +++ b/kcmkwin/kwindecoration/kwindecoration.cpp @@ -44,13 +44,13 @@ #include #include #include +#include // KDE #include #include #include #include #include -#include #include #include #include @@ -117,7 +117,7 @@ void KWinDecorationModule::init() // init already called return; } - const QString mainQmlPath = KStandardDirs::locate("data", "kwin/kcm_kwindecoration/main.qml"); + const QString mainQmlPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kwin/kcm_kwindecoration/main.qml"); if (mainQmlPath.isNull()) { // TODO 4.11 i18n this KMessageBox::error(this, "

Installation error

" @@ -147,7 +147,7 @@ void KWinDecorationModule::init() m_ui->decorationList->rootContext()->setContextProperty("options", m_decorationButtons); m_ui->decorationList->rootContext()->setContextProperty("highlightColor", m_ui->decorationList->palette().color(QPalette::Highlight)); m_ui->decorationList->rootContext()->setContextProperty("sliderWidth", m_ui->decorationList->verticalScrollBar()->width()); - m_ui->decorationList->rootContext()->setContextProperty("auroraeSource", KStandardDirs::locate("data", "kwin/aurorae/aurorae.qml")); + m_ui->decorationList->rootContext()->setContextProperty("auroraeSource", QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kwin/aurorae/aurorae.qml")); m_ui->decorationList->rootContext()->setContextProperty("decorationActiveCaptionColor", KDecoration::options()->color(ColorFont, true)); m_ui->decorationList->rootContext()->setContextProperty("decorationInactiveCaptionColor", KDecoration::options()->color(ColorFont, false)); m_ui->decorationList->rootContext()->setContextProperty("decorationActiveTitleBarColor", KDecoration::options()->color(ColorTitleBar, true)); @@ -396,8 +396,8 @@ void KWinDecorationModule::slotConfigureDecoration() KConfigDialogManager *configManager = NULL; if (index.data(DecorationModel::TypeRole).toInt() == DecorationModelData::QmlDecoration) { const QString packageName = index.data(DecorationModel::AuroraeNameRole).toString(); - const QString uiPath = KStandardDirs::locate("data", "kwin/decorations/" + packageName + "/contents/ui/config.ui"); - const QString configPath = KStandardDirs::locate("data", "kwin/decorations/" + packageName + "/contents/config/main.xml"); + const QString uiPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kwin/decorations/" + packageName + "/contents/ui/config.ui"); + const QString configPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kwin/decorations/" + packageName + "/contents/config/main.xml"); if (!uiPath.isEmpty() && !configPath.isEmpty()) { // load the KConfigSkeleton QFile configFile(configPath); diff --git a/kcmkwin/kwinscreenedges/monitor.cpp b/kcmkwin/kwinscreenedges/monitor.cpp index e28c414b89..72fcfa69a7 100644 --- a/kcmkwin/kwinscreenedges/monitor.cpp +++ b/kcmkwin/kwinscreenedges/monitor.cpp @@ -23,7 +23,6 @@ along with this program. If not, see . #include #include -#include #include #include #include diff --git a/kcmkwin/kwinscripts/module.cpp b/kcmkwin/kwinscripts/module.cpp index b505c2e547..34c42b255c 100644 --- a/kcmkwin/kwinscripts/module.cpp +++ b/kcmkwin/kwinscripts/module.cpp @@ -27,7 +27,6 @@ #include #include -#include #include #include #include diff --git a/kcmkwin/kwintabbox/layoutpreview.cpp b/kcmkwin/kwintabbox/layoutpreview.cpp index 9f01f95e01..b2a63ac45c 100644 --- a/kcmkwin/kwintabbox/layoutpreview.cpp +++ b/kcmkwin/kwintabbox/layoutpreview.cpp @@ -24,6 +24,7 @@ along with this program. If not, see . #include #include #include +#include #include #include #include @@ -32,7 +33,6 @@ along with this program. If not, see . #include #include #include -#include namespace KWin { @@ -51,7 +51,7 @@ LayoutPreview::LayoutPreview(QWidget* parent) foreach (const QString &importPath, KGlobal::dirs()->findDirs("module", "imports")) { engine()->addImportPath(importPath); } - foreach (const QString &importPath, KGlobal::dirs()->findDirs("data", "kwin/tabbox")) { + foreach (const QString &importPath, QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "kwin/tabbox", QStandardPaths::LocateDirectoty)) { engine()->addImportPath(importPath); } ExampleClientModel *model = new ExampleClientModel(this); @@ -64,7 +64,7 @@ LayoutPreview::LayoutPreview(QWidget* parent) rootContext()->setContextProperty("clientModel", model); rootContext()->setContextProperty("sourcePath", QString()); rootContext()->setContextProperty("name", QString()); - setSource(KStandardDirs::locate("data", "kwin/kcm_kwintabbox/main.qml")); + setSource(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kwin/kcm_kwintabbox/main.qml")); } LayoutPreview::~LayoutPreview() diff --git a/kcmkwin/kwintabbox/main.cpp b/kcmkwin/kwintabbox/main.cpp index d5ce83d108..af3f1539bb 100644 --- a/kcmkwin/kwintabbox/main.cpp +++ b/kcmkwin/kwintabbox/main.cpp @@ -23,6 +23,7 @@ along with this program. If not, see . #include #include #include +#include // KDE #include @@ -36,7 +37,6 @@ along with this program. If not, see . #include #include #include -#include #include // own @@ -182,7 +182,9 @@ void KWinTabBoxConfig::initLayoutLists() continue; } const QString scriptName = service->property("X-Plasma-MainScript").toString(); - const QString scriptFile = KStandardDirs::locate("data", "kwin/tabbox/" + pluginName + "/contents/" + scriptName); + const QString scriptFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, + "kwin/tabbox/" + pluginName + "/contents/" + + scriptName); if (scriptFile.isNull()) { continue; } diff --git a/kcmkwin/kwintabbox/thumbnailitem.cpp b/kcmkwin/kwintabbox/thumbnailitem.cpp index 9dc5426866..6b4f2599f2 100644 --- a/kcmkwin/kwintabbox/thumbnailitem.cpp +++ b/kcmkwin/kwintabbox/thumbnailitem.cpp @@ -23,9 +23,9 @@ along with this program. If not, see . #include #include #include +#include // KDE #include -#include namespace KWin { @@ -53,16 +53,16 @@ void WindowThumbnailItem::findImage() QString imagePath; switch (m_wId) { case Konqueror: - imagePath = KStandardDirs::locate("data", "kwin/kcm_kwintabbox/konqueror.png"); + imagePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kwin/kcm_kwintabbox/konqueror.png"); break; case Systemsettings: - imagePath = KStandardDirs::locate("data", "kwin/kcm_kwintabbox/systemsettings.png"); + imagePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kwin/kcm_kwintabbox/systemsettings.png"); break; case KMail: - imagePath = KStandardDirs::locate("data", "kwin/kcm_kwintabbox/kmail.png"); + imagePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kwin/kcm_kwintabbox/kmail.png"); break; case Dolphin: - imagePath = KStandardDirs::locate("data", "kwin/kcm_kwintabbox/dolphin.png"); + imagePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kwin/kcm_kwintabbox/dolphin.png"); break; default: // ignore