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 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'src/browser.cpp') 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(); } } -- cgit v1.2.1