Commit 71f3b147 authored by Laurent Montel's avatar Laurent Montel 😁 Committed by Pali Rohár

Port to QStandardDirs

parent cf7f90b4
......@@ -54,6 +54,7 @@
#include <QSplitter>
#include <QMimeData>
#include <QScrollBar>
#include <KSharedConfig>
K_PLUGIN_FACTORY(ChatWindowPluginFactory, registerPlugin<ChatWindowPlugin>();
)
......
......@@ -86,6 +86,7 @@
#include <qtoolbutton.h>
#include <kxmlguifactory.h>
#include <KTabBar>
#include <KSharedConfig>
typedef QMap<Kopete::Account *, KopeteChatWindow *> AccountMap;
typedef QMap<Kopete::Group *, KopeteChatWindow *> GroupMap;
......
......@@ -30,6 +30,7 @@
#include <kdebug.h>
#include <KLocalizedString>
#include <kstandarddirs.h>
#include <QStandardPaths>
class ChatWindowStyle::Private
{
......@@ -75,7 +76,7 @@ ChatWindowStyle::ChatWindowStyle(const QString &styleName, const QString &varian
void ChatWindowStyle::init(const QString &styleName, StyleBuildMode styleBuildMode)
{
QStringList styleDirs = KGlobal::dirs()->findDirs("appdata", QStringLiteral("styles/%1/Contents/Resources/").arg(styleName));
QStringList styleDirs = QStandardPaths::locateAll(QStandardPaths::DataLocation, QStringLiteral("styles/%1/Contents/Resources/").arg(styleName));
if (styleDirs.isEmpty()) {
kDebug(14000) << "Failed to find style" << styleName;
return;
......
......@@ -34,6 +34,7 @@
#include <kio/netaccess.h>
#include <ksharedconfig.h>
#include <kconfiggroup.h>
#include <QStandardPaths>
#include "kopetechatwindowstyle.h"
......@@ -86,9 +87,9 @@ ChatWindowStyleManager::~ChatWindowStyleManager()
void ChatWindowStyleManager::loadStyles()
{
// Make sure there exists a directory where chat styles can be installed to and it will be watched for changes
KStandardDirs::locateLocal("appdata", QStringLiteral("styles/"));
QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + QStringLiteral("styles/");
QStringList chatStyles = KGlobal::dirs()->findDirs("appdata", QStringLiteral("styles"));
QStringList chatStyles = QStandardPaths::locateAll(QStandardPaths::DataLocation, QStringLiteral("styles"));
foreach (const QString &styleDir, chatStyles) {
kDebug(14000) << styleDir;
d->styleDirs.push(QUrl::fromLocalFile(styleDir));
......@@ -113,7 +114,7 @@ QStringList ChatWindowStyleManager::getAvailableStyles() const
int ChatWindowStyleManager::installStyle(const QString &styleBundlePath)
{
QString localStyleDir;
QStringList chatStyles = KGlobal::dirs()->findDirs("appdata", QStringLiteral("styles"));
QStringList chatStyles = QStandardPaths::locateAll(QStandardPaths::DataLocation, QStringLiteral("styles"));
// findDirs returns preferred paths first, let's check if one of them is writable
foreach (const QString &styleDir, chatStyles) {
if (QFileInfo(styleDir).isWritable()) {
......@@ -266,7 +267,7 @@ bool ChatWindowStyleManager::removeStyle(const QString &styleName)
delete deletedStyle;
}
QStringList styleDirs = KGlobal::dirs()->findDirs("appdata", QStringLiteral("styles/%1").arg(styleName));
QStringList styleDirs = QStandardPaths::locateAll(QStandardPaths::DataLocation, QStringLiteral("styles/%1").arg(styleName));
if (styleDirs.isEmpty()) {
kDebug(14000) << "Failed to find style" << styleName;
return false;
......
......@@ -68,6 +68,7 @@
#include <QIcon>
#include <QMenu>
#include <QAction>
#include <KSharedConfig>
K_PLUGIN_FACTORY(EmailWindowPluginFactory, registerPlugin<EmailWindowPlugin>();
)
......
......@@ -40,6 +40,7 @@
#include <QTextCursor>
#include <QTextCharFormat>
#include <QTextDocumentFragment>
#include <KSharedConfig>
// TODO: Add i18n context
......
......@@ -44,7 +44,7 @@
#include <KLocalizedString>
#include <kmessagebox.h>
#include <QPushButton>
#include <kstandarddirs.h>
#include <kurlrequesterdialog.h>
#include <krun.h>
#include <kfiledialog.h>
......@@ -53,6 +53,7 @@
#include "kopeteglobal.h"
#include <qtabwidget.h>
#include <KSharedConfig>
#include "kopeteappearancesettings.h"
#include "contactlistlayoutwidget.h"
......
......@@ -74,6 +74,7 @@
#include <kopetechatsessionmanager.h>
#include <kopetestatusmessage.h>
#include <kopeteappearancesettings.h>
#include <KSharedConfig>
#include "kopeteemoticons.h"
......
......@@ -21,14 +21,14 @@
#include "contactlistlayoutmanager.h"
#include <KMessageBox>
#include <KStandardDirs>
#include <QUrl>
#include <KGlobal>
#include <KConfig>
#include <KConfigGroup>
#include <KDebug>
#include <KLocale>
#include <KStandardDirs>
#include <kio/global.h>
#include <kio/job.h>
......@@ -36,6 +36,8 @@
#include <QDomDocument>
#include <QFile>
#include <QStringList>
#include <QStandardPaths>
#include <KSharedConfig>
#include "kopeteitembase.h"
......@@ -109,7 +111,7 @@ ContactListLayout LayoutManager::activeLayout()
void LayoutManager::loadUserLayouts()
{
QDir layoutsDir = QDir(KStandardDirs::locateLocal("appdata", QStringLiteral("contactlistlayouts")));
QDir layoutsDir = QDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + QStringLiteral("contactlistlayouts"));
layoutsDir.setSorting(QDir::Name);
......@@ -129,8 +131,8 @@ void LayoutManager::loadUserLayouts()
void LayoutManager::loadDefaultLayouts()
{
loadLayouts(KStandardDirs::locate("data", QStringLiteral("kopete/DefaultContactListLayouts.xml")), false);
loadLayouts(KStandardDirs::locate("data", QStringLiteral("kopete/CompactContactListLayouts.xml")), false);
loadLayouts(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kopete/DefaultContactListLayouts.xml")), false);
loadLayouts(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kopete/CompactContactListLayouts.xml")), false);
}
void LayoutManager::loadLayouts(const QString &fileName, bool user)
......@@ -253,7 +255,7 @@ bool LayoutManager::addUserLayout(const QString &name, ContactListLayout layout)
doc.appendChild(layouts_element);
layouts_element.appendChild(newLayout);
QString dirName = KStandardDirs::locateLocal("appdata", QStringLiteral("contactlistlayouts"));
QString dirName = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + QStringLiteral("contactlistlayouts");
QDir layoutsDir = QDir(dirName);
//make sure that this dir exists
......@@ -339,7 +341,7 @@ bool LayoutManager::deleteLayout(const QString &layout)
{
//check if layout is editable
if (m_layouts.value(layout).isEditable()) {
QDir layoutsDir = QDir(KStandardDirs::locateLocal("appdata", QStringLiteral("contactlistlayouts")));
QDir layoutsDir = QDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + QStringLiteral("contactlistlayouts"));
QString xmlFile = layoutsDir.path() + '/' + layout + ".xml";
qDebug() << "deleting file: " << xmlFile;
......
......@@ -31,6 +31,7 @@
#include <KDebug>
#include <KEmoticonsTheme>
#include <kmessagebox_queued.h>
#include <QStandardPaths>
#include "kopeteaccount.h"
#include "kopetepicture.h"
......@@ -47,7 +48,7 @@
#include "kopetemessageevent.h"
#include "kopetechatsessionmanager.h"
#include "kopeteuiglobal.h"
#include <KStandardDirs>
namespace Kopete {
namespace UI {
......@@ -176,7 +177,7 @@ bool ContactListModel::loadModelSettings(const QString &modelType)
{
QDomDocument doc;
QString fileName = KStandardDirs::locateLocal("appdata", QStringLiteral("contactlistmodel.xml"));
QString fileName = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + QStringLiteral("contactlistmodel.xml");
if (QFile::exists(fileName)) {
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly) || !doc.setContent(&file)) {
......@@ -214,7 +215,7 @@ bool ContactListModel::saveModelSettings(const QString &modelType)
{
QDomDocument doc;
QString fileName = KStandardDirs::locateLocal("appdata", QStringLiteral("contactlistmodel.xml"));
QString fileName = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + QStringLiteral("contactlistmodel.xml");
if (QFile::exists(fileName)) {
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly) || !doc.setContent(&file)) {
......
......@@ -18,15 +18,16 @@
#include <qtextstream.h>
#include <qdom.h>
#include <kstandarddirs.h>
#include <kcomponentdata.h>
#include <QStandardPaths>
static QTextStream qcerr(stderr, QIODevice::WriteOnly);
int main()
{
KComponentData inst("Update script");
QString filename = KStandardDirs::locateLocal("data", QLatin1String("kopete/contactlist.xml"));
QString filename = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/kopete/contactlist.xml");
// Load contact list & save backup.
QFile contactListFile(filename);
......
......@@ -30,6 +30,7 @@
#include <kcmdlineargs.h>
#include <kmessagebox.h>
#include <solid/networking.h>
#include <KSharedConfig>
#include "addaccountwizard.h"
#include "kabcpersistence.h"
......
......@@ -71,6 +71,7 @@
#include <solid/networking.h>
#include <kstatusbarofflineindicator.h>
#include <kfilterproxysearchline.h>
#include <KSharedConfig>
#include "addcontactpage.h"
#include "addressbooklinkwidget.h"
......
......@@ -43,6 +43,7 @@
#include <kopeteaccount.h>
#include <kopetecontact.h>
#include <kopetemessage.h>
#include <QStandardPaths>
#include "history2logger.h"
......@@ -271,7 +272,7 @@ int History2Import::countLogs(QDir dir, int depth)
void History2Import::importKopete()
{
cancel = false;
QString logDir = KStandardDirs::locateLocal("data", QString("kopete/logs/"));
QString logDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + QString("kopete/logs/");
QDir dd(logDir);
if (selectByHand->isChecked() || !dd.exists()) {
logDir = QFileDialog::getExistingDirectory(mainWidget(), i18n("Select Log Directory"), QDir::homePath());
......
......@@ -35,8 +35,9 @@
#include <QHash>
#include <kdebug.h>
#include <kstandarddirs.h>
#include <QSaveFile>
#include <QStandardPaths>
#include "kopeteglobal.h"
#include "kopetecontact.h"
......@@ -54,7 +55,7 @@ History2Logger *History2Logger::m_Instance = 0;
History2Logger::History2Logger()
{
QString path = KStandardDirs::locateLocal("appdata", "kopete_history.db");
QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + "kopete_history.db";
m_db = QSqlDatabase::addDatabase("QSQLITE", "kopete-history");
m_db.setDatabaseName(path);
if (!m_db.open()) {
......
......@@ -31,6 +31,7 @@
#include <kcodecs.h>
#include <kmessagebox.h>
#include <kmessagebox_queued.h>
#include <KSharedConfig>
#include "kopetechatsessionmanager.h"
#include "kopeteuiglobal.h"
......
......@@ -29,7 +29,7 @@
#include <ui/kopeteview.h>
#include <kopetemessage.h>
#include <kdebug.h>
#include <kstandarddirs.h>
#include <kmessagebox.h>
#include <qicon.h>
#include <kactioncollection.h>
......
......@@ -25,7 +25,7 @@
#include <kxmlguiclient.h>
#include <kglobal.h>
#include <kstandarddirs.h>
#include <kiconloader.h>
#include <kopetemessage.h>
......
......@@ -28,6 +28,7 @@
#include <qfile.h>
#include <qcolor.h>
#include <KStandardDirs>
#include <kdebug.h>
#include <qaction.h>
#include <kconfig.h>
......
......@@ -40,7 +40,7 @@
#include <kapplication.h>
#include <kpassivepopup.h>
#include <kiconloader.h>
#include <kstandarddirs.h>
#include <kcomponentdata.h>
#include <kopeteaccountmanager.h>
......
......@@ -48,7 +48,7 @@ void PipesConfig::setPipes(PipesPlugin::PipeOptionsList pipes)
void PipesConfig::save()
{
KConfigGroup config(KGlobal::config(), "PipesPlugin_Pipes");
KConfigGroup config(KSharedConfig::openConfig(), "PipesPlugin_Pipes");
config.deleteGroup();
QStringList uids;
......@@ -64,7 +64,7 @@ void PipesConfig::save()
void PipesConfig::load()
{
KConfigGroup config(KGlobal::config(), "PipesPlugin_Pipes");
KConfigGroup config(KSharedConfig::openConfig(), "PipesPlugin_Pipes");
const QStringList uidList = config.readEntry("Pipes", QStringList());
PipesPlugin::PipeOptions pipeOptions;
......
......@@ -26,13 +26,14 @@
#include <kdebug.h>
#include <kmessagebox.h>
#include <kstandarddirs.h>
#include <time.h>
#include <QStandardPaths>
StatisticsDB::StatisticsDB()
{
QString path = KStandardDirs::locateLocal("appdata", QStringLiteral("kopete_statistics-0.1.db"));
QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + QStringLiteral("kopete_statistics-0.1.db");
kDebug(14315) << "DB path:" << path;
m_db = QSqlDatabase::addDatabase(QStringLiteral("QSQLITE"), QStringLiteral("kopete-statistics"));
m_db.setDatabaseName(path);
......
......@@ -34,7 +34,7 @@
#include <kdialog.h>
#include <klocalizedstring.h>
#include <khtml_part.h>
#include <kstandarddirs.h>
#include "kopetemetacontact.h"
#include "kopeteonlinestatus.h"
......
......@@ -28,7 +28,7 @@
#include <QAction>
#include <kactioncollection.h>
#include <kmessagebox.h>
#include <kstandarddirs.h>
#include <kapplication.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment