diff options
| author | Jonathan Bauer | 2011-01-25 16:17:12 +0100 |
|---|---|---|
| committer | Jonathan Bauer | 2011-01-25 16:17:12 +0100 |
| commit | c8b822a69d424d61d4d7b8c7ded80238e1212623 (patch) | |
| tree | 0f9bbf73dd14f1622fa2fee4938969e9702751ce | |
| parent | Updated code structure... (diff) | |
| download | fbgui-c8b822a69d424d61d4d7b8c7ded80238e1212623.tar.gz fbgui-c8b822a69d424d61d4d7b8c7ded80238e1212623.tar.xz fbgui-c8b822a69d424d61d4d7b8c7ded80238e1212623.zip | |
new try...
| -rw-r--r-- | fbbrowser/fbgui.cpp | 83 | ||||
| -rw-r--r-- | fbbrowser/fbgui.h | 27 | ||||
| -rw-r--r-- | fbbrowser/fbgui.o | bin | 0 -> 320592 bytes | |||
| -rw-r--r-- | fbbrowser/fbgui.pro | 12 | ||||
| -rw-r--r-- | fbbrowser/fbgui.qrc | 5 |
5 files changed, 127 insertions, 0 deletions
diff --git a/fbbrowser/fbgui.cpp b/fbbrowser/fbgui.cpp new file mode 100644 index 0000000..4d34fa9 --- /dev/null +++ b/fbbrowser/fbgui.cpp @@ -0,0 +1,83 @@ +#include "fbbrowser.h" + +#include <QtGui> +#include <QApplication> +#include <iostream> +#include <getopt.h> +#include <fbgui.h> + + +void printUsage() +{ + // Prints usage information, incomplete. + // Q: How is the -qws option handled, mention it here or not? + QTextStream qout(stdout); + qout << QObject::tr("Usage: ./fbbrowser [OPTIONS] <URL>") << endl; + qout << QObject::tr("Options:") << endl; + qout << "-h or --help " << QObject::tr("Prints usage information.") << endl; + qout << "-qws " << QObject::tr("Set this application to also be the server application.") << endl; + qout << " " << QObject::tr("Skip this option if you have a QT server application") << endl; + exit(1); +} + +QString getPath(const char* c) +{ + QString appPath = c; + // Locate last '/' in the full path and remove all the chars after it. + appPath.chop(appPath.length() - 1 + - appPath.lastIndexOf("/", appPath.length()-1)); + qDebug() << "Application path: " << appPath; + return appPath; +} + +int main(int argc, char *argv[]) +{ + // Parse command line arguments. + int opt = 1; + 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 = "hqws"; + 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); + } + // This is the main object of a QT Application. + QApplication a(argc, argv); + // Is this really needed, since we kill the app through the fbbrowser object? + QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); + // Get the application path. + QString appPath = getPath(argv[0]); + // 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); + // Listen to the signalQuitAll() Signal to kill the app from within the browser. + QObject::connect(fbb, SIGNAL(signalQuitAll()), &a, SLOT(quit())); + // Display the browser. + fbb->show(); + + // Exit the application. + return a.exec(); +} diff --git a/fbbrowser/fbgui.h b/fbbrowser/fbgui.h new file mode 100644 index 0000000..4d387a6 --- /dev/null +++ b/fbbrowser/fbgui.h @@ -0,0 +1,27 @@ +#ifndef FBGUI_H +#define FBGUI_H + +#include <QtGui> + + +//QT_BEGIN_NAMESPACE +//QT_END_NAMESPACE + +class fbgui : public QMainWindow +{ + Q_OBJECT + +public: + fbgui(); + ~fbgui(); + void printUsage(); + +//private: + +//private slots: + +//signals: + +}; + +#endif // FBGUI_H diff --git a/fbbrowser/fbgui.o b/fbbrowser/fbgui.o Binary files differnew file mode 100644 index 0000000..c79ce7a --- /dev/null +++ b/fbbrowser/fbgui.o diff --git a/fbbrowser/fbgui.pro b/fbbrowser/fbgui.pro new file mode 100644 index 0000000..c1bcf82 --- /dev/null +++ b/fbbrowser/fbgui.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +TARGET = fbgui +CONFIG += qt debug +QT += core \ + gui \ + webkit \ + network +HEADERS += fbbrowser.h +SOURCES += fbgui.cpp \ + fbbrowser.cpp +FORMS += fbbrowser.ui +RESOURCES += fbgui.qrc diff --git a/fbbrowser/fbgui.qrc b/fbbrowser/fbgui.qrc new file mode 100644 index 0000000..da051a4 --- /dev/null +++ b/fbbrowser/fbgui.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> + <qresource> + <file>html/errorPage.html</file> + </qresource> + </RCC> |
