summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonathan Bauer2011-03-05 20:42:59 +0100
committerJonathan Bauer2011-03-05 20:42:59 +0100
commitb50c681d6fac718f65abf58057889fcbe9b6aa10 (patch)
treeab6734b95f2710f50a5a793630a8c4a169cd3b43 /src
parentURL parsing now works with CommandLineOptions. Incomplete... (diff)
downloadfbgui-b50c681d6fac718f65abf58057889fcbe9b6aa10.tar.gz
fbgui-b50c681d6fac718f65abf58057889fcbe9b6aa10.tar.xz
fbgui-b50c681d6fac718f65abf58057889fcbe9b6aa10.zip
help fixed, misc cleanups...
Diffstat (limited to 'src')
-rw-r--r--src/CommandLineOptions.cpp5
-rw-r--r--src/DownloadManager.cpp3
-rw-r--r--src/fbgui.cpp25
3 files changed, 22 insertions, 11 deletions
diff --git a/src/CommandLineOptions.cpp b/src/CommandLineOptions.cpp
index 3b1fbd1..67135f2 100644
--- a/src/CommandLineOptions.cpp
+++ b/src/CommandLineOptions.cpp
@@ -29,11 +29,12 @@ CommandLineOptions::CommandLineOptions(int argc, char * const argv[]){
switch(opt)
{
case 'u':
- qDebug() << "Added URL to clOptions:" << optarg;
options.insert("url", optarg);
+ qDebug() << "Added URL to clOptions:" << optarg;
break;
case 'h':
- //printUsage();
+ options.insert("help", "help");
+ qDebug() << "Added help to clOptions.";
break;
}
opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
diff --git a/src/DownloadManager.cpp b/src/DownloadManager.cpp
index dc2502f..5bb5387 100644
--- a/src/DownloadManager.cpp
+++ b/src/DownloadManager.cpp
@@ -29,7 +29,6 @@ void DownloadManager::startNextDownload()
qDebug() << "Starting next download: " << dlQ.head().toString()
<< "(" << dlQ.size() << "in queue.)";
- // TODO: needed ?
if (dlQ.isEmpty())
{
qDebug() << "Download queue empty! Exiting...";
@@ -37,7 +36,6 @@ void DownloadManager::startNextDownload()
}
// Dequeue next URL to download.
QUrl url = dlQ.dequeue();
- //qDebug() << "Dequeueing..." << url.toString();
// Extract the filename from the URL
QString path = url.path();
QString basename = QFileInfo(path).fileName();
@@ -53,7 +51,6 @@ void DownloadManager::startNextDownload()
startNextDownload();
return;
}
- qDebug() << "spot 1";
// Start the request for this URL.
QNetworkRequest request(url);
currentDownload = qnam->get(request);
diff --git a/src/fbgui.cpp b/src/fbgui.cpp
index 6b70214..3fad734 100644
--- a/src/fbgui.cpp
+++ b/src/fbgui.cpp
@@ -27,24 +27,37 @@ int main(int argc, char *argv[])
// This is the main object of a QT Application.
QApplication a(argc, argv);
+ // Note: The QT arguments (-qws, -display etc) seems to be gone at this point.
+ // So we should be able to ignore the QT arguments when calling fbgui,
+ // and add them "manually" to argc/argv here? Testworthy!
+
/* SETTINGS TEST */
CommandLineOptions clOptions(argc, argv);
+
+ // Check if help was requested, if so printUsage() and exit.
+ if (clOptions.contains("help"))
+ {
+ qDebug() << "Help requested. Printing usage info. Exiting...";
+ printUsage();
+ // Not quite sure what the best exit statement is.
+ // Maybe better a.quit() ?
+ //exit(0);
+ // Probably use the EXIT_SUCCESS / EXIT_FAILURE constants as defined in "man exit"
+ return EXIT_SUCCESS;
+ }
+
+ // Check if URL was given at cmdline argument,
+ // if not set default.
QUrl url;
if (clOptions.contains("url"))
- {
- qDebug() << "URL from clOptions is: " << clOptions.value("url");
url = clOptions.value("url");
- }
else
url = QUrl("qrc:/html/errorPage.html");
- // TODO: parse url arg from CommmandLineOptions object.
-
/* SETTINGS TEST */
// Get the application path and prints on screen.
qDebug() << "Application Path: " << a.applicationDirPath();
- // Is this really needed, since we kill the app through the fbbrowser object?
QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
// Create a new Framebuffer-Browser object for displaying the given URL.