-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
67 lines (52 loc) · 1.88 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
59
60
61
62
63
64
65
66
67
#include "mainwindow.h"
#include <DApplication>
#include <QDesktopWidget>
#include <QDir>
#include <qcef_context.h>
#include <qcef_util.h>
DWIDGET_USE_NAMESPACE
const char kPlatformThemeName[] = "QT_QPA_PLATFORMTHEME";
const char kGtk2Theme[] = "gtk2";
int main(int argc, char *argv[])
{
// If platform theme name is empty, fallback to gtk2.
// gtk2 theme is included in libqt5libqgtk2 package.
if (qgetenv(kPlatformThemeName) != kGtk2Theme) {
qputenv(kPlatformThemeName, kGtk2Theme);
}
QCefGlobalSettings settings;
// Do not use sandbox.
settings.setNoSandbox(true);
// Flash plugin only works on x86 platform.
if (IsX86Architecture()) {
// Pepper flash plugin crashes on chromium 60
// settings.setPepperFlash(true);
}
// Use socks5 proxy.
// settings.setProxyServer("socks5://127.0.0.1:1080");
// Open http://localhost:9222 in chromium browser to see dev tools.
settings.setRemoteDebug(true);
settings.setLogSeverity(QCefGlobalSettings::LogSeverity::Info);
// Register user script.
settings.registerUserScript(":/resources/user_script.js",
QUrl("qrc://resources/user_script.js"));
// Disable GPU process.
settings.addCommandLineSwitch("--disable-gpu", "");
// Enable aggressive storage commit to minimize data loss.
// See public/common/content_switches.cc.
settings.addCommandLineSwitch("--enable-aggressive-domstorage-flushing", "");
const int exit_code = QCefInit(argc, argv, settings);
if (exit_code >= 0) {
return exit_code;
}
DApplication::loadDXcbPlugin();
DApplication a(argc, argv);
a.setTheme("light");
MainWindow w;
w.resize(322, 495);
w.show();
w.move((QApplication::desktop()->width() - w.width()) / 2,
(QApplication::desktop()->height() - w.height()) / 2);
QCefBindApp(&a);
return a.exec();
}