port from KStandardDirs to QStandardPaths

REVIEW: 120498
wilder-portage
Michal Humpula 12 years ago
parent cc85a5243c
commit 15d09f9161
  1. 3
      src/Application.cpp
  2. 13
      src/BookmarkHandler.cpp
  3. 24
      src/ColorSchemeManager.cpp
  4. 1
      src/History.cpp
  5. 13
      src/KeyboardTranslatorManager.cpp
  6. 4
      src/ManageProfilesDialog.cpp
  7. 16
      src/ProfileManager.cpp
  8. 4
      src/ProfileReader.cpp
  9. 5
      src/ProfileWriter.cpp
  10. 3
      src/Session.cpp
  11. 1
      src/SessionController.cpp

@ -30,7 +30,6 @@
#include <KActionCollection>
#include <KCmdLineArgs>
#include <KDebug>
#include <KStandardDirs>
// Konsole
#include "SessionManager.h"
@ -415,7 +414,7 @@ Profile::Ptr Application::processProfileChangeArgs(KCmdLineArgs* args, Profile::
// Note: KCmdLineArgs::count() return the number of arguments
// that aren't options.
if (args->count() == 0 && KStandardDirs::findExe(commandExec).isEmpty()) {
if (args->count() == 0 && QStandardPaths::findExecutable(commandExec).isEmpty()) {
// Example: konsole -e "man ls"
ShellCommand shellCommand(args->getOption("e"));
commandExec = shellCommand.command();

@ -26,12 +26,13 @@
// Qt
#include <QtCore/QFileInfo>
#include <QtCore/QStandardPaths>
#include <QtCore/QDir>
// KDE
#include <KShell>
#include <KBookmarkMenu>
#include <KBookmarkOwner>
#include <KStandardDirs>
#include <KLocalizedString>
// Konsole
@ -51,9 +52,13 @@ BookmarkHandler::BookmarkHandler(KActionCollection* collection,
{
setObjectName(QLatin1String("BookmarkHandler"));
_file = KStandardDirs::locate("data", "konsole/bookmarks.xml");
if (_file.isEmpty())
_file = KStandardDirs::locateLocal("data", "konsole/bookmarks.xml");
_file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/bookmarks.xml"));
if (_file.isEmpty()) {
_file = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/konsole");
QDir().mkpath(_file);
_file += QStringLiteral("/bookmarks.xml");
}
KBookmarkManager* manager = KBookmarkManager::managerForFile(_file, "konsole");

@ -26,9 +26,9 @@
#include <QtCore/QIODevice>
#include <QtCore/QFileInfo>
#include <QtCore/QFile>
#include <QtCore/QDir>
// KDE
#include <KStandardDirs>
#include <KGlobal>
#include <KConfig>
#include <KLocalizedString>
@ -268,16 +268,12 @@ bool ColorSchemeManager::loadKDE3ColorScheme(const QString& filePath)
QStringList ColorSchemeManager::listColorSchemes()
{
return KGlobal::dirs()->findAllResources("data",
"konsole/*.colorscheme",
KStandardDirs::NoDuplicates);
return QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/*.colorscheme"));
}
QStringList ColorSchemeManager::listKDE3ColorSchemes()
{
return KGlobal::dirs()->findAllResources("data",
"konsole/*.schema",
KStandardDirs::NoDuplicates);
return QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/*.schema"));
}
const ColorScheme ColorSchemeManager::_defaultColorScheme;
@ -297,7 +293,10 @@ void ColorSchemeManager::addColorScheme(ColorScheme* scheme)
_colorSchemes.insert(scheme->name(), scheme);
// save changes to disk
QString path = KGlobal::dirs()->saveLocation("data", "konsole/") + scheme->name() + ".colorscheme";
const QString dir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("konsole/");
QDir().mkpath(dir);
const QString path = dir + scheme->name() + QStringLiteral(".colorscheme");
KConfig config(path , KConfig::NoGlobals);
scheme->write(config);
@ -352,13 +351,12 @@ const ColorScheme* ColorSchemeManager::findColorScheme(const QString& name)
QString ColorSchemeManager::findColorSchemePath(const QString& name) const
{
QString path = KStandardDirs::locate("data", "konsole/" + name + ".colorscheme");
QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/") + name + QStringLiteral(".colorscheme"));
if (!path.isEmpty())
if (!path.isEmpty()) {
return path;
}
path = KStandardDirs::locate("data", "konsole/" + name + ".schema");
return path;
return QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/") + name + QStringLiteral(".schema"));
}

@ -32,7 +32,6 @@
// KDE
#include <kde_file.h>
#include <KDebug>
#include <KStandardDirs>
#include <QDir>

@ -25,11 +25,11 @@
// Qt
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QDir>
// KDE
#include <KDebug>
#include <KGlobal>
#include <KStandardDirs>
using namespace Konsole;
@ -78,14 +78,12 @@ bool KeyboardTranslatorManager::deleteTranslator(const QString& name)
QString KeyboardTranslatorManager::findTranslatorPath(const QString& name)
{
return KStandardDirs::locate("data", "konsole/" + name + ".keytab");
return QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/") + name + QStringLiteral(".keytab"));
}
void KeyboardTranslatorManager::findTranslators()
{
QStringList list = KGlobal::dirs()->findAllResources("data",
"konsole/*.keytab",
KStandardDirs::NoDuplicates);
QStringList list = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/*.keytab"));
// add the name of each translator to the list and associated
// the name with a null pointer to indicate that the translator
@ -120,8 +118,9 @@ const KeyboardTranslator* KeyboardTranslatorManager::findTranslator(const QStrin
bool KeyboardTranslatorManager::saveTranslator(const KeyboardTranslator* translator)
{
const QString path = KGlobal::dirs()->saveLocation("data", "konsole/") + translator->name()
+ ".keytab";
const QString dir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("konsole/");
QDir().mkpath(dir);
const QString path = dir + translator->name() + QStringLiteral(".keytab");
//kDebug() << "Saving translator to" << path;

@ -22,11 +22,11 @@
// Qt
#include <QtCore/QFileInfo>
#include <QtCore/QStandardPaths>
#include <QStandardItem>
// KDE
#include <KKeySequenceWidget>
#include <KStandardDirs>
#include <KDebug>
#include <KLocalizedString>
@ -404,7 +404,7 @@ Profile::Ptr ManageProfilesDialog::currentProfile() const
}
bool ManageProfilesDialog::isProfileDeletable(Profile::Ptr profile) const
{
static const QString systemDataLocation = KStandardDirs::installPath("data") + "konsole/";
static const QString systemDataLocation = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).last() + QStringLiteral("konsole/");
if (profile) {
QFileInfo fileInfo(profile->path());

@ -33,7 +33,6 @@
#include <KGlobal>
#include <KDebug>
#include <KConfigGroup>
#include <KStandardDirs>
// Konsole
#include "ProfileReader.h"
@ -90,7 +89,8 @@ ProfileManager::ProfileManager()
}
// load the default profile
const QString path = KStandardDirs::locate("data", "konsole/" + defaultProfileFileName);
const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/") + defaultProfileFileName);
if (!path.isEmpty()) {
Profile::Ptr profile = loadProfile(path);
if (profile)
@ -137,7 +137,7 @@ Profile::Ptr ProfileManager::loadProfile(const QString& shortPath)
// if the file is not an absolute path, look it up
if (!fileInfo.isAbsolute())
path = KStandardDirs::locate("data", path);
path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, path);
// if the file is not found, return immediately
if (path.isEmpty()) {
@ -471,7 +471,7 @@ void ProfileManager::loadShortcuts()
// if the file is not an absolute path, look it up
QFileInfo fileInfo(profilePath);
if (!fileInfo.isAbsolute()) {
profilePath = KStandardDirs::locate("data", "konsole/" + profilePath);
profilePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/") + profilePath);
}
data.profilePath = profilePath;
@ -497,8 +497,8 @@ void ProfileManager::saveShortcuts()
if (fileInfo.isAbsolute()) {
// Check to see if file is under KDE's data locations. If not,
// store full path.
QString location = KGlobal::dirs()->locate("data",
"konsole/" + fileInfo.fileName());
const QString location = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
QStringLiteral("konsole/") + fileInfo.fileName());
if (location.isEmpty()) {
profileName = iter.value().profilePath;
} else {
@ -580,8 +580,8 @@ void ProfileManager::saveFavorites()
if (fileInfo.isAbsolute()) {
// Check to see if file is under KDE's data locations. If not,
// store full path.
QString location = KGlobal::dirs()->locate("data",
"konsole/" + fileInfo.fileName());
const QString location = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/") + fileInfo.fileName());
if (location.isEmpty()) {
profileName = profile->path();
} else {

@ -29,7 +29,6 @@
#include <KConfig>
#include <KConfigGroup>
#include <KGlobal>
#include <KStandardDirs>
// Konsole
#include "ShellCommand.h"
@ -41,8 +40,7 @@ static const char GENERAL_GROUP[] = "General";
QStringList KDE4ProfileReader::findProfiles()
{
return KGlobal::dirs()->findAllResources("data", "konsole/*.profile",
KStandardDirs::NoDuplicates);
return QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/*.profile"));
}
void KDE4ProfileReader::readProperties(const KConfig& config, Profile::Ptr profile,
const Profile::PropertyInfo* properties)

@ -29,7 +29,6 @@
#include <KConfig>
#include <KConfigGroup>
#include <KGlobal>
#include <KStandardDirs>
// Konsole
#include "ShellCommand.h"
@ -42,8 +41,8 @@ static const char GENERAL_GROUP[] = "General";
QString KDE4ProfileWriter::getPath(const Profile::Ptr profile)
{
// both location have trailing slash
static const QString localDataLocation = KGlobal::dirs()->saveLocation("data", "konsole/");
static const QString systemDataLocation = KStandardDirs::installPath("data") + "konsole/";
static const QString localDataLocation = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("konsole/");
static const QString systemDataLocation = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).last() + QStringLiteral("konsole/");
const QString candidateLocalPath = localDataLocation + profile->untranslatedName() + ".profile";
QString newPath;

@ -45,7 +45,6 @@
#include <KRun>
#include <KShell>
#include <KProcess>
#include <KStandardDirs>
#include <KConfigGroup>
// Konsole
@ -392,7 +391,7 @@ QString Session::checkProgram(const QString& program)
exec = KRun::binaryName(exec, false);
exec = KShell::tildeExpand(exec);
QString pexec = KStandardDirs::findExe(exec);
const QString pexec = QStandardPaths::findExecutable(exec);
if (pexec.isEmpty()) {
kError() << i18n("Could not find binary: ") << exec;
return QString();

@ -42,7 +42,6 @@
#include <KRun>
#include <KShell>
#include <KToolInvocation>
#include <KStandardDirs>
#include <KToggleAction>
#include <KSelectAction>
#include <KXmlGuiWindow>

Loading…
Cancel
Save