diff options
Diffstat (limited to 'src/browser.cpp')
-rw-r--r-- | src/browser.cpp | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/src/browser.cpp b/src/browser.cpp index 9ee7315..355c24b 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -162,36 +162,43 @@ BlockerManager *Browser::blocklists() void Browser::setConfigPath(const QString &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); - } + QString configLocation, defaultsLocation; + // set defaults location // 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"); + if(QFile::exists("/usr/share/smolbote/poi.conf")) { + defaultsLocation = "/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"); + defaultsLocation = "/usr/local/share/smolbote/poi.conf"; } #endif - else { - m_settings = new Settings(); + // if no default config is found, then use the built-in one + if(defaultsLocation.isEmpty()) { + defaultsLocation = ":/poi.toml"; } + // set custom config path if any + if(!path.isEmpty()) { + configLocation = path; + + } else { + // check if config file exists for this user + QString cpath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/poi.conf"; + if(QFile::exists(cpath)) { + configLocation = cpath; + } + } + + m_settings = new Settings(configLocation, defaultsLocation); + if(m_settings->isEmpty()) { // There are no keys in the settings QMessageBox::information(0, tr("Configuration is empty"), - tr("The configuration file <i>%1</i> is empty. Using default values").arg(m_settings->filePath())); + tr("The configuration file <i>%1</i> is empty.<br>" + "Using default values from <i>%2</i>.").arg(configLocation, defaultsLocation)); } } |