Commit dbaa9c76 authored by Rafał Malinowski's avatar Rafał Malinowski

misc: remove singleton aspect of PathsProvider

Signed-off-by: Rafał Malinowski's avatarRafał Malinowski <rafal.przemyslaw.malinowski@gmail.com>
parent 469bcebd
......@@ -29,6 +29,7 @@
#include "contacts/contact.h"
#include "misc/change-notifier.h"
#include "misc/paths-provider.h"
#include "kadu-application.h"
#include "avatar-shared.h"
......@@ -51,7 +52,7 @@ AvatarShared * AvatarShared::loadFromStorage(const std::shared_ptr<StoragePoint>
AvatarShared::AvatarShared(const QUuid &uuid) :
Shared(uuid)
{
AvatarsDir = PathsProvider::instance()->profilePath() + QLatin1String("avatars/");
AvatarsDir = KaduApplication::instance()->pathsProvider()->profilePath() + QLatin1String("avatars/");
connect(&changeNotifier(), SIGNAL(changed()), this, SIGNAL(updated()));
}
......@@ -142,7 +143,7 @@ void AvatarShared::storeAvatar()
storeValue("LastUpdated", LastUpdated);
storeValue("NextUpdate", NextUpdate);
QDir avatarsDir(PathsProvider::instance()->profilePath() + QLatin1String("avatars"));
QDir avatarsDir(KaduApplication::instance()->pathsProvider()->profilePath() + QLatin1String("avatars"));
if (!avatarsDir.exists())
avatarsDir.mkpath(QLatin1String("."));
......@@ -172,7 +173,7 @@ void AvatarShared::storeSmallPixmap()
if (!isValidStorage())
return;
QDir avatarsDir(PathsProvider::instance()->profilePath() + QLatin1String("avatars"));
QDir avatarsDir(KaduApplication::instance()->pathsProvider()->profilePath() + QLatin1String("avatars"));
if (!avatarsDir.exists())
avatarsDir.mkpath(QLatin1String("."));
......
......@@ -252,7 +252,7 @@ void ChatStyleManager::loadStyles()
QFileInfo fi;
QStringList files;
path = PathsProvider::instance()->profilePath() + QLatin1String("syntax/chat/");
path = KaduApplication::instance()->pathsProvider()->profilePath() + QLatin1String("syntax/chat/");
dir.setPath(path);
files = dir.entryList();
......@@ -277,7 +277,7 @@ void ChatStyleManager::loadStyles()
}
}
path = PathsProvider::instance()->dataPath() + QLatin1String("syntax/chat/");
path = KaduApplication::instance()->pathsProvider()->dataPath() + QLatin1String("syntax/chat/");
dir.setPath(path);
files = dir.entryList();
......
......@@ -30,6 +30,7 @@
#include "message/message-html-renderer-service.h"
#include "misc/paths-provider.h"
#include "misc/memory.h"
#include "kadu-application.h"
#include <QtCore/QDir>
......@@ -66,9 +67,9 @@ QString AdiumStyleEngine::defaultVariant(const QString &styleName)
QStringList AdiumStyleEngine::styleVariants(QString styleName)
{
QDir dir;
QString styleBaseHref = PathsProvider::instance()->profilePath() + QLatin1String("syntax/chat/") + styleName + QLatin1String("/Contents/Resources/Variants/");
QString styleBaseHref = KaduApplication::instance()->pathsProvider()->profilePath() + QLatin1String("syntax/chat/") + styleName + QLatin1String("/Contents/Resources/Variants/");
if (!dir.exists(styleBaseHref))
styleBaseHref = PathsProvider::instance()->dataPath() + QLatin1String("syntax/chat/") + styleName + QLatin1String("/Contents/Resources/Variants/");
styleBaseHref = KaduApplication::instance()->pathsProvider()->dataPath() + QLatin1String("syntax/chat/") + styleName + QLatin1String("/Contents/Resources/Variants/");
dir.setPath(styleBaseHref);
dir.setNameFilters(QStringList("*.css"));
return dir.entryList();
......
......@@ -22,6 +22,7 @@
#include "adium-style.h"
#include "misc/paths-provider.h"
#include "kadu-application.h"
#include <QtCore/QDir>
#include <QtCore/QTextCodec>
......@@ -100,9 +101,9 @@ AdiumStyle::AdiumStyle(const QString &styleName) :
Name{styleName}, StyleViewVersion{0}, DefaultBackgroundIsTransparent{false}, UsesCustomTemplateHtml{false}
{
QDir dir;
BaseHref = PathsProvider::instance()->profilePath() + QLatin1String("syntax/chat/") + styleName + QLatin1String("/Contents/Resources/");
BaseHref = KaduApplication::instance()->pathsProvider()->profilePath() + QLatin1String("syntax/chat/") + styleName + QLatin1String("/Contents/Resources/");
if (!dir.exists(BaseHref))
BaseHref = PathsProvider::instance()->dataPath() + QLatin1String("syntax/chat/") + styleName + QLatin1String("/Contents/Resources/");
BaseHref = KaduApplication::instance()->pathsProvider()->dataPath() + QLatin1String("syntax/chat/") + styleName + QLatin1String("/Contents/Resources/");
readConfiugrationFile();
loadHtmlFiles();
......@@ -138,7 +139,7 @@ void AdiumStyle::loadHtmlFiles()
TemplateHref = BaseHref + "template.html";
else
{
TemplateHref = PathsProvider::instance()->dataPath() + QLatin1String("syntax/chat/Default/Template.html");
TemplateHref = KaduApplication::instance()->pathsProvider()->dataPath() + QLatin1String("syntax/chat/Default/Template.html");
UsesCustomTemplateHtml = false;
}
......
......@@ -228,9 +228,9 @@ Core::Core() :
MainConfigurationHolder::createInstance();
Parser::GlobalVariables.insert(QLatin1String("DATA_PATH"), PathsProvider::instance()->dataPath());
Parser::GlobalVariables.insert(QLatin1String("DATA_PATH"), KaduApplication::instance()->pathsProvider()->dataPath());
Parser::GlobalVariables.insert(QLatin1String("HOME"), PathsProvider::homePath());
Parser::GlobalVariables.insert(QLatin1String("KADU_CONFIG"), PathsProvider::instance()->profilePath());
Parser::GlobalVariables.insert(QLatin1String("KADU_CONFIG"), KaduApplication::instance()->pathsProvider()->profilePath());
DateTimeParserTags::registerParserTags();
importPre10Configuration();
......@@ -544,25 +544,25 @@ void Core::deleteOldConfigurationFiles()
{
kdebugf();
QDir oldConfigs(PathsProvider::instance()->profilePath(), "kadu-0.12.conf.xml.backup.*", QDir::Name, QDir::Files);
QDir oldConfigs(KaduApplication::instance()->pathsProvider()->profilePath(), "kadu-0.12.conf.xml.backup.*", QDir::Name, QDir::Files);
if (oldConfigs.count() > 20)
for (unsigned int i = 0, max = oldConfigs.count() - 20; i < max; ++i)
QFile::remove(PathsProvider::instance()->profilePath() + oldConfigs[static_cast<int>(i)]);
QFile::remove(KaduApplication::instance()->pathsProvider()->profilePath() + oldConfigs[static_cast<int>(i)]);
QDir oldConfigs2(PathsProvider::instance()->profilePath(), "kadu-0.6.6.conf.xml.backup.*", QDir::Name, QDir::Files);
QDir oldConfigs2(KaduApplication::instance()->pathsProvider()->profilePath(), "kadu-0.6.6.conf.xml.backup.*", QDir::Name, QDir::Files);
if (oldConfigs2.count() > 20)
for (unsigned int i = 0, max = oldConfigs2.count() - 20; i < max; ++i)
QFile::remove(PathsProvider::instance()->profilePath() + oldConfigs2[static_cast<int>(i)]);
QFile::remove(KaduApplication::instance()->pathsProvider()->profilePath() + oldConfigs2[static_cast<int>(i)]);
QDir oldBacktraces(PathsProvider::instance()->profilePath(), "kadu.backtrace.*", QDir::Name, QDir::Files);
QDir oldBacktraces(KaduApplication::instance()->pathsProvider()->profilePath(), "kadu.backtrace.*", QDir::Name, QDir::Files);
if (oldBacktraces.count() > 20)
for (unsigned int i = 0, max = oldBacktraces.count() - 20; i < max; ++i)
QFile::remove(PathsProvider::instance()->profilePath() + oldBacktraces[static_cast<int>(i)]);
QFile::remove(KaduApplication::instance()->pathsProvider()->profilePath() + oldBacktraces[static_cast<int>(i)]);
QDir oldDebugs(PathsProvider::instance()->profilePath(), "kadu.log.*", QDir::Name, QDir::Files);
QDir oldDebugs(KaduApplication::instance()->pathsProvider()->profilePath(), "kadu.log.*", QDir::Name, QDir::Files);
if (oldDebugs.count() > 20)
for (unsigned int i = 0, max = oldDebugs.count() - 20; i < max; ++i)
QFile::remove(PathsProvider::instance()->profilePath() + oldDebugs[static_cast<int>(i)]);
QFile::remove(KaduApplication::instance()->pathsProvider()->profilePath() + oldDebugs[static_cast<int>(i)]);
kdebugf2();
}
......@@ -733,7 +733,7 @@ void Core::runServices()
CurrentPluginDependencyGraphBuilder = new PluginDependencyGraphBuilder(this);
CurrentPluginMetadataFinder->setDirectory(PathsProvider::instance()->dataPath() + QLatin1String{"plugins"});
CurrentPluginMetadataFinder->setDirectory(KaduApplication::instance()->pathsProvider()->dataPath() + QLatin1String{"plugins"});
CurrentPluginMetadataFinder->setPluginMetadataReader(CurrentPluginMetadataReader);
CurrentPluginDependencyHandler = new PluginDependencyHandler(this);
......
......@@ -215,7 +215,7 @@ QList<ConfigWidget *> ConfigurationWidget::processUiSectionFromDom(QDomNode sect
QString iconPath = sectionElement.attribute("icon");
// Additional slash is needed so that QUrl would treat the rest as _path_, which is desired here.
if (iconPath.startsWith("datapath:///"))
iconPath = PathsProvider::instance()->dataPath() + iconPath.midRef(static_cast<int>(qstrlen("datapath:///")));
iconPath = KaduApplication::instance()->pathsProvider()->dataPath() + iconPath.midRef(static_cast<int>(qstrlen("datapath:///")));
configSection(KaduIcon(iconPath), QCoreApplication::translate("@default", sectionName.toUtf8().constData()), true);
const QDomNodeList children = sectionElement.childNodes();
......
......@@ -29,6 +29,7 @@
#include "gui/windows/message-dialog.h"
#include "misc/paths-provider.h"
#include "misc/syntax-list.h"
#include "kadu-application.h"
#include "syntax-editor.h"
......@@ -86,9 +87,9 @@ void SyntaxEditor::syntaxChangedSlot(const QString &newSyntax)
SyntaxInfo info = (*syntaxList)[newSyntax];
if (info.global)
fileName = PathsProvider::instance()->dataPath() + QLatin1String("syntax/") + category.toLower() + '/' + newSyntax + QLatin1String(".syntax");
fileName = KaduApplication::instance()->pathsProvider()->dataPath() + QLatin1String("syntax/") + category.toLower() + '/' + newSyntax + QLatin1String(".syntax");
else
fileName = PathsProvider::instance()->profilePath() + QLatin1String("syntax/") + category.toLower() + '/' + newSyntax + QLatin1String(".syntax");
fileName = KaduApplication::instance()->pathsProvider()->profilePath() + QLatin1String("syntax/") + category.toLower() + '/' + newSyntax + QLatin1String(".syntax");
file.setFileName(fileName);
if (!file.open(QIODevice::ReadOnly))
......
......@@ -43,6 +43,7 @@
#include "protocols/services/chat-image-service.h"
#include "protocols/services/chat-service.h"
#include "services/chat-image-request-service.h"
#include "kadu-application.h"
#include <QtGui/QKeyEvent>
#include <QtWebKitWidgets/QWebFrame>
......@@ -210,7 +211,7 @@ void WebkitMessagesView::refreshView()
ChatStyleRendererConfiguration WebkitMessagesView::rendererConfiguration()
{
QFile file{PathsProvider::instance()->dataPath() + QLatin1String("scripts/chat-scripts.js")};
QFile file{KaduApplication::instance()->pathsProvider()->dataPath() + QLatin1String("scripts/chat-scripts.js")};
auto javaScript = file.open(QIODevice::ReadOnly | QIODevice::Text)
? file.readAll()
: QString{};
......
......@@ -56,6 +56,7 @@
#include "os/generic/window-geometry-manager.h"
#include "url-handlers/url-handler-manager.h"
#include "debug.h"
#include "kadu-application.h"
#include "about.h"
......@@ -232,7 +233,7 @@ QString About::loadFile(const QString &name)
{
kdebugf();
QFile file(PathsProvider::instance()->dataPath() + name);
QFile file(KaduApplication::instance()->pathsProvider()->dataPath() + name);
if (!file.open(QIODevice::ReadOnly))
{
kdebugm(KDEBUG_ERROR, "About::loadFile(%s) cannot open file\n", qPrintable(name));
......
......@@ -69,6 +69,7 @@
#include "status/status-container.h"
#include "status/status.h"
#include "themes/icon-theme-manager.h"
#include "kadu-application.h"
#include "icons/icons-manager.h"
#include "debug.h"
......@@ -174,7 +175,7 @@ MainConfigurationWindow::MainConfigurationWindow() :
{
setWindowRole("kadu-configuration");
widget()->appendUiFile(PathsProvider::instance()->dataPath() + QLatin1String("configuration/dialog.ui"));
widget()->appendUiFile(KaduApplication::instance()->pathsProvider()->dataPath() + QLatin1String("configuration/dialog.ui"));
#ifndef DEBUG_ENABLED
widget()->widgetById("debug")->hide();
......@@ -310,7 +311,7 @@ void MainConfigurationWindow::installIconTheme()
if (fileName.isEmpty())
return;
const QString &profilePath = PathsProvider::instance()->profilePath();
const QString &profilePath = KaduApplication::instance()->pathsProvider()->profilePath();
ArchiveExtractor extractor;
bool success = extractor.extract(fileName, profilePath + "icons");
if (success)
......@@ -395,7 +396,7 @@ void MainConfigurationWindow::showLookChatAdvanced()
if (!lookChatAdvanced)
{
lookChatAdvanced = new ConfigurationWindow("LookChatAdvanced", tr("Advanced chat's look configuration"), "General", instanceDataManager());
lookChatAdvanced.data()->widget()->appendUiFile(PathsProvider::instance()->dataPath() + QLatin1String("configuration/dialog-look-chat-advanced.ui"));
lookChatAdvanced.data()->widget()->appendUiFile(KaduApplication::instance()->pathsProvider()->dataPath() + QLatin1String("configuration/dialog-look-chat-advanced.ui"));
lookChatAdvanced.data()->widget()->widgetById("chatSyntax")->setToolTip(QCoreApplication::translate("@default", SyntaxText));
lookChatAdvanced.data()->widget()->widgetById("conferencePrefix")->setToolTip(QCoreApplication::translate("@default", SyntaxText));
......
......@@ -49,9 +49,9 @@
#include "model/model-chain.h"
#include "model/roles.h"
#include "talkable/model/talkable-proxy-model.h"
#include "activate.h"
#include "debug.h"
#include "kadu-application.h"
#include "open-chat-with-contact-list-runner.h"
#include "open-chat-with-runner-manager.h"
......@@ -110,7 +110,7 @@ OpenChatWith::OpenChatWith() :
BuddiesView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
BuddiesView->setResizeMode(QDeclarativeView::SizeRootObjectToView);
BuddiesView->setSource(QUrl(PathsProvider::instance()->dataPath() + "qml/openChatWith.qml"));
BuddiesView->setSource(QUrl(KaduApplication::instance()->pathsProvider()->dataPath() + "qml/openChatWith.qml"));
connect(BuddiesView->rootObject(), SIGNAL(itemActivated(int)), this, SLOT(itemActivated(int)));
......
......@@ -69,9 +69,14 @@ KaduApplication::~KaduApplication()
m_instance = nullptr;
}
void KaduApplication::setProfileDirectory(QString profileDirectory)
{
m_pathsProvider = make_qobject<PathsProvider>(std::move(profileDirectory));
}
void KaduApplication::readConfiguration() try
{
auto profilePath = PathsProvider::instance()->profilePath();
auto profilePath = m_pathsProvider->profilePath();
m_configurationStorage = make_qobject<ConfigurationStorage>(profilePath, this);
m_configuration = make_qobject<Configuration>(this);
......@@ -94,4 +99,9 @@ Configuration * KaduApplication::configuration() const
return m_configuration.get();
}
PathsProvider * KaduApplication::pathsProvider() const
{
return m_pathsProvider.get();
}
#include "moc_kadu-application.cpp"
......@@ -42,6 +42,7 @@
class Configuration;
class ConfigurationStorage;
class PathsProvider;
class KADUAPI KaduApplication : public QApplication
{
......@@ -53,14 +54,17 @@ public:
KaduApplication(int &argc, char *argv[]);
virtual ~KaduApplication();
void setProfileDirectory(QString profileDirectory);
void readConfiguration();
Configuration * configuration() const;
PathsProvider * pathsProvider() const;
private:
static KaduApplication * m_instance;
qobject_ptr<Configuration> m_configuration;
qobject_ptr<ConfigurationStorage> m_configurationStorage;
qobject_ptr<PathsProvider> m_pathsProvider;
};
......@@ -25,6 +25,7 @@
#include <QtCore/QDir>
#include "misc/paths-provider.h"
#include "kadu-application.h"
#include "languages-manager.h"
......@@ -32,7 +33,7 @@ QMap<QString, QString> LanguagesManager::Languages;
void LanguagesManager::loadLanguages()
{
QDir tranlationsDir(PathsProvider::instance()->dataPath() + QLatin1String("translations"));
QDir tranlationsDir(KaduApplication::instance()->pathsProvider()->dataPath() + QLatin1String("translations"));
QStringList languagesFilter;
languagesFilter << "*.language";
......
......@@ -55,14 +55,13 @@
#include "execution-arguments/execution-arguments.h"
#include "execution-arguments/execution-arguments-parser.h"
#include "gui/windows/message-dialog.h"
#include "icons/icons-manager.h"
#include "misc/date-time.h"
#include "misc/paths-provider.h"
#include "os/qtsingleapplication/qtlocalpeer.h"
#include "os/win/wsa-exception.h"
#include "os/win/wsa-handler.h"
#include "protocols/protocols-manager.h"
#include "icons/icons-manager.h"
#include "misc/date-time.h"
#include "misc/paths-provider.h"
#include "debug.h"
#include "kadu-application.h"
#include "kadu-config.h"
......@@ -197,7 +196,8 @@ int main(int argc, char *argv[]) try
auto profileDirectory = executionArguments.profileDirectory().isEmpty()
? QString::fromUtf8(qgetenv("CONFIG_DIR"))
: executionArguments.profileDirectory();
PathsProvider::createInstance(profileDirectory);
application->setProfileDirectory(profileDirectory);
#ifndef Q_OS_WIN32
// Qt version is better on win32
......@@ -215,11 +215,11 @@ int main(int argc, char *argv[]) try
const QString lang = KaduApplication::instance()->configuration()->deprecatedApi()->readEntry("General", "Language", QLocale::system().name().left(2));
QTranslator qt_qm, kadu_qm;
qt_qm.load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
kadu_qm.load("kadu_" + lang, PathsProvider::instance()->dataPath() + QLatin1String("translations"));
kadu_qm.load("kadu_" + lang, KaduApplication::instance()->pathsProvider()->dataPath() + QLatin1String("translations"));
QCoreApplication::installTranslator(&qt_qm);
QCoreApplication::installTranslator(&kadu_qm);
QtLocalPeer *peer = new QtLocalPeer(application.get(), PathsProvider::instance()->profilePath());
QtLocalPeer *peer = new QtLocalPeer(application.get(), KaduApplication::instance()->pathsProvider()->profilePath());
if (peer->isClient())
{
if (!executionArguments.openIds().isEmpty())
......@@ -252,8 +252,6 @@ int main(int argc, char *argv[]) try
kdebugm(KDEBUG_INFO, "exiting main\n");
PathsProvider::destroyInstance();
return ret;
}
#if defined(Q_OS_WIN32)
......
......@@ -90,7 +90,7 @@ static void kadu_signal_handler(int signal)
fprintf(stderr, "======= END OF BACKTRACE ======\n");
fflush(stderr);
FILE *backtraceFile = fopen(qPrintable(QString(PathsProvider::instance()->profilePath() + backtraceFileName)), "w");
FILE *backtraceFile = fopen(qPrintable(QString(KaduApplication::instance()->pathsProvider()->profilePath() + backtraceFileName)), "w");
if (backtraceFile)
{
fprintf(backtraceFile, "======= BEGIN OF BACKTRACE =====\n");
......
......@@ -32,20 +32,6 @@
#include "paths-provider.h"
PathsProvider * PathsProvider::Instance;
void PathsProvider::createInstance(const QString &customProfileDir)
{
if (!Instance)
Instance = new PathsProvider(customProfileDir);
}
void PathsProvider::destroyInstance()
{
delete Instance;
Instance = 0;
}
QString PathsProvider::homePath()
{
#ifdef Q_OS_WIN
......@@ -79,12 +65,17 @@ QString PathsProvider::webKitPath(const QString &path)
#endif
}
PathsProvider::PathsProvider(const QString &customProfileDir)
PathsProvider::PathsProvider(const QString &customProfileDir, QObject *parent) :
QObject{parent}
{
initBasicPaths();
initProfilePath(customProfileDir);
}
PathsProvider::~PathsProvider()
{
}
void PathsProvider::initBasicPaths()
{
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
......
......@@ -17,11 +17,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KADU_PATHS_H
#define KADU_PATHS_H
#pragma once
#include <QtCore/QString>
#include <QtCore/QtGlobal>
#include <QtCore/QObject>
#include "exports.h"
......@@ -33,12 +31,11 @@
* upon class instance creation, and path to the current user profile is created if it does not
* exist yet. Details are described in the individual getter methods.
*/
class KADUAPI PathsProvider
class KADUAPI PathsProvider : public QObject
{
Q_OBJECT
Q_DISABLE_COPY(PathsProvider)
static PathsProvider *Instance;
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
QString DesktopFilePath;
#endif
......@@ -46,15 +43,12 @@ class KADUAPI PathsProvider
QString PluginsLibPath;
QString DataPath;
PathsProvider(const QString &customProfileDir);
void initBasicPaths();
void initProfilePath(const QString &customProfileDir);
public:
static void createInstance(const QString &customProfileDir);
static void destroyInstance();
static PathsProvider * instance() { return Instance; }
explicit PathsProvider(const QString &customProfileDir, QObject *parent = nullptr);
virtual ~PathsProvider();
/**
* @short Returns roaming persistent data storage path on Windows and QDir::homePath() on other platforms.
......@@ -140,7 +134,7 @@ public:
*
* The default path to the current user profile may overwritten by existence
* of file named "portable" in directory returned by the dataPath() method. Then
* current user profile is located in the same location as PathsProvider::instance()->dataPath() + QLatin1String("config")
* current user profile is located in the same location as KaduApplication::instance()->pathsProvider()->dataPath() + QLatin1String("config")
* would give. It may be also overwritten by CONFIG_DIR environment variable
* and --config-dir command-line option (the latter takes precedence). We will
* call it CONFIG_DIR in this description, not matter which way it was set.
......@@ -158,5 +152,3 @@ public:
const QString & profilePath() const { return ProfilePath; }
};
#endif // KADU_PATHS_H
......@@ -28,6 +28,7 @@
#include <QtCore/QTextStream>
#include "misc/paths-provider.h"
#include "kadu-application.h"
#include "syntax-list.h"
......@@ -41,12 +42,12 @@ QString SyntaxList::readSyntax(const QString &category, const QString &name, con
{
QString path;
QFile syntaxFile;
path = PathsProvider::instance()->dataPath() + QLatin1String("syntax/") + category + '/' + name + QLatin1String(".syntax");
path = KaduApplication::instance()->pathsProvider()->dataPath() + QLatin1String("syntax/") + category + '/' + name + QLatin1String(".syntax");
syntaxFile.setFileName(path);
if (!syntaxFile.open(QIODevice::ReadOnly))
{
path = PathsProvider::instance()->profilePath() + QLatin1String("syntax/") + category + '/' + name + QLatin1String(".syntax");
path = KaduApplication::instance()->pathsProvider()->profilePath() + QLatin1String("syntax/") + category + '/' + name + QLatin1String(".syntax");
syntaxFile.setFileName(path);
if (!syntaxFile.open(QIODevice::ReadOnly))
......@@ -75,7 +76,7 @@ void SyntaxList::reload()
SyntaxInfo info;
info.global = false;
path = PathsProvider::instance()->profilePath() + QLatin1String("syntax/") + category + '/';
path = KaduApplication::instance()->pathsProvider()->profilePath() + QLatin1String("syntax/") + category + '/';
dir.setPath(path);
dir.setNameFilters(QStringList("*.syntax"));
......@@ -89,7 +90,7 @@ void SyntaxList::reload()
}
info.global = true;
path = PathsProvider::instance()->dataPath() + QLatin1String("syntax/") + category + '/';
path = KaduApplication::instance()->pathsProvider()->dataPath() + QLatin1String("syntax/") + category + '/';
dir.setPath(path);
files = dir.entryList();
......@@ -112,13 +113,13 @@ void SyntaxList::reload()
bool SyntaxList::updateSyntax(const QString &name, const QString &syntax)
{
QString path = PathsProvider::instance()->profilePath() + QLatin1String("syntax/");
QString path = KaduApplication::instance()->pathsProvider()->profilePath() + QLatin1String("syntax/");
QDir dir(path);
if (!dir.exists())
if (!dir.mkdir(path))
return false;
path = PathsProvider::instance()->profilePath() + QLatin1String("syntax/") + category + '/';
path = KaduApplication::instance()->pathsProvider()->profilePath() + QLatin1String("syntax/") + category + '/';
dir.setPath(path);
if (!dir.exists())
if (!dir.mkdir(path))
......@@ -151,9 +152,9 @@ QString SyntaxList::readSyntax(const QString &name)
SyntaxInfo info = *(find(name));
QString path;
if (info.global)
path = PathsProvider::instance()->dataPath() + QLatin1String("syntax/") + category + '/' + name + QLatin1String(".syntax");
path = KaduApplication::instance()->pathsProvider()->dataPath() + QLatin1String("syntax/") + category + '/' + name + QLatin1String(".syntax");
else
path = PathsProvider::instance()->profilePath() + QLatin1String("syntax/") + category + '/' + name + QLatin1String(".syntax");
path = KaduApplication::instance()->pathsProvider()->profilePath() + QLatin1String("syntax/") + category + '/' + name + QLatin1String(".syntax");
QFile syntaxFile;
syntaxFile.setFileName(path);
......@@ -178,7 +179,7 @@ bool SyntaxList::deleteSyntax(const QString &name)
if (info.global)
return false;
QString path = PathsProvider::instance()->profilePath() + QLatin1String("syntax/") + category + '/' + name + QLatin1String(".syntax");
QString path = KaduApplication::instance()->pathsProvider()->profilePath() + QLatin1String("syntax/") + category + '/' + name + QLatin1String(".syntax");
QFile file;
file.setFileName(path);
......
......@@ -24,6 +24,7 @@
#include "plugin/activation/plugin-activation-error-exception.h"
#include "plugin/plugin-root-component.h"
#include "debug.h"
#include "kadu-application.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QEvent>
......@@ -43,7 +44,7 @@
PluginLoader::PluginLoader(const QString &pluginName, QObject *parent) noexcept(false) :
QObject{parent},
m_pluginLoader{make_unique<QPluginLoader>(PathsProvider::instance()->pluginsLibPath() + "/" + QLatin1String{SO_PREFIX} + pluginName + QLatin1String{"." SO_EXT})}
m_pluginLoader{make_unique<QPluginLoader>(KaduApplication::instance()->pathsProvider()->pluginsLibPath() + "/" + QLatin1String{SO_PREFIX} + pluginName + QLatin1String{"." SO_EXT})}
{
m_pluginLoader->setLoadHints(QLibrary::ExportExternalSymbolsHint);
......
......@@ -34,7 +34,7 @@ PluginTranslationsLoader::PluginTranslationsLoader(const QString &pluginName) no
{
auto const lang = KaduApplication::instance()->configuration()->deprecatedApi()->readEntry("General", "Language");
if (m_translator->load(pluginName + '_' + lang, PathsProvider::instance()->dataPath() + QLatin1String{"plugins/translations"}))
if (m_translator->load(pluginName + '_' + lang, KaduApplication::instance()->pathsProvider()->dataPath() + QLatin1String{"plugins/translations"}))
QCoreApplication::installTranslator(m_translator.get());
else
m_translator.reset();
......
......@@ -23,15 +23,16 @@
#include <QtCore/QUrl>
#include <QtCore/QUuid>
#include "icons/kadu-icon.h"
#include "misc/paths-provider.h"
#include "kadu-application.h"
#include <icons/kadu-icon.h>
#include "image-storage-service.h"
ImageStorageService::ImageStorageService(QObject *parent) :
QObject(parent)
{
StoragePath = PathsProvider::instance()->profilePath() + QLatin1String("images/");
StoragePath = KaduApplication::instance()->pathsProvider()->profilePath() + QLatin1String("images/");
}
ImageStorageService::~ImageStorageService()
......
......@@ -33,6 +33,7 @@
#include "misc/paths-provider.h"
#include "misc/misc.h"
#include "debug.h"
#include "kadu-application.h"
#include "themes.h"
......@@ -154,11 +155,11 @@ QStringList Themes::defaultPathsProviderWithThemes() const
{
QStringList result;
foreach(const QString &it, getSubDirs(PathsProvider::instance()->dataPath() + QLatin1String("themes/") + Name))
result << (PathsProvider::instance()->dataPath() + QLatin1String("themes/") + Name + '/' + it + '/');
foreach(const QString &it, getSubDirs(KaduApplication::instance()->pathsProvider()->dataPath() + QLatin1String("themes/") + Name))
result << (KaduApplication::instance()->pathsProvider()->dataPath() + QLatin1String("themes/") + Name + '/' + it + '/');
foreach(const QString &it, getSubDirs(PathsProvider::instance()->profilePath() + Name))
result << (PathsProvider::instance()->profilePath() + Name + '/' + it + '/');
foreach(const QString &it, getSubDirs(KaduApplication::instance()->pathsProvider()->profilePath() + Name))
result << (KaduApplication::instance()->pathsProvider()->profilePath() + Name + '/' + it + '/');
return result;
}
......
......@@ -29,6 +29,7 @@
#include <QtCore/QStringList>
#include "misc/paths-provider.h"
#include "kadu-application.h"
#include "icon-theme-manager.h"
......@@ -54,8 +55,8 @@ QString IconThemeManager::defaultThemeName() const
QStringList IconThemeManager::defaultThemePaths() const
{
// Allow local themes to override global ones.
QStringList result = getSubDirs(PathsProvider::instance()->profilePath() + QLatin1String("icons"));
result += getSubDirs(PathsProvider::instance()->dataPath() + QLatin1String("themes/icons"));