更新上游库
This commit is contained in:
parent
c8274d8295
commit
3830c3d47f
@ -13,12 +13,12 @@
|
||||
#pragma once
|
||||
|
||||
// clang-format off
|
||||
#define CEF_VERSION "126.2.18+g3647d39+chromium-126.0.6478.183"
|
||||
#define CEF_VERSION_MAJOR 126
|
||||
#define CEF_VERSION_MINOR 2
|
||||
#define CEF_VERSION_PATCH 18
|
||||
#define CEF_COMMIT_NUMBER 3019
|
||||
#define CEF_COMMIT_HASH "3647d39e700c215bd78172c5964eb1c550950f0f"
|
||||
#define CEF_VERSION "134.3.2+g615db2f+chromium-134.0.6998.89"
|
||||
#define CEF_VERSION_MAJOR 134
|
||||
#define CEF_VERSION_MINOR 3
|
||||
#define CEF_VERSION_PATCH 2
|
||||
#define CEF_COMMIT_NUMBER 3151
|
||||
#define CEF_COMMIT_HASH "615db2f583e46822d28a4f2a57c3ef7316c5b17d"
|
||||
// clang-format on
|
||||
|
||||
#endif // CefVersion
|
||||
BIN
3rdparty/CefViewCore/lib/libCefViewCore.a
vendored
Normal file
BIN
3rdparty/CefViewCore/lib/libCefViewCore.a
vendored
Normal file
Binary file not shown.
12
3rdparty/QCefView/include/CefVersion.h
vendored
12
3rdparty/QCefView/include/CefVersion.h
vendored
@ -13,12 +13,12 @@
|
||||
#pragma once
|
||||
|
||||
// clang-format off
|
||||
#define CEF_VERSION "126.2.18+g3647d39+chromium-126.0.6478.183"
|
||||
#define CEF_VERSION_MAJOR 126
|
||||
#define CEF_VERSION_MINOR 2
|
||||
#define CEF_VERSION_PATCH 18
|
||||
#define CEF_COMMIT_NUMBER 3019
|
||||
#define CEF_COMMIT_HASH "3647d39e700c215bd78172c5964eb1c550950f0f"
|
||||
#define CEF_VERSION "134.3.2+g615db2f+chromium-134.0.6998.89"
|
||||
#define CEF_VERSION_MAJOR 134
|
||||
#define CEF_VERSION_MINOR 3
|
||||
#define CEF_VERSION_PATCH 2
|
||||
#define CEF_COMMIT_NUMBER 3151
|
||||
#define CEF_COMMIT_HASH "615db2f583e46822d28a4f2a57c3ef7316c5b17d"
|
||||
// clang-format on
|
||||
|
||||
#endif // CefVersion
|
||||
|
||||
BIN
3rdparty/QCefView/lib/libQCefView.a
vendored
BIN
3rdparty/QCefView/lib/libQCefView.a
vendored
Binary file not shown.
BIN
3rdparty/QCefViewCore/lib/libCefViewCore.a
vendored
BIN
3rdparty/QCefViewCore/lib/libCefViewCore.a
vendored
Binary file not shown.
@ -830,9 +830,7 @@ NET_ERROR(ZSTD_WINDOW_SIZE_TOO_BIG, -386)
|
||||
// The compression dictionary cannot be loaded.
|
||||
NET_ERROR(DICTIONARY_LOAD_FAILED, -387)
|
||||
|
||||
// The "content-dictionary" response header is unexpected. This is used both
|
||||
// when there is no "content-dictionary" response header and when the received
|
||||
// "content-dictionary" response header does not match the expected value.
|
||||
// The header of dictionary compressed stream does not match the expected value.
|
||||
NET_ERROR(UNEXPECTED_CONTENT_DICTIONARY_HEADER, -388)
|
||||
|
||||
// The cache does not have the requested entry.
|
||||
|
||||
@ -42,13 +42,13 @@
|
||||
// way that may cause binary incompatibility with other builds. The universal
|
||||
// hash value will change if any platform is affected whereas the platform hash
|
||||
// values will change only if that particular platform is affected.
|
||||
#define CEF_API_HASH_UNIVERSAL "ed1dfa5ff8a041241f8fb72eb7454811f358f0d3"
|
||||
#define CEF_API_HASH_UNIVERSAL "d3709fcbd6630817b73287083d5440bffffcfb0b"
|
||||
#if defined(OS_WIN)
|
||||
#define CEF_API_HASH_PLATFORM "0d99d1b9b85b2efab91a39d6fc325bb6d56fd524"
|
||||
#define CEF_API_HASH_PLATFORM "2e66390b5f0fa21ab4667b503e76164037cd674e"
|
||||
#elif defined(OS_MAC)
|
||||
#define CEF_API_HASH_PLATFORM "e585e190387e31a71267207b66d175e213991470"
|
||||
#define CEF_API_HASH_PLATFORM "94ce56bc6f289ae039ca7db2ac8d32901e71a4e1"
|
||||
#elif defined(OS_LINUX)
|
||||
#define CEF_API_HASH_PLATFORM "09d3e280ed38f7a082b794c56ff71c52f86f0ea8"
|
||||
#define CEF_API_HASH_PLATFORM "2fda6a422c06b87a4ce47bdfd4c985346f1eaab8"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -187,8 +187,9 @@
|
||||
E_CPONLY(CEF_ColorSysWhite) \
|
||||
/* Inverse. */ \
|
||||
E_CPONLY(CEF_ColorSysInversePrimary) \
|
||||
E_CPONLY(CEF_ColorSysInverseSurface) \
|
||||
E_CPONLY(CEF_ColorSysInverseOnSurface) \
|
||||
E_CPONLY(CEF_ColorSysInverseSurface) \
|
||||
E_CPONLY(CEF_ColorSysInverseSurfacePrimary) \
|
||||
/* Surfaces. */ \
|
||||
E_CPONLY(CEF_ColorSysSurface) \
|
||||
E_CPONLY(CEF_ColorSysSurface1) \
|
||||
@ -225,6 +226,7 @@
|
||||
E_CPONLY(CEF_ColorSysStateRippleNeutralOnProminent) \
|
||||
E_CPONLY(CEF_ColorSysStateRippleNeutralOnSubtle) \
|
||||
E_CPONLY(CEF_ColorSysStateRipplePrimary) \
|
||||
E_CPONLY(CEF_ColorSysStateScrim) \
|
||||
E_CPONLY(CEF_ColorSysStateFocusRing) \
|
||||
E_CPONLY(CEF_ColorSysStateFocusHighlight) \
|
||||
E_CPONLY(CEF_ColorSysStateTextHighlight) \
|
||||
@ -288,6 +290,7 @@
|
||||
E_CPONLY(CEF_ColorAppMenuProfileRowChipHovered) \
|
||||
E_CPONLY(CEF_ColorAppMenuRowBackgroundHovered) \
|
||||
E_CPONLY(CEF_ColorAppMenuUpgradeRowBackground) \
|
||||
E_CPONLY(CEF_ColorAppMenuUpgradeRowSubstringForeground) \
|
||||
E_CPONLY(CEF_ColorAvatarHeaderArt) \
|
||||
E_CPONLY(CEF_ColorAvatarIconGuest) \
|
||||
E_CPONLY(CEF_ColorAvatarIconIncognito) \
|
||||
@ -416,6 +419,7 @@
|
||||
E_CPONLY(CEF_ColorMenuDropmarker) \
|
||||
E_CPONLY(CEF_ColorMenuIcon) \
|
||||
E_CPONLY(CEF_ColorMenuIconDisabled) \
|
||||
E_CPONLY(CEF_ColorMenuIconOnEmphasizedBackground) \
|
||||
E_CPONLY(CEF_ColorMenuItemBackgroundAlertedInitial) \
|
||||
E_CPONLY(CEF_ColorMenuItemBackgroundAlertedTarget) \
|
||||
E_CPONLY(CEF_ColorMenuItemBackgroundHighlighted) \
|
||||
@ -803,7 +807,6 @@
|
||||
E_CPONLY(CEF_ColorComposeDialogResultForeground) \
|
||||
E_CPONLY(CEF_ColorComposeDialogResultForegroundWhileLoading) \
|
||||
E_CPONLY(CEF_ColorComposeDialogResultIcon) \
|
||||
E_CPONLY(CEF_ColorComposeDialogResultButtonsDivider) \
|
||||
E_CPONLY(CEF_ColorComposeDialogResultContainerScrollbarThumb) \
|
||||
E_CPONLY(CEF_ColorComposeDialogScrollbarThumb) \
|
||||
E_CPONLY(CEF_ColorComposeDialogTitle) \
|
||||
@ -895,6 +898,8 @@
|
||||
/* Intent Picker colors. */ \
|
||||
E_CPONLY(CEF_ColorIntentPickerItemBackgroundHovered) \
|
||||
E_CPONLY(CEF_ColorIntentPickerItemBackgroundSelected) \
|
||||
/* Lens overlay colors. */ \
|
||||
E_CPONLY(CEF_ColorLensOverlayToastBackground) \
|
||||
/* Location bar colors. */ \
|
||||
E_CPONLY(CEF_ColorLocationBarBackground) \
|
||||
E_CPONLY(CEF_ColorLocationBarBackgroundHovered) \
|
||||
@ -969,6 +974,9 @@
|
||||
E_CPONLY(CEF_ColorNewTabPageModuleControlBorder) \
|
||||
E_CPONLY(CEF_ColorNewTabPageModuleContextMenuDivider) \
|
||||
E_CPONLY(CEF_ColorNewTabPageModuleBackground) \
|
||||
E_CPONLY(CEF_ColorNewTabPageModuleCalendarEventCollapsedBackground) \
|
||||
E_CPONLY(CEF_ColorNewTabPageModuleCalendarEventExpandedBackground) \
|
||||
E_CPONLY(CEF_ColorNewTabPageModuleCalendarEventTimeStatusBackground) \
|
||||
E_CPONLY(CEF_ColorNewTabPageModuleIconBackground) \
|
||||
E_CPONLY(CEF_ColorNewTabPageModuleElementDivider) \
|
||||
E_CPONLY(CEF_ColorNewTabPageModuleIconContainerBackground) \
|
||||
@ -1072,10 +1080,10 @@
|
||||
E_CPONLY(CEF_ColorPageInfoBackgroundTonal) \
|
||||
E_CPONLY(CEF_ColorPageInfoChosenObjectDeleteButtonIcon) \
|
||||
E_CPONLY(CEF_ColorPageInfoChosenObjectDeleteButtonIconDisabled) \
|
||||
E_CPONLY(CEF_ColorPageInfoForeground) \
|
||||
E_CPONLY(CEF_ColorPageInfoForegroundTonal) \
|
||||
E_CPONLY(CEF_ColorPageInfoIconHover) \
|
||||
E_CPONLY(CEF_ColorPageInfoIconPressed) \
|
||||
E_CPONLY(CEF_ColorPageInfoLensOverlayBackground) \
|
||||
E_CPONLY(CEF_ColorPageInfoLensOverlayForeground) \
|
||||
E_CPONLY(CEF_ColorPageInfoPermissionBlockedOnSystemLevelDisabled) \
|
||||
E_CPONLY(CEF_ColorPageInfoPermissionForeground) \
|
||||
E_CPONLY(CEF_ColorPageInfoPermissionUsedIcon) \
|
||||
@ -1112,6 +1120,7 @@
|
||||
E_CPONLY(CEF_ColorProductSpecificationsDivider) \
|
||||
E_CPONLY(CEF_ColorProductSpecificationsPageBackground) \
|
||||
E_CPONLY(CEF_ColorProductSpecificationsPrimaryTitle) \
|
||||
E_CPONLY(CEF_ColorProductSpecificationsIcon) \
|
||||
E_CPONLY(CEF_ColorProductSpecificationsSecondaryTitle) \
|
||||
E_CPONLY(CEF_ColorProductSpecificationsSummaryBackground) \
|
||||
/* Profile Menu colors. */ \
|
||||
|
||||
@ -239,7 +239,9 @@
|
||||
#define IDC_RECENT_TABS_LOGIN_FOR_DEVICE_TABS 40277
|
||||
#define IDC_OPEN_RECENT_TAB 40278
|
||||
#define IDC_OPEN_SAFETY_HUB 40279
|
||||
#define IDC_SHOW_PASSWORD_CHECKUP 40280
|
||||
#define IDC_SAFETY_HUB_SHOW_PASSWORD_CHECKUP 40280
|
||||
#define IDC_SAFETY_HUB_MANAGE_EXTENSIONS 40281
|
||||
#define IDC_SHOW_GOOGLE_LENS_SHORTCUT 40282
|
||||
#define IDC_SPELLCHECK_SUGGESTION_0 41000
|
||||
#define IDC_SPELLCHECK_SUGGESTION_1 41001
|
||||
#define IDC_SPELLCHECK_SUGGESTION_2 41002
|
||||
@ -418,7 +420,6 @@
|
||||
#define IDC_CONTENT_CONTEXT_QUICK_ANSWERS_INLINE_ANSWER 52413
|
||||
#define IDC_CONTENT_CONTEXT_QUICK_ANSWERS_INLINE_QUERY 52414
|
||||
#define IDC_CONTENT_CONTEXT_RUN_LAYOUT_EXTRACTION 52420
|
||||
#define IDC_CONTENT_CONTEXT_PDF_OCR 52421
|
||||
#define IDC_TAB_SEARCH 52500
|
||||
#define IDC_TAB_SEARCH_CLOSE 52501
|
||||
#define IDC_DEBUG_TOGGLE_TABLET_MODE 52510
|
||||
|
||||
3288
3rdparty/libcef_dll_wrapper/include/cef_pack_resources.h
vendored
3288
3rdparty/libcef_dll_wrapper/include/cef_pack_resources.h
vendored
File diff suppressed because it is too large
Load Diff
21994
3rdparty/libcef_dll_wrapper/include/cef_pack_strings.h
vendored
21994
3rdparty/libcef_dll_wrapper/include/cef_pack_strings.h
vendored
File diff suppressed because it is too large
Load Diff
@ -35,18 +35,18 @@
|
||||
#ifndef CEF_INCLUDE_CEF_VERSION_H_
|
||||
#define CEF_INCLUDE_CEF_VERSION_H_
|
||||
|
||||
#define CEF_VERSION "126.2.18+g3647d39+chromium-126.0.6478.183"
|
||||
#define CEF_VERSION_MAJOR 126
|
||||
#define CEF_VERSION_MINOR 2
|
||||
#define CEF_VERSION_PATCH 18
|
||||
#define CEF_COMMIT_NUMBER 3019
|
||||
#define CEF_COMMIT_HASH "3647d39e700c215bd78172c5964eb1c550950f0f"
|
||||
#define CEF_VERSION "127.3.5+g114ea2a+chromium-127.0.6533.120"
|
||||
#define CEF_VERSION_MAJOR 127
|
||||
#define CEF_VERSION_MINOR 3
|
||||
#define CEF_VERSION_PATCH 5
|
||||
#define CEF_COMMIT_NUMBER 3037
|
||||
#define CEF_COMMIT_HASH "114ea2af1ba9da18c4ac5e599ccdbb17d01ba75a"
|
||||
#define COPYRIGHT_YEAR 2024
|
||||
|
||||
#define CHROME_VERSION_MAJOR 126
|
||||
#define CHROME_VERSION_MAJOR 127
|
||||
#define CHROME_VERSION_MINOR 0
|
||||
#define CHROME_VERSION_BUILD 6478
|
||||
#define CHROME_VERSION_PATCH 183
|
||||
#define CHROME_VERSION_BUILD 6533
|
||||
#define CHROME_VERSION_PATCH 120
|
||||
|
||||
#define DO_MAKE_STRING(p) #p
|
||||
#define MAKE_STRING(p) DO_MAKE_STRING(p)
|
||||
|
||||
@ -514,6 +514,13 @@ typedef struct _cef_settings_t {
|
||||
/// runtime on Windows.
|
||||
///
|
||||
int chrome_app_icon_id;
|
||||
|
||||
#if defined(OS_POSIX) && !defined(OS_ANDROID)
|
||||
///
|
||||
/// Specify whether signal handlers must be disabled on POSIX systems.
|
||||
///
|
||||
int disable_signal_handlers;
|
||||
#endif
|
||||
} cef_settings_t;
|
||||
|
||||
///
|
||||
|
||||
@ -438,12 +438,12 @@ typedef enum {
|
||||
|
||||
/// Website setting which is used for UnusedSitePermissionsService to store
|
||||
/// auto-revoked notification permissions from abusive sites.
|
||||
REVOKED_ABUSIVE_NOTIFICATION_PERMISSIONS,
|
||||
CEF_CONTENT_SETTING_TYPE_REVOKED_ABUSIVE_NOTIFICATION_PERMISSIONS,
|
||||
|
||||
/// Content setting that controls tracking protection status per site.
|
||||
/// BLOCK: Protections enabled. This is the default state.
|
||||
/// ALLOW: Protections disabled.
|
||||
TRACKING_PROTECTION,
|
||||
CEF_CONTENT_SETTING_TYPE_TRACKING_PROTECTION,
|
||||
} cef_content_setting_types_t;
|
||||
|
||||
///
|
||||
|
||||
@ -437,6 +437,10 @@ struct CefSettingsTraits {
|
||||
cef_string_set(src->chrome_policy_id.str, src->chrome_policy_id.length,
|
||||
&target->chrome_policy_id, copy);
|
||||
target->chrome_app_icon_id = src->chrome_app_icon_id;
|
||||
|
||||
#if defined(OS_POSIX) && !defined(OS_ANDROID)
|
||||
target->disable_signal_handlers = src->disable_signal_handlers;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
BIN
3rdparty/libcef_dll_wrapper/lib/libcef_dll_wrapper.a
vendored
BIN
3rdparty/libcef_dll_wrapper/lib/libcef_dll_wrapper.a
vendored
Binary file not shown.
@ -16,28 +16,43 @@ set(CMAKE_FOLDER "QCefView")
|
||||
# - refer to: cmake\QtConfig.cmake
|
||||
#
|
||||
SET(QT_SDK_DIR "D:/Dev/Qt/6.8.0/mingw1310_static_x64/lib/cmake")
|
||||
|
||||
#变量缓存清理,获取所有缓存变量列表
|
||||
get_cmake_property(cache_vars CACHE_VARIABLES)
|
||||
|
||||
# 遍历变量并删除匹配项
|
||||
foreach(var IN LISTS cache_vars)
|
||||
if(var MATCHES "^BUILD_")
|
||||
unset(${var} CACHE)
|
||||
endif()
|
||||
if(var MATCHES "^STATIC_")
|
||||
unset(${var} CACHE)
|
||||
endif()
|
||||
if(var MATCHES "^USE_")
|
||||
unset(${var} CACHE)
|
||||
endif()
|
||||
endforeach()
|
||||
# options
|
||||
option(BUILD_DEMO "Build the demo" OFF)
|
||||
option(BUILD_STATIC "Build QCefView as static library" ON)
|
||||
option(STATIC_CRT "Use MultiThreaded linkage for MSVC" OFF)
|
||||
option(USE_SANDBOX "Enable CEF Sandbox" OFF)
|
||||
option(USE_WIN_DCOMPOSITION "Enabled Windows direct composition for hardware rendering, _WIN32_WINNT >= 0x602 (Windows 8) is required" ON)
|
||||
SET(CMAKE_BUILD_TYPE "Release")
|
||||
# Only works for Windows & Linux, always enabled on macOS
|
||||
# If enable then:
|
||||
# CefSettings.multi_threaded_message_loop = false && CefSettings.external_message_pump = true
|
||||
# else:
|
||||
# CefSettings.multi_threaded_message_loop = true && CefSettings.external_message_pump = false
|
||||
option(USE_QT_EVENT_LOOP "Enable the integration of CEF message loop thread into Qt event loop" OFF)
|
||||
option(USE_QT_EVENT_LOOP "Enable the integration of CEF message loop thread into Qt event loop" ON)
|
||||
|
||||
# append cmake config module path
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
# Only generate Debug and Release configuration types.
|
||||
set(CMAKE_CONFIGURATION_TYPES Debug Release)
|
||||
# 指定仅支持 Debug 和 Release 两种配置
|
||||
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Debug")
|
||||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose build type" FORCE)
|
||||
endif()
|
||||
|
||||
# Use folders in the resulting project files.
|
||||
@ -51,18 +66,19 @@ set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
add_definitions(-D_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING=1)
|
||||
# 禁用弃用警告
|
||||
if(MSVC)
|
||||
add_definitions(-D_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING=1)
|
||||
elseif(MINGW)
|
||||
add_compile_options(-Wno-deprecated-declarations)
|
||||
endif()
|
||||
|
||||
# Determine the project architecture.
|
||||
if(NOT DEFINED PROJECT_ARCH)
|
||||
if(OS_WINDOWS AND "${CMAKE_GENERATOR_PLATFORM}" STREQUAL "arm64")
|
||||
set(PROJECT_ARCH "arm64")
|
||||
elseif(CMAKE_SIZEOF_VOID_P MATCHES 8)
|
||||
if(CMAKE_SIZEOF_VOID_P MATCHES 8)
|
||||
set(PROJECT_ARCH "x86_64")
|
||||
else()
|
||||
set(PROJECT_ARCH "x86")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
||||
set(OS_MACOS 1)
|
||||
@ -90,7 +106,7 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||
set(OS_POSIX 1)
|
||||
add_definitions(-DOS_LINUX=1 -DOS_POSIX=1)
|
||||
add_compile_options(
|
||||
#"-g"
|
||||
"-g"
|
||||
"$<$<CONFIG:DEBUG>:-O0>"
|
||||
"$<$<CONFIG:RELEASE>:-O3>"
|
||||
)
|
||||
@ -105,35 +121,52 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||
add_link_options(-m32)
|
||||
endif()
|
||||
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
|
||||
set(OS_WINDOWS 1)
|
||||
if(MSVC)
|
||||
set(OS_WINDOWS 1)
|
||||
|
||||
# Disable the sandbox on Windows, because the sandbox.lib is MT which is conflict with Qt
|
||||
set(USE_SANDBOX OFF CACHE BOOL "Disable sandbox on Windows" FORCE)
|
||||
add_definitions(
|
||||
-DOS_WINDOWS=1
|
||||
-D_WIN32_WINNT=0x0A00
|
||||
)
|
||||
|
||||
if(USE_WIN_DCOMPOSITION)
|
||||
# Disable the sandbox on Windows, because the sandbox.lib is MT which is conflict with Qt
|
||||
set(USE_SANDBOX OFF CACHE BOOL "Disable sandbox on Windows" FORCE)
|
||||
add_definitions(
|
||||
-DENABLE_WINDOWS_DIRECT_COMPOSITION=1
|
||||
-DOS_WINDOWS=1
|
||||
-D_WIN32_WINNT=0x0A00
|
||||
)
|
||||
|
||||
if(USE_WIN_DCOMPOSITION)
|
||||
add_definitions(
|
||||
-DENABLE_WINDOWS_DIRECT_COMPOSITION=1
|
||||
)
|
||||
endif()
|
||||
|
||||
add_compile_options(
|
||||
/W3
|
||||
/WX
|
||||
/M$<IF:$<BOOL:${STATIC_CRT}>,T,D>$<$<CONFIG:Debug>:d>
|
||||
)
|
||||
add_link_options(/DEBUG)
|
||||
elseif(MINGW)
|
||||
set(OS_WINDOWS 1)
|
||||
add_definitions(
|
||||
-DOS_WINDOWS=1
|
||||
-D_WIN32_WINNT=0x0A00
|
||||
)
|
||||
if(USE_WIN_DCOMPOSITION)
|
||||
add_definitions(
|
||||
-DENABLE_WINDOWS_DIRECT_COMPOSITION=1
|
||||
)
|
||||
endif()
|
||||
add_definitions(
|
||||
-DOS_WINDOWS=1
|
||||
-D_WIN32_WINNT=0x0A00
|
||||
)
|
||||
endif()
|
||||
add_compile_options(
|
||||
#"-g"
|
||||
"$<$<CONFIG:DEBUG>:-O0>"
|
||||
"$<$<CONFIG:RELEASE>:-O3>"
|
||||
)
|
||||
# add_compile_options(
|
||||
# /W3
|
||||
# /WX
|
||||
# /M$<IF:$<BOOL:${STATIC_CRT}>,T,D>$<$<CONFIG:Debug>:d>
|
||||
# )
|
||||
# add_link_options(/DEBUG)
|
||||
endif()
|
||||
|
||||
set(QCEFVIEW_LIB_TYPE STATIC)
|
||||
add_definitions(-DQCEFVIEW_STATIC=1)
|
||||
if(BUILD_STATIC)
|
||||
set(QCEFVIEW_LIB_TYPE STATIC)
|
||||
add_definitions(-DQCEFVIEW_STATIC=1)
|
||||
else()
|
||||
set(QCEFVIEW_LIB_TYPE SHARED)
|
||||
endif()
|
||||
|
||||
# detect whether we are in sub folder
|
||||
get_directory_property(QCefView_HAS_PARENT_DIRECTORY PARENT_DIRECTORY)
|
||||
@ -141,10 +174,16 @@ get_directory_property(QCefView_HAS_PARENT_DIRECTORY PARENT_DIRECTORY)
|
||||
if(NOT QCefView_HAS_PARENT_DIRECTORY)
|
||||
message(STATUS "QCefView is not in subdirectory, put all output together")
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/$<CONFIG>/bin)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/$<CONFIG>/bin)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/$<CONFIG>/lib)
|
||||
if(BUILD_STATIC)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/$<CONFIG>/lib)
|
||||
else()
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/$<CONFIG>/bin)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message(STATUS "QCEFVIEW_RUNTIME_OUTPUT_DIRECTORY: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
|
||||
message(STATUS "QCEFVIEW_LIBRARY_OUTPUT_DIRECTORY: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
|
||||
message(STATUS "QCEFVIEW_ARCHIVE_OUTPUT_DIRECTORY: ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}")
|
||||
# Config the QT package
|
||||
# ##############################################################
|
||||
set(QT_SDK_DIR "" CACHE PATH "Qt build toolchain path")
|
||||
@ -182,11 +221,11 @@ if(OS_MACOS)
|
||||
endif()
|
||||
|
||||
# use the greater one as the minimum deployment target
|
||||
# if(${QT_MIN_DEPLOYMENT_TARGET} VERSION_LESS ${CEF_MIN_DEPLOYMENT_TARGET})
|
||||
# set(CMAKE_OSX_DEPLOYMENT_TARGET ${CEF_MIN_DEPLOYMENT_TARGET})
|
||||
# else()
|
||||
# set(CMAKE_OSX_DEPLOYMENT_TARGET ${QT_MIN_DEPLOYMENT_TARGET})
|
||||
# endif()
|
||||
if(${QT_MIN_DEPLOYMENT_TARGET} VERSION_LESS ${CEF_MIN_DEPLOYMENT_TARGET})
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET ${CEF_MIN_DEPLOYMENT_TARGET})
|
||||
else()
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET ${QT_MIN_DEPLOYMENT_TARGET})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Config QCefView target
|
||||
@ -195,8 +234,8 @@ add_subdirectory(src)
|
||||
|
||||
# Config the Demo project
|
||||
# ##############################################################
|
||||
# if(BUILD_DEMO)
|
||||
# add_subdirectory(example/QCefViewTest)
|
||||
# endif()
|
||||
if(BUILD_DEMO)
|
||||
add_subdirectory(example/QCefViewTest)
|
||||
endif()
|
||||
|
||||
# ##############################################################
|
||||
|
||||
253
3rdparty_build/QCefView/src/CMakeLists.txt
Normal file
253
3rdparty_build/QCefView/src/CMakeLists.txt
Normal file
@ -0,0 +1,253 @@
|
||||
# ## QCefView
|
||||
# ###############################################################################################
|
||||
set(CMAKE_GLOBAL_AUTOGEN_TARGET OFF)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets REQUIRED)
|
||||
|
||||
file(GLOB_RECURSE QCefView_INCLUDE_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../include/*.h"
|
||||
)
|
||||
source_group(
|
||||
TREE "${CMAKE_CURRENT_SOURCE_DIR}/../include"
|
||||
PREFIX Include
|
||||
FILES ${QCefView_INCLUDE_FILES}
|
||||
)
|
||||
|
||||
file(GLOB QCefView_SRC_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
|
||||
)
|
||||
source_group(
|
||||
TREE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PREFIX Source
|
||||
FILES ${QCefView_SRC_FILES}
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE QCefView_details_SRC_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/details/*.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/details/*.cpp"
|
||||
)
|
||||
source_group(
|
||||
TREE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PREFIX Source
|
||||
FILES ${QCefView_details_SRC_FILES}
|
||||
)
|
||||
|
||||
if(USE_SANDBOX AND(OS_WINDOWS OR OS_MACOS))
|
||||
add_definitions(-DCEF_USE_SANDBOX)
|
||||
endif()
|
||||
|
||||
if(USE_QT_EVENT_LOOP)
|
||||
add_definitions(-DCEF_USE_QT_EVENT_LOOP)
|
||||
endif()
|
||||
|
||||
if(OS_WINDOWS)
|
||||
file(GLOB_RECURSE QCefView_Windows_SRC_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/win/*.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/win/*.cpp"
|
||||
)
|
||||
source_group(
|
||||
TREE "${CMAKE_CURRENT_SOURCE_DIR}/win"
|
||||
PREFIX Source
|
||||
FILES ${QCefView_Windows_SRC_FILES}
|
||||
)
|
||||
|
||||
add_library(QCefView ${QCEFVIEW_LIB_TYPE}
|
||||
${QCefView_INCLUDE_FILES}
|
||||
${QCefView_SRC_FILES}
|
||||
${QCefView_details_SRC_FILES}
|
||||
${QCefView_Windows_SRC_FILES}
|
||||
)
|
||||
|
||||
target_compile_definitions(QCefView PRIVATE
|
||||
UNICODE
|
||||
_UNICODE
|
||||
QCEFVIEW_LIB
|
||||
)
|
||||
|
||||
target_link_options(QCefView PRIVATE
|
||||
"/DELAYLOAD:libcef.dll"
|
||||
)
|
||||
|
||||
target_link_libraries(QCefView
|
||||
PRIVATE
|
||||
d3d11
|
||||
d3dcompiler
|
||||
dcomp
|
||||
)
|
||||
|
||||
# add_custom_command(TARGET QCefView
|
||||
# PRE_BUILD
|
||||
|
||||
# # copy binary files of CefViewCore
|
||||
# COMMAND ${CMAKE_COMMAND}
|
||||
# -E copy_directory
|
||||
# "$<TARGET_FILE_DIR:${CEFVIEW_WING_NAME}>"
|
||||
# "$<TARGET_FILE_DIR:QCefView>/CefView"
|
||||
|
||||
# # gnerate a file contains timestamp
|
||||
# COMMAND ${CMAKE_COMMAND}
|
||||
# -E echo "/* Auto Build Trigger */" > "${CMAKE_BINARY_DIR}/auto_rebuild.cpp"
|
||||
# )
|
||||
endif() # OS_WINDOWS
|
||||
|
||||
if(OS_LINUX)
|
||||
find_package(Qt${QT_VERSION_MAJOR}Gui ${QT_MIN_VERSION} CONFIG REQUIRED Private)
|
||||
|
||||
file(GLOB_RECURSE QCefView_Linux_SRC_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/linux/*.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/linux/*.cpp"
|
||||
)
|
||||
source_group(
|
||||
TREE "${CMAKE_CURRENT_SOURCE_DIR}/linux"
|
||||
PREFIX Source
|
||||
FILES ${QCefView_Linux_SRC_FILES}
|
||||
)
|
||||
|
||||
add_library(QCefView ${QCEFVIEW_LIB_TYPE}
|
||||
${QCefView_INCLUDE_FILES}
|
||||
${QCefView_SRC_FILES}
|
||||
${QCefView_details_SRC_FILES}
|
||||
${QCefView_Linux_SRC_FILES}
|
||||
)
|
||||
|
||||
target_compile_definitions(QCefView
|
||||
PRIVATE
|
||||
QCEFVIEW_LIB
|
||||
)
|
||||
|
||||
set_target_properties(${PROJECT_NAME}
|
||||
PROPERTIES
|
||||
INSTALL_RPATH "$ORIGIN"
|
||||
BUILD_WITH_INSTALL_RPATH TRUE
|
||||
)
|
||||
|
||||
add_custom_command(TARGET QCefView
|
||||
PRE_BUILD
|
||||
|
||||
# copy binary files of CefViewCore
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-E copy_directory
|
||||
"$<TARGET_FILE_DIR:${CEFVIEW_WING_NAME}>"
|
||||
"$<TARGET_FILE_DIR:QCefView>"
|
||||
)
|
||||
endif() # OS_LINUX
|
||||
|
||||
if(OS_MACOS)
|
||||
file(GLOB_RECURSE QCefView_INCLUDE_HEADERS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../include/*.h"
|
||||
)
|
||||
source_group(
|
||||
TREE "${CMAKE_CURRENT_SOURCE_DIR}/../include"
|
||||
PREFIX Include
|
||||
FILES ${QCefView_INCLUDE_HEADERS}
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE QCefView_macOS_SRC_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/mac/*.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/mac/*.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/mac/*.mm"
|
||||
)
|
||||
source_group(
|
||||
TREE "${CMAKE_CURRENT_SOURCE_DIR}/mac"
|
||||
PREFIX Source
|
||||
FILES ${QCefView_macOS_SRC_FILES}
|
||||
)
|
||||
set(QCefView_INFO_PLIST_FILE "${CMAKE_CURRENT_LIST_DIR}/mac/Info.plist")
|
||||
|
||||
add_library(QCefView ${QCEFVIEW_LIB_TYPE}
|
||||
${QCefView_INCLUDE_FILES}
|
||||
${QCefView_SRC_FILES}
|
||||
${QCefView_details_SRC_FILES}
|
||||
${QCefView_macOS_SRC_FILES}
|
||||
${QCefView_INFO_PLIST_FILE}
|
||||
)
|
||||
|
||||
find_library(METAL_FRAMEWORK Metal)
|
||||
find_library(QUARTZCORE_FRAMEWORK QuartzCore)
|
||||
target_link_libraries(QCefView
|
||||
PRIVATE
|
||||
${METAL_FRAMEWORK}
|
||||
${QUARTZCORE_FRAMEWORK}
|
||||
)
|
||||
|
||||
set_target_properties(QCefView
|
||||
PROPERTIES
|
||||
FRAMEWORK TRUE
|
||||
|
||||
# compiler settings
|
||||
COMPILE_FLAGS "-fobjc-arc"
|
||||
CLANG_ENABLE_OBJC_ARC "YES"
|
||||
|
||||
# xcode settings
|
||||
PUBLIC_HEADER "${QCefView_INCLUDE_HEADERS}"
|
||||
MACOSX_FRAMEWORK_INFO_PLIST "${QCefView_INFO_PLIST_FILE}"
|
||||
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "com.cefview.qcefview"
|
||||
XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "gnu++11" # -std=gnu++11
|
||||
XCODE_ATTRIBUTE_CLANG_LINK_OBJC_RUNTIME "NO" # -fno-objc-link-runtime
|
||||
XCODE_ATTRIBUTE_COPY_PHASE_STRIP "NO"
|
||||
XCODE_ATTRIBUTE_DEAD_CODE_STRIPPING[variant=Release] "YES" # -Wl,-dead_strip
|
||||
XCODE_ATTRIBUTE_GCC_C_LANGUAGE_STANDARD "c99" # -std=c99
|
||||
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../Frameworks @loader_path/Frameworks"
|
||||
)
|
||||
|
||||
add_custom_command(TARGET QCefView
|
||||
POST_BUILD
|
||||
|
||||
# create plugins directory
|
||||
COMMAND mkdir -p
|
||||
"$<TARGET_BUNDLE_DIR:QCefView>/Resources/PlugIns/"
|
||||
|
||||
# copy the CefViewCore binaries to resource directory
|
||||
COMMAND cp -a
|
||||
"$<TARGET_BUNDLE_DIR:CefViewWing>/../"
|
||||
"$<TARGET_BUNDLE_DIR:QCefView>/Resources/PlugIns/"
|
||||
|
||||
# adjust file permission
|
||||
COMMAND
|
||||
cd "$<TARGET_BUNDLE_DIR:QCefView>/Resources/PlugIns/Chromium Embedded Framework.framework/Resources" && chmod +rw *.bin
|
||||
|
||||
# sign the cef framework
|
||||
COMMAND codesign
|
||||
--force
|
||||
--sign -
|
||||
"$<TARGET_BUNDLE_DIR:QCefView>/Resources/PlugIns/Chromium Embedded Framework.framework"
|
||||
)
|
||||
endif() # OS_MACOS
|
||||
|
||||
target_compile_definitions(QCefView PRIVATE NOMINMAX)
|
||||
|
||||
target_include_directories(QCefView
|
||||
PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../include"
|
||||
PRIVATE
|
||||
${CefViewCore_EXPORT_INCLUDE_PATH}
|
||||
)
|
||||
|
||||
add_dependencies(QCefView
|
||||
CefViewCore::CefViewCore
|
||||
)
|
||||
|
||||
target_link_libraries(QCefView
|
||||
PUBLIC
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Widgets
|
||||
PRIVATE
|
||||
CefViewCore::CefViewCore
|
||||
)
|
||||
|
||||
# install QCefView files
|
||||
install(
|
||||
TARGETS QCefView
|
||||
ARCHIVE DESTINATION "QCefView/lib$<$<CONFIG:Debug>:/Debug>"
|
||||
LIBRARY DESTINATION "QCefView/bin$<$<CONFIG:Debug>:/Debug>"
|
||||
FRAMEWORK DESTINATION "QCefView/lib$<$<CONFIG:Debug>:/Debug>"
|
||||
)
|
||||
|
||||
if(NOT OS_MACOS)
|
||||
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include" DESTINATION "QCefView")
|
||||
install(DIRECTORY "$<TARGET_FILE_DIR:QCefView>/" DESTINATION "QCefView/bin$<$<CONFIG:Debug>:/Debug>")
|
||||
endif()
|
||||
326
3rdparty_build/QCefView/thirdparty/CMakeLists.txt
vendored
326
3rdparty_build/QCefView/thirdparty/CMakeLists.txt
vendored
@ -1,66 +1,272 @@
|
||||
include(FetchContent)
|
||||
# ## QCefView
|
||||
# ###############################################################################################
|
||||
set(CMAKE_GLOBAL_AUTOGEN_TARGET OFF)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets REQUIRED)
|
||||
|
||||
if(NOT CEFVIEW_CORE_VERSION)
|
||||
set(DEFAULT_CEFVIEW_CORE_VERSION "ca9f2c009a6a248a13ff0a2e33bbf46e7a044581")
|
||||
set(CEFVIEW_CORE_VERSION ${DEFAULT_CEFVIEW_CORE_VERSION})
|
||||
message(STATUS "CEFVIEW_CORE_VERSION not set, use default value:${CEFVIEW_CORE_VERSION}")
|
||||
file(GLOB_RECURSE QCefView_INCLUDE_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../include/*.h"
|
||||
)
|
||||
source_group(
|
||||
TREE "${CMAKE_CURRENT_SOURCE_DIR}/../include"
|
||||
PREFIX Include
|
||||
FILES ${QCefView_INCLUDE_FILES}
|
||||
)
|
||||
|
||||
file(GLOB QCefView_SRC_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
|
||||
)
|
||||
source_group(
|
||||
TREE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PREFIX Source
|
||||
FILES ${QCefView_SRC_FILES}
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE QCefView_details_SRC_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/details/*.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/details/*.cpp"
|
||||
)
|
||||
source_group(
|
||||
TREE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PREFIX Source
|
||||
FILES ${QCefView_details_SRC_FILES}
|
||||
)
|
||||
|
||||
if(USE_SANDBOX AND(OS_WINDOWS OR OS_MACOS))
|
||||
add_definitions(-DCEF_USE_SANDBOX)
|
||||
endif()
|
||||
|
||||
# fetch CefViewCore project
|
||||
FetchContent_Declare(
|
||||
CefViewCore
|
||||
GIT_REPOSITORY https://github.com/CefView/CefViewCore.git
|
||||
GIT_TAG ${CEFVIEW_CORE_VERSION}
|
||||
if(USE_QT_EVENT_LOOP)
|
||||
add_definitions(-DCEF_USE_QT_EVENT_LOOP)
|
||||
endif()
|
||||
|
||||
if(OS_WINDOWS)
|
||||
file(GLOB_RECURSE QCefView_Windows_SRC_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/win/*.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/win/*.cpp"
|
||||
)
|
||||
source_group(
|
||||
TREE "${CMAKE_CURRENT_SOURCE_DIR}/win"
|
||||
PREFIX Source
|
||||
FILES ${QCefView_Windows_SRC_FILES}
|
||||
)
|
||||
|
||||
add_library(QCefView ${QCEFVIEW_LIB_TYPE}
|
||||
${QCefView_INCLUDE_FILES}
|
||||
${QCefView_SRC_FILES}
|
||||
${QCefView_details_SRC_FILES}
|
||||
${QCefView_Windows_SRC_FILES}
|
||||
)
|
||||
|
||||
target_compile_definitions(QCefView PRIVATE
|
||||
UNICODE
|
||||
_UNICODE
|
||||
QCEFVIEW_LIB
|
||||
)
|
||||
if(MSVC)
|
||||
target_link_options(QCefView PRIVATE
|
||||
"/DELAYLOAD:libcef.dll"
|
||||
)
|
||||
add_custom_command(TARGET QCefView
|
||||
PRE_BUILD
|
||||
|
||||
# copy binary files of CefViewCore
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-E copy_directory
|
||||
"$<TARGET_FILE_DIR:CefViewCore>"
|
||||
"$<TARGET_FILE_DIR:QCefView>/CefView"
|
||||
|
||||
# gnerate a file contains timestamp
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-E echo "/* Auto Build Trigger */" > "${CMAKE_BINARY_DIR}/auto_rebuild.cpp"
|
||||
)
|
||||
elseif(MINGW)
|
||||
target_link_options(QCefView PRIVATE
|
||||
"-Wl,--enable-auto-import"
|
||||
"-Wl,--as-needed"
|
||||
"-lcef"
|
||||
)
|
||||
add_custom_command(TARGET QCefView
|
||||
PRE_BUILD
|
||||
|
||||
# copy binary files of CefViewCore
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-E copy_directory
|
||||
"$<TARGET_FILE_DIR:CefViewCore>"
|
||||
"$<TARGET_FILE_DIR:QCefView>/CefView"
|
||||
|
||||
# generate a file contains timestamp
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-E echo "/* Auto Build Trigger */" > "${CMAKE_BINARY_DIR}/auto_rebuild.cpp"
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(QCefView
|
||||
PRIVATE
|
||||
d3d11
|
||||
d3dcompiler
|
||||
dcomp
|
||||
)
|
||||
endif() # OS_WINDOWS
|
||||
|
||||
if(OS_LINUX)
|
||||
find_package(Qt${QT_VERSION_MAJOR}Gui ${QT_MIN_VERSION} CONFIG REQUIRED Private)
|
||||
|
||||
file(GLOB_RECURSE QCefView_Linux_SRC_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/linux/*.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/linux/*.cpp"
|
||||
)
|
||||
source_group(
|
||||
TREE "${CMAKE_CURRENT_SOURCE_DIR}/linux"
|
||||
PREFIX Source
|
||||
FILES ${QCefView_Linux_SRC_FILES}
|
||||
)
|
||||
|
||||
add_library(QCefView ${QCEFVIEW_LIB_TYPE}
|
||||
${QCefView_INCLUDE_FILES}
|
||||
${QCefView_SRC_FILES}
|
||||
${QCefView_details_SRC_FILES}
|
||||
${QCefView_Linux_SRC_FILES}
|
||||
)
|
||||
|
||||
target_compile_definitions(QCefView
|
||||
PRIVATE
|
||||
QCEFVIEW_LIB
|
||||
)
|
||||
|
||||
set_target_properties(${PROJECT_NAME}
|
||||
PROPERTIES
|
||||
INSTALL_RPATH "$ORIGIN"
|
||||
BUILD_WITH_INSTALL_RPATH TRUE
|
||||
)
|
||||
|
||||
add_custom_command(TARGET QCefView
|
||||
PRE_BUILD
|
||||
|
||||
# copy binary files of CefViewCore
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-E copy_directory
|
||||
"$<TARGET_FILE_DIR:${CEFVIEW_WING_NAME}>"
|
||||
"$<TARGET_FILE_DIR:QCefView>"
|
||||
)
|
||||
endif() # OS_LINUX
|
||||
|
||||
if(OS_MACOS)
|
||||
file(GLOB_RECURSE QCefView_INCLUDE_HEADERS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../include/*.h"
|
||||
)
|
||||
source_group(
|
||||
TREE "${CMAKE_CURRENT_SOURCE_DIR}/../include"
|
||||
PREFIX Include
|
||||
FILES ${QCefView_INCLUDE_HEADERS}
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE QCefView_macOS_SRC_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/mac/*.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/mac/*.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/mac/*.mm"
|
||||
)
|
||||
source_group(
|
||||
TREE "${CMAKE_CURRENT_SOURCE_DIR}/mac"
|
||||
PREFIX Source
|
||||
FILES ${QCefView_macOS_SRC_FILES}
|
||||
)
|
||||
set(QCefView_INFO_PLIST_FILE "${CMAKE_CURRENT_LIST_DIR}/mac/Info.plist")
|
||||
|
||||
add_library(QCefView ${QCEFVIEW_LIB_TYPE}
|
||||
${QCefView_INCLUDE_FILES}
|
||||
${QCefView_SRC_FILES}
|
||||
${QCefView_details_SRC_FILES}
|
||||
${QCefView_macOS_SRC_FILES}
|
||||
${QCefView_INFO_PLIST_FILE}
|
||||
)
|
||||
|
||||
find_library(METAL_FRAMEWORK Metal)
|
||||
find_library(QUARTZCORE_FRAMEWORK QuartzCore)
|
||||
target_link_libraries(QCefView
|
||||
PRIVATE
|
||||
${METAL_FRAMEWORK}
|
||||
${QUARTZCORE_FRAMEWORK}
|
||||
)
|
||||
|
||||
set_target_properties(QCefView
|
||||
PROPERTIES
|
||||
FRAMEWORK TRUE
|
||||
|
||||
# compiler settings
|
||||
COMPILE_FLAGS "-fobjc-arc"
|
||||
CLANG_ENABLE_OBJC_ARC "YES"
|
||||
|
||||
# xcode settings
|
||||
PUBLIC_HEADER "${QCefView_INCLUDE_HEADERS}"
|
||||
MACOSX_FRAMEWORK_INFO_PLIST "${QCefView_INFO_PLIST_FILE}"
|
||||
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "com.cefview.qcefview"
|
||||
XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "gnu++11" # -std=gnu++11
|
||||
XCODE_ATTRIBUTE_CLANG_LINK_OBJC_RUNTIME "NO" # -fno-objc-link-runtime
|
||||
XCODE_ATTRIBUTE_COPY_PHASE_STRIP "NO"
|
||||
XCODE_ATTRIBUTE_DEAD_CODE_STRIPPING[variant=Release] "YES" # -Wl,-dead_strip
|
||||
XCODE_ATTRIBUTE_GCC_C_LANGUAGE_STANDARD "c99" # -std=c99
|
||||
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../Frameworks @loader_path/Frameworks"
|
||||
)
|
||||
|
||||
add_custom_command(TARGET QCefView
|
||||
POST_BUILD
|
||||
|
||||
# create plugins directory
|
||||
COMMAND mkdir -p
|
||||
"$<TARGET_BUNDLE_DIR:QCefView>/Resources/PlugIns/"
|
||||
|
||||
# copy the CefViewCore binaries to resource directory
|
||||
COMMAND cp -a
|
||||
"$<TARGET_BUNDLE_DIR:CefViewWing>/../"
|
||||
"$<TARGET_BUNDLE_DIR:QCefView>/Resources/PlugIns/"
|
||||
|
||||
# adjust file permission
|
||||
COMMAND
|
||||
cd "$<TARGET_BUNDLE_DIR:QCefView>/Resources/PlugIns/Chromium Embedded Framework.framework/Resources" && chmod +rw *.bin
|
||||
|
||||
# sign the cef framework
|
||||
COMMAND codesign
|
||||
--force
|
||||
--sign -
|
||||
"$<TARGET_BUNDLE_DIR:QCefView>/Resources/PlugIns/Chromium Embedded Framework.framework"
|
||||
)
|
||||
endif() # OS_MACOS
|
||||
|
||||
target_compile_definitions(QCefView PRIVATE NOMINMAX)
|
||||
|
||||
target_include_directories(QCefView
|
||||
PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../include"
|
||||
PRIVATE
|
||||
${CefViewCore_EXPORT_INCLUDE_PATH}
|
||||
)
|
||||
message(STATUS "CefViewCore_EXPORT_INCLUDE_PATH: ${CefViewCore_EXPORT_INCLUDE_PATH}")
|
||||
|
||||
add_dependencies(QCefView
|
||||
CefViewCore::CefViewCore
|
||||
)
|
||||
|
||||
# set CEF version to be used
|
||||
# https://cef-builds.spotifycdn.com/index.html
|
||||
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding.md
|
||||
# set(CEF_SDK_VERSION "89.0.18+gb36241d+chromium-89.0.4389.114") # GOOD
|
||||
# set(CEF_SDK_VERSION "91.1.23+g04c8d56+chromium-91.0.4472.164") # GOOD
|
||||
# set(CEF_SDK_VERSION "92.0.27+g274abcf+chromium-92.0.4515.159") # GOOD
|
||||
# set(CEF_SDK_VERSION "93.1.14+gf38ce34+chromium-93.0.4577.82") # GOOD
|
||||
# set(CEF_SDK_VERSION "94.4.11+gc4d96f0+chromium-94.0.4606.81") # GOOD
|
||||
# set(CEF_SDK_VERSION "95.7.18+g0d6005e+chromium-95.0.4638.69") # GOOD
|
||||
# set(CEF_SDK_VERSION "96.0.18+gfe551e4+chromium-96.0.4664.110") # GOOD
|
||||
# set(CEF_SDK_VERSION "97.1.9+ga00bca5+chromium-97.0.4692.99") # GOOD
|
||||
# set(CEF_SDK_VERSION "98.2.1+g29d6e22+chromium-98.0.4758.109") # GOOD
|
||||
# set(CEF_SDK_VERSION "99.2.15+g71e9523+chromium-99.0.4844.84") # IME poisition incorrect
|
||||
# set(CEF_SDK_VERSION "100.0.24+g0783cf8+chromium-100.0.4896.127") # IME poisition incorrect
|
||||
# set(CEF_SDK_VERSION "101.0.18+g367b4a0+chromium-101.0.4951.67") # IME poisition incorrect
|
||||
# set(CEF_SDK_VERSION "102.0.10+gf249b2e+chromium-102.0.5005.115") # IME poisition incorrect
|
||||
# set(CEF_SDK_VERSION "103.0.12+g8eb56c7+chromium-103.0.5060.134") # IME poisition incorrect
|
||||
# set(CEF_SDK_VERSION "104.4.26+g4180781+chromium-104.0.5112.102") # GOOD
|
||||
# set(CEF_SDK_VERSION "105.3.39+g2ec21f9+chromium-105.0.5195.127") # GOOD
|
||||
# set(CEF_SDK_VERSION "106.1.1+g5891c70+chromium-106.0.5249.119") # GOOD
|
||||
# set(CEF_SDK_VERSION "107.1.12+g65b79a6+chromium-107.0.5304.122") # GOOD
|
||||
# set(CEF_SDK_VERSION "108.4.13+ga98cd4c+chromium-108.0.5359.125") # GOOD
|
||||
# set(CEF_SDK_VERSION "109.1.18+gf1c41e4+chromium-109.0.5414.120") # GOOD
|
||||
# set(CEF_SDK_VERSION "110.0.32+g291f1df+chromium-110.0.5481.180") # GOOD
|
||||
# set(CEF_SDK_VERSION "111.2.7+gebf5d6a+chromium-111.0.5563.148") # GOOD
|
||||
# set(CEF_SDK_VERSION "112.3.0+gb09c4ca+chromium-112.0.5615.165") # GOOD
|
||||
# set(CEF_SDK_VERSION "113.3.1+g525fa10+chromium-113.0.5672.128") # GOOD
|
||||
# set(CEF_SDK_VERSION "119.4.7+g55e15c8+chromium-119.0.6045.199") # GOOD
|
||||
# set(CEF_SDK_VERSION "120.1.6+gf08b1fd+chromium-120.0.6099.71") # GOOD
|
||||
# set(CEF_SDK_VERSION "121.3.15+g4d3b0b4+chromium-121.0.6167.184") # GOOD
|
||||
# set(CEF_SDK_VERSION "122.1.13+gde5b724+chromium-122.0.6261.130") # GOOD
|
||||
# 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 "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
|
||||
|
||||
# set(CEF_SDK_VERSION "128.4.9+g9840ad9+chromium-128.0.6613.120") # BAD # debugbreak - debug mode
|
||||
|
||||
# set folder
|
||||
set(CMAKE_FOLDER "QCefView/Core")
|
||||
|
||||
# populate CefViewCore project
|
||||
FetchContent_MakeAvailable(CefViewCore)
|
||||
|
||||
configure_file(
|
||||
"${CefViewCore_SOURCE_DIR}/include/CefVersion.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../include/CefVersion.h"
|
||||
COPYONLY
|
||||
target_link_libraries(QCefView
|
||||
PUBLIC
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Widgets
|
||||
CefViewCore::CefViewCore
|
||||
)
|
||||
|
||||
# install QCefView files
|
||||
install(
|
||||
TARGETS QCefView
|
||||
ARCHIVE DESTINATION "QCefView/lib$<$<CONFIG:Debug>:/Debug>"
|
||||
LIBRARY DESTINATION "QCefView/bin$<$<CONFIG:Debug>:/Debug>"
|
||||
FRAMEWORK DESTINATION "QCefView/lib$<$<CONFIG:Debug>:/Debug>"
|
||||
)
|
||||
|
||||
if(NOT OS_MACOS)
|
||||
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include" DESTINATION "QCefView")
|
||||
install(DIRECTORY "$<TARGET_FILE_DIR:QCefView>/" DESTINATION "QCefView/bin$<$<CONFIG:Debug>:/Debug>")
|
||||
endif()
|
||||
|
||||
@ -1,5 +1,23 @@
|
||||
生成QCefView.a库的时候请先把
|
||||
build/_deps/cefviewcore-build/output/lib下的.a库放到
|
||||
build/out/Release/lib下
|
||||
顺便把build/_deps/cefviewcore-src/dep/cef_binary/Release下的libcef.lib改名为libcef.a并放到
|
||||
build/out/Release/lib下
|
||||
使用情况CMakelists.txt
|
||||
add_definitions(-DQCEFVIEW_STATIC)
|
||||
#libcef_dll_wrapper
|
||||
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/CefViewCore/include)
|
||||
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/CefViewCore/lib)
|
||||
|
||||
#QCefView
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/QCefView/include)
|
||||
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/QCefView/lib)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
-lQCefView
|
||||
-lCefViewCore
|
||||
-lcef_dll_wrapper
|
||||
-lcef
|
||||
d3d11
|
||||
d3dcompiler
|
||||
dcomp
|
||||
)
|
||||
@ -71,13 +71,14 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cmark-gfm/extensions)
|
||||
add_subdirectory(${PROJECT_SOURCE_DIR}/3rdparty/MicroTeX)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/MicroTeX/src)
|
||||
|
||||
add_definitions(-DQCEFVIEW_STATIC)
|
||||
#libcef_dll_wrapper
|
||||
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)
|
||||
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/QCefViewCore/lib)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/CefViewCore/include)
|
||||
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/CefViewCore/lib)
|
||||
|
||||
#QCefView
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/QCefView/include)
|
||||
@ -93,7 +94,7 @@ MESSAGE(STATUS "---------- END---------------")
|
||||
|
||||
#增加sui的cpp
|
||||
FILE(GLOB src_sui "${PROJECT_SOURCE_DIR}/src/*.*")
|
||||
FILE(GLOB browser "${PROJECT_SOURCE_DIR}/src/browser/*.*")
|
||||
FILE(GLOB browser "${PROJECT_SOURCE_DIR}/src/Cef/*.*")
|
||||
SET(PROJECT_SOURCES ${browser} ${src_sui})
|
||||
|
||||
# 设置消息策略为qFatal来禁用qDebug信息
|
||||
@ -165,8 +166,8 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
-lCefViewCore
|
||||
-lcef_dll_wrapper
|
||||
-lcef
|
||||
-std=c++17
|
||||
-static-libgcc
|
||||
-static-libstdc++
|
||||
d3d11
|
||||
d3dcompiler
|
||||
dcomp
|
||||
)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
52
src/Cef/CefDownloadManager.cpp
Normal file
52
src/Cef/CefDownloadManager.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
#include "CefDownloadManager.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
CefDownloadManager&
|
||||
CefDownloadManager::getInstance()
|
||||
{
|
||||
static CefDownloadManager s_instance;
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
void
|
||||
CefDownloadManager::AddNewDownloadItem(const QSharedPointer<QCefDownloadItem>& item)
|
||||
{
|
||||
qDebug() << "downloadManager::AddNewDownloadItem:"
|
||||
<< " id: " << item->id() << "\n"
|
||||
<< " name: " << item->suggestedFileName() << "\n"
|
||||
<< " path: " << item->fullPath() << "\n"
|
||||
<< " percent: " << item->percentComplete() << "%, " << item->totalBytes() << "/" << item->receivedBytes()
|
||||
<< "\n"
|
||||
<< " canceled: " << item->isCanceled() << "\n"
|
||||
<< " complete: " << item->isComplete();
|
||||
|
||||
m_mapDownloadingItem[item->id()] = item;
|
||||
item->start("", true);
|
||||
}
|
||||
|
||||
void
|
||||
CefDownloadManager::UpdateDownloadItem(const QSharedPointer<QCefDownloadItem>& item)
|
||||
{
|
||||
qDebug() << "downloadManager::UpdateDownloadItem:"
|
||||
<< " id: " << item->id() << "\n"
|
||||
<< " name: " << item->suggestedFileName() << "\n"
|
||||
<< " path: " << item->fullPath() << "\n"
|
||||
<< " percent: " << item->percentComplete() << "%, " << item->totalBytes() << "/" << item->receivedBytes()
|
||||
<< "\n"
|
||||
<< " canceled: " << item->isCanceled() << "\n"
|
||||
<< " complete: " << item->isComplete();
|
||||
|
||||
if (item->isCanceled() || item->isComplete())
|
||||
m_mapDownloadingItem.remove(item->id());
|
||||
}
|
||||
|
||||
CefDownloadManager::CefDownloadManager() {}
|
||||
|
||||
CefDownloadManager::~CefDownloadManager()
|
||||
{
|
||||
for (auto& item : m_mapDownloadingItem) {
|
||||
item->cancel();
|
||||
}
|
||||
m_mapDownloadingItem.clear();
|
||||
}
|
||||
26
src/Cef/CefDownloadManager.h
Normal file
26
src/Cef/CefDownloadManager.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef CEFDOWNLOADMANAGER_H
|
||||
#define CEFDOWNLOADMANAGER_H
|
||||
#pragma once
|
||||
|
||||
#include <QMap>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include <QCefDownloadItem.h>
|
||||
|
||||
class CefDownloadManager
|
||||
{
|
||||
public:
|
||||
static CefDownloadManager& getInstance();
|
||||
|
||||
void AddNewDownloadItem(const QSharedPointer<QCefDownloadItem>& item);
|
||||
|
||||
void UpdateDownloadItem(const QSharedPointer<QCefDownloadItem>& item);
|
||||
|
||||
private:
|
||||
CefDownloadManager();
|
||||
~CefDownloadManager();
|
||||
|
||||
QMap<qint32, QSharedPointer<QCefDownloadItem>> m_mapDownloadingItem;
|
||||
};
|
||||
|
||||
#endif
|
||||
128
src/Cef/CefViewWidget.cpp
Normal file
128
src/Cef/CefViewWidget.cpp
Normal file
@ -0,0 +1,128 @@
|
||||
#include "CefViewWidget.h"
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
#include <windows.h>
|
||||
#elif defined(Q_OS_MAC)
|
||||
#elif defined(Q_OS_LINUX)
|
||||
#else
|
||||
#endif
|
||||
|
||||
#include <QColor>
|
||||
#include <QDebug>
|
||||
#include <QPainterPath>
|
||||
#include <QRandomGenerator>
|
||||
#include <QResizeEvent>
|
||||
#include <QWindow>
|
||||
|
||||
#include "CefDownloadManager.h"
|
||||
|
||||
CefViewWidget::CefViewWidget(const QString url, const QCefSetting* setting, QWidget* parent /* = 0*/)
|
||||
: QCefView(url, setting, parent)
|
||||
{
|
||||
// setStyleSheet("background: blue;");
|
||||
|
||||
connect(this, &CefViewWidget::draggableRegionChanged, this, &CefViewWidget::onDraggableRegionChanged);
|
||||
connect(this, &CefViewWidget::nativeBrowserCreated, this, &CefViewWidget::onNativeBrowserWindowCreated);
|
||||
}
|
||||
|
||||
CefViewWidget::~CefViewWidget() {}
|
||||
|
||||
void
|
||||
CefViewWidget::onScreenChanged(QScreen* screen)
|
||||
{
|
||||
if (!m_pCefWindow)
|
||||
return;
|
||||
|
||||
updateMask();
|
||||
}
|
||||
|
||||
void
|
||||
CefViewWidget::onNativeBrowserWindowCreated(QWindow* window)
|
||||
{
|
||||
m_pCefWindow = window;
|
||||
if (!m_pCefWindow)
|
||||
return;
|
||||
|
||||
connect(this->window()->windowHandle(), SIGNAL(screenChanged(QScreen*)), this, SLOT(onScreenChanged(QScreen*)));
|
||||
|
||||
updateMask();
|
||||
}
|
||||
|
||||
void
|
||||
CefViewWidget::onDraggableRegionChanged(const QRegion& draggableRegion, const QRegion& nonDraggableRegion)
|
||||
{
|
||||
m_draggableRegion = draggableRegion;
|
||||
m_nonDraggableRegion = nonDraggableRegion;
|
||||
}
|
||||
|
||||
bool
|
||||
CefViewWidget::onNewPopup(const QCefFrameId& sourceFrameId,
|
||||
const QString& targetUrl,
|
||||
QString& targetFrameName,
|
||||
QCefView::CefWindowOpenDisposition targetDisposition,
|
||||
QRect& rect,
|
||||
QCefSetting& settings,
|
||||
bool& disableJavascriptAccess)
|
||||
{
|
||||
// create new QCefView as popup browser
|
||||
// settings.setBackgroundColor(Qt::red);
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
CefViewWidget::onNewDownloadItem(const QSharedPointer<QCefDownloadItem>& item, const QString& suggestedName)
|
||||
{
|
||||
// keep the item into list or map, and call item->start() to allow the download
|
||||
|
||||
CefDownloadManager::getInstance().AddNewDownloadItem(item);
|
||||
}
|
||||
|
||||
void
|
||||
CefViewWidget::onUpdateDownloadItem(const QSharedPointer<QCefDownloadItem>& item)
|
||||
{
|
||||
|
||||
// control the download by invoking item->pause(), item->resume(), item->cancel()
|
||||
|
||||
CefDownloadManager::getInstance().UpdateDownloadItem(item);
|
||||
}
|
||||
|
||||
void
|
||||
CefViewWidget::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
// update mask first, because the new mask will be
|
||||
// used in the QCefView::resizeEvent
|
||||
updateMask();
|
||||
|
||||
QCefView::resizeEvent(event);
|
||||
}
|
||||
|
||||
void
|
||||
CefViewWidget::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
QCefView::mousePressEvent(event);
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
if (event->buttons().testFlag(Qt::LeftButton) && m_draggableRegion.contains(event->pos())) {
|
||||
HWND hWnd = ::GetAncestor((HWND)(window()->windowHandle()->winId()), GA_ROOT);
|
||||
POINT pt;
|
||||
::GetCursorPos(&pt);
|
||||
::ReleaseCapture();
|
||||
::SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, POINTTOPOINTS(pt));
|
||||
}
|
||||
#elif defined(Q_OS_MAC)
|
||||
#elif defined(Q_OS_LINUX)
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
CefViewWidget::updateMask()
|
||||
{
|
||||
// create a rect with rounded corner (50px radius) as mask
|
||||
QPainterPath path;
|
||||
path.addRoundedRect(rect(), 50, 50);
|
||||
QRegion mask = QRegion(path.toFillPolygon().toPolygon());
|
||||
|
||||
// apply the mask
|
||||
setMask(mask);
|
||||
}
|
||||
58
src/Cef/CefViewWidget.h
Normal file
58
src/Cef/CefViewWidget.h
Normal file
@ -0,0 +1,58 @@
|
||||
#ifndef CEFVIEWWIDGET_H
|
||||
#define CEFVIEWWIDGET_H
|
||||
|
||||
#include <QScreen>
|
||||
|
||||
#include <QCefView.h>
|
||||
|
||||
/// <summary>
|
||||
/// Represents the customized QCefView
|
||||
/// </summary>
|
||||
class CefViewWidget : public QCefView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CefViewWidget(const QString url, const QCefSetting* setting, QWidget* parent = 0);
|
||||
|
||||
~CefViewWidget();
|
||||
|
||||
protected slots:
|
||||
void onScreenChanged(QScreen* screen);
|
||||
|
||||
void onNativeBrowserWindowCreated(QWindow* window);
|
||||
|
||||
void onDraggableRegionChanged(const QRegion& draggableRegion, const QRegion& nonDraggableRegion);
|
||||
|
||||
protected:
|
||||
bool onNewPopup(const QCefFrameId& sourceFrameId,
|
||||
const QString& targetUrl,
|
||||
QString& targetFrameName,
|
||||
QCefView::CefWindowOpenDisposition targetDisposition,
|
||||
QRect& rect,
|
||||
QCefSetting& settings,
|
||||
bool& disableJavascriptAccess) override;
|
||||
|
||||
void onNewDownloadItem(const QSharedPointer<QCefDownloadItem>& item, const QString& suggestedName) override;
|
||||
|
||||
void onUpdateDownloadItem(const QSharedPointer<QCefDownloadItem>& item) override;
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
|
||||
private:
|
||||
void updateMask();
|
||||
|
||||
private:
|
||||
QWindow* m_pCefWindow = nullptr;
|
||||
|
||||
int m_iCornerRadius = 50;
|
||||
|
||||
QRegion m_draggableRegion;
|
||||
|
||||
QRegion m_nonDraggableRegion;
|
||||
};
|
||||
|
||||
#endif // CUSTOMCEFVIEW_H
|
||||
149
src/Cef/CefWidget.cpp
Normal file
149
src/Cef/CefWidget.cpp
Normal file
@ -0,0 +1,149 @@
|
||||
#include "CefWidget.h"
|
||||
|
||||
CefWidget::CefWidget(QWidget* parent)
|
||||
: QMainWindow(parent /*, Qt::FramelessWindowHint*/)
|
||||
{
|
||||
initBrowser();
|
||||
}
|
||||
CefWidget::~CefWidget()
|
||||
{
|
||||
}
|
||||
void CefWidget::initBrowser()
|
||||
{
|
||||
m_centralWidget = new QWidget(this);
|
||||
if (m_viewWidget) {
|
||||
m_viewWidget->deleteLater();
|
||||
m_viewWidget = nullptr;
|
||||
}
|
||||
|
||||
QCefSetting setting;
|
||||
setting.setWindowlessFrameRate(1000);
|
||||
setting.setHardwareAcceleration(false);
|
||||
// setting.setBackgroundColor(Qt::magenta);
|
||||
|
||||
m_viewWidget = new CefViewWidget("https://www.baidu.com/", &setting, this);
|
||||
// connect the invokeMethod to the slot
|
||||
// connect(m_viewWidget, &QCefView::invokeMethod, this, &CefWidget::onInvokeMethod);
|
||||
|
||||
// // connect the cefQueryRequest to the slot
|
||||
// connect(m_viewWidget, &QCefView::cefUrlRequest, this, &CefWidget::onQCefUrlRequest);
|
||||
// connect(m_viewWidget, &QCefView::cefQueryRequest, this, &CefWidget::onQCefQueryRequest);
|
||||
// connect(m_viewWidget, &QCefView::reportJavascriptResult, this, &CefWidget::onJavascriptResult);
|
||||
// connect(m_viewWidget, &QCefView::loadStart, this, &CefWidget::onLoadStart);
|
||||
// connect(m_viewWidget, &QCefView::loadEnd, this, &CefWidget::onLoadEnd);
|
||||
// connect(m_viewWidget, &QCefView::loadError, this, &CefWidget::onLoadError);
|
||||
m_centralWidget->layout()->addWidget(m_viewWidget);
|
||||
setCentralWidget(m_centralWidget);
|
||||
}
|
||||
void
|
||||
CefWidget::onInvokeMethod(const QCefBrowserId& browserId,
|
||||
const QCefFrameId& frameId,
|
||||
const QString& method,
|
||||
const QVariantList& arguments)
|
||||
{
|
||||
// extract the arguments and dispatch the invocation to corresponding handler
|
||||
if (0 == method.compare("TestMethod")) {
|
||||
QString title("QCef InvokeMethod Notify");
|
||||
QString text = QString("================== Current Thread: QT_UI ==================\r\n"
|
||||
"Frame: %1\r\n"
|
||||
"Method: %2\r\n"
|
||||
"Arguments:\r\n")
|
||||
.arg(frameId)
|
||||
.arg(method);
|
||||
|
||||
for (int i = 0; i < arguments.size(); i++) {
|
||||
auto jv = QJsonValue::fromVariant(arguments[i]);
|
||||
|
||||
// clang-format off
|
||||
text.append(
|
||||
QString("%1 Type:%2, Value:%3\r\n")
|
||||
.arg(i).arg(arguments[i].typeName()).arg(arguments[i].toString())
|
||||
);
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
auto jsonValue = QJsonDocument::fromVariant(arguments);
|
||||
auto jsonString = QString(jsonValue.toJson());
|
||||
text.append(QString("\r\nArguments List in JSON format:\r\n%1").arg(jsonString));
|
||||
|
||||
QMessageBox::information(this->window(), title, text);
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CefWidget::onQCefUrlRequest(const QCefBrowserId& browserId, const QCefFrameId& frameId, const QString& url)
|
||||
{
|
||||
QString title("QCef URL Request");
|
||||
QString text = QString("Current Thread: QT_UI\r\n"
|
||||
"URL: %1")
|
||||
.arg(url);
|
||||
|
||||
QMessageBox::information(this->window(), title, text);
|
||||
}
|
||||
|
||||
void
|
||||
CefWidget::onQCefQueryRequest(const QCefBrowserId& browserId, const QCefFrameId& frameId, const QCefQuery& query)
|
||||
{
|
||||
QString title("QCef Query Request");
|
||||
QString text = QString("Current Thread: QT_UI\r\n"
|
||||
"Query: %1")
|
||||
.arg(query.request());
|
||||
|
||||
QMessageBox::information(this->window(), title, text);
|
||||
|
||||
QString response = query.request().toUpper();
|
||||
query.setResponseResult(true, response);
|
||||
m_viewWidget->responseQCefQuery(query);
|
||||
}
|
||||
|
||||
void
|
||||
CefWidget::onJavascriptResult(const QCefBrowserId& browserId,
|
||||
const QCefFrameId& frameId,
|
||||
const QString& context,
|
||||
const QVariant& result)
|
||||
{
|
||||
auto jsonValue = QJsonDocument::fromVariant(result);
|
||||
auto jsonString = QString(jsonValue.toJson());
|
||||
|
||||
QString title("Javascript result notification");
|
||||
QString text = QString("Context: %1\r\nResult in JSON format:\r\n%2").arg(context).arg(jsonString);
|
||||
|
||||
QMessageBox::information(this->window(), title, text);
|
||||
}
|
||||
|
||||
void
|
||||
CefWidget::onLoadingStateChanged(const QCefBrowserId& browserId, bool isLoading, bool canGoBack, bool canGoForward)
|
||||
{
|
||||
qDebug() << "onLoadingStateChanged, browserId:" << browserId << ", isLoading:" << isLoading
|
||||
<< ", canGoBack:" << canGoBack << ", canGoForward:" << canGoForward;
|
||||
}
|
||||
|
||||
void
|
||||
CefWidget::onLoadStart(const QCefBrowserId& browserId,
|
||||
const QCefFrameId& frameId,
|
||||
bool isMainFrame,
|
||||
int transitionType)
|
||||
{
|
||||
qDebug() << "onLoadStart, browserId:" << browserId << ", frameId:" << frameId << ", isMainFrame:" << isMainFrame
|
||||
<< ", transitionType:" << transitionType;
|
||||
}
|
||||
|
||||
void
|
||||
CefWidget::onLoadEnd(const QCefBrowserId& browserId, const QCefFrameId& frameId, bool isMainFrame, int httpStatusCode)
|
||||
{
|
||||
qDebug() << "onLoadEnd, browserId:" << browserId << ", frameId:" << frameId << ", isMainFrame:" << isMainFrame
|
||||
<< ", httpStatusCode:" << httpStatusCode;
|
||||
}
|
||||
|
||||
void
|
||||
CefWidget::onLoadError(const QCefBrowserId& browserId,
|
||||
const QCefFrameId& frameId,
|
||||
bool isMainFrame,
|
||||
int errorCode,
|
||||
const QString& errorMsg,
|
||||
const QString& failedUrl)
|
||||
{
|
||||
qDebug() << "onLoadError, browserId:" << browserId << ", frameId:" << frameId << ", isMainFrame:" << isMainFrame
|
||||
<< ", errorCode:" << errorCode;
|
||||
}
|
||||
53
src/Cef/CefWidget.h
Normal file
53
src/Cef/CefWidget.h
Normal file
@ -0,0 +1,53 @@
|
||||
#ifndef BROWSER_H
|
||||
#define BROWSER_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLayout>
|
||||
#include <QCloseEvent>
|
||||
#include <QMessageBox>
|
||||
#include <QJsonDocument>
|
||||
#include "CefviewWidget.h"
|
||||
#include <QMainWindow>
|
||||
class CefWidget : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CefWidget(QWidget *parent = nullptr);
|
||||
~CefWidget();
|
||||
|
||||
private:
|
||||
void initBrowser();
|
||||
CefViewWidget* m_viewWidget={};
|
||||
QWidget* m_centralWidget={};
|
||||
// QCefView slots
|
||||
protected slots:
|
||||
void onInvokeMethod(const QCefBrowserId &browserId,
|
||||
const QCefFrameId &frameId,
|
||||
const QString &method,
|
||||
const QVariantList &arguments);
|
||||
|
||||
void onQCefUrlRequest(const QCefBrowserId &browserId, const QCefFrameId &frameId, const QString &url);
|
||||
|
||||
void onQCefQueryRequest(const QCefBrowserId &browserId, const QCefFrameId &frameId, const QCefQuery &query);
|
||||
|
||||
void onJavascriptResult(const QCefBrowserId &browserId,
|
||||
const QCefFrameId &frameId,
|
||||
const QString &context,
|
||||
const QVariant &result);
|
||||
|
||||
void onLoadingStateChanged(const QCefBrowserId &browserId, bool isLoading, bool canGoBack, bool canGoForward);
|
||||
|
||||
void onLoadStart(const QCefBrowserId &browserId, const QCefFrameId &frameId, bool isMainFrame, int transitionType);
|
||||
|
||||
void onLoadEnd(const QCefBrowserId &browserId, const QCefFrameId &frameId, bool isMainFrame, int httpStatusCode);
|
||||
|
||||
void onLoadError(const QCefBrowserId &browserId,
|
||||
const QCefFrameId &frameId,
|
||||
bool isMainFrame,
|
||||
int errorCode,
|
||||
const QString &errorMsg,
|
||||
const QString &failedUrl);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -1,14 +0,0 @@
|
||||
#include "ctaiBrowser.h"
|
||||
|
||||
ctaiBrowser::ctaiBrowser(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
initBrowser();
|
||||
}
|
||||
ctaiBrowser::~ctaiBrowser()
|
||||
{
|
||||
}
|
||||
void ctaiBrowser::initBrowser()
|
||||
{
|
||||
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
#ifndef CTAIBROWSER_H
|
||||
#define CTAIBROWSER_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QApplication>
|
||||
class ctaiBrowser : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ctaiBrowser(QWidget *parent = nullptr);
|
||||
~ctaiBrowser();
|
||||
private:
|
||||
void initBrowser();
|
||||
};
|
||||
|
||||
#endif
|
||||
135
src/main.cpp
135
src/main.cpp
@ -4,8 +4,8 @@
|
||||
#include "sui_base_ex.h"
|
||||
#include "ctai.h"
|
||||
#include <QApplication>
|
||||
//#include "QCefContext.h"
|
||||
|
||||
#include "QCefContext.h"
|
||||
#include "Cef/CefWidget.h"
|
||||
// void init_Browser(QApplication& instance,int argc, char *argv[]){
|
||||
// // build QCefConfig
|
||||
// QCefConfig config;
|
||||
@ -18,26 +18,26 @@
|
||||
// // 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);
|
||||
// //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);
|
||||
|
||||
// //config.setWindowlessRenderingEnabled(true);
|
||||
// //config.addCommandLineSwitch("no-sandbox");
|
||||
// // add command line args, you can any cef supported switches or parameters
|
||||
// config.addCommandLineSwitch("use-mock-keychain");
|
||||
// // config.addCommandLineSwitch("disable-gpu");
|
||||
// //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");
|
||||
// //config.addCommandLineSwitchWithValue("renderer-process-limit", "1");
|
||||
// // allow remote debugging
|
||||
// config.addCommandLineSwitchWithValue("remote-allow-origins", "*");
|
||||
// //config.addCommandLineSwitchWithValue("remote-allow-origins", "*");
|
||||
// // config.addCommandLineSwitchWithValue("disable-features", "BlinkGenPropertyTrees,TranslateUI,site-per-process");
|
||||
|
||||
// // set cache folder
|
||||
@ -47,31 +47,98 @@
|
||||
// // the lifecycle of cefContext must be the same as QApplication instance
|
||||
// QCefContext cefContext(&instance, argc, argv, &config);
|
||||
// }
|
||||
int main(int argc, char *argv[])
|
||||
// int main(int argc, char *argv[])
|
||||
// {
|
||||
// QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||
// qputenv("QT_QPA_PLATFORM", "windows:fontengine=freetype");
|
||||
// QApplication a(argc, argv);
|
||||
// //加载语言包
|
||||
// QTranslator qtBaseTranslator;
|
||||
// if (!qtBaseTranslator.load(QStringLiteral(":/res/translator/qtbase_zh_CN.qm")))
|
||||
// {
|
||||
// // 处理加载翻译文件失败的情况
|
||||
// qDebug() << "Failed to load translation file.";
|
||||
// return -1;
|
||||
// }
|
||||
// a.installTranslator(&qtBaseTranslator);
|
||||
// //初始化浏览器
|
||||
// init_Browser(a,argc,argv);
|
||||
// //读取窗体的配置并初始化
|
||||
// sui_init_config();
|
||||
// ctai x;
|
||||
// x.init_layout();
|
||||
// // 仅限于windows平台
|
||||
// #if defined(__WIN32__)
|
||||
// x.title()->set_type(QD_TYPE::QD_EXIT);
|
||||
// #endif
|
||||
// x.show();
|
||||
// CefWidget w;
|
||||
// w.show();
|
||||
// return a.exec();
|
||||
// }
|
||||
#include <QCefContext.h>
|
||||
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")))
|
||||
{
|
||||
// 处理加载翻译文件失败的情况
|
||||
qDebug() << "Failed to load translation file.";
|
||||
return -1;
|
||||
}
|
||||
a.installTranslator(&qtBaseTranslator);
|
||||
//初始化浏览器
|
||||
//init_Browser(a,argc,argv);
|
||||
//读取窗体的配置并初始化
|
||||
sui_init_config();
|
||||
ctai x;
|
||||
x.init_layout();
|
||||
// 仅限于windows平台
|
||||
#if defined(__WIN32__)
|
||||
x.title()->set_type(QD_TYPE::QD_EXIT);
|
||||
#if (QT_VERSION <= QT_VERSION_CHECK(6, 0, 0))
|
||||
// For off-screen rendering, Qt::AA_EnableHighDpiScaling must be enabled. If not,
|
||||
// then all devicePixelRatio methods will always return 1.0,
|
||||
// so CEF will not scale the web content
|
||||
// NOET: There is bugs in Qt 6.2.4, the HighDpi doesn't work
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||
#endif
|
||||
x.show();
|
||||
//阻塞主进程
|
||||
a.exec();
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
// create QApplication instance
|
||||
QApplication a(argc, 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(&a, argc, argv, &config);
|
||||
|
||||
// application window
|
||||
CefWidget w;
|
||||
w.show();
|
||||
|
||||
// flying
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user