From 00aca12880c7bfff9a291c36d357f9eeb4d42735 Mon Sep 17 00:00:00 2001 From: HO-COOH Date: Mon, 17 Oct 2022 00:58:28 +0800 Subject: [PATCH 1/8] Build success with chromium 106 --- include/QCefSetting.h | 10 +++++----- src/QCefSetting.cpp | 14 +++++++------- src/details/QCefDownloadItemPrivate.cpp | 9 +++++---- src/details/QCefSettingPrivate.cpp | 10 +++++----- src/details/QCefSettingPrivate.h | 2 +- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/include/QCefSetting.h b/include/QCefSetting.h index 0998afd7..4402ae6b 100644 --- a/include/QCefSetting.h +++ b/include/QCefSetting.h @@ -274,11 +274,11 @@ class QCEFVIEW_EXPORT QCefSetting /// True to enalbe; false to disable void setPlugins(const bool value); - /// - /// Gets whether to enable or disable plugins - /// - /// True to enalbe; false to disable - const QVariant plugins() const; + ///// + ///// Gets whether to enable or disable plugins + ///// + ///// True to enalbe; false to disable + //const QVariant plugins() const; /// /// Sets to enable or disable the permission of loading images diff --git a/src/QCefSetting.cpp b/src/QCefSetting.cpp index 94381418..5cc7f217 100644 --- a/src/QCefSetting.cpp +++ b/src/QCefSetting.cpp @@ -280,15 +280,15 @@ void QCefSetting::setPlugins(const bool value) { Q_D(QCefSetting); - d->plugins_ = value; + //d->plugins_ = value; } -const QVariant -QCefSetting::plugins() const -{ - Q_D(const QCefSetting); - return d->plugins_; -} +//const QVariant +//QCefSetting::plugins() const +//{ +// Q_D(const QCefSetting); +// //return d->plugins_; +//} void QCefSetting::setImageLoading(const bool value) diff --git a/src/details/QCefDownloadItemPrivate.cpp b/src/details/QCefDownloadItemPrivate.cpp index d7412079..c40e2e9b 100644 --- a/src/details/QCefDownloadItemPrivate.cpp +++ b/src/details/QCefDownloadItemPrivate.cpp @@ -24,11 +24,12 @@ QCefDownloadItemPrivate::createQCefDownloadItem(CCefClientDelegate::RefPtr handl double t = 0; cef_time_t ct; - ct = cefItem.GetStartTime(); + cef_time_from_basetime(cefItem.GetStartTime(), &ct); + if (cef_time_to_doublet(&ct, &t)) p->d_ptr->startTime = QDateTime::fromSecsSinceEpoch(t); - ct = cefItem.GetEndTime(); + cef_time_from_basetime(cefItem.GetEndTime(), &ct); if (cef_time_to_doublet(&ct, &t)) p->d_ptr->endTime = QDateTime::fromSecsSinceEpoch(t); @@ -62,11 +63,11 @@ QCefDownloadItemPrivate::updateDownloadItem(QCefDownloadItem* p, double t = 0; cef_time_t ct; - ct = cefItem.GetStartTime(); + cef_time_from_basetime(cefItem.GetStartTime(), &ct); if (cef_time_to_doublet(&ct, &t)) p->d_ptr->startTime = QDateTime::fromSecsSinceEpoch(t); - ct = cefItem.GetEndTime(); + cef_time_from_basetime(cefItem.GetEndTime(), &ct); if (cef_time_to_doublet(&ct, &t)) p->d_ptr->endTime = QDateTime::fromSecsSinceEpoch(t); diff --git a/src/details/QCefSettingPrivate.cpp b/src/details/QCefSettingPrivate.cpp index aef4d1e3..c8dc64dd 100644 --- a/src/details/QCefSettingPrivate.cpp +++ b/src/details/QCefSettingPrivate.cpp @@ -63,9 +63,9 @@ QCefSettingPrivate::CopyFromCefBrowserSettings(QCefSetting* qs, const CefBrowser if (cs->javascript_dom_paste != STATE_DEFAULT) qs->d_ptr->javascriptDomPaste_ = cs->javascript_dom_paste == STATE_ENABLED; - - if (cs->plugins != STATE_DEFAULT) - qs->d_ptr->plugins_ = cs->plugins == STATE_ENABLED; + + //if (cs->plugins != STATE_DEFAULT) + // qs->d_ptr->plugins_ = cs->plugins == STATE_ENABLED; if (cs->image_loading != STATE_DEFAULT) qs->d_ptr->imageLoading_ = cs->image_loading == STATE_ENABLED; @@ -157,8 +157,8 @@ QCefSettingPrivate::CopyToCefBrowserSettings(const QCefSetting* qs, CefBrowserSe if (qs->d_ptr->javascriptDomPaste_.canConvert()) cs->javascript_dom_paste = qs->d_ptr->javascriptDomPaste_.toBool() ? STATE_ENABLED : STATE_DISABLED; - if (qs->d_ptr->plugins_.canConvert()) - cs->plugins = qs->d_ptr->plugins_.toBool() ? STATE_ENABLED : STATE_DISABLED; + //if (qs->d_ptr->plugins_.canConvert()) + // cs->plugins = qs->d_ptr->plugins_.toBool() ? STATE_ENABLED : STATE_DISABLED; if (qs->d_ptr->imageLoading_.canConvert()) cs->image_loading = qs->d_ptr->imageLoading_.toBool() ? STATE_ENABLED : STATE_DISABLED; diff --git a/src/details/QCefSettingPrivate.h b/src/details/QCefSettingPrivate.h index 063380f5..e3c63afd 100644 --- a/src/details/QCefSettingPrivate.h +++ b/src/details/QCefSettingPrivate.h @@ -50,7 +50,7 @@ class QCefSettingPrivate /* bool */ QVariant javascriptCloseWindows_; /* bool */ QVariant javascriptAccessClipboard_; /* bool */ QVariant javascriptDomPaste_; - /* bool */ QVariant plugins_; + /* bool */ //QVariant plugins_; /* bool */ QVariant imageLoading_; /* bool */ QVariant imageShrinkStandaloneToFit_; /* bool */ QVariant textAreaResize_; From bf3d970b551e24b0e687a4c8c713bee235a0de16 Mon Sep 17 00:00:00 2001 From: HO-COOH Date: Mon, 17 Oct 2022 02:10:27 +0800 Subject: [PATCH 2/8] Add conditional macro --- include/QCefSetting.h | 12 +++++++----- src/QCefSetting.cpp | 16 +++++++++------- src/details/QCefDownloadItemPrivate.cpp | 18 +++++++++++++++++- src/details/QCefSettingPrivate.cpp | 14 +++++++++----- src/details/QCefSettingPrivate.h | 5 ++++- 5 files changed, 46 insertions(+), 19 deletions(-) diff --git a/include/QCefSetting.h b/include/QCefSetting.h index 4402ae6b..de6d35f0 100644 --- a/include/QCefSetting.h +++ b/include/QCefSetting.h @@ -268,17 +268,19 @@ class QCEFVIEW_EXPORT QCefSetting /// True to enalbe; false to disable const QVariant javascriptDomPaste() const; + #if CEF_VERSION_MAJOR < 100 /// /// Sets to enable or disable plugins /// /// True to enalbe; false to disable void setPlugins(const bool value); - ///// - ///// Gets whether to enable or disable plugins - ///// - ///// True to enalbe; false to disable - //const QVariant plugins() const; + /// + /// Gets whether to enable or disable plugins + /// + /// True to enalbe; false to disable + const QVariant plugins() const; + #endif /// /// Sets to enable or disable the permission of loading images diff --git a/src/QCefSetting.cpp b/src/QCefSetting.cpp index 5cc7f217..e2b75801 100644 --- a/src/QCefSetting.cpp +++ b/src/QCefSetting.cpp @@ -276,19 +276,21 @@ QCefSetting::javascriptDomPaste() const return d->javascriptDomPaste_; } +#if CEF_VERSION_MAJOR < 100 void QCefSetting::setPlugins(const bool value) { Q_D(QCefSetting); - //d->plugins_ = value; + d->plugins_ = value; } -//const QVariant -//QCefSetting::plugins() const -//{ -// Q_D(const QCefSetting); -// //return d->plugins_; -//} +const QVariant +QCefSetting::plugins() const +{ + Q_D(const QCefSetting); + return d->plugins_; +} +#endif void QCefSetting::setImageLoading(const bool value) diff --git a/src/details/QCefDownloadItemPrivate.cpp b/src/details/QCefDownloadItemPrivate.cpp index c40e2e9b..1a66bc25 100644 --- a/src/details/QCefDownloadItemPrivate.cpp +++ b/src/details/QCefDownloadItemPrivate.cpp @@ -1,6 +1,7 @@ #include "QCefDownloadItemPrivate.h" #include +#include QSharedPointer QCefDownloadItemPrivate::createQCefDownloadItem(CCefClientDelegate::RefPtr handler, @@ -24,12 +25,19 @@ QCefDownloadItemPrivate::createQCefDownloadItem(CCefClientDelegate::RefPtr handl double t = 0; cef_time_t ct; + #if CEF_VERSION_MAJOR >= 104 cef_time_from_basetime(cefItem.GetStartTime(), &ct); - + #else + ct = cefItem.GetStartTime(); + #endif if (cef_time_to_doublet(&ct, &t)) p->d_ptr->startTime = QDateTime::fromSecsSinceEpoch(t); + #if CEF_VERSION_MAJOR >= 104 cef_time_from_basetime(cefItem.GetEndTime(), &ct); + #else + ct = cefItem.GetEndTime(); + #endif if (cef_time_to_doublet(&ct, &t)) p->d_ptr->endTime = QDateTime::fromSecsSinceEpoch(t); @@ -63,11 +71,19 @@ QCefDownloadItemPrivate::updateDownloadItem(QCefDownloadItem* p, double t = 0; cef_time_t ct; + #if CEF_VERSION_MAJOR >= 104 cef_time_from_basetime(cefItem.GetStartTime(), &ct); + #else + ct = cefItem.GetStartTime(); + #endif if (cef_time_to_doublet(&ct, &t)) p->d_ptr->startTime = QDateTime::fromSecsSinceEpoch(t); + #if CEF_VERSION_MAJOR >= 104 cef_time_from_basetime(cefItem.GetEndTime(), &ct); + #else + ct = cefItem.GetEndTime(); + #endif if (cef_time_to_doublet(&ct, &t)) p->d_ptr->endTime = QDateTime::fromSecsSinceEpoch(t); diff --git a/src/details/QCefSettingPrivate.cpp b/src/details/QCefSettingPrivate.cpp index c8dc64dd..bd22b2e8 100644 --- a/src/details/QCefSettingPrivate.cpp +++ b/src/details/QCefSettingPrivate.cpp @@ -63,9 +63,11 @@ QCefSettingPrivate::CopyFromCefBrowserSettings(QCefSetting* qs, const CefBrowser if (cs->javascript_dom_paste != STATE_DEFAULT) qs->d_ptr->javascriptDomPaste_ = cs->javascript_dom_paste == STATE_ENABLED; - - //if (cs->plugins != STATE_DEFAULT) - // qs->d_ptr->plugins_ = cs->plugins == STATE_ENABLED; + + #if CEF_VERSION_MAJOR < 100 + if (cs->plugins != STATE_DEFAULT) + qs->d_ptr->plugins_ = cs->plugins == STATE_ENABLED; + #endif if (cs->image_loading != STATE_DEFAULT) qs->d_ptr->imageLoading_ = cs->image_loading == STATE_ENABLED; @@ -157,8 +159,10 @@ QCefSettingPrivate::CopyToCefBrowserSettings(const QCefSetting* qs, CefBrowserSe if (qs->d_ptr->javascriptDomPaste_.canConvert()) cs->javascript_dom_paste = qs->d_ptr->javascriptDomPaste_.toBool() ? STATE_ENABLED : STATE_DISABLED; - //if (qs->d_ptr->plugins_.canConvert()) - // cs->plugins = qs->d_ptr->plugins_.toBool() ? STATE_ENABLED : STATE_DISABLED; + #if CEF_VERSION_MAJOR < 100 + if (qs->d_ptr->plugins_.canConvert()) + cs->plugins = qs->d_ptr->plugins_.toBool() ? STATE_ENABLED : STATE_DISABLED; + #endif if (qs->d_ptr->imageLoading_.canConvert()) cs->image_loading = qs->d_ptr->imageLoading_.toBool() ? STATE_ENABLED : STATE_DISABLED; diff --git a/src/details/QCefSettingPrivate.h b/src/details/QCefSettingPrivate.h index e3c63afd..0256501d 100644 --- a/src/details/QCefSettingPrivate.h +++ b/src/details/QCefSettingPrivate.h @@ -7,6 +7,7 @@ #pragma region cef_headers #include +#include #pragma endregion cef_headers #pragma region qt_headers @@ -50,7 +51,9 @@ class QCefSettingPrivate /* bool */ QVariant javascriptCloseWindows_; /* bool */ QVariant javascriptAccessClipboard_; /* bool */ QVariant javascriptDomPaste_; - /* bool */ //QVariant plugins_; + #if CEF_VERSION_MAJOR < 100 + /* bool */ QVariant plugins_; + #endif /* bool */ QVariant imageLoading_; /* bool */ QVariant imageShrinkStandaloneToFit_; /* bool */ QVariant textAreaResize_; From 1486c4c5623348eb4ab2e74d0f6da71b8e9dfdce Mon Sep 17 00:00:00 2001 From: HO-COOH Date: Mon, 17 Oct 2022 02:16:31 +0800 Subject: [PATCH 3/8] Add missing cef_version.h include --- include/QCefSetting.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/QCefSetting.h b/include/QCefSetting.h index de6d35f0..6c6bfe41 100644 --- a/include/QCefSetting.h +++ b/include/QCefSetting.h @@ -17,6 +17,10 @@ #include #pragma endregion qt_headers +#pragma region cef_headers +#include +#pragma endregion cef_headers + class QCefSettingPrivate; /// From 2104fc581d4dcab113a5d2a18509c2b49e879f70 Mon Sep 17 00:00:00 2001 From: HO-COOH Date: Mon, 17 Oct 2022 21:32:30 +0800 Subject: [PATCH 4/8] update submodule CefViewCore --- CefViewCore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CefViewCore b/CefViewCore index e973c411..93e926fe 160000 --- a/CefViewCore +++ b/CefViewCore @@ -1 +1 @@ -Subproject commit e973c4112366f17eb262ab1421dc29c41081e1b7 +Subproject commit 93e926feba5e1a43cb7414e37e180bf4d85b086f From e6c61042e53e3565d54c8a624ff8a349d15f58ba Mon Sep 17 00:00:00 2001 From: HO-COOH Date: Mon, 17 Oct 2022 22:27:02 +0800 Subject: [PATCH 5/8] Fix missing macro in MainWindow.cpp of Test project --- example/QCefViewTest/CMakeLists.txt | 1 + example/QCefViewTest/MainWindow.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/example/QCefViewTest/CMakeLists.txt b/example/QCefViewTest/CMakeLists.txt index c15abf39..408ffdd0 100644 --- a/example/QCefViewTest/CMakeLists.txt +++ b/example/QCefViewTest/CMakeLists.txt @@ -27,6 +27,7 @@ file(WRITE ${CMAKE_BINARY_DIR}/auto_rebuild.cpp "/* Auto Rebuild Trigger */") include_directories( ${CMAKE_SOURCE_DIR}/include + ${CefViewCore_EXPORT_INCLUDE_PATH} ) file(GLOB _SRC_FILES diff --git a/example/QCefViewTest/MainWindow.cpp b/example/QCefViewTest/MainWindow.cpp index 58443b8b..a5b12b48 100644 --- a/example/QCefViewTest/MainWindow.cpp +++ b/example/QCefViewTest/MainWindow.cpp @@ -55,7 +55,11 @@ MainWindow::createCefView() ///* // build settings for per QCefView QCefSetting setting; + + #if CEF_VERSION_MAJOR < 100 setting.setPlugins(false); + #endif + setting.setWindowlessFrameRate(60); setting.setBackgroundColor(QColor::fromRgba(qRgba(255, 255, 220, 255))); // setting.setBackgroundColor(Qt::blue); From 04f1e2616e002ea3f77f1ec3cf8f313934562fda Mon Sep 17 00:00:00 2001 From: HO-COOH Date: Tue, 18 Oct 2022 01:52:43 +0800 Subject: [PATCH 6/8] Remove include cef_version.h, add CEF_VERSION_MAJOR in cmake --- CMakeLists.txt | 1 + example/QCefViewTest/CMakeLists.txt | 1 - include/QCefSetting.h | 4 +--- src/details/QCefDownloadItemPrivate.cpp | 1 - src/details/QCefSettingPrivate.h | 1 - 5 files changed, 2 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d408364..8bc2802e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/$/lib) # Include CefViewCore add_subdirectory(CefViewCore) set_target_properties(CefViewCore PROPERTIES FOLDER core) +add_compile_definitions(CEF_VERSION_MAJOR=${CEF_VERSION}) foreach(CefViewWingTarget ${CefViewCore_HELPER_APP_TARGETS}) set_target_properties(${CefViewWingTarget} PROPERTIES FOLDER core) diff --git a/example/QCefViewTest/CMakeLists.txt b/example/QCefViewTest/CMakeLists.txt index 408ffdd0..c15abf39 100644 --- a/example/QCefViewTest/CMakeLists.txt +++ b/example/QCefViewTest/CMakeLists.txt @@ -27,7 +27,6 @@ file(WRITE ${CMAKE_BINARY_DIR}/auto_rebuild.cpp "/* Auto Rebuild Trigger */") include_directories( ${CMAKE_SOURCE_DIR}/include - ${CefViewCore_EXPORT_INCLUDE_PATH} ) file(GLOB _SRC_FILES diff --git a/include/QCefSetting.h b/include/QCefSetting.h index 6c6bfe41..454868b0 100644 --- a/include/QCefSetting.h +++ b/include/QCefSetting.h @@ -17,9 +17,7 @@ #include #pragma endregion qt_headers -#pragma region cef_headers -#include -#pragma endregion cef_headers + class QCefSettingPrivate; diff --git a/src/details/QCefDownloadItemPrivate.cpp b/src/details/QCefDownloadItemPrivate.cpp index 1a66bc25..035e3297 100644 --- a/src/details/QCefDownloadItemPrivate.cpp +++ b/src/details/QCefDownloadItemPrivate.cpp @@ -1,7 +1,6 @@ #include "QCefDownloadItemPrivate.h" #include -#include QSharedPointer QCefDownloadItemPrivate::createQCefDownloadItem(CCefClientDelegate::RefPtr handler, diff --git a/src/details/QCefSettingPrivate.h b/src/details/QCefSettingPrivate.h index 0256501d..3b5355d0 100644 --- a/src/details/QCefSettingPrivate.h +++ b/src/details/QCefSettingPrivate.h @@ -7,7 +7,6 @@ #pragma region cef_headers #include -#include #pragma endregion cef_headers #pragma region qt_headers From 560f225b0970743d8cc64fbb022720e9107e769c Mon Sep 17 00:00:00 2001 From: Sheen Tian Date: Tue, 25 Oct 2022 21:26:45 +0800 Subject: [PATCH 7/8] Update Core --- CMakeLists.txt | 21 ++++++++++++- CefViewCore | 2 +- example/QCefViewTest/MainWindow.cpp | 8 ++--- example/QCefViewTest/main.cpp | 2 +- include/QCefSetting.h | 6 ++-- include/QCefView_global.h | 28 ++++++++++------- src/QCefSetting.cpp | 7 ++++- src/QCefView_global.h.in | 40 +++++++++++++++++++++++++ src/details/QCefDownloadItemPrivate.cpp | 28 +++++++++-------- src/details/QCefSettingPrivate.cpp | 12 +++++--- src/details/QCefSettingPrivate.h | 4 +-- 11 files changed, 118 insertions(+), 40 deletions(-) create mode 100644 src/QCefView_global.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bc2802e..618106b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,7 +118,6 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/$/lib) # Include CefViewCore add_subdirectory(CefViewCore) set_target_properties(CefViewCore PROPERTIES FOLDER core) -add_compile_definitions(CEF_VERSION_MAJOR=${CEF_VERSION}) foreach(CefViewWingTarget ${CefViewCore_HELPER_APP_TARGETS}) set_target_properties(${CefViewWingTarget} PROPERTIES FOLDER core) @@ -126,6 +125,26 @@ endforeach(CefViewWingTarget) set_target_properties(libcef_dll_wrapper PROPERTIES FOLDER core) +# read CEF version from cef_version.h +file(READ "${CefViewCore_CEF_INCLUDE_DIR}/cef_version.h" cef_version_content) +string(REGEX MATCH "#define CEF_VERSION_MAJOR ([0-9]+)" _ ${cef_version_content}) +set(CEF_VERSION_MAJOR ${CMAKE_MATCH_1}) +message(STATUS "CEF_VERSION_MAJOR: ${CEF_VERSION_MAJOR}") + +string(REGEX MATCH "#define CEF_VERSION_MINOR ([0-9]+)" _ ${cef_version_content}) +set(CEF_VERSION_MINOR ${CMAKE_MATCH_1}) +message(STATUS "CEF_VERSION_MINOR: ${CEF_VERSION_MINOR}") + +string(REGEX MATCH "#define CEF_VERSION_PATCH ([0-9]+)" _ ${cef_version_content}) +set(CEF_VERSION_PATCH ${CMAKE_MATCH_1}) +message(STATUS "CEF_VERSION_PATCH: ${CEF_VERSION_PATCH}") + +configure_file( + "${CMAKE_SOURCE_DIR}/src/QCefView_global.h.in" + "${CMAKE_SOURCE_DIR}/include/QCefView_global.h" + @ONLY +) + # Config QCefView target # ############################################################## add_subdirectory(src) diff --git a/CefViewCore b/CefViewCore index 93e926fe..da36bcd7 160000 --- a/CefViewCore +++ b/CefViewCore @@ -1 +1 @@ -Subproject commit 93e926feba5e1a43cb7414e37e180bf4d85b086f +Subproject commit da36bcd7aa19de6a6e722f77652bb9cb6773281e diff --git a/example/QCefViewTest/MainWindow.cpp b/example/QCefViewTest/MainWindow.cpp index a5b12b48..391172be 100644 --- a/example/QCefViewTest/MainWindow.cpp +++ b/example/QCefViewTest/MainWindow.cpp @@ -55,11 +55,11 @@ MainWindow::createCefView() ///* // build settings for per QCefView QCefSetting setting; - - #if CEF_VERSION_MAJOR < 100 + +#if CEF_VERSION_MAJOR < 100 setting.setPlugins(false); - #endif - +#endif + setting.setWindowlessFrameRate(60); setting.setBackgroundColor(QColor::fromRgba(qRgba(255, 255, 220, 255))); // setting.setBackgroundColor(Qt::blue); diff --git a/example/QCefViewTest/main.cpp b/example/QCefViewTest/main.cpp index fbc93672..30db1b46 100644 --- a/example/QCefViewTest/main.cpp +++ b/example/QCefViewTest/main.cpp @@ -18,7 +18,7 @@ main(int argc, char* argv[]) config.setBackgroundColor(Qt::lightGray); // WindowlessRenderingEnabled is set to true by default, set to false to disable the OSR mode - config.setWindowlessRenderingEnabled(false); + // config.setWindowlessRenderingEnabled(false); // config.addCommandLineSwitch("disable-gpu"); // add command line args diff --git a/include/QCefSetting.h b/include/QCefSetting.h index 454868b0..aae199a2 100644 --- a/include/QCefSetting.h +++ b/include/QCefSetting.h @@ -17,8 +17,6 @@ #include #pragma endregion qt_headers - - class QCefSettingPrivate; /// @@ -270,7 +268,7 @@ class QCEFVIEW_EXPORT QCefSetting /// True to enalbe; false to disable const QVariant javascriptDomPaste() const; - #if CEF_VERSION_MAJOR < 100 +#if CEF_VERSION_MAJOR < 100 /// /// Sets to enable or disable plugins /// @@ -282,7 +280,7 @@ class QCEFVIEW_EXPORT QCefSetting /// /// True to enalbe; false to disable const QVariant plugins() const; - #endif +#endif /// /// Sets to enable or disable the permission of loading images diff --git a/include/QCefView_global.h b/include/QCefView_global.h index 074d5849..9611d54b 100644 --- a/include/QCefView_global.h +++ b/include/QCefView_global.h @@ -10,23 +10,31 @@ #define QCEFEVIEW_GLOBAL_H #pragma once +// clang-format off #pragma region qt_headers #include - #include #pragma endregion qt_headers #ifdef QCEFVIEW_STATIC -#define QCEFVIEW_EXPORT -#else -#ifdef QCEFVIEW_LIB -#define QCEFVIEW_EXPORT Q_DECL_EXPORT + // Static library, no need export + #define QCEFVIEW_EXPORT #else -#define QCEFVIEW_EXPORT Q_DECL_IMPORT -#if _WIN32 -#pragma comment(lib, "QCefView.lib") -#endif -#endif + // Dynamic library + #ifdef QCEFVIEW_LIB + // Build QCefView project, export API + #define QCEFVIEW_EXPORT Q_DECL_EXPORT + #else + // Referenced by other project, import API + #define QCEFVIEW_EXPORT Q_DECL_IMPORT + #if _WIN32 + #pragma comment(lib, "QCefView.lib") + #endif + #endif #endif +// CEF major version number +#define CEF_VERSION_MAJOR 106 +// clang-format on + #endif // QCEFEVIEW_GLOBAL_H diff --git a/src/QCefSetting.cpp b/src/QCefSetting.cpp index e2b75801..2228ee5a 100644 --- a/src/QCefSetting.cpp +++ b/src/QCefSetting.cpp @@ -1,5 +1,9 @@ #include "QCefSetting.h" +#pragma region cef_headers +#include +#pragma endregion cef_headers + #include "details/QCefSettingPrivate.h" #include "details/utils/CommonUtils.h" @@ -7,7 +11,8 @@ REGISTER_METATYPE(QCefSetting); QCefSetting::QCefSetting() : d_ptr(new QCefSettingPrivate) -{} +{ +} QCefSetting::QCefSetting(const QCefSetting& other) : d_ptr(new QCefSettingPrivate) diff --git a/src/QCefView_global.h.in b/src/QCefView_global.h.in new file mode 100644 index 00000000..4e2c7212 --- /dev/null +++ b/src/QCefView_global.h.in @@ -0,0 +1,40 @@ +/* + * File: QCefView_global.h + * Project: QCefView + * Created: 29th March 2016 + * Author: Sheen + * Source: https://github.com/cefview/qcefview + * Docs: https://cefview.github.io/QCefView/ + */ +#ifndef QCEFEVIEW_GLOBAL_H +#define QCEFEVIEW_GLOBAL_H +#pragma once + +// clang-format off +#pragma region qt_headers +#include +#include +#pragma endregion qt_headers + +#ifdef QCEFVIEW_STATIC + // Static library, no need export + #define QCEFVIEW_EXPORT +#else + // Dynamic library + #ifdef QCEFVIEW_LIB + // Build QCefView project, export API + #define QCEFVIEW_EXPORT Q_DECL_EXPORT + #else + // Referenced by other project, import API + #define QCEFVIEW_EXPORT Q_DECL_IMPORT + #if _WIN32 + #pragma comment(lib, "QCefView.lib") + #endif + #endif +#endif + +// CEF major version number +#cmakedefine CEF_VERSION_MAJOR @CEF_VERSION_MAJOR@ +// clang-format on + +#endif // QCEFEVIEW_GLOBAL_H diff --git a/src/details/QCefDownloadItemPrivate.cpp b/src/details/QCefDownloadItemPrivate.cpp index 035e3297..fa57fcf5 100644 --- a/src/details/QCefDownloadItemPrivate.cpp +++ b/src/details/QCefDownloadItemPrivate.cpp @@ -1,5 +1,9 @@ #include "QCefDownloadItemPrivate.h" +#pragma region cef_headers +#include +#pragma endregion cef_headers + #include QSharedPointer @@ -24,19 +28,19 @@ QCefDownloadItemPrivate::createQCefDownloadItem(CCefClientDelegate::RefPtr handl double t = 0; cef_time_t ct; - #if CEF_VERSION_MAJOR >= 104 +#if CEF_VERSION_MAJOR >= 104 cef_time_from_basetime(cefItem.GetStartTime(), &ct); - #else +#else ct = cefItem.GetStartTime(); - #endif +#endif if (cef_time_to_doublet(&ct, &t)) p->d_ptr->startTime = QDateTime::fromSecsSinceEpoch(t); - #if CEF_VERSION_MAJOR >= 104 +#if CEF_VERSION_MAJOR >= 104 cef_time_from_basetime(cefItem.GetEndTime(), &ct); - #else +#else ct = cefItem.GetEndTime(); - #endif +#endif if (cef_time_to_doublet(&ct, &t)) p->d_ptr->endTime = QDateTime::fromSecsSinceEpoch(t); @@ -70,19 +74,19 @@ QCefDownloadItemPrivate::updateDownloadItem(QCefDownloadItem* p, double t = 0; cef_time_t ct; - #if CEF_VERSION_MAJOR >= 104 +#if CEF_VERSION_MAJOR >= 104 cef_time_from_basetime(cefItem.GetStartTime(), &ct); - #else +#else ct = cefItem.GetStartTime(); - #endif +#endif if (cef_time_to_doublet(&ct, &t)) p->d_ptr->startTime = QDateTime::fromSecsSinceEpoch(t); - #if CEF_VERSION_MAJOR >= 104 +#if CEF_VERSION_MAJOR >= 104 cef_time_from_basetime(cefItem.GetEndTime(), &ct); - #else +#else ct = cefItem.GetEndTime(); - #endif +#endif if (cef_time_to_doublet(&ct, &t)) p->d_ptr->endTime = QDateTime::fromSecsSinceEpoch(t); diff --git a/src/details/QCefSettingPrivate.cpp b/src/details/QCefSettingPrivate.cpp index bd22b2e8..632741c2 100644 --- a/src/details/QCefSettingPrivate.cpp +++ b/src/details/QCefSettingPrivate.cpp @@ -7,6 +7,10 @@ #include #pragma endregion qt_headers +#pragma region cef_headers +#include +#pragma endregion cef_headers + #include #include @@ -64,10 +68,10 @@ QCefSettingPrivate::CopyFromCefBrowserSettings(QCefSetting* qs, const CefBrowser if (cs->javascript_dom_paste != STATE_DEFAULT) qs->d_ptr->javascriptDomPaste_ = cs->javascript_dom_paste == STATE_ENABLED; - #if CEF_VERSION_MAJOR < 100 +#if CEF_VERSION_MAJOR < 100 if (cs->plugins != STATE_DEFAULT) qs->d_ptr->plugins_ = cs->plugins == STATE_ENABLED; - #endif +#endif if (cs->image_loading != STATE_DEFAULT) qs->d_ptr->imageLoading_ = cs->image_loading == STATE_ENABLED; @@ -159,10 +163,10 @@ QCefSettingPrivate::CopyToCefBrowserSettings(const QCefSetting* qs, CefBrowserSe if (qs->d_ptr->javascriptDomPaste_.canConvert()) cs->javascript_dom_paste = qs->d_ptr->javascriptDomPaste_.toBool() ? STATE_ENABLED : STATE_DISABLED; - #if CEF_VERSION_MAJOR < 100 +#if CEF_VERSION_MAJOR < 100 if (qs->d_ptr->plugins_.canConvert()) cs->plugins = qs->d_ptr->plugins_.toBool() ? STATE_ENABLED : STATE_DISABLED; - #endif +#endif if (qs->d_ptr->imageLoading_.canConvert()) cs->image_loading = qs->d_ptr->imageLoading_.toBool() ? STATE_ENABLED : STATE_DISABLED; diff --git a/src/details/QCefSettingPrivate.h b/src/details/QCefSettingPrivate.h index 3b5355d0..50e7ac70 100644 --- a/src/details/QCefSettingPrivate.h +++ b/src/details/QCefSettingPrivate.h @@ -50,9 +50,9 @@ class QCefSettingPrivate /* bool */ QVariant javascriptCloseWindows_; /* bool */ QVariant javascriptAccessClipboard_; /* bool */ QVariant javascriptDomPaste_; - #if CEF_VERSION_MAJOR < 100 +#if CEF_VERSION_MAJOR < 100 /* bool */ QVariant plugins_; - #endif +#endif /* bool */ QVariant imageLoading_; /* bool */ QVariant imageShrinkStandaloneToFit_; /* bool */ QVariant textAreaResize_; From 135cd313a103ee31e20d2c77b9a1a0c30b09d93a Mon Sep 17 00:00:00 2001 From: Sheen Tian Date: Tue, 25 Oct 2022 22:43:03 +0800 Subject: [PATCH 8/8] Mac: 10.13 is now the minimum required macOS version --- CMakeLists.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 618106b1..82ad23b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,10 +107,6 @@ else() ) endif() -if(OS_MACOS) - set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11) -endif() - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/$/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/$/bin) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/$/lib) @@ -145,6 +141,14 @@ configure_file( @ONLY ) +if(OS_MACOS) + if(CEF_VERSION_MAJOR LESS 104) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11) + else() + set(CMAKE_OSX_DEPLOYMENT_TARGET 10.13) + endif() +endif() + # Config QCefView target # ############################################################## add_subdirectory(src)