#include #include #include #include #include #include #include "fbgui.h" extern QUrl baseURL; 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(argc, argv, QApplication::GuiServer); app.setOrganizationName("team_projekt_2011"); app.setApplicationName("fbgui"); app.setObjectName("test"); // Translator, for later (maybe). QTranslator translator; translator.load(":" + QLocale::system().name()); app.installTranslator(&translator); /* Parse cmdline argus. */ QMap clo; 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': clo.insert("url", optarg); break; case 'h': clo.insert("help", "help"); break; } opt = getopt_long(argc, argv, optString, longOpts, &longIndex); } if (clo.contains("help")) { printHelp(); exit(EXIT_SUCCESS); } // Read the config file, for now hardcoded expected name. QSettings confFileSettings(app.applicationDirPath() + "/fbgui.conf", QSettings::IniFormat); confFileSettings.setIniCodec("UTF-8"); if (clo.contains("url")) baseURL = clo.value("url"); else if (confFileSettings.contains("default/url")) baseURL = confFileSettings.value("default/url").toUrl(); else baseURL = DEFAULT_URL; // Start fbgui. fbgui *gui = new fbgui(); gui->setParent(&app); gui->startBrowser(); return app.exec(); }