From 4caca2ce1a9c87884f33dcf23229e306bf10c780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Me=C3=9Fmer?= Date: Mon, 14 Jan 2013 00:48:26 +0100 Subject: [PATCH] The configuration directory is a static attribute in mirallconfigfile class --- src/mirall/application.cpp | 12 +----------- src/mirall/application.h | 5 ----- src/mirall/folderman.cpp | 6 +++--- src/mirall/mirallconfigfile.cpp | 9 +++++++-- src/mirall/mirallconfigfile.h | 3 +++ 5 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/mirall/application.cpp b/src/mirall/application.cpp index 24a69eb59..9fddf19c2 100644 --- a/src/mirall/application.cpp +++ b/src/mirall/application.cpp @@ -63,10 +63,6 @@ void mirallLogCatcher(QtMsgType type, const char *msg) // ---------------------------------------------------------------------------------- -Application *Application::getInstance() { - return dynamic_cast(qApp); -} - Application::Application(int &argc, char **argv) : SharedTools::QtSingleApplication(argc, argv), _tray(0), @@ -78,7 +74,6 @@ Application::Application(int &argc, char **argv) : _theme(Theme::instance()), _updateDetector(0), _logBrowser(0), - _dataLocation(QDesktopServices::storageLocation(QDesktopServices::DataLocation)), _showLogWindow(false), _logFlush(false), _helpOnly(false) @@ -186,11 +181,6 @@ Application::~Application() qDebug() << "* Mirall shutdown"; } -const QString &Application::getDataLocation() const -{ - return _dataLocation; -} - void Application::slotStartUpdateDetector() { _updateDetector = new UpdateDetector(this); @@ -960,7 +950,7 @@ void Application::parseOptions(const QStringList &options) _theme->setSystrayUseMonoIcons(true); } else if (option == QLatin1String("--confdir")) { if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) { - _dataLocation=it.next(); + MirallConfigFile::setConfDir(it.next()); } else { showHelp(); } diff --git a/src/mirall/application.h b/src/mirall/application.h index 58825e37f..d8d327a8c 100644 --- a/src/mirall/application.h +++ b/src/mirall/application.h @@ -53,10 +53,6 @@ public: bool giveHelp(); - static Application *getInstance(); - - const QString &getDataLocation() const; - signals: protected slots: @@ -132,7 +128,6 @@ private: QMap _overallStatusStrings; LogBrowser *_logBrowser; QString _logFile; - QString _dataLocation; bool _showLogWindow; bool _logFlush; bool _helpOnly; diff --git a/src/mirall/folderman.cpp b/src/mirall/folderman.cpp index 5f2750ead..f5fef96c2 100644 --- a/src/mirall/folderman.cpp +++ b/src/mirall/folderman.cpp @@ -29,7 +29,6 @@ #endif #include -#include "application.h" namespace Mirall { @@ -38,9 +37,10 @@ FolderMan::FolderMan(QObject *parent) : { // if QDir::mkpath would not be so stupid, I would not need to have this // duplication of folderConfigPath() here - QDir storageDir(Application::getInstance()->getDataLocation()); + MirallConfigFile cfg; + QDir storageDir(cfg.configPath()); storageDir.mkpath(QLatin1String("folders")); - _folderConfigPath = Application::getInstance()->getDataLocation() + QLatin1String("/folders"); + _folderConfigPath = cfg.configPath() + QLatin1String("folders"); _folderChangeSignalMapper = new QSignalMapper(this); connect(_folderChangeSignalMapper, SIGNAL(mapped(const QString &)), diff --git a/src/mirall/mirallconfigfile.cpp b/src/mirall/mirallconfigfile.cpp index 427284f68..119426a32 100644 --- a/src/mirall/mirallconfigfile.cpp +++ b/src/mirall/mirallconfigfile.cpp @@ -18,7 +18,6 @@ #include "mirall/owncloudtheme.h" #include "mirall/miralltheme.h" #include "mirall/credentialstore.h" -#include "mirall/application.h" #include #include @@ -32,6 +31,7 @@ namespace Mirall { QString MirallConfigFile::_oCVersion; +QString MirallConfigFile::_confDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); bool MirallConfigFile::_askedUser = false; MirallConfigFile::MirallConfigFile( const QString& appendix ) @@ -39,9 +39,14 @@ MirallConfigFile::MirallConfigFile( const QString& appendix ) { } +void MirallConfigFile::setConfDir(const QString &value) +{ + _confDir=value; +} + QString MirallConfigFile::configPath() const { - QString dir = Application::getInstance()->getDataLocation(); + QString dir = _confDir; if( !dir.endsWith(QLatin1Char('/')) ) dir.append(QLatin1Char('/')); return dir; } diff --git a/src/mirall/mirallconfigfile.h b/src/mirall/mirallconfigfile.h index 20bde292e..ba8e19c71 100644 --- a/src/mirall/mirallconfigfile.h +++ b/src/mirall/mirallconfigfile.h @@ -97,6 +97,8 @@ public: int proxyPort() const; QString proxyUser() const; QString proxyPassword() const; + + static void setConfDir(const QString &value); protected: // these classes can only be access from CredentialStore as a friend class. @@ -112,6 +114,7 @@ private: private: static bool _askedUser; static QString _oCVersion; + static QString _confDir; QString _customHandle; };