66 lines
2.5 KiB
C++
66 lines
2.5 KiB
C++
#include <iostream>
|
|
#include <QTranslator>
|
|
#include "sui_base_config.h"
|
|
#include "sui_base_ex.h"
|
|
#include "ctai.h"
|
|
#include <QApplication>
|
|
#include <QCefContext.h>
|
|
#include "QCefWidget/CefWidget.h"
|
|
int main(int argc, char *argv[])
|
|
{
|
|
QString exeDir = QDir::currentPath();
|
|
QCoreApplication::addLibraryPath(exeDir+"/cef_binary/Release");
|
|
qDebug()<<"error:"<<exeDir;
|
|
QApplication a(argc, argv);
|
|
QCefConfig config;
|
|
config.setUserAgent("QCefViewTest");
|
|
config.setLogLevel(QCefConfig::LOGSEVERITY_VERBOSE);
|
|
config.setBridgeObjectName("CallBridge");
|
|
config.setBuiltinSchemeName("CefView");
|
|
config.setWindowlessRenderingEnabled(true);
|
|
config.addCommandLineSwitch("single-process");
|
|
config.addCommandLineSwitch("use-alloy-style");
|
|
config.addCommandLineSwitch("off-screen-rendering-enabled");
|
|
config.addCommandLineSwitch("multi-threaded-message-loop");
|
|
config.addCommandLineSwitch("external-message-pump");
|
|
config.addCommandLineSwitch("enable-chrome-runtime");
|
|
config.addCommandLineSwitch("enable-gpu");
|
|
config.addCommandLineSwitch("use-views");
|
|
config.addCommandLineSwitch("site-per-process");
|
|
config.addCommandLineSwitch("no-sandbox");
|
|
config.addCommandLineSwitch("in-process-gpu");
|
|
config.addCommandLineSwitch("use-mock-keychain");
|
|
config.addCommandLineSwitchWithValue("ignore-certificate-errors","true");
|
|
config.addCommandLineSwitchWithValue("enable-gpu-rasterizatio","true");
|
|
config.addCommandLineSwitchWithValue("enable-accelerated-video","true");
|
|
config.addCommandLineSwitchWithValue("use-fake-ui-for-media-stream","true");
|
|
config.addCommandLineSwitchWithValue("use-fake-device-for-media-stream","true");
|
|
config.addCommandLineSwitchWithValue("renderer-process-limit", "1");
|
|
config.addCommandLineSwitchWithValue("disable-features", "BlinkGenPropertyTrees,TranslateUI,site-per-process");
|
|
QCefContext cefContext(&a, argc, argv, &config);
|
|
CefWidget cw;
|
|
cw.show();
|
|
|
|
qputenv("QT_QPA_PLATFORM", "windows:fontengine=freetype");
|
|
// 加载语言包
|
|
QTranslator qtBaseTranslator;
|
|
if (!qtBaseTranslator.load(QStringLiteral(":/res/translator/qtbase_zh_CN.qm")))
|
|
{
|
|
// 处理加载翻译文件失败的情况
|
|
qDebug() << "Failed to load translation file.";
|
|
return -1;
|
|
}
|
|
a.installTranslator(&qtBaseTranslator);
|
|
// 读取窗体的配置并初始化
|
|
sui_init_config();
|
|
ctai x;
|
|
x.init_layout();
|
|
// 仅限于windows平台
|
|
#if defined(__WIN32__)
|
|
x.title()->set_type(QD_TYPE::QD_EXIT);
|
|
#endif
|
|
x.show();
|
|
return a.exec();
|
|
}
|
|
|