Porting kcmkwin to Qt5/KF5: QStandardPaths

REVIEW: 111975
This commit is contained in:
Anselmo L. S. Melo 2013-08-03 17:34:58 -03:00
parent d97069590a
commit 00d507b7ff
7 changed files with 28 additions and 24 deletions

View file

@ -28,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QtGui/QPainter>
#include <QStyle>
#include <QtGui/QTextDocument>
#include <QStandardPaths>
// KDE
#include <KConfigGroup>
#include <KDesktopFile>
@ -35,7 +36,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KIcon>
#include <KDE/KLocalizedString>
#include <KServiceTypeTrader>
#include <KStandardDirs>
#include <KPluginInfo>
#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);

View file

@ -44,13 +44,13 @@
#include <QGraphicsObject>
#include <QScrollBar>
#include <QUiLoader>
#include <QtCore/QStandardPaths>
// KDE
#include <KAboutData>
#include <KDialog>
#include <KDE/KLocalizedString>
#include <KMessageBox>
#include <KNS3/DownloadDialog>
#include <KDE/KStandardDirs>
#include <KDE/KConfigDialogManager>
#include <KPluginFactory>
#include <Plasma/ConfigLoader>
@ -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, "<h1>Installation error</h1>"
@ -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);

View file

@ -23,7 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kdebug.h>
#include <klocale.h>
#include <kstandarddirs.h>
#include <qgraphicsitem.h>
#include <qgraphicsview.h>
#include <qgraphicsscene.h>

View file

@ -27,7 +27,6 @@
#include <KDE/KAboutData>
#include <KDE/KPluginFactory>
#include <KDE/KStandardDirs>
#include <KDE/KMessageBox>
#include <KDE/KFileDialog>
#include <KDE/KMessageWidget>

View file

@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QtDeclarative/QDeclarativeContext>
#include <QtDeclarative/QDeclarativeEngine>
#include <QGraphicsObject>
#include <QtCore/QStandardPaths>
#include <kdeclarative.h>
#include <KDE/KConfigGroup>
#include <KDE/KDesktopFile>
@ -32,7 +33,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KDE/KIconEffect>
#include <KDE/KIconLoader>
#include <KDE/KService>
#include <KDE/KStandardDirs>
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()

View file

@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QtDBus/QtDBus>
#include <QDesktopWidget>
#include <QVBoxLayout>
#include <QStandardPaths>
// KDE
#include <KAction>
@ -36,7 +37,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KTitleWidget>
#include <KServiceTypeTrader>
#include <KShortcutsEditor>
#include <KStandardDirs>
#include <KNS3/DownloadDialog>
// 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;
}

View file

@ -23,9 +23,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QtDeclarative/QDeclarativeContext>
#include <QtDeclarative/QDeclarativeEngine>
#include <QtDeclarative/QDeclarativeView>
#include <QtCore/QStandardPaths>
// KDE
#include <KDE/KDebug>
#include <KDE/KStandardDirs>
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