summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp46
1 files changed, 46 insertions, 0 deletions
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 <QMessageBox>
+#include <QApplication>
+#include <QKeyEvent>
+#include <QCommandLineParser>
+
+class KeyHandler : public QObject
+{
+public:
+ bool eventFilter(QObject *obj, QEvent *event)
+ {
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent *keyEvent = static_cast<QKeyEvent*>(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;
+}