Porting clients to Qt5/KF5: QStandardPaths

REVIEW: 111972
icc-effect-5.14.5
Anselmo L. S. Melo 2013-08-03 17:29:13 -03:00
parent c9b079e628
commit c2942c4e73
3 changed files with 12 additions and 13 deletions

View File

@ -44,11 +44,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "workspace.h" #include "workspace.h"
// KDE // KDE
#include <KDE/KIconLoader> #include <KDE/KIconLoader>
#include <KDE/KStandardDirs>
#include <KDE/KWindowSystem> #include <KDE/KWindowSystem>
// Qt // Qt
#include <QApplication> #include <QApplication>
#include <QProcess> #include <QProcess>
#include <QStandardPaths>
#ifdef KWIN_BUILD_SCRIPTING #ifdef KWIN_BUILD_SCRIPTING
#include <QScriptEngine> #include <QScriptEngine>
#include <QScriptProgram> #include <QScriptProgram>
@ -1362,7 +1362,7 @@ void Client::killProcess(bool ask, xcb_timestamp_t timestamp)
::kill(pid, SIGTERM); ::kill(pid, SIGTERM);
} else { } else {
QString hostname = clientMachine()->isLocal() ? QStringLiteral("localhost") : QString::fromUtf8(clientMachine()->hostName()); QString hostname = clientMachine()->isLocal() ? QStringLiteral("localhost") : QString::fromUtf8(clientMachine()->hostName());
QProcess::startDetached(KStandardDirs::findExe(QStringLiteral("kwin_killer_helper")), QProcess::startDetached(QStandardPaths::findExecutable(QStringLiteral("kwin_killer_helper")),
QStringList() << QStringLiteral("--pid") << QString::number(unsigned(pid)) << QStringLiteral("--hostname") << hostname QStringList() << QStringLiteral("--pid") << QString::number(unsigned(pid)) << QStringLiteral("--hostname") << hostname
<< QStringLiteral("--windowname") << caption() << QStringLiteral("--windowname") << caption()
<< QStringLiteral("--applicationname") << QString::fromUtf8(resourceClass()) << QStringLiteral("--applicationname") << QString::fromUtf8(resourceClass())
@ -1742,7 +1742,7 @@ void Client::setCaption(const QString& _s, bool force)
static QScriptProgram stripTitle; static QScriptProgram stripTitle;
static QScriptValue script; static QScriptValue script;
if (stripTitle.isNull()) { if (stripTitle.isNull()) {
const QString scriptFile = KStandardDirs::locate("data", QStringLiteral(KWIN_NAME) + QStringLiteral("/stripTitle.js")); const QString scriptFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral(KWIN_NAME) + QStringLiteral("/stripTitle.js"));
if (!scriptFile.isEmpty()) { if (!scriptFile.isEmpty()) {
QFile f(scriptFile); QFile f(scriptFile);
if (f.open(QIODevice::ReadOnly|QIODevice::Text)) { if (f.open(QIODevice::ReadOnly|QIODevice::Text)) {

View File

@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QtDeclarative/QDeclarativeItem> #include <QtDeclarative/QDeclarativeItem>
#include <QGraphicsView> #include <QGraphicsView>
#include <QPaintEngine> #include <QPaintEngine>
#include <QStandardPaths>
#include <KConfig> #include <KConfig>
#include <KConfigGroup> #include <KConfigGroup>
@ -33,7 +34,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KGlobal> #include <KGlobal>
#include <KPluginInfo> #include <KPluginInfo>
#include <KServiceTypeTrader> #include <KServiceTypeTrader>
#include <KStandardDirs>
#include <Plasma/FrameSvg> #include <Plasma/FrameSvg>
namespace Aurorae namespace Aurorae
@ -92,12 +92,12 @@ void AuroraeFactory::initAurorae(KConfig &conf, KConfigGroup &group)
/* use logic from KDeclarative::setupBindings(): /* use logic from KDeclarative::setupBindings():
"addImportPath adds the path at the beginning, so to honour user's "addImportPath adds the path at the beginning, so to honour user's
paths we need to traverse the list in reverse order" */ paths we need to traverse the list in reverse order" */
QStringListIterator paths(KGlobal::dirs()->findDirs("module", QStringLiteral("imports"))); QStringListIterator paths(QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("module/imports"), QStandardPaths::LocateDirectory));
paths.toBack(); paths.toBack();
while (paths.hasPrevious()) { while (paths.hasPrevious()) {
m_engine->addImportPath(paths.previous()); m_engine->addImportPath(paths.previous());
} }
m_component->loadUrl(QUrl(KStandardDirs::locate("data", QStringLiteral("kwin/aurorae/aurorae.qml")))); m_component->loadUrl(QUrl(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kwin/aurorae/aurorae.qml"))));
m_engine->rootContext()->setContextProperty(QStringLiteral("auroraeTheme"), m_theme); m_engine->rootContext()->setContextProperty(QStringLiteral("auroraeTheme"), m_theme);
m_themeName = themeName; m_themeName = themeName;
} }
@ -120,7 +120,7 @@ void AuroraeFactory::initQML(const KConfigGroup &group)
KPluginInfo plugininfo(service); KPluginInfo plugininfo(service);
const QString pluginName = service->property(QStringLiteral("X-KDE-PluginInfo-Name")).toString(); const QString pluginName = service->property(QStringLiteral("X-KDE-PluginInfo-Name")).toString();
const QString scriptName = service->property(QStringLiteral("X-Plasma-MainScript")).toString(); const QString scriptName = service->property(QStringLiteral("X-Plasma-MainScript")).toString();
const QString file = KStandardDirs::locate("data", QStringLiteral(KWIN_NAME) + QStringLiteral("/decorations/") + pluginName + QStringLiteral("/contents/") + scriptName); const QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral(KWIN_NAME) + QStringLiteral("/decorations/") + pluginName + QStringLiteral("/contents/") + scriptName);
if (file.isNull()) { if (file.isNull()) {
kDebug(1212) << "Could not find script file for " << pluginName; kDebug(1212) << "Could not find script file for " << pluginName;
// TODO: what to do in error case? // TODO: what to do in error case?
@ -131,7 +131,7 @@ void AuroraeFactory::initQML(const KConfigGroup &group)
/* use logic from KDeclarative::setupBindings(): /* use logic from KDeclarative::setupBindings():
"addImportPath adds the path at the beginning, so to honour user's "addImportPath adds the path at the beginning, so to honour user's
paths we need to traverse the list in reverse order" */ paths we need to traverse the list in reverse order" */
QStringListIterator paths(KGlobal::dirs()->findDirs("module", QStringLiteral("imports"))); QStringListIterator paths(QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("module/imports"), QStandardPaths::LocateDirectory));
paths.toBack(); paths.toBack();
while (paths.hasPrevious()) { while (paths.hasPrevious()) {
m_engine->addImportPath(paths.previous()); m_engine->addImportPath(paths.previous());

View File

@ -27,7 +27,6 @@
#include <KDE/KConfig> #include <KDE/KConfig>
#include <KDE/KConfigGroup> #include <KDE/KConfigGroup>
#include <KDE/KDebug> #include <KDE/KDebug>
#include <KDE/KStandardDirs>
#include <KDE/KGlobal> #include <KDE/KGlobal>
namespace Aurorae { namespace Aurorae {
@ -65,11 +64,11 @@ AuroraeThemePrivate::~AuroraeThemePrivate()
void AuroraeThemePrivate::initButtonFrame(AuroraeButtonType type) void AuroraeThemePrivate::initButtonFrame(AuroraeButtonType type)
{ {
QString file(QStringLiteral("aurorae/themes/") + themeName + QStringLiteral("/") + AuroraeTheme::mapButtonToName(type) + QStringLiteral(".svg")); QString file(QStringLiteral("aurorae/themes/") + themeName + QStringLiteral("/") + AuroraeTheme::mapButtonToName(type) + QStringLiteral(".svg"));
QString path = KGlobal::dirs()->findResource("data", file); QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, file);
if (path.isEmpty()) { if (path.isEmpty()) {
// let's look for svgz // let's look for svgz
file.append(QStringLiteral("z")); file.append(QStringLiteral("z"));
path = KGlobal::dirs()->findResource("data", file); path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, file);
} }
if (!path.isEmpty()) { if (!path.isEmpty()) {
pathes[ type ] = path; pathes[ type ] = path;
@ -113,10 +112,10 @@ void AuroraeTheme::loadTheme(const QString &name, const KConfig &config)
{ {
d->themeName = name; d->themeName = name;
QString file(QStringLiteral("aurorae/themes/") + d->themeName + QStringLiteral("/decoration.svg")); QString file(QStringLiteral("aurorae/themes/") + d->themeName + QStringLiteral("/decoration.svg"));
QString path = KGlobal::dirs()->findResource("data", file); QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, file);
if (path.isEmpty()) { if (path.isEmpty()) {
file += QStringLiteral("z"); file += QStringLiteral("z");
path = KGlobal::dirs()->findResource("data", file); path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, file);
} }
if (path.isEmpty()) { if (path.isEmpty()) {
kDebug(1216) << "Could not find decoration svg: aborting"; kDebug(1216) << "Could not find decoration svg: aborting";