增加QCefViewCore自动编译脚本
This commit is contained in:
parent
dba2db6a80
commit
c8274d8295
BIN
3rdparty/QCefViewCore/lib/libCefViewCore.a
vendored
BIN
3rdparty/QCefViewCore/lib/libCefViewCore.a
vendored
Binary file not shown.
@ -47,7 +47,7 @@ FetchContent_Declare(
|
||||
# set(CEF_SDK_VERSION "123.0.13+gfc703fb+chromium-123.0.6312.124") # NOT TEST
|
||||
# set(CEF_SDK_VERSION "124.3.9+g9bd638f+chromium-124.0.6367.207") # NOT TEST
|
||||
# set(CEF_SDK_VERSION "125.0.22+gc410c95+chromium-125.0.6422.142") # NOT TEST
|
||||
set(CEF_SDK_VERSION "126.2.18+g3647d39+chromium-126.0.6478.183") # NOT TEST
|
||||
set(CEF_SDK_VERSION "134.3.2+g615db2f+chromium-134.0.6998.89") # NOT TEST
|
||||
|
||||
# set(CEF_SDK_VERSION "127.3.5+g114ea2a+chromium-127.0.6533.120") # GOOD
|
||||
|
||||
|
||||
@ -76,11 +76,11 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/libcef_dll_wrapper)
|
||||
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/libcef_dll_wrapper/lib)
|
||||
|
||||
#QCefViewCore
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/QCefViewCore)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/QCefViewCore/include)
|
||||
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/QCefViewCore/lib)
|
||||
|
||||
#QCefView
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/QCefView)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/QCefView/include)
|
||||
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/QCefView/lib)
|
||||
#查找QT模块
|
||||
FIND_PACKAGE(Qt6 REQUIRED Core Gui Widgets)
|
||||
@ -165,4 +165,8 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
-lCefViewCore
|
||||
-lcef_dll_wrapper
|
||||
-lcef
|
||||
-std=c++17
|
||||
-static-libgcc
|
||||
-static-libstdc++
|
||||
)
|
||||
|
||||
@ -10,23 +10,5 @@ ctaiBrowser::~ctaiBrowser()
|
||||
}
|
||||
void ctaiBrowser::initBrowser()
|
||||
{
|
||||
// 以下是将 SimpleHandler 与窗体进行关联的代码
|
||||
CefWindowInfo cef_wnd_info;
|
||||
std::string str_url = "www.baidu.com";
|
||||
QRect rect = this->geometry();
|
||||
CefRect win_rect(
|
||||
rect.left(),
|
||||
rect.top(),
|
||||
rect.left() + rect.width() * devicePixelRatio(),
|
||||
rect.top() + rect.height() * devicePixelRatio());
|
||||
|
||||
cef_wnd_info.SetAsChild((HWND)this->winId(), win_rect); //将cef界面嵌入qt界面中
|
||||
CefBrowserSettings cef_browser_settings;
|
||||
simple_handler = CefRefPtr<SimpleHandler>(SimpleHandler::GetInstance());
|
||||
CefBrowserHost::CreateBrowser(cef_wnd_info,
|
||||
simple_handler,
|
||||
str_url,
|
||||
cef_browser_settings,
|
||||
nullptr,
|
||||
CefRequestContext::GetGlobalContext());
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include <QApplication>
|
||||
#include "simple_handler.h"
|
||||
class ctaiBrowser : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -12,7 +11,6 @@ public:
|
||||
~ctaiBrowser();
|
||||
private:
|
||||
void initBrowser();
|
||||
CefRefPtr<SimpleHandler> simple_handler;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -1,201 +0,0 @@
|
||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "simple_app.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "include/cef_browser.h"
|
||||
#include "include/cef_command_line.h"
|
||||
#include "include/views/cef_browser_view.h"
|
||||
#include "include/views/cef_window.h"
|
||||
#include "include/wrapper/cef_helpers.h"
|
||||
#include "simple_handler.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
// When using the Views framework this object provides the delegate
|
||||
// implementation for the CefWindow that hosts the Views-based browser.
|
||||
class SimpleWindowDelegate : public CefWindowDelegate
|
||||
{
|
||||
public:
|
||||
SimpleWindowDelegate(CefRefPtr<CefBrowserView> browser_view,
|
||||
cef_runtime_style_t runtime_style,
|
||||
cef_show_state_t initial_show_state)
|
||||
: browser_view_(browser_view),
|
||||
runtime_style_(runtime_style),
|
||||
initial_show_state_(initial_show_state) {}
|
||||
|
||||
void OnWindowCreated(CefRefPtr<CefWindow> window) override
|
||||
{
|
||||
// Add the browser view and show the window.
|
||||
window->AddChildView(browser_view_);
|
||||
|
||||
if (initial_show_state_ != CEF_SHOW_STATE_HIDDEN)
|
||||
{
|
||||
window->Show();
|
||||
}
|
||||
}
|
||||
|
||||
void OnWindowDestroyed(CefRefPtr<CefWindow> window) override
|
||||
{
|
||||
browser_view_ = nullptr;
|
||||
}
|
||||
|
||||
bool CanClose(CefRefPtr<CefWindow> window) override
|
||||
{
|
||||
// Allow the window to close if the browser says it's OK.
|
||||
CefRefPtr<CefBrowser> browser = browser_view_->GetBrowser();
|
||||
if (browser)
|
||||
{
|
||||
return browser->GetHost()->TryCloseBrowser();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
CefSize GetPreferredSize(CefRefPtr<CefView> view) override
|
||||
{
|
||||
return CefSize(800, 600);
|
||||
}
|
||||
|
||||
cef_show_state_t GetInitialShowState(CefRefPtr<CefWindow> window) override
|
||||
{
|
||||
return initial_show_state_;
|
||||
}
|
||||
|
||||
cef_runtime_style_t GetWindowRuntimeStyle() override
|
||||
{
|
||||
return runtime_style_;
|
||||
}
|
||||
|
||||
private:
|
||||
CefRefPtr<CefBrowserView> browser_view_;
|
||||
const cef_runtime_style_t runtime_style_;
|
||||
const cef_show_state_t initial_show_state_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(SimpleWindowDelegate);
|
||||
DISALLOW_COPY_AND_ASSIGN(SimpleWindowDelegate);
|
||||
};
|
||||
|
||||
class SimpleBrowserViewDelegate : public CefBrowserViewDelegate
|
||||
{
|
||||
public:
|
||||
explicit SimpleBrowserViewDelegate(cef_runtime_style_t runtime_style)
|
||||
: runtime_style_(runtime_style) {}
|
||||
|
||||
bool OnPopupBrowserViewCreated(CefRefPtr<CefBrowserView> browser_view,
|
||||
CefRefPtr<CefBrowserView> popup_browser_view,
|
||||
bool is_devtools) override
|
||||
{
|
||||
// Create a new top-level Window for the popup. It will show itself after
|
||||
// creation.
|
||||
CefWindow::CreateTopLevelWindow(new SimpleWindowDelegate(
|
||||
popup_browser_view, runtime_style_, CEF_SHOW_STATE_NORMAL));
|
||||
|
||||
// We created the Window.
|
||||
return true;
|
||||
}
|
||||
|
||||
cef_runtime_style_t GetBrowserRuntimeStyle() override
|
||||
{
|
||||
return runtime_style_;
|
||||
}
|
||||
|
||||
private:
|
||||
const cef_runtime_style_t runtime_style_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(SimpleBrowserViewDelegate);
|
||||
DISALLOW_COPY_AND_ASSIGN(SimpleBrowserViewDelegate);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
SimpleApp::SimpleApp() = default;
|
||||
|
||||
void SimpleApp::OnContextInitialized()
|
||||
{
|
||||
// CEF_REQUIRE_UI_THREAD();
|
||||
|
||||
// CefRefPtr<CefCommandLine> command_line =
|
||||
// CefCommandLine::GetGlobalCommandLine();
|
||||
|
||||
// // Check if Alloy style will be used.
|
||||
// cef_runtime_style_t runtime_style = CEF_RUNTIME_STYLE_DEFAULT;
|
||||
// bool use_alloy_style = command_line->HasSwitch("use-alloy-style");
|
||||
// if (use_alloy_style) {
|
||||
// runtime_style = CEF_RUNTIME_STYLE_ALLOY;
|
||||
// }
|
||||
|
||||
// // SimpleHandler implements browser-level callbacks.
|
||||
// CefRefPtr<SimpleHandler> handler(new SimpleHandler(use_alloy_style));
|
||||
|
||||
// // Specify CEF browser settings here.
|
||||
// CefBrowserSettings browser_settings;
|
||||
|
||||
// std::string url;
|
||||
|
||||
// // Check if a "--url=" value was provided via the command-line. If so, use
|
||||
// // that instead of the default URL.
|
||||
// url = command_line->GetSwitchValue("url");
|
||||
// if (url.empty()) {
|
||||
// url = "https://www.google.com";
|
||||
// }
|
||||
|
||||
// // Views is enabled by default (add `--use-native` to disable).
|
||||
// const bool use_views = !command_line->HasSwitch("use-native");
|
||||
|
||||
// // If using Views create the browser using the Views framework, otherwise
|
||||
// // create the browser using the native platform framework.
|
||||
// if (use_views) {
|
||||
// // Create the BrowserView.
|
||||
// CefRefPtr<CefBrowserView> browser_view = CefBrowserView::CreateBrowserView(
|
||||
// handler, url, browser_settings, nullptr, nullptr,
|
||||
// new SimpleBrowserViewDelegate(runtime_style));
|
||||
|
||||
// // Optionally configure the initial show state.
|
||||
// cef_show_state_t initial_show_state = CEF_SHOW_STATE_NORMAL;
|
||||
// const std::string& show_state_value =
|
||||
// command_line->GetSwitchValue("initial-show-state");
|
||||
// if (show_state_value == "minimized") {
|
||||
// initial_show_state = CEF_SHOW_STATE_MINIMIZED;
|
||||
// } else if (show_state_value == "maximized") {
|
||||
// initial_show_state = CEF_SHOW_STATE_MAXIMIZED;
|
||||
// }
|
||||
// #if defined(OS_MAC)
|
||||
// // Hidden show state is only supported on MacOS.
|
||||
// else if (show_state_value == "hidden") {
|
||||
// initial_show_state = CEF_SHOW_STATE_HIDDEN;
|
||||
// }
|
||||
// #endif
|
||||
|
||||
// // Create the Window. It will show itself after creation.
|
||||
// CefWindow::CreateTopLevelWindow(new SimpleWindowDelegate(
|
||||
// browser_view, runtime_style, initial_show_state));
|
||||
// } else {
|
||||
// // Information used when creating the native window.
|
||||
// CefWindowInfo window_info;
|
||||
|
||||
// #if defined(OS_WIN)
|
||||
// // On Windows we need to specify certain flags that will be passed to
|
||||
// // CreateWindowEx().
|
||||
// window_info.SetAsPopup(nullptr, "cefsimple");
|
||||
// #endif
|
||||
|
||||
// // Alloy style will create a basic native window. Chrome style will create a
|
||||
// // fully styled Chrome UI window.
|
||||
// window_info.runtime_style = runtime_style;
|
||||
|
||||
// // Create the first browser window.
|
||||
// CefBrowserHost::CreateBrowser(window_info, handler, url, browser_settings,
|
||||
// nullptr, nullptr);
|
||||
// }
|
||||
return;
|
||||
}
|
||||
|
||||
CefRefPtr<CefClient> SimpleApp::GetDefaultClient()
|
||||
{
|
||||
// Called when a new browser window is created via Chrome style UI.
|
||||
return SimpleHandler::GetInstance();
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_TESTS_CEFSIMPLE_SIMPLE_APP_H_
|
||||
#define CEF_TESTS_CEFSIMPLE_SIMPLE_APP_H_
|
||||
|
||||
#include "include/cef_app.h"
|
||||
|
||||
// Implement application-level callbacks for the browser process.
|
||||
class SimpleApp : public CefApp, public CefBrowserProcessHandler {
|
||||
public:
|
||||
SimpleApp();
|
||||
|
||||
// CefApp methods:
|
||||
CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() override {
|
||||
return this;
|
||||
}
|
||||
|
||||
// CefBrowserProcessHandler methods:
|
||||
void OnContextInitialized() override;
|
||||
CefRefPtr<CefClient> GetDefaultClient() override;
|
||||
|
||||
private:
|
||||
// Include the default reference counting implementation.
|
||||
IMPLEMENT_REFCOUNTING(SimpleApp);
|
||||
};
|
||||
|
||||
#endif // CEF_TESTS_CEFSIMPLE_SIMPLE_APP_H_
|
||||
@ -1,179 +0,0 @@
|
||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "simple_handler.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "include/base/cef_callback.h"
|
||||
#include "include/cef_app.h"
|
||||
#include "include/cef_parser.h"
|
||||
#include "include/views/cef_browser_view.h"
|
||||
#include "include/views/cef_window.h"
|
||||
#include "include/wrapper/cef_closure_task.h"
|
||||
#include "include/wrapper/cef_helpers.h"
|
||||
|
||||
namespace {
|
||||
|
||||
SimpleHandler* g_instance = nullptr;
|
||||
|
||||
// Returns a data: URI with the specified contents.
|
||||
std::string GetDataURI(const std::string& data, const std::string& mime_type) {
|
||||
return "data:" + mime_type + ";base64," +
|
||||
CefURIEncode(CefBase64Encode(data.data(), data.size()), false)
|
||||
.ToString();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
SimpleHandler::SimpleHandler(bool is_alloy_style)
|
||||
: is_alloy_style_(is_alloy_style) {
|
||||
DCHECK(!g_instance);
|
||||
g_instance = this;
|
||||
}
|
||||
|
||||
SimpleHandler::~SimpleHandler() {
|
||||
g_instance = nullptr;
|
||||
}
|
||||
|
||||
// static
|
||||
SimpleHandler* SimpleHandler::GetInstance() {
|
||||
return g_instance;
|
||||
}
|
||||
|
||||
void SimpleHandler::OnTitleChange(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& title) {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
|
||||
if (auto browser_view = CefBrowserView::GetForBrowser(browser)) {
|
||||
// Set the title of the window using the Views framework.
|
||||
CefRefPtr<CefWindow> window = browser_view->GetWindow();
|
||||
if (window) {
|
||||
window->SetTitle(title);
|
||||
}
|
||||
} else if (is_alloy_style_) {
|
||||
// Set the title of the window using platform APIs.
|
||||
PlatformTitleChange(browser, title);
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
|
||||
// Sanity-check the configured runtime style.
|
||||
CHECK_EQ(is_alloy_style_ ? CEF_RUNTIME_STYLE_ALLOY : CEF_RUNTIME_STYLE_CHROME,
|
||||
browser->GetHost()->GetRuntimeStyle());
|
||||
|
||||
// Add to the list of existing browsers.
|
||||
browser_list_.push_back(browser);
|
||||
}
|
||||
|
||||
bool SimpleHandler::DoClose(CefRefPtr<CefBrowser> browser) {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
|
||||
// Closing the main window requires special handling. See the DoClose()
|
||||
// documentation in the CEF header for a detailed destription of this
|
||||
// process.
|
||||
if (browser_list_.size() == 1) {
|
||||
// Set a flag to indicate that the window close should be allowed.
|
||||
is_closing_ = true;
|
||||
}
|
||||
|
||||
// Allow the close. For windowed browsers this will result in the OS close
|
||||
// event being sent.
|
||||
return false;
|
||||
}
|
||||
|
||||
void SimpleHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
|
||||
// Remove from the list of existing browsers.
|
||||
BrowserList::iterator bit = browser_list_.begin();
|
||||
for (; bit != browser_list_.end(); ++bit) {
|
||||
if ((*bit)->IsSame(browser)) {
|
||||
browser_list_.erase(bit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (browser_list_.empty()) {
|
||||
// All browser windows have closed. Quit the application message loop.
|
||||
CefQuitMessageLoop();
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleHandler::OnLoadError(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
ErrorCode errorCode,
|
||||
const CefString& errorText,
|
||||
const CefString& failedUrl) {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
|
||||
// Allow Chrome to show the error page.
|
||||
if (!is_alloy_style_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't display an error for downloaded files.
|
||||
if (errorCode == ERR_ABORTED) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Display a load error message using a data: URI.
|
||||
std::stringstream ss;
|
||||
ss << "<html><body bgcolor=\"white\">"
|
||||
"<h2>Failed to load URL "
|
||||
<< std::string(failedUrl) << " with error " << std::string(errorText)
|
||||
<< " (" << errorCode << ").</h2></body></html>";
|
||||
|
||||
frame->LoadURL(GetDataURI(ss.str(), "text/html"));
|
||||
}
|
||||
|
||||
void SimpleHandler::ShowMainWindow() {
|
||||
if (!CefCurrentlyOn(TID_UI)) {
|
||||
// Execute on the UI thread.
|
||||
CefPostTask(TID_UI, base::BindOnce(&SimpleHandler::ShowMainWindow, this));
|
||||
return;
|
||||
}
|
||||
|
||||
if (browser_list_.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto main_browser = browser_list_.front();
|
||||
|
||||
if (auto browser_view = CefBrowserView::GetForBrowser(main_browser)) {
|
||||
// Show the window using the Views framework.
|
||||
if (auto window = browser_view->GetWindow()) {
|
||||
window->Show();
|
||||
}
|
||||
} else if (is_alloy_style_) {
|
||||
PlatformShowWindow(main_browser);
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleHandler::CloseAllBrowsers(bool force_close) {
|
||||
if (!CefCurrentlyOn(TID_UI)) {
|
||||
// Execute on the UI thread.
|
||||
CefPostTask(TID_UI, base::BindOnce(&SimpleHandler::CloseAllBrowsers, this,
|
||||
force_close));
|
||||
return;
|
||||
}
|
||||
|
||||
if (browser_list_.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BrowserList::const_iterator it = browser_list_.begin();
|
||||
for (; it != browser_list_.end(); ++it) {
|
||||
(*it)->GetHost()->CloseBrowser(force_close);
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(OS_MAC)
|
||||
void SimpleHandler::PlatformShowWindow(CefRefPtr<CefBrowser> browser) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
#endif
|
||||
@ -1,70 +0,0 @@
|
||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_TESTS_CEFSIMPLE_SIMPLE_HANDLER_H_
|
||||
#define CEF_TESTS_CEFSIMPLE_SIMPLE_HANDLER_H_
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "include/cef_client.h"
|
||||
|
||||
class SimpleHandler : public CefClient,
|
||||
public CefDisplayHandler,
|
||||
public CefLifeSpanHandler,
|
||||
public CefLoadHandler {
|
||||
public:
|
||||
explicit SimpleHandler(bool is_alloy_style);
|
||||
~SimpleHandler() override;
|
||||
|
||||
// Provide access to the single global instance of this object.
|
||||
static SimpleHandler* GetInstance();
|
||||
|
||||
// CefClient methods:
|
||||
CefRefPtr<CefDisplayHandler> GetDisplayHandler() override { return this; }
|
||||
CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() override { return this; }
|
||||
CefRefPtr<CefLoadHandler> GetLoadHandler() override { return this; }
|
||||
|
||||
// CefDisplayHandler methods:
|
||||
void OnTitleChange(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& title) override;
|
||||
|
||||
// CefLifeSpanHandler methods:
|
||||
void OnAfterCreated(CefRefPtr<CefBrowser> browser) override;
|
||||
bool DoClose(CefRefPtr<CefBrowser> browser) override;
|
||||
void OnBeforeClose(CefRefPtr<CefBrowser> browser) override;
|
||||
|
||||
// CefLoadHandler methods:
|
||||
void OnLoadError(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
ErrorCode errorCode,
|
||||
const CefString& errorText,
|
||||
const CefString& failedUrl) override;
|
||||
|
||||
void ShowMainWindow();
|
||||
|
||||
// Request that all existing browser windows close.
|
||||
void CloseAllBrowsers(bool force_close);
|
||||
|
||||
bool IsClosing() const { return is_closing_; }
|
||||
|
||||
private:
|
||||
// Platform-specific implementation.
|
||||
void PlatformTitleChange(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& title);
|
||||
void PlatformShowWindow(CefRefPtr<CefBrowser> browser);
|
||||
|
||||
// True if this client is Alloy style, otherwise Chrome style.
|
||||
const bool is_alloy_style_;
|
||||
|
||||
// List of existing browser windows. Only accessed on the CEF UI thread.
|
||||
typedef std::list<CefRefPtr<CefBrowser>> BrowserList;
|
||||
BrowserList browser_list_;
|
||||
|
||||
bool is_closing_ = false;
|
||||
|
||||
// Include the default reference counting implementation.
|
||||
IMPLEMENT_REFCOUNTING(SimpleHandler);
|
||||
};
|
||||
|
||||
#endif // CEF_TESTS_CEFSIMPLE_SIMPLE_HANDLER_H_
|
||||
@ -1,19 +0,0 @@
|
||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "simple_handler.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "include/cef_browser.h"
|
||||
|
||||
void SimpleHandler::PlatformTitleChange(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& title) {
|
||||
CefWindowHandle hwnd = browser->GetHost()->GetWindowHandle();
|
||||
if (hwnd) {
|
||||
SetWindowText(hwnd, std::wstring(title).c_str());
|
||||
}
|
||||
}
|
||||
50
src/main.cpp
50
src/main.cpp
@ -4,10 +4,54 @@
|
||||
#include "sui_base_ex.h"
|
||||
#include "ctai.h"
|
||||
#include <QApplication>
|
||||
//#include "QCefContext.h"
|
||||
|
||||
// void init_Browser(QApplication& instance,int argc, char *argv[]){
|
||||
// // build QCefConfig
|
||||
// QCefConfig config;
|
||||
// // set user agent
|
||||
// config.setUserAgent("QCefViewTest");
|
||||
// // set log level
|
||||
// config.setLogLevel(QCefConfig::LOGSEVERITY_DEFAULT);
|
||||
// // set JSBridge object name (default value is CefViewClient)
|
||||
// config.setBridgeObjectName("CallBridge");
|
||||
// // set Built-in scheme name (default value is CefView)
|
||||
// config.setBuiltinSchemeName("CefView");
|
||||
// // port for remote debugging (default is 0 and means to disable remote debugging)
|
||||
// config.setRemoteDebuggingPort(9000);
|
||||
// // set background color for all browsers
|
||||
// // (QCefSetting.setBackgroundColor will overwrite this value for specified browser instance)
|
||||
// // config.setBackgroundColor(Qt::lightGray);
|
||||
|
||||
// // WindowlessRenderingEnabled is set to true by default,
|
||||
// // set to false to disable the OSR mode
|
||||
// config.setWindowlessRenderingEnabled(true);
|
||||
|
||||
// // add command line args, you can any cef supported switches or parameters
|
||||
// config.addCommandLineSwitch("use-mock-keychain");
|
||||
// // config.addCommandLineSwitch("disable-gpu");
|
||||
// // config.addCommandLineSwitch("enable-media-stream");
|
||||
// // config.addCommandLineSwitch("allow-file-access-from-files");
|
||||
// // config.addCommandLineSwitch("disable-spell-checking");
|
||||
// // config.addCommandLineSwitch("disable-site-isolation-trials");
|
||||
// // config.addCommandLineSwitch("enable-aggressive-domstorage-flushing");
|
||||
// config.addCommandLineSwitchWithValue("renderer-process-limit", "1");
|
||||
// // allow remote debugging
|
||||
// config.addCommandLineSwitchWithValue("remote-allow-origins", "*");
|
||||
// // config.addCommandLineSwitchWithValue("disable-features", "BlinkGenPropertyTrees,TranslateUI,site-per-process");
|
||||
|
||||
// // set cache folder
|
||||
// config.setCachePath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
|
||||
|
||||
// // create QCefContext instance with config,
|
||||
// // the lifecycle of cefContext must be the same as QApplication instance
|
||||
// QCefContext cefContext(&instance, argc, argv, &config);
|
||||
// }
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
qputenv("QT_QPA_PLATFORM", "windows:fontengine=freetype");
|
||||
QApplication a(argc, argv);
|
||||
//加载语言包
|
||||
QTranslator qtBaseTranslator;
|
||||
if (!qtBaseTranslator.load(QStringLiteral(":/res/translator/qtbase_zh_CN.qm")))
|
||||
{
|
||||
@ -16,10 +60,10 @@ int main(int argc, char *argv[])
|
||||
return -1;
|
||||
}
|
||||
a.installTranslator(&qtBaseTranslator);
|
||||
|
||||
//init widget config
|
||||
//初始化浏览器
|
||||
//init_Browser(a,argc,argv);
|
||||
//读取窗体的配置并初始化
|
||||
sui_init_config();
|
||||
//init ctai
|
||||
ctai x;
|
||||
x.init_layout();
|
||||
// 仅限于windows平台
|
||||
|
||||
Loading…
Reference in New Issue
Block a user