- fix spew from QDir when not using a config file

This commit is contained in:
Alfred Reynolds
2021-10-23 14:03:53 +13:00
parent 88f2a02652
commit 87315a7bda
3 changed files with 21 additions and 1 deletions

1
.gitignore vendored
View File

@@ -3,3 +3,4 @@ make
.git
build
.vscode
test_config/slide.options.json

View File

@@ -49,6 +49,11 @@ void SetJSONBool(bool &value, QJsonObject jsonDoc, const char *key) {
}
Config loadConfiguration(const std::string &configFilePath, const Config &currentConfig) {
if(configFilePath.empty())
{
return currentConfig;
}
QString jsonFile(configFilePath.c_str());
QDir directory;
if(!directory.exists(jsonFile))
@@ -130,7 +135,7 @@ QString getAppConfigFilePath(const std::string &configPath) {
std::string userConfigFolder = "~/.config/slide/";
std::string systemConfigFolder = "/etc/slide";
QString baseConfigFilename("slide.options.json");
QDir directory(userConfigFolder.c_str());
QString jsonFile = "";
if (!configPath.empty())
@@ -218,6 +223,11 @@ QVector<PathEntry> parsePathEntry(QJsonObject &jsonMainDoc, bool baseRecursive,
}
AppConfig loadAppConfiguration(const AppConfig &commandLineConfig) {
if(commandLineConfig.configPath.empty())
{
return commandLineConfig;
}
QString jsonFile = getAppConfigFilePath(commandLineConfig.configPath);
QDir directory;
if(!directory.exists(jsonFile))
@@ -272,6 +282,10 @@ AppConfig loadAppConfiguration(const AppConfig &commandLineConfig) {
}
Config getConfigurationForFolder(const std::string &folderPath, const Config &currentConfig) {
if(folderPath.empty())
{
return currentConfig;
}
QDir directory(folderPath.c_str());
QString jsonFile = directory.filePath(QString("options.json"));
if(directory.exists(jsonFile))

View File

@@ -210,6 +210,11 @@ std::unique_ptr<ImageSelector> GetSelectorForApp(const AppConfig& appConfig)
void ReloadConfigIfNeeded(AppConfig &appConfig, MainWindow &w, ImageSwitcher *switcher)
{
if(appConfig.configPath.empty())
{
return;
}
QString jsonFile = getAppConfigFilePath(appConfig.configPath);
QDir directory;
if(!directory.exists(jsonFile))