summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorJonathan Bauer2011-03-08 23:12:12 +0100
committerJonathan Bauer2011-03-08 23:12:12 +0100
commit0c6fa0dbb3522f643e6916092a310ad0a2622044 (patch)
tree583afb1bbb4a8a3185adecfa14bf128b865b2e2f /src/main.cpp
parentchanged testcode back to what it was supposed to be :P (diff)
downloadfbgui-0c6fa0dbb3522f643e6916092a310ad0a2622044.tar.gz
fbgui-0c6fa0dbb3522f643e6916092a310ad0a2622044.tar.xz
fbgui-0c6fa0dbb3522f643e6916092a310ad0a2622044.zip
misc
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp52
1 files changed, 31 insertions, 21 deletions
diff --git a/src/main.cpp b/src/main.cpp
index bd4951d..b53f25e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -13,7 +13,7 @@ void printHelp()
qout << QObject::tr("Usage: ./fbgui [OPTIONS]") << endl;
qout << QObject::tr("Options:") << endl;
qout << "-u <URL>, --url=<URL> " << QObject::tr("Set which URL to load.") << endl;
- qout << "-d <dir>, --downloaddir <dir> " << QObject::tr("Specifiy the download directory.") << endl;
+ qout << "-d <dir>, --downloaddir=<dir> " << QObject::tr("Specifiy the download directory.") << endl;
qout << "-D, --debug " << QObject::tr("Activate debug mode.") << endl;
qout << "-h, --help " << QObject::tr("Prints usage information.") << endl;
qout.flush();
@@ -34,7 +34,7 @@ int main(int argc, char *argv[])
app.installTranslator(&translator);
/* Parse cmdline argus. */
- QMap<QString, QString> clo;
+ QMap<QString, QString> clOpts;
int longIndex = 0;
static const char *optString = "u:hDd:";
static const struct option longOpts[] =
@@ -42,7 +42,7 @@ int main(int argc, char *argv[])
{"url", required_argument, NULL, 'u'},
{"downloaddir", required_argument, NULL, 'd'},
{"debug", no_argument, NULL, 'D'},
- {"help", no_argument, NULL, 'h'}
+ {"help", no_argument, NULL, 'h'}
};
int opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
while (opt != -1)
@@ -50,25 +50,25 @@ int main(int argc, char *argv[])
switch(opt)
{
case 'u':
- clo.insert("url", optarg);
+ clOpts.insert("url", optarg);
break;
case 'd':
- clo.insert("downloadDir", optarg);
+ clOpts.insert("downloadDir", optarg);
break;
case 'D':
- clo.insert("debug", "debug");
+ clOpts.insert("debug", "debug");
break;
case 'h':
- clo.insert("help", "help");
+ clOpts.insert("help", "help");
break;
}
opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
}
// Print help
- if (clo.contains("help"))
+ if (clOpts.contains("help"))
printHelp();
// Debug mode
- if (clo.contains("debug")){
+ if (clOpts.contains("debug")){
debug = true;
qDebug() << "Debug mode activated.";
}
@@ -76,28 +76,38 @@ int main(int argc, char *argv[])
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 (clOpts.contains("url")) {
+ baseURL = QUrl(clOpts.value("url"));
+ if (debug) qDebug() << "URL loaded from cmdline.";
+ }
+ else if (confFileSettings.contains("default/url")) {
+ baseURL = confFileSettings.value("default/url").toUrl();
+ if (debug) qDebug() << "URL loaded from config file.";
+ }
+ else {
+ baseURL = DEFAULT_URL;
+ if (debug) qDebug() << "URL set by default.";
+ }
if (debug) qDebug() << "Base URL: " << baseURL.toString();
// Setting target downloads directory.
- if (clo.contains("downloadDir")){
- downloadPath = clo.value("downloadDir");
+ if (clOpts.contains("downloadDir")){
+ downloadPath = clOpts.value("downloadDir");
+ if (debug) qDebug() << "Download directory loaded from cmdline.";
}
else if (confFileSettings.contains("default/downloadDirectory")){
downloadPath = confFileSettings.value("default/downloadDirectory").toString();
+ if (debug) qDebug() << "Download directory loaded from config file.";
}
else
+ {
downloadPath = "/downloads"; // Default download dir.
+ if (debug) qDebug() << "Download directory set by default.";
+ }
if (debug) qDebug() << "Download directory: " << downloadPath;
- // Start fbgui.
- fbgui gui(&app);
- gui.setAttribute(Qt::WA_QuitOnClose, true);
- gui.show();
+
+ fbgui gui;
+ gui.setAttribute(Qt::WA_QuitOnClose, true);
return app.exec();
}