summaryrefslogtreecommitdiffstats
path: root/src/fbgui.cpp
diff options
context:
space:
mode:
authorJonathan Bauer2011-03-05 16:09:54 +0100
committerJonathan Bauer2011-03-05 16:09:54 +0100
commitcf9609c876318f0c27914a723af915a9acfdbcc3 (patch)
treefcf2b5477835528b00c7ba3cacd7cd240ae57e86 /src/fbgui.cpp
parentwebkitTest.html: resetting of progress bar when download finishes. (diff)
downloadfbgui-cf9609c876318f0c27914a723af915a9acfdbcc3.tar.gz
fbgui-cf9609c876318f0c27914a723af915a9acfdbcc3.tar.xz
fbgui-cf9609c876318f0c27914a723af915a9acfdbcc3.zip
Command line options parsing moved to its own class, in preparation for Settings
Diffstat (limited to 'src/fbgui.cpp')
-rw-r--r--src/fbgui.cpp61
1 files changed, 22 insertions, 39 deletions
diff --git a/src/fbgui.cpp b/src/fbgui.cpp
index 8cd58bc..5552643 100644
--- a/src/fbgui.cpp
+++ b/src/fbgui.cpp
@@ -1,16 +1,20 @@
#include "fbgui.h"
+#include "CommandLineOptions.h"
#include "fbbrowser.h"
#include "DownloadManager.h"
-#include <getopt.h>
-#include <limits.h>
-#include <unistd.h>
+
#include <QApplication>
-#include <QThread>
+#include <QSettings>
+
+//#include <getopt.h>
+//#include <limits.h>
+//#include <unistd.h>
+
void printUsage()
{
- // Prints usage information, incomplete.
- // Q: How is the -qws option handled, mention it here or not?
+ // Prints usage information.
+ // TODO: Complete usage info.
QTextStream qout(stdout);
qout << QObject::tr("Usage: ./fbgui [OPTIONS] <URL>") << endl;
qout << QObject::tr("Options:") << endl;
@@ -22,45 +26,24 @@ void printUsage()
int main(int argc, char *argv[])
{
- // Parse command line arguments.
- int opt = 0;
- int longIndex = 0;
- // Declare the short options as a char*, these have exactly one - followed by letter from optString.
- // For example: ./fbbrowser -h
- // Declare the long options in the const struct, these have two - followed by a string found in longOpts[].
- // Same as: ./fbbrowser --help
- // Note: I included 'qws' here to not have errors, when setting fbbrowser to be the server app aswell.
- static const char *optString = "hqwsdiplay";
- static const struct option longOpts[] =
- {
- // If an option requires parameters, write this number instead of no_argument.
- // The last argument, is the corresponding char to the option string.
- {"help", no_argument, NULL, 'h'}
- };
- // getopt_long returns the index of the next argument to be read, -1 if there are no more arguments.
- opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
- while (opt != -1)
- {
- switch(opt)
- {
- case 'h':
- printUsage();
- break;
- }
- opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
- }
+ /* SETTINGS TEST */
+ //CommandLineOptions clOptions(argc, argv);
+
+ // TODO: parse url arg from CommmandLineOptions object.
+ // hackfix for now...
+ QUrl url(argv[4]);
+ QUrl defaultUrl = QUrl("http://132.230.4.3/webkitTest.html");
+ qDebug() << "URL given: " << url.toString();
+
+ /* SETTINGS TEST */
+
// This is the main object of a QT Application.
QApplication a(argc, argv);
// 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()));
- // This part reads the URL to load from the arguments given through the commandline.
- QUrl url;
- if (argc > 1)
- url = QUrl(argv[1]);
- else //Default URL to load
- url = QUrl("http://132.230.4.3/webkitTest.html");
+
// Create a new Framebuffer-Browser object for displaying the given URL.
fbbrowser* fbb = new fbbrowser(url);