aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
blob: ef6a5e13d35c555dbeb622e7631b15f0c0b6684c (plain)
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
#include "browser.h"
#include "mainwindow.h"
#include <QApplication>
#include <QCommandLineParser>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    app.setApplicationName("smolbote");
    app.setApplicationVersion("0.0.0");

    QCommandLineParser parser;
    parser.setApplicationDescription("Test browser using QtWebEngine");
    parser.addHelpOption();
    parser.addVersionOption();

    parser.addPositionalArgument("URL", "URL to open");

    QCommandLineOption configOption(QStringList() << "c" << "config", "Set configuration file.", "PATH");
    parser.addOption(configOption);

    parser.process(app);

    Browser instance(parser.value(configOption));

    if(parser.positionalArguments().length() > 0) {
        QUrl url = QUrl::fromUserInput(parser.positionalArguments().at(0));
        if(url.isValid()) {
            instance.addWindow(new MainWindow(&instance, url));
        } else {
            instance.addWindow(new MainWindow(&instance));
        }
    } else {
        instance.addWindow(new MainWindow(&instance));
    }

    return app.exec();
}