From f5663edb4e1a53b6d80de909f2888ffd9ee1e170 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 7 Jul 2017 15:21:28 +0200 Subject: FIRST!!!1 --- src/main.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/main.cpp (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..6c53756 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,46 @@ +#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; +} -- cgit v1.2.3-55-g7522