Porting clients to Qt5/KF5: QStandardPaths

REVIEW: 111972
This commit is contained in:
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"
// KDE
#include <KDE/KIconLoader>
#include <KDE/KStandardDirs>
#include <KDE/KWindowSystem>
// Qt
#include <QApplication>
#include <QProcess>
#include <QStandardPaths>
#ifdef KWIN_BUILD_SCRIPTING
#include <QScriptEngine>
#include <QScriptProgram>
@ -1362,7 +1362,7 @@ void Client::killProcess(bool ask, xcb_timestamp_t timestamp)
::kill(pid, SIGTERM);
} else {
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
<< QStringLiteral("--windowname") << caption()
<< QStringLiteral("--applicationname") << QString::fromUtf8(resourceClass())
@ -1742,7 +1742,7 @@ void Client::setCaption(const QString& _s, bool force)
static QScriptProgram stripTitle;
static QScriptValue script;
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()) {
QFile f(scriptFile);
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 <QGraphicsView>
#include <QPaintEngine>
#include <QStandardPaths>
#include <KConfig>
#include <KConfigGroup>
@ -33,7 +34,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KGlobal>
#include <KPluginInfo>
#include <KServiceTypeTrader>
#include <KStandardDirs>
#include <Plasma/FrameSvg>
namespace Aurorae
@ -92,12 +92,12 @@ void AuroraeFactory::initAurorae(KConfig &conf, KConfigGroup &group)
/* use logic from KDeclarative::setupBindings():
"addImportPath adds the path at the beginning, so to honour user's
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();
while (paths.hasPrevious()) {
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_themeName = themeName;
}
@ -120,7 +120,7 @@ void AuroraeFactory::initQML(const KConfigGroup &group)
KPluginInfo plugininfo(service);
const QString pluginName = service->property(QStringLiteral("X-KDE-PluginInfo-Name")).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()) {
kDebug(1212) << "Could not find script file for " << pluginName;
// TODO: what to do in error case?
@ -131,7 +131,7 @@ void AuroraeFactory::initQML(const KConfigGroup &group)
/* use logic from KDeclarative::setupBindings():
"addImportPath adds the path at the beginning, so to honour user's
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();
while (paths.hasPrevious()) {
m_engine->addImportPath(paths.previous());

View file

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