forked from shownb/FBrowser
-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.cpp
58 lines (48 loc) · 1.52 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <QApplication>
#include "config.h"
#ifdef FULLBROWSER
#include "browser.h"
#include "browserwindow.h"
#include "tabwidget.h"
#include <QWebEngineProfile>
#include <QWebEngineSettings>
#include <QtWebEngineWidgets/QWebEngineSettings>
#include <QtWebEngineWidgets/QWebEngineProfile>
QUrl commandLineUrlArgument()
{
const QStringList args = QCoreApplication::arguments();
for (const QString &arg : args.mid(1)) {
if (!arg.startsWith(QLatin1Char('-')))
return QUrl::fromUserInput(arg);
}
return QUrl(QStringLiteral("https://www.google.com"));
}
#else
#include "mainwindow.h"
#endif
int main(int argc, char *argv[])
{
QCoreApplication::setOrganizationName("e1z0");
QApplication a(argc, argv);
#ifdef FULLBROWSER
qDebug() << "full browser mode enabled";
// fix font
QFont font;
font.setPixelSize(12);
a.setFont(font);
a.setWindowIcon(QIcon(QStringLiteral(":AppLogoColor.png")));
QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::PluginsEnabled, true);
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::DnsPrefetchEnabled, true);
QWebEngineProfile::defaultProfile()->setUseForGlobalCertificateVerification();
#endif
QUrl url = commandLineUrlArgument();
Browser browser;
BrowserWindow *window = browser.createWindow();
window->tabWidget()->setUrl(url);
#else
MainWindow* mainWindow = new MainWindow();
mainWindow->show();
#endif
return a.exec();
}