From 5b72a6b5787a360e36d137fe2d52f47be926a588 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 19 Mar 2017 14:33:07 +0100 Subject: Added build script Additional locations are searched for configuration --- src/browser.cpp | 28 +++++++++++++++++++++++----- src/mainwindow.cpp | 2 +- src/settings.h | 2 +- 3 files changed, 25 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/browser.cpp b/src/browser.cpp index 4697ac5..41c6355 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -125,12 +125,30 @@ DownloadDialog *Browser::downloads() void Browser::setConfigPath(const QString &path) { - if(path.isEmpty()) { - // set default config path - m_settings = new Settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/poi.conf"); - } else { - // set custom config path + // set custom config path if any + if(!path.isEmpty()) { m_settings = new Settings(path); + return; + } + + // check if config file exists for this user + QString cpath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/poi.conf"; + if(QFile::exists(cpath)) { + m_settings = new Settings(cpath); + } + + // check system-specific locations +#ifdef Q_OS_LINUX + else if(QFile::exists("/usr/share/smolbote/poi.conf")) { + m_settings = new Settings("/usr/share/smolbote/poi.conf"); + } + else if(QFile::exists("/usr/local/share/smolbote/poi.conf")) { + m_settings = new Settings("/usr/local/share/smolbote/poi.conf"); + } +#endif + + else { + m_settings = new Settings(); } } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f455fae..087c5f8 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -161,7 +161,7 @@ void MainWindow::about() "

This program comes with ABSOLUTELY NO WARRANTY. " "This is free software, and you are welcome to redistribute it under the conditions set by the GNU GPLv3.

" "

Configuration lives in: %2

") - .arg(qApp->applicationVersion()).arg(sSettings->filePath())); + .arg(DESCRIBE).arg(sSettings->filePath())); } void MainWindow::loadProfile(const QString &name) diff --git a/src/settings.h b/src/settings.h index 12c508b..54a3917 100644 --- a/src/settings.h +++ b/src/settings.h @@ -27,7 +27,7 @@ class Settings { public: - Settings(const QString &configFile); + Settings(const QString &configFile = QString()); ~Settings(); QString filePath() const; -- cgit v1.2.1