diff options
author | Jonathan Bauer | 2011-03-06 12:08:34 +0100 |
---|---|---|
committer | Jonathan Bauer | 2011-03-06 12:08:34 +0100 |
commit | 5443c7182151c7f9082e58f207d7c88e11826d08 (patch) | |
tree | 47913f4393444d1aeec838adc2d85c5961bae024 /src/fbgui.cpp | |
parent | url short option fixed (diff) | |
download | fbgui-5443c7182151c7f9082e58f207d7c88e11826d08.tar.gz fbgui-5443c7182151c7f9082e58f207d7c88e11826d08.tar.xz fbgui-5443c7182151c7f9082e58f207d7c88e11826d08.zip |
updated code structure, main loop now separate from fbgui class.......
Diffstat (limited to 'src/fbgui.cpp')
-rw-r--r-- | src/fbgui.cpp | 78 |
1 files changed, 11 insertions, 67 deletions
diff --git a/src/fbgui.cpp b/src/fbgui.cpp index d7fc65e..4ae9174 100644 --- a/src/fbgui.cpp +++ b/src/fbgui.cpp @@ -1,77 +1,21 @@ #include "fbgui.h" -#include "CommandLineOptions.h" #include "fbbrowser.h" #include "DownloadManager.h" -#include <QApplication> -#include <QSettings> +#include <iostream> #include <QUrl> -void printUsage() +fbgui::fbgui(QApplication *parent) { - // Prints usage information. - // TODO: Complete usage info. - QTextStream qout(stdout); - 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 << "-h, --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); + // Test if parent is accessible? + qDebug() << "Still alive?"; + qDebug() << "Parent name: " << parent->objectName(); + /* Create the browser and connect to quit() */ + fbb = new fbbrowser(QUrl("http://132.230.4.3/webkitTest.html")); + QObject::connect(fbb, SIGNAL(killApp()), parent, SLOT(quit())); + fbb->show(); } - -int main(int argc, char *argv[]) +fbgui::~fbgui() { - // This is the main object of a QT Application. - // The third argument sets the application as the GUI-Server, - // so the same as using "-qws" when calling the application. - QApplication a(argc, argv, QApplication::GuiServer); - a.setQuitOnLastWindowClosed(true); - - // 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); - - // TODO: Use QSettings for accessing the ini file but - // check first if option was set from cmdline. - // (if it was, dont set it from ini). - - // Check if help was requested, if so printUsage() and exit. - if (clOptions.contains("help")) - { - qDebug() << "Help requested. Printing usage info. Exiting..."; - printUsage(); - return EXIT_SUCCESS; - } - - // Check if URL was given at cmdline argument, if not set default. - QUrl url; - if (clOptions.contains("url")) - url = clOptions.value("url"); - else - url = QUrl("qrc:/html/errorPage.html"); - /* SETTINGS TEST */ - - - // Get the application path and prints on screen. - qDebug() << "Application Path: " << a.applicationDirPath(); -; - - // 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(killApp()), &a, SLOT(quit())); - // Alternative - - - // Display the browser. - fbb->show(); - - // Execute the application. - return a.exec(); + delete fbb; } |