From 7f9f2c8543949c504b5cceb998cbb78d390cb70f Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Wed, 13 Jul 2022 10:40:29 +0800 Subject: [PATCH] adapt to latest qt change And install some missing files Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- README.md | 12 +++++++++--- src/core/CMakeLists.txt | 15 ++++++++++++++- src/core/framelesshelper_win.cpp | 4 ++++ src/quick/CMakeLists.txt | 11 ++++++++++- src/widgets/CMakeLists.txt | 12 +++++++++++- 5 files changed, 48 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3656434..508c6c6 100644 --- a/README.md +++ b/README.md @@ -8,15 +8,21 @@ You can join our [Discord channel](https://discord.gg/grrM4Tmesy) to communicate ## Roadmap -- Common: Add cross-platform blur behind window feature. - Common: Add cross-platform customizable system menu for both Qt Widgets and Qt Quick. Also supports both light and dark theme. -- Common: Migrate to categorized logging output. - Examples: Add QtWebEngine based demo projects for both Qt Widgets and Qt Quick. The whole user interface will be written in HTML instead of C++/QML. - Examples: Add demo projects that emulate the classic appearance of UWP applications. They will have a backward button on the left side of the title bar and a search box in the middle of the title bar. And maybe a side bar on the left side to switch between different pages. - Examples: Add demo projects that the main window is not resizable. - Examples: Add demo projects that have transparent background and doesn't have rectangular window frame. - Feature requests are welcome! +## Highlights v2.2 + +- Common: Added blur behind window feature for Windows (7~11), Linux and macOS. +- CMake: Implemented CMake package support. It's now possible to use `find_package` to find FramelessHelper. +- Examples: Enabled blur behind window and round window corner by default. +- Common: Migrated to categorized logging output. +- Common: Internal code improvements & bug fixes. + ## Highlights v2.1 - Windows: Added support for the snap layout feature introduced in Windows 11. @@ -97,7 +103,7 @@ cmake --install . --config Release --strip **IMPORTANT NOTE**: On Linux you need to install the _GTK3_ and _X11_ development packages first. -Once the compilation and installation is done, you will be able to use the `find_package(FramelessHelper REQUIRED COMPONENTS Core Widgets Quick)` command to find and link to the FramelessHelper library. But before doing that, please make sure CMake knows where to find FramelessHelper, by passing the `CMAKE_PREFIX_PATH` variable to it. For example: `-DCMAKE_PREFIX_PATH=C:/my-cmake-packages;C:/my-toolchain;etc...`. Build FramelessHelper as a sub-directory of your CMake project is of course also supported. +Once the compilation and installation is done, you will be able to use the `find_package(FramelessHelper REQUIRED COMPONENTS Core Widgets Quick)` command to find and link to the FramelessHelper library. But before doing that, please make sure CMake knows where to find FramelessHelper, by passing the `CMAKE_PREFIX_PATH` variable to it. For example: `-DCMAKE_PREFIX_PATH=C:/my-cmake-packages;C:/my-toolchain;etc...`. Build FramelessHelper as a sub-directory of your CMake project is of course also supported. The supported FramelessHelper target names are `FramelessHelper::FramelessHelperCore`, `FramelessHelper::FramelessHelperWidgets` and `FramelessHelper::FramelessHelperQuick`. ## Use diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index b65b3bd..d04c985 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -46,6 +46,14 @@ set(PUBLIC_HEADERS ${INCLUDE_PREFIX}/chromepalette.h ) +set(PUBLIC_HEADERS_ALIAS + ${INCLUDE_PREFIX}/Global + ${INCLUDE_PREFIX}/FramelessHelper_Qt + ${INCLUDE_PREFIX}/FramelessManager + ${INCLUDE_PREFIX}/Utils + ${INCLUDE_PREFIX}/ChromePalette +) + set(PRIVATE_HEADERS ${INCLUDE_PREFIX}/private/framelessmanager_p.h ${INCLUDE_PREFIX}/private/framelessconfig_p.h @@ -69,6 +77,10 @@ if(WIN32) ${INCLUDE_PREFIX}/framelesshelper_windows.h ${INCLUDE_PREFIX}/framelesshelper_win.h ) + list(APPEND PUBLIC_HEADERS_ALIAS + ${INCLUDE_PREFIX}/FramelessHelper_Windows + ${INCLUDE_PREFIX}/FramelessHelper_Win + ) list(APPEND SOURCES utils_win.cpp framelesshelper_win.cpp @@ -130,7 +142,7 @@ if(MSVC) _WIN32_IE=${_WIN32_WINNT_WIN10} NTDDI_VERSION=${NTDDI_WIN10_CO} ) target_compile_options(${SUB_PROJ_NAME} PRIVATE - /utf-8 /W3 /WX + /utf-8 /W3 /WX # Cannot use /W4 here, Qt's own headers are not warning-clean. ) else() target_compile_options(${SUB_PROJ_NAME} PRIVATE @@ -184,6 +196,7 @@ export(EXPORT ${SUB_PROJ_NAME}Targets ) install(FILES ${PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${SUB_PROJ_PATH}) +install(FILES ${PUBLIC_HEADERS_ALIAS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${SUB_PROJ_PATH}) install(FILES ${PRIVATE_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${SUB_PROJ_PATH}/private) install(EXPORT ${SUB_PROJ_NAME}Targets diff --git a/src/core/framelesshelper_win.cpp b/src/core/framelesshelper_win.cpp index 4e0a5bc..e1ffb8a 100644 --- a/src/core/framelesshelper_win.cpp +++ b/src/core/framelesshelper_win.cpp @@ -479,7 +479,9 @@ void FramelessHelperWin::addWindow(const SystemParameters ¶ms) static const bool isWin10RS1OrGreater = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1607); if (isWin10RS1OrGreater) { const bool dark = Utils::shouldAppsUseDarkMode(); +#if (QT_VERSION < QT_VERSION_CHECK(6, 4, 0)) Utils::updateWindowFrameBorderColor(windowId, dark); +#endif static const bool isWin10RS5OrGreater = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1809); if (isWin10RS5OrGreater) { static const bool isQtQuickApplication = (params.getCurrentApplicationType() == ApplicationType::Quick); @@ -1081,7 +1083,9 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me && (std::wcscmp(reinterpret_cast(lParam), kThemeSettingChangeEventName) == 0)) { systemThemeChanged = true; const bool dark = Utils::shouldAppsUseDarkMode(); +#if (QT_VERSION < QT_VERSION_CHECK(6, 4, 0)) Utils::updateWindowFrameBorderColor(windowId, dark); +#endif static const bool isWin10RS5OrGreater = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1809); if (isWin10RS5OrGreater) { static const bool isQtQuickApplication = (data.params.getCurrentApplicationType() == ApplicationType::Quick); diff --git a/src/quick/CMakeLists.txt b/src/quick/CMakeLists.txt index 11de4a3..81fd6a2 100644 --- a/src/quick/CMakeLists.txt +++ b/src/quick/CMakeLists.txt @@ -39,6 +39,14 @@ set(PUBLIC_HEADERS ${INCLUDE_PREFIX}/quickchromepalette.h ) +set(PUBLIC_HEADERS_ALIAS + ${INCLUDE_PREFIX}/Global + ${INCLUDE_PREFIX}/FramelessQuickModule + ${INCLUDE_PREFIX}/FramelessQuickHelper + ${INCLUDE_PREFIX}/FramelessQuickUtils + ${INCLUDE_PREFIX}/QuickChromePalette +) + set(PRIVATE_HEADERS ${INCLUDE_PREFIX}/private/quickstandardsystembutton_p.h ${INCLUDE_PREFIX}/private/quickstandardtitlebar_p.h @@ -150,7 +158,7 @@ if(MSVC) _WIN32_IE=${_WIN32_WINNT_WIN10} NTDDI_VERSION=${NTDDI_WIN10_CO} ) target_compile_options(${SUB_PROJ_NAME} PRIVATE - /utf-8 /W3 /WX + /utf-8 /W3 /WX # Cannot use /W4 here, Qt's own headers are not warning-clean. ) else() target_compile_options(${SUB_PROJ_NAME} PRIVATE @@ -189,6 +197,7 @@ export(EXPORT ${SUB_PROJ_NAME}Targets ) install(FILES ${PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${SUB_PROJ_PATH}) +install(FILES ${PUBLIC_HEADERS_ALIAS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${SUB_PROJ_PATH}) install(FILES ${PRIVATE_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${SUB_PROJ_PATH}/private) install(EXPORT ${SUB_PROJ_NAME}Targets diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index 0fafb15..d53163e 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -37,6 +37,15 @@ set(PUBLIC_HEADERS ${INCLUDE_PREFIX}/standardtitlebar.h ) +set(PUBLIC_HEADERS_ALIAS + ${INCLUDE_PREFIX}/Global + ${INCLUDE_PREFIX}/FramelessWidget + ${INCLUDE_PREFIX}/FramelessMainWindow + ${INCLUDE_PREFIX}/StandardSystemButton + ${INCLUDE_PREFIX}/FramelessWidgetsHelper + ${INCLUDE_PREFIX}/StandardTitleBar +) + set(PRIVATE_HEADERS ${INCLUDE_PREFIX}/private/framelesswidgetshelper_p.h ${INCLUDE_PREFIX}/private/standardsystembutton_p.h @@ -98,7 +107,7 @@ target_compile_definitions(${SUB_PROJ_NAME} PRIVATE if(MSVC) target_compile_options(${SUB_PROJ_NAME} PRIVATE - /utf-8 /W3 /WX + /utf-8 /W3 /WX # Cannot use /W4 here, Qt's own headers are not warning-clean. ) else() target_compile_options(${SUB_PROJ_NAME} PRIVATE @@ -135,6 +144,7 @@ export(EXPORT ${SUB_PROJ_NAME}Targets ) install(FILES ${PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${SUB_PROJ_PATH}) +install(FILES ${PUBLIC_HEADERS_ALIAS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${SUB_PROJ_PATH}) install(FILES ${PRIVATE_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${SUB_PROJ_PATH}/private) install(EXPORT ${SUB_PROJ_NAME}Targets