无滞留进程
This commit is contained in:
parent
0245968901
commit
0bd903f5fd
BIN
3rdparty/QCefView/lib/libQCefView.a
vendored
BIN
3rdparty/QCefView/lib/libQCefView.a
vendored
Binary file not shown.
@ -17,6 +17,7 @@
|
|||||||
<file name="vk_swiftshader.dll" loadFrom=".\cef_binary\vk_swiftshader.dll"></file>
|
<file name="vk_swiftshader.dll" loadFrom=".\cef_binary\vk_swiftshader.dll"></file>
|
||||||
<file name="vk_swiftshader_icd.json" loadFrom=".\cef_binary\vk_swiftshader_icd.json"></file>
|
<file name="vk_swiftshader_icd.json" loadFrom=".\cef_binary\vk_swiftshader_icd.json"></file>
|
||||||
<file name="vulkan-1.dll" loadFrom=".\cef_binary\vulkan-1.dll"></file>
|
<file name="vulkan-1.dll" loadFrom=".\cef_binary\vulkan-1.dll"></file>
|
||||||
|
<file name="ffmpegsumo.dll" loadFrom=".\cef_binary\ffmpegsumo.dll"></file>
|
||||||
|
|
||||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
<security>
|
<security>
|
||||||
|
|||||||
@ -52,10 +52,7 @@ CefWidget::CefWidget(QWidget *parent)
|
|||||||
m_Layout->setStretch(1, 8);
|
m_Layout->setStretch(1, 8);
|
||||||
setBaseSize(QSize(width(),height()));
|
setBaseSize(QSize(width(),height()));
|
||||||
setLayout(m_Layout);
|
setLayout(m_Layout);
|
||||||
setWindowFlags(Qt::Window); // 使用标准窗口样式
|
|
||||||
setAttribute(Qt::WA_TranslucentBackground, false);
|
|
||||||
initBrowser();
|
initBrowser();
|
||||||
setObjectName("CefWidget");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CefWidget::~CefWidget()
|
CefWidget::~CefWidget()
|
||||||
@ -71,7 +68,7 @@ void CefWidget::initBrowser()
|
|||||||
}
|
}
|
||||||
setting.setWindowlessFrameRate(1000);
|
setting.setWindowlessFrameRate(1000);
|
||||||
setting.setHardwareAcceleration(true);
|
setting.setHardwareAcceleration(true);
|
||||||
m_CefWidget = new CefViewWidget("about:blank", &setting, this);
|
m_CefWidget = new QCefView("about:blank", &setting, this);
|
||||||
connect(m_CefWidget, &QCefView::invokeMethod, this, &CefWidget::onInvokeMethod);
|
connect(m_CefWidget, &QCefView::invokeMethod, this, &CefWidget::onInvokeMethod);
|
||||||
connect(m_CefWidget, &QCefView::cefUrlRequest, this, &CefWidget::onQCefUrlRequest);
|
connect(m_CefWidget, &QCefView::cefUrlRequest, this, &CefWidget::onQCefUrlRequest);
|
||||||
connect(m_CefWidget, &QCefView::cefQueryRequest, this, &CefWidget::onQCefQueryRequest);
|
connect(m_CefWidget, &QCefView::cefQueryRequest, this, &CefWidget::onQCefQueryRequest);
|
||||||
@ -156,6 +153,7 @@ void CefWidget::onInvokeMethod(const QCefBrowserId &browserId,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,8 +7,8 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
//#include <QCefView.h>
|
#include <QCefView.h>
|
||||||
#include "CefViewWidget.h"
|
//#include "CefViewWidget.h"
|
||||||
class CefWidget : public QWidget
|
class CefWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -32,14 +32,12 @@ private:
|
|||||||
QLineEdit* m_TextToUrl={};
|
QLineEdit* m_TextToUrl={};
|
||||||
QPushButton* m_BtnToUrl={};
|
QPushButton* m_BtnToUrl={};
|
||||||
QPushButton* m_BtnToString={};
|
QPushButton* m_BtnToString={};
|
||||||
CefViewWidget* m_CefWidget ={};
|
QCefView* m_CefWidget ={};
|
||||||
QCefSetting setting;
|
QCefSetting setting;
|
||||||
bool DevMode=true;
|
bool DevMode=true;
|
||||||
QString html_template;
|
QString html_template;
|
||||||
protected:
|
|
||||||
void createLeftCefView();
|
|
||||||
// QCefView slots
|
// QCefView slots
|
||||||
protected slots:
|
public slots:
|
||||||
void onInvokeMethod(const QCefBrowserId& browserId,
|
void onInvokeMethod(const QCefBrowserId& browserId,
|
||||||
const QCefFrameId& frameId,
|
const QCefFrameId& frameId,
|
||||||
const QString& method,
|
const QString& method,
|
||||||
@ -60,7 +58,7 @@ protected slots:
|
|||||||
const QString& errorMsg,
|
const QString& errorMsg,
|
||||||
const QString& failedUrl);
|
const QString& failedUrl);
|
||||||
//ui slots
|
//ui slots
|
||||||
protected slots:
|
public slots:
|
||||||
void onBtnShowDevToolsClicked();
|
void onBtnShowDevToolsClicked();
|
||||||
void onBtnSetFocusClicked();
|
void onBtnSetFocusClicked();
|
||||||
void onBtnCallJSCodeClicked();
|
void onBtnCallJSCodeClicked();
|
||||||
|
|||||||
68
src/main.cpp
68
src/main.cpp
@ -5,10 +5,9 @@
|
|||||||
#include "sui_base_ex.h"
|
#include "sui_base_ex.h"
|
||||||
#include "ctai.h"
|
#include "ctai.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QStandardPaths>
|
|
||||||
#include <QCefContext.h>
|
#include <QCefContext.h>
|
||||||
#include "QCefWidget/CefWidget.h"
|
#include "QCefWidget/CefWidget.h"
|
||||||
#define DEBUG_PRINT true
|
#define DEBUG_PRINT false
|
||||||
void debug_print_argv(int argc, char *argv[])
|
void debug_print_argv(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (!argc)
|
if (!argc)
|
||||||
@ -63,48 +62,42 @@ void initConfig(int argc, char *argv[], QCefConfig &config, QString currentDir)
|
|||||||
config.setCachePath(currentDir + "/user/userCache");
|
config.setCachePath(currentDir + "/user/userCache");
|
||||||
config.setResourceDirectoryPath(currentDir + "/cef_binary");
|
config.setResourceDirectoryPath(currentDir + "/cef_binary");
|
||||||
config.setLocalesDirectoryPath(currentDir + "/cef_binary/locales");
|
config.setLocalesDirectoryPath(currentDir + "/cef_binary/locales");
|
||||||
|
config.setBridgeObjectName("CallBridge");
|
||||||
|
config.setBuiltinSchemeName("CefView");
|
||||||
// 浏览器标识
|
// 浏览器标识
|
||||||
config.setUserAgent("Mozilla/5.0 (Windows NT 10.0; CEF/3.2272.2035) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 SoftwareInformer/1.6.1400");
|
config.setUserAgent("Mozilla/5.0 (Windows NT 10.0; CEF/3.2272.2035) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 SoftwareInformer/1.6.1400");
|
||||||
// 日志输出级别
|
// 日志输出级别
|
||||||
config.setLogLevel(QCefConfig::LOGSEVERITY_VERBOSE);
|
config.setLogLevel(QCefConfig::LOGSEVERITY_VERBOSE);
|
||||||
// 桥名字
|
|
||||||
config.setBridgeObjectName("CtaiClient");
|
|
||||||
// 内置的协议方案名称
|
|
||||||
config.setBuiltinSchemeName("Ctai");
|
|
||||||
// 无窗口渲染模式
|
// 无窗口渲染模式
|
||||||
// config.setWindowlessRenderingEnabled(true);
|
config.setWindowlessRenderingEnabled(false);
|
||||||
// 远程Debug端口
|
// 远程Debug端口
|
||||||
// config.setRemoteDebuggingPort(9000);
|
// config.setRemoteDebuggingPort(9000);
|
||||||
// 请求头的语言
|
// 请求头的语言
|
||||||
config.setAcceptLanguageList("zh-CN");
|
config.setAcceptLanguageList("zh-CN");
|
||||||
// 允许忽略 localhost 上的 TLS/SSL 错误
|
// 允许忽略 localhost 上的 TLS/SSL 错误
|
||||||
config.addCommandLineSwitch("allow-insecure-localhost");
|
|
||||||
config.addCommandLineSwitch("ignore-certificate-errors-spki-list");
|
config.addCommandLineSwitch("ignore-certificate-errors-spki-list");
|
||||||
config.addCommandLineSwitch("ignore-ssl-errors");
|
config.addCommandLineSwitch("ignore-ssl-errors");
|
||||||
// 单进程模式
|
// 单进程模式
|
||||||
// config.addCommandLineSwitch("single-process");
|
// config.addCommandLineSwitch("single-process");
|
||||||
// 启用GPU加速
|
// 启用GPU加速
|
||||||
config.addCommandLineSwitch("enable-gpu");
|
config.addCommandLineSwitch("enable-gpu");
|
||||||
// GPU加速合成
|
// GPU加速合成
|
||||||
config.addCommandLineSwitch("enable-gpu-compositing");
|
//config.addCommandLineSwitch("enable-gpu-compositing");
|
||||||
// 在进程中使用GPU渲染-开启后只有一个进程
|
// 在进程中使用GPU渲染-开启后只有一个进程
|
||||||
config.addCommandLineSwitch("in-process-gpu");
|
//config.addCommandLineSwitch("in-process-gpu");
|
||||||
// 无头模式
|
// 无头模式
|
||||||
// config.addCommandLineSwitch("headless");
|
// config.addCommandLineSwitch("headless");
|
||||||
// 密钥链
|
|
||||||
config.addCommandLineSwitch("use-mock-keychain");
|
|
||||||
// chrome运行时环境
|
// chrome运行时环境
|
||||||
config.addCommandLineSwitch("enable-chrome-runtime");
|
config.addCommandLineSwitch("enable-chrome-runtime");
|
||||||
// Alloy 风格
|
|
||||||
config.addCommandLineSwitch("use-alloy-style");
|
|
||||||
// 离屏渲染
|
// 离屏渲染
|
||||||
// config.addCommandLineSwitch("off-screen-rendering-enabled");
|
config.addCommandLineSwitch("off-screen-rendering-enabled");
|
||||||
// 网络服务In进程
|
// 网络服务In进程
|
||||||
config.addCommandLineSwitchWithValue("enable-features", "NetworkServiceInProcess");
|
//config.addCommandLineSwitchWithValue("enable-features", "NetworkServiceInProcess");
|
||||||
// 语言
|
// 语言
|
||||||
config.addCommandLineSwitchWithValue("lang", "zh-CN");
|
config.addCommandLineSwitchWithValue("lang", "zh-CN");
|
||||||
// 跨域进行远程
|
// 跨域进行远程
|
||||||
// config.addCommandLineSwitchWithValue("remote-allow-origins", "*");
|
// config.addCommandLineSwitchWithValue("remote-allow-origins", "*");
|
||||||
|
|
||||||
// 禁用沙盒
|
// 禁用沙盒
|
||||||
config.addCommandLineSwitchWithValue("no-sandbox", "ture");
|
config.addCommandLineSwitchWithValue("no-sandbox", "ture");
|
||||||
// 渲染进程限制
|
// 渲染进程限制
|
||||||
@ -112,7 +105,8 @@ void initConfig(int argc, char *argv[], QCefConfig &config, QString currentDir)
|
|||||||
// 外部消息循环
|
// 外部消息循环
|
||||||
config.addCommandLineSwitchWithValue("external-message-pump", "false");
|
config.addCommandLineSwitchWithValue("external-message-pump", "false");
|
||||||
// 多线程消息循环
|
// 多线程消息循环
|
||||||
config.addCommandLineSwitchWithValue("multi-threaded-message-loop", "true");
|
config.addCommandLineSwitchWithValue("multi-threaded-message-loop", "false");
|
||||||
|
|
||||||
}
|
}
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -128,25 +122,25 @@ int main(int argc, char *argv[])
|
|||||||
QCefContext cefContext(&a, argc, argv, &config);
|
QCefContext cefContext(&a, argc, argv, &config);
|
||||||
CefWidget cw;
|
CefWidget cw;
|
||||||
cw.show();
|
cw.show();
|
||||||
qputenv("QT_QPA_PLATFORM", "windows:fontengine=freetype");
|
// qputenv("QT_QPA_PLATFORM", "windows:fontengine=freetype");
|
||||||
// 加载语言包
|
// // 加载语言包
|
||||||
QTranslator qtBaseTranslator;
|
// QTranslator qtBaseTranslator;
|
||||||
if (!qtBaseTranslator.load(QStringLiteral(":/res/translator/qtbase_zh_CN.qm")))
|
// if (!qtBaseTranslator.load(QStringLiteral(":/res/translator/qtbase_zh_CN.qm")))
|
||||||
{
|
// {
|
||||||
// 处理加载翻译文件失败的情况
|
// // 处理加载翻译文件失败的情况
|
||||||
qDebug() << "Failed to load translation file.";
|
// qDebug() << "Failed to load translation file.";
|
||||||
return -1;
|
// return -1;
|
||||||
}
|
// }
|
||||||
a.installTranslator(&qtBaseTranslator);
|
// a.installTranslator(&qtBaseTranslator);
|
||||||
// 读取窗体的配置并初始化
|
// // 读取窗体的配置并初始化
|
||||||
sui_init_config();
|
// sui_init_config();
|
||||||
ctai x;
|
// ctai x;
|
||||||
x.init_layout();
|
// x.init_layout();
|
||||||
// 仅限于windows平台
|
// // 仅限于windows平台
|
||||||
#if defined(__WIN32__)
|
// #if defined(__WIN32__)
|
||||||
x.title()->set_type(QD_TYPE::QD_EXIT);
|
// x.title()->set_type(QD_TYPE::QD_EXIT);
|
||||||
#endif
|
// #endif
|
||||||
x.show();
|
// x.show();
|
||||||
a.exec();
|
a.exec();
|
||||||
qDebug() << "EXIT";
|
qDebug() << "EXIT";
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user