diff --git a/src/mirall/application.cpp b/src/mirall/application.cpp index 557e64a1f..24a69eb59 100644 --- a/src/mirall/application.cpp +++ b/src/mirall/application.cpp @@ -63,6 +63,10 @@ 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), @@ -74,6 +78,7 @@ Application::Application(int &argc, char **argv) : _theme(Theme::instance()), _updateDetector(0), _logBrowser(0), + _dataLocation(QDesktopServices::storageLocation(QDesktopServices::DataLocation)), _showLogWindow(false), _logFlush(false), _helpOnly(false) @@ -181,6 +186,11 @@ Application::~Application() qDebug() << "* Mirall shutdown"; } +const QString &Application::getDataLocation() const +{ + return _dataLocation; +} + void Application::slotStartUpdateDetector() { _updateDetector = new UpdateDetector(this); @@ -948,6 +958,12 @@ void Application::parseOptions(const QStringList &options) _logFlush = true; } else if (option == QLatin1String("--monoicons")) { _theme->setSystrayUseMonoIcons(true); + } else if (option == QLatin1String("--confdir")) { + if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) { + _dataLocation=it.next(); + } else { + showHelp(); + } } } } @@ -1040,6 +1056,7 @@ void Application::showHelp() std::cout << " --logfile : write log output to file ." << std::endl; std::cout << " --logflush : flush the log file after every write." << std::endl; std::cout << " --monoicons : Use black/white pictograms for systray." << std::endl; + std::cout << " --confdir : Use the given configuration directory." << std::endl; std::cout << std::endl; if (_theme->appName() == QLatin1String("ownCloud")) std::cout << "For more information, see http://www.owncloud.org" << std::endl; diff --git a/src/mirall/application.h b/src/mirall/application.h index d8d327a8c..58825e37f 100644 --- a/src/mirall/application.h +++ b/src/mirall/application.h @@ -53,6 +53,10 @@ public: bool giveHelp(); + static Application *getInstance(); + + const QString &getDataLocation() const; + signals: protected slots: @@ -128,6 +132,7 @@ 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 5d3391446..5f2750ead 100644 --- a/src/mirall/folderman.cpp +++ b/src/mirall/folderman.cpp @@ -28,8 +28,8 @@ #include #endif -#include #include +#include "application.h" namespace Mirall { @@ -38,9 +38,9 @@ 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(QDesktopServices::storageLocation(QDesktopServices::DataLocation)); + QDir storageDir(Application::getInstance()->getDataLocation()); storageDir.mkpath(QLatin1String("folders")); - _folderConfigPath = QDesktopServices::storageLocation(QDesktopServices::DataLocation) + QLatin1String("/folders"); + _folderConfigPath = Application::getInstance()->getDataLocation() + 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 cc293ca2e..427284f68 100644 --- a/src/mirall/mirallconfigfile.cpp +++ b/src/mirall/mirallconfigfile.cpp @@ -18,6 +18,7 @@ #include "mirall/owncloudtheme.h" #include "mirall/miralltheme.h" #include "mirall/credentialstore.h" +#include "mirall/application.h" #include #include @@ -40,7 +41,7 @@ MirallConfigFile::MirallConfigFile( const QString& appendix ) QString MirallConfigFile::configPath() const { - QString dir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + QString dir = Application::getInstance()->getDataLocation(); if( !dir.endsWith(QLatin1Char('/')) ) dir.append(QLatin1Char('/')); return dir; }