diff options
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 98 |
1 files changed, 48 insertions, 50 deletions
diff --git a/src/main.cpp b/src/main.cpp index 2897403..ac545d8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,12 +15,14 @@ void printHelp() qout << "-u <URL>, --url=<URL> " << QObject::tr("Set which URL to load.") << endl; qout << "-d, --debug " << QObject::tr("Activate debug mode.") << endl; qout << "-h, --help " << QObject::tr("Prints usage information.") << endl; + qout.flush(); + exit(EXIT_SUCCESS); } int main(int argc, char *argv[]) { - debug = false; - QApplication app(argc, argv, QApplication::GuiServer); + debug = false; + QApplication app(argc, argv, QApplication::GuiServer); app.setOrganizationName("team_projekt_2011"); app.setApplicationName("prebootGUI"); app.setObjectName("test"); @@ -33,24 +35,24 @@ int main(int argc, char *argv[]) /* Parse cmdline argus. */ QMap<QString, QString> clo; - int longIndex = 0; - static const char *optString = "u:hDd"; - static const struct option longOpts[] = - { - {"url", required_argument, NULL, 'u'}, - {"downloadtodir", required_argument, NULL, 'd'}, - {"debug", no_argument, NULL, 'D'}, - {"help", no_argument, NULL, 'h'} - }; - int opt = getopt_long(argc, argv, optString, longOpts, &longIndex); - while (opt != -1) - { - switch(opt) - { - case 'u': - clo.insert("url", optarg); - break; - case 'd': + int longIndex = 0; + static const char *optString = "u:hDd"; + static const struct option longOpts[] = + { + {"url", required_argument, NULL, 'u'}, + {"downloadtodir", required_argument, NULL, 'd'}, + {"debug", no_argument, NULL, 'D'}, + {"help", no_argument, NULL, 'h'} + }; + int opt = getopt_long(argc, argv, optString, longOpts, &longIndex); + while (opt != -1) + { + switch(opt) + { + case 'u': + clo.insert("url", optarg); + break; + case 'd': clo.insert("downloadDir", optarg); break; case 'D': @@ -59,39 +61,35 @@ int main(int argc, char *argv[]) case 'h': clo.insert("help", "help"); break; - } - opt = getopt_long(argc, argv, optString, longOpts, &longIndex); - } - // Print help - if (clo.contains("help")){ - printHelp(); - exit(EXIT_SUCCESS); } - // Debug mode - if (clo.contains("debug")){ - debug = true; - qDebug() << "Debug mode activated."; - } - else - debug = false; - // Read the config file, for now hardcoded expected name. - QSettings confFileSettings(app.applicationDirPath() + "/fbgui.conf", QSettings::IniFormat); - confFileSettings.setIniCodec("UTF-8"); + opt = getopt_long(argc, argv, optString, longOpts, &longIndex); + } + // Print help + if (clo.contains("help")) + printHelp(); + // Debug mode + if (clo.contains("debug")) + debug = true; + else + debug = false; + // Read the config file, for now hardcoded expected name. + QSettings confFileSettings(app.applicationDirPath() + "/fbgui.conf", QSettings::IniFormat); + confFileSettings.setIniCodec("UTF-8"); - if (clo.contains("url")) - baseURL = QUrl(clo.value("url")); - else if (confFileSettings.contains("default/url")) - baseURL = confFileSettings.value("default/url").toUrl(); - else - baseURL = DEFAULT_URL; + if (clo.contains("url")) + baseURL = QUrl(clo.value("url")); + else if (confFileSettings.contains("default/url")) + baseURL = confFileSettings.value("default/url").toUrl(); + else + baseURL = DEFAULT_URL; - if (clo.contains("downloadDir")) - downloadDirectory = QDir(clo.value("downloadDir")); - else if (confFileSettings.contains("default/downloadDirectory")) - downloadDirectory = QDir(confFileSettings.value("default/downloadDirectory").toString()); - else - downloadDirectory = QDir("."); - // Start fbgui. + if (clo.contains("downloadDir")) + downloadDirectory = QDir(clo.value("downloadDir")); + else if (confFileSettings.contains("default/downloadDirectory")) + downloadDirectory = QDir(confFileSettings.value("default/downloadDirectory").toString()); + else + downloadDirectory = QDir("."); + // Start fbgui. fbgui gui(&app); gui.show(); return app.exec(); |
