From a8a717221c2f485bcdd9bbfa7b24e1c61083e95e Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 7 Nov 2016 15:47:26 +0100 Subject: Fallback to user/default config if cmdline config was not found; print config path used --- src/main.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 5e18c8c..e511c09 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -86,12 +86,12 @@ int main(int argc, char *argv[]) { } std::cerr << a.translate("Console", - "vmchooser: failed to run session").toUtf8().data() + "vmchooser: failed to run session").toUtf8().constData() << std::endl; return EXIT_FAILURE; } else { std::cerr - << a.translate("Console", "vmchooser: invalid session file").toUtf8().data() + << a.translate("Console", "vmchooser: invalid session file").toUtf8().constData() << std::endl; return EXIT_FAILURE; } @@ -103,12 +103,24 @@ int main(int argc, char *argv[]) { // global vmchooser.conf QString confFile; if (cmdOptions.contains("config")) { - confFile = cmdOptions.value("config"); - } else if (QFileInfo(userConfFile).exists()) { + if (QFileInfo(cmdOptions.value("config")).exists()) { + confFile = cmdOptions.value("config"); + } else { + std::cerr << a.translate("Console", "Requested --config not found: ").toUtf8().constData() << cmdOptions.value("config").toUtf8().constData() << std::endl; + } + } + if (confFile.isEmpty() && QFileInfo(userConfFile).exists()) { confFile = userConfFile; - } else { + std::cerr << a.translate("Console", "Using user specific config: ").toUtf8().constData() << userConfFile.toUtf8().constData() << std::endl; + } + if (confFile.isEmpty() && QFileInfo(globalConfFile).exists()) { confFile = globalConfFile; + std::cerr << a.translate("Console", "Using global config: ").toUtf8().constData() << globalConfFile.toUtf8().constData() << std::endl; + } + if (confFile.isEmpty()) { + std::cerr << a.translate("Console", "No config file found or given").toUtf8().constData() << std::endl; } + // TODO: This is the system wide settings, give proper name QSettings settings(confFile, QSettings::IniFormat); settings.setIniCodec("UTF-8"); -- cgit v1.2.3-55-g7522