#include #include #include #include #include #include "fbgui.h" QMap options; void printHelp() { // Prints usage information. 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; } int main(int argc, char *argv[]) { QApplication *app = new QApplication(argc, argv, QApplication::GuiServer); app->setOrganizationName("team_projekt_2011"); app->setApplicationName("fbgui"); app->setObjectName("test"); // Initialise fbgui fbgui *gui = new fbgui(); gui->setParent(app); /* Parse cmdline argus. */ //qDebug() << "Received " << argc << "arguments:"; //for (int i = 0; i < argc; i++) // qDebug() << i + 1 << ": " << argv[i]; int longIndex = 0; static const char *optString = "u:h"; static const struct option longOpts[] = { {"url", required_argument, NULL, 'u'}, {"help", no_argument, NULL, 'h'} }; int opt = getopt_long(argc, argv, optString, longOpts, &longIndex); while (opt != -1) { switch(opt) { case 'u': options.insert("url", optarg); break; case 'h': options.insert("help", "help"); break; } opt = getopt_long(argc, argv, optString, longOpts, &longIndex); } // if (options.contains("help")) { printHelp(); exit(EXIT_SUCCESS); } // if (options.contains("url")) { QUrl url = options.value("url"); gui->setUrl(url); } else { std::cout << "No URL specified. Exiting..."; exit(EXIT_FAILURE); } // TODO: Read INI. // Start fbgui. gui->startBrowser(); return app->exec(); }