#include "slxbrowser.h" #include #include #include #include class KeyHandler : public QObject { public: bool eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast(event); if ( keyEvent->key() == Qt::Key_Q && (keyEvent->modifiers() & Qt::ControlModifier)) exit(0); } return QObject::eventFilter(obj, event); } }; /** * MAIN */ int main(int argc, char** argv) { QApplication app(argc, argv); QCommandLineParser parser; parser.addHelpOption(); parser.addPositionalArgument("url", "URL to load"); QCommandLineOption ignoreSsl("insecure", "Ignore SSL errors"); QCommandLineOption fullscreen("full-screen", "Run browser in full screen"); parser.addOption(ignoreSsl); parser.addOption(fullscreen); parser.process(app); QStringList list(parser.positionalArguments()); if (list.empty()) { QMessageBox::critical(NULL, "Error", "Need one argument: file name"); return 1; } QString url(list[0]); SLXbrowser main(url, parser.isSet(fullscreen), parser.isSet(ignoreSsl)); main.show(); app.installEventFilter(new KeyHandler()); app.exec(); return 0; }