blob: 6c53756924ba5951f1cd3f865be9a246426b27f3 (
plain) (
tree)
|
|
#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;
}
|