forked from gort818/qtwebflix
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
41 lines (35 loc) · 1.03 KB
/
main.cpp
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
#include "mainwindow.h"
#include <QApplication>
#include <QLibraryInfo>
#include <QWebEngineSettings>
#include <QWebEngineView>
#include <iostream>
#include <QIcon>
#include <QUrl>
#include <QFileDialog>
#include "qtws.h"
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QString filename;
if (argc < 2) {
filename = QFileDialog::getOpenFileName(nullptr, QString("Open configuration file"), QString(), QString("*.qtws|*.json"));
if (filename.length() == 0)
return -1;
} else {
filename = QString(argv[1]);
}
try {
QtWS *configHandler = new QtWS(filename);
app.setWindowIcon(QIcon(configHandler->getIconPath()));
MainWindow* w = new MainWindow(NULL, configHandler, &app);
w->show();
if (argc == 3) {
w->gotoUrl(QUrl(QString(argv[2])));
}
} catch (QString str) {
std::cout << str.toStdString();
// qWarning("Error: " + str.toLatin1() + ".");
return -1;
}
return app.exec();
}