#include "fbgui.h" #include "CommandLineOptions.h" #include "fbbrowser.h" #include "DownloadManager.h" #include #include #include void printUsage() { // 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= " << 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); } int main(int argc, char *argv[]) { // 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(); // 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. // TODO: fix short options parsing, doesn't work atm. 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(); }