blob: 9ac77483b6def2fcd56250fc51730d7b266dc591 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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("fullscreen", "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;
}
|