diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..4f83b118 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/SARibbonBar/3rdparty/qwindowkit"] + path = src/SARibbonBar/3rdparty/qwindowkit + url = https://github.com/stdware/qwindowkit diff --git a/CMakeLists.txt b/CMakeLists.txt index 3995f490..9af60414 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,16 +4,17 @@ cmake_minimum_required(VERSION 3.5) -set(SARIBBON_VERSION_MAJOR 1) -set(SARIBBON_VERSION_MINOR 1) -set(SARIBBON_VERSION_PATCH 2) +set(SARIBBON_VERSION_MAJOR 2) +set(SARIBBON_VERSION_MINOR 0) +set(SARIBBON_VERSION_PATCH 0) set(SARIBBON_VERSION "${SARIBBON_VERSION_MAJOR}.${SARIBBON_VERSION_MINOR}.${SARIBBON_VERSION_PATCH}") +message(STATUS "SARibbon v${SARIBBON_VERSION}") project(SARibbon VERSION ${SARIBBON_VERSION} LANGUAGES CXX) # option(BUILD_SHARED_LIBS "build the SARibbonBar in shared lib mode" ON) option(SARIBBON_BUILD_EXAMPLES "build the examples" ON) -# frameless能提供windows的窗口特效,如边缘吸附,且对高分屏多屏幕的支持更好 -option(SARIBBON_USE_FRAMELESS_LIB "use frameless lib" OFF) +# frameless能提供windows的窗口特效,如边缘吸附,且对高分屏多屏幕的支持更好,默认开启 +option(SARIBBON_USE_FRAMELESS_LIB "use frameless lib" ON) # load Qt library, minimum version required is 5.8 # cn:Qt库加载,最低版本要求为5.8 @@ -88,18 +89,13 @@ if(MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4819") endif() -message(STATUS "SARibbon ${SARIBBON_VERSION}") + # 平台判断 if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4") set(SARIBBON_PLATFORM "x86") else() set(SARIBBON_PLATFORM "x64") endif() - - - -include(cmake/WinResource.cmake) - # The bin file directory is one level above the current directory # cn:bin文件目录在当前目录的上上一级 set(SARIBBON_BIN_NAME bin_qt${QT_VERSION}_${CMAKE_BUILD_TYPE}_${SARIBBON_PLATFORM}) @@ -110,8 +106,19 @@ if(WIN32) set(CMAKE_INSTALL_PREFIX "${SARIBBON_BIN_DIR}") endif() +################################## +# subdirectory +################################## + +if(SARIBBON_USE_FRAMELESS_LIB) + if(NOT DEFINED QWindowKit_DIR) + message(WARNING "option SARIBBON_USE_FRAMELESS_LIB=ON,but QWindowKit_DIR not defined,will set QWindowKit_DIR=${SARIBBON_BIN_DIR}/cmake/QWindowKit") + set(QWindowKit_DIR ${SARIBBON_BIN_DIR}/lib/cmake/QWindowKit) + endif() +endif() + +include(cmake/WinResource.cmake) add_subdirectory(src) -add_subdirectory(cmake) ################################## # install diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt deleted file mode 100644 index cefc53d0..00000000 --- a/cmake/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -#string (TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) -set(SA_LIB_NAME SARibbonBar) -string(TOLOWER ${SA_LIB_NAME} SA_LIB_NAME_LOWER) -configure_file (project-config.cmake.in - "${PROJECT_BINARY_DIR}/${SA_LIB_NAME_LOWER}-config.cmake" @ONLY) - -configure_file (project-config-version.cmake.in - "${PROJECT_BINARY_DIR}/${SA_LIB_NAME_LOWER}-config-version.cmake" @ONLY) - -install (FILES - "${PROJECT_BINARY_DIR}/${SA_LIB_NAME_LOWER}-config.cmake" - DESTINATION lib/cmake/${SA_LIB_NAME} -) - -install (FILES - "${PROJECT_BINARY_DIR}/${SA_LIB_NAME_LOWER}-config-version.cmake" - DESTINATION lib/cmake/${SA_LIB_NAME} -) \ No newline at end of file diff --git a/cmake/SARibbonUtils.cmake b/cmake/SARibbonUtils.cmake new file mode 100644 index 00000000..e00138bf --- /dev/null +++ b/cmake/SARibbonUtils.cmake @@ -0,0 +1,16 @@ +macro(saribbon_set_bin_name _var) + set(DA_MIN_QT_VERSION 5.14) + find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) + ######################################################## + # 平台判断 + ######################################################## + if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4") + set(_platform_name "x86") + else() + set(_platform_name "x64") + endif() + ######################################################## + # 安装路径设置 + ######################################################## + set(_var bin_qt${QT_VERSION}_${CMAKE_BUILD_TYPE}_${_platform_name}) +endmacro(damacro_set_bin_name) \ No newline at end of file diff --git a/cmake/project-config-version.cmake.in b/cmake/project-config-version.cmake.in deleted file mode 100644 index 61d8e63b..00000000 --- a/cmake/project-config-version.cmake.in +++ /dev/null @@ -1,4 +0,0 @@ -set (PACKAGE_VERSION "@PROJECT_VERSION@") -set (PACKAGE_VERSION_MAJOR "@PROJECT_VERSION_MAJOR@") -set (PACKAGE_VERSION_MINOR "@PROJECT_VERSION_MINOR@") -set (PACKAGE_VERSION_PATCH "@PROJECT_VERSION_PATCH@") \ No newline at end of file diff --git a/cmake/project-config.cmake.in b/cmake/project-config.cmake.in deleted file mode 100644 index fd6fde23..00000000 --- a/cmake/project-config.cmake.in +++ /dev/null @@ -1,30 +0,0 @@ -# This module defines -# @PROJECT_NAME@_FOUND, if false, do not try to link to @PROJECT_NAME@ -# @PROJECT_NAME@_INCLUDE_DIRS, where to find the headers -# @PROJECT_NAME@_LIBRARY_DIRS, where to find the libs - -message(STATUS "Reading ${CMAKE_CURRENT_LIST_FILE}") -set(@PROJECT_NAME@_Version 0.0.1) -message(STATUS "@PROJECT_NAME@ configuration, version ${@PROJECT_NAME@_Version}") - -get_filename_component(_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -get_filename_component(_ROOT ${_DIR}/.. ABSOLUTE) -set(@PROJECT_NAME@_INCLUDE_DIRS "${_ROOT}/include") -set(@PROJECT_NAME@_LIBRARY_DIRS "${_ROOT}/lib") -set(@PROJECT_NAME@_LIBRARIES "") - -set(SARIBBON_LIBS "SARibbonBar") -foreach(_var ${SARIBBON_LIBS}) - find_library (_var_path ${_var} - PATHS "${_ROOT}/lib") - list(APPEND @PROJECT_NAME@_LIBRARIES ${_var_path}) -endforeach(_var ${SARIBBON_LIBS}) - -find_library ( @LIB_NAME@ - PATHS "${_ROOT}/lib") - -set(@PROJECT_NAME@_BINARY_DIRS "${_ROOT}/bin") -set(@PROJECT_NAME@_FOUND TRUE) - -unset (_ROOT) -unset (_DIR) \ No newline at end of file diff --git a/src/SARibbonBar/3rdparty/CMakeLists.txt b/src/SARibbonBar/3rdparty/CMakeLists.txt new file mode 100644 index 00000000..2ee7c430 --- /dev/null +++ b/src/SARibbonBar/3rdparty/CMakeLists.txt @@ -0,0 +1,49 @@ + +# Cmake的命令不区分打下写,例如message,set等命令;但Cmake的变量区分大小写 +# 为统一风格,本项目的Cmake命令全部采用小写,变量全部采用大写加下划线组合。 + +cmake_minimum_required(VERSION 3.5) +project(SARibbon-3rdparty-build + LANGUAGES CXX + DESCRIPTION "SARibbon : 3rdparty build" +) + +######################################################## +# 安装路径设置 +######################################################## +# load Qt library, minimum version required is 5.12 +# cn:Qt库加载,最低版本要求为5.12 +set(SARIBBON_MIN_QT_VERSION 5.12) +find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} ${SARIBBON_MIN_QT_VERSION} COMPONENTS + Core + Gui + Widgets + REQUIRED +) +# 平台判断 +if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4") + set(SARIBBON_PLATFORM "x86") +else() + set(SARIBBON_PLATFORM "x64") +endif() +# The bin file directory is one level above the current directory +# cn:bin文件目录在当前目录的上上一级 +set(SARIBBON_BIN_NAME bin_qt${QT_VERSION}_${CMAKE_BUILD_TYPE}_${SARIBBON_PLATFORM}) +set(SARIBBON_BIN_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../${SARIBBON_BIN_NAME}) +# windows系统下,默认直接安装到当前文件夹下 +if(WIN32) + set(CMAKE_INSTALL_PREFIX "${SARIBBON_BIN_DIR}") +endif() +######################################################## +# 第三方库参数设置 +######################################################## +# +set(QWINDOWKIT_BUILD_WIDGETS ON) +set(QWINDOWKIT_BUILD_EXAMPLES OFF) +set(QWINDOWKIT_BUILD_QUICK OFF) +set(QWINDOWKIT_INSTALL ON) +######################################################## +# 安装第三方库 +######################################################## +add_subdirectory(qwindowkit) diff --git a/src/SARibbonBar/3rdparty/framelesshelper/CMakeLists.txt b/src/SARibbonBar/3rdparty/framelesshelper/CMakeLists.txt deleted file mode 100644 index 678ce12e..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/CMakeLists.txt +++ /dev/null @@ -1,329 +0,0 @@ -#[[ - MIT License - - Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -]] - -cmake_minimum_required(VERSION 3.20) - -project(FramelessHelper - VERSION "2.5.0" - DESCRIPTION "Cross-platform window customization framework for Qt Widgets and Qt Quick." - HOMEPAGE_URL "https://github.com/wangwenx190/framelesshelper/" -) - -include(CMakeDependentOption) -include(cmake/utils.cmake) - -# TODO: Use add_feature_info() for every option below? Is it worth doing? -option(FRAMELESSHELPER_BUILD_STATIC "Build FramelessHelper as a static library." OFF) -option(FRAMELESSHELPER_BUILD_WIDGETS "Build FramelessHelper's Widgets module." ON) -option(FRAMELESSHELPER_BUILD_QUICK "Build FramelessHelper's Quick module." ON) -option(FRAMELESSHELPER_BUILD_EXAMPLES "Build FramelessHelper demo applications." OFF) -option(FRAMELESSHELPER_EXAMPLES_DEPLOYQT "Deploy the Qt framework after building the demo projects." OFF) -option(FRAMELESSHELPER_NO_DEBUG_OUTPUT "Suppress the debug messages from FramelessHelper." ON) -option(FRAMELESSHELPER_NO_BUNDLE_RESOURCE "Do not bundle any resources within FramelessHelper." OFF) -option(FRAMELESSHELPER_NO_PRIVATE "Do not use any private functionalities from Qt." OFF) -option(FRAMELESSHELPER_ENABLE_VCLTL "MSVC only: link to the system MSVCRT/UCRT and get rid of API sets." OFF) -option(FRAMELESSHELPER_ENABLE_YYTHUNKS "MSVC only: dynamic load most Win32 APIs to give better compatibility for old Windows versions." OFF) -option(FRAMELESSHELPER_NO_PERMISSIVE_CHECKS "MSVC only: disable the additional permissive checks." OFF) -option(FRAMELESSHELPER_NO_INSTALL "Don't install any files." OFF) -option(FRAMELESSHELPER_NO_SUMMARY "Don't show CMake configure summary." ON) -option(FRAMELESSHELPER_ENABLE_SPECTRE "Mitigate Spectre security vulnerabilities." OFF) -option(FRAMELESSHELPER_ENABLE_EHCONTGUARD "MSVC only: Enable EH Continuation (EHCONT) Metadata." OFF) -option(FRAMELESSHELPER_ENABLE_INTELCET "Enable Intel CET." OFF) -#option(FRAMELESSHELPER_ENABLE_INTELJCC "Enable Intel JCC." OFF) # Always enabled now. -option(FRAMELESSHELPER_ENABLE_CFGUARD "Enable Control Flow Guard (CFG)." OFF) -option(FRAMELESSHELPER_EXAMPLES_STANDALONE "Build the demo projects as standalone CMake projects." OFF) -cmake_dependent_option(FRAMELESSHELPER_ENABLE_UNIVERSAL_BUILD "macOS only: build universal library/example for Mac." ON APPLE OFF) -option(FRAMELESSHELPER_FORCE_LTO "Force enable LTO/LTCG even when building static libraries." OFF) -#option(FRAMELESSHELPER_REPRODUCIBLE_OUTPUT "Don't update the build commit and date dynamically." ON) # Always enabled now. -option(FRAMELESSHELPER_NO_WINDOW "Disable the pre-defined FramelessWindow wrapper class." OFF) -option(FRAMELESSHELPER_NO_TITLEBAR "Disable the pre-defined StandardTitleBar control." OFF) -option(FRAMELESSHELPER_NO_TRANSLATION "Don't bundle the I18N translations into the library." OFF) -option(FRAMELESSHELPER_NO_MICA_MATERIAL "Disable the cross-platform homemade Mica Material." OFF) -option(FRAMELESSHELPER_NO_BORDER_PAINTER "Disable the cross-platform window frame border painter." OFF) -option(FRAMELESSHELPER_NO_SYSTEM_BUTTON "Disable the pre-defined StandardSystemButton control." OFF) -cmake_dependent_option(FRAMELESSHELPER_NATIVE_IMPL "Use platform native implementation instead of Qt to get best experience." ON WIN32 OFF) - -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui) - -find_package(QT NAMES Qt6 Qt5 QUIET COMPONENTS Widgets Quick) -find_package(Qt${QT_VERSION_MAJOR} QUIET COMPONENTS Widgets Quick) - -if(FRAMELESSHELPER_NATIVE_IMPL AND NOT WIN32) - message(WARNING "FRAMELESSHELPER_NATIVE_IMPL currently only supports the Windows platform!") - set(FRAMELESSHELPER_NATIVE_IMPL OFF) -endif() - -if(FRAMELESSHELPER_NO_WINDOW AND FRAMELESSHELPER_BUILD_EXAMPLES) - message(WARNING "You can't build the examples when the FramelessWindow class is disabled at the same time!") - set(FRAMELESSHELPER_BUILD_EXAMPLES OFF) -endif() - -if(FRAMELESSHELPER_ENABLE_UNIVERSAL_BUILD AND NOT APPLE) - message(WARNING "Universal build is a macOS only feature, it will be disabled on current platform.") - set(FRAMELESSHELPER_ENABLE_UNIVERSAL_BUILD OFF) -elseif(APPLE AND ((QT_VERSION VERSION_LESS "6.2" AND QT_VERSION VERSION_GREATER_EQUAL "6.0") OR (QT_VERSION VERSION_LESS "5.15.9"))) - message(WARNING "Your Qt version ${QT_VERSION} doesn't support universal build, it will be disabled.") - set(FRAMELESSHELPER_ENABLE_UNIVERSAL_BUILD OFF) -endif() - -if(FRAMELESSHELPER_NO_BUNDLE_RESOURCE) - message(WARNING "Nothing will be embeded into the FramelessHelper library, the chrome buttons will have no icon.") -endif() - -if(FRAMELESSHELPER_ENABLE_VCLTL AND NOT MSVC) - message(WARNING "VC-LTL is only available for the MSVC toolchain.") - set(FRAMELESSHELPER_ENABLE_VCLTL OFF) -endif() - -if(FRAMELESSHELPER_ENABLE_YYTHUNKS AND NOT MSVC) - message(WARNING "YY-Thunks is only available for the MSVC toolchain.") - set(FRAMELESSHELPER_ENABLE_YYTHUNKS OFF) -endif() - -if(NOT TARGET Qt${QT_VERSION_MAJOR}::Core OR NOT TARGET Qt${QT_VERSION_MAJOR}::Gui) - message(WARNING "Can't find the QtCore and/or QtGui module. Nothing will be built.") - set(FRAMELESSHELPER_BUILD_WIDGETS OFF) - set(FRAMELESSHELPER_BUILD_QUICK OFF) - set(FRAMELESSHELPER_BUILD_EXAMPLES OFF) -endif() - -if(FRAMELESSHELPER_BUILD_QUICK AND NOT TARGET Qt${QT_VERSION_MAJOR}::Quick) - message(WARNING "Can't find the QtQuick module. FramelessHelper's QtQuick implementation and the QtQuick demo won't be built.") - set(FRAMELESSHELPER_BUILD_QUICK OFF) -endif() - -set(FRAMELESSHELPER_64BIT_POSTFIX "") -if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(FRAMELESSHELPER_64BIT_POSTFIX "64") -endif() - -set(FRAMELESSHELPER_LICENSE_HEADER "/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the \"Software\"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */") - -set(__extra_flags "") -if(NOT FRAMELESSHELPER_BUILD_STATIC) - list(APPEND __extra_flags ENABLE_LTO) -endif() -setup_project( - QT_PROJECT - QML_IMPORT_DIR "${PROJECT_BINARY_DIR}/imports" - LICENSE_HEADER "${FRAMELESSHELPER_LICENSE_HEADER}" - LANGUAGES CXX RC - MAX_WARNING - RTTI - EXCEPTIONS - ${__extra_flags} -) -unset(__extra_flags) - -if(MINGW AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set(FRAMELESSHELPER_ENABLE_SPECTRE OFF) - set(FRAMELESSHELPER_ENABLE_EHCONTGUARD OFF) - set(FRAMELESSHELPER_ENABLE_INTELCET OFF) - #set(FRAMELESSHELPER_ENABLE_INTELJCC OFF) - set(FRAMELESSHELPER_ENABLE_CFGUARD OFF) -endif() - -if(FRAMELESSHELPER_ENABLE_VCLTL) - include(cmake/VC-LTL.cmake) - if("x${SupportLTL}" STREQUAL "xtrue") - # Make sure we will always overwrite the previous settings. - unset(CMAKE_MSVC_RUNTIME_LIBRARY) - unset(CMAKE_MSVC_RUNTIME_LIBRARY CACHE) - #unset(CMAKE_MSVC_RUNTIME_LIBRARY PARENT_SCOPE) - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" CACHE STRING "" FORCE) - endif() -endif() -if(FRAMELESSHELPER_ENABLE_YYTHUNKS) - unset(YYTHUNKS_TARGET_OS) - unset(YYTHUNKS_TARGET_OS CACHE) - #unset(YYTHUNKS_TARGET_OS PARENT_SCOPE) - set(YYTHUNKS_TARGET_OS "WinXP" CACHE STRING "" FORCE) - include(cmake/YY-Thunks.cmake) -endif() - -set(__extra_flags "") -if(FRAMELESSHELPER_NO_INSTALL) - list(APPEND __extra_flags NO_INSTALL) -endif() -prepare_package_export( - PACKAGE_NAME "${PROJECT_NAME}" - PACKAGE_VERSION "${PROJECT_VERSION}" - ${__extra_flags} -) -unset(__extra_flags) - -set(FRAMELESSHELPER_VERSION_FILE "${PROJECT_BINARY_DIR}/framelesshelper.version") -generate_project_version( - PATH "${FRAMELESSHELPER_VERSION_FILE}" - COMMIT_HASH COMMIT_SUBJECT COMMIT_AUTHOR - COMMIT_DATETIME COMMIT_BRANCH COMPILER_NAME - COMPILER_VENDOR COMPILER_VERSION BUILD_DATETIME - ARCHITECTURE CMAKE_VERSION GENERATOR -) - -set(FRAMELESSHELPER_CONFIG_FILE "${PROJECT_BINARY_DIR}/framelesshelper.config") -add_project_config(KEY "static_build" CONDITION FRAMELESSHELPER_BUILD_STATIC) -add_project_config(KEY "widgets" CONDITION FRAMELESSHELPER_BUILD_WIDGETS) -add_project_config(KEY "quick" CONDITION FRAMELESSHELPER_BUILD_QUICK) -add_project_config(KEY "debug_output" CONDITION NOT FRAMELESSHELPER_NO_DEBUG_OUTPUT) -add_project_config(KEY "bundle_resource" CONDITION NOT FRAMELESSHELPER_NO_BUNDLE_RESOURCE) -add_project_config(KEY "private_qt" CONDITION NOT FRAMELESSHELPER_NO_PRIVATE) -add_project_config(KEY "window" CONDITION NOT FRAMELESSHELPER_NO_WINDOW) -add_project_config(KEY "titlebar" CONDITION NOT FRAMELESSHELPER_NO_TITLEBAR) -add_project_config(KEY "translation" CONDITION NOT FRAMELESSHELPER_NO_TRANSLATION) -add_project_config(KEY "mica_material" CONDITION NOT FRAMELESSHELPER_NO_MICA_MATERIAL) -add_project_config(KEY "border_painter" CONDITION NOT FRAMELESSHELPER_NO_BORDER_PAINTER) -add_project_config(KEY "system_button" CONDITION NOT FRAMELESSHELPER_NO_SYSTEM_BUTTON) -add_project_config(KEY "native_impl" CONDITION FRAMELESSHELPER_NATIVE_IMPL) -generate_project_config(PATH "${FRAMELESSHELPER_CONFIG_FILE}") - -function(setup_custom_moc_macros) - cmake_parse_arguments(arg "" "" "TARGETS" ${ARGN}) - if(arg_UNPARSED_ARGUMENTS) - message(AUTHOR_WARNING "setup_custom_moc_macros: Unrecognized arguments: ${arg_UNPARSED_ARGUMENTS}") - endif() - foreach(__target ${arg_TARGETS}) - if(NOT TARGET ${__target}) - message(AUTHOR_WARNING "${__target} is not a valid CMake target!") - continue() - endif() - set_property(TARGET ${__target} APPEND PROPERTY AUTOMOC_MACRO_NAMES "FRAMELESSHELPER_QT_CLASS;FRAMELESSHELPER_PUBLIC_QT_CLASS;FRAMELESSHELPER_PRIVATE_QT_CLASS") - endforeach() -endfunction() - -if(FRAMELESSHELPER_BUILD_WIDGETS OR FRAMELESSHELPER_BUILD_QUICK) - add_subdirectory(src) -endif() - -if(FRAMELESSHELPER_BUILD_EXAMPLES) - add_subdirectory(examples) -endif() - -if(WIN32 AND NOT FRAMELESSHELPER_NO_INSTALL) - set(__data_dir ".") - compute_install_dir(DATA_DIR __data_dir) - install(FILES "msbuild/FramelessHelper.props" DESTINATION "${__data_dir}") -endif() - -if(NOT FRAMELESSHELPER_NO_SUMMARY) - message("--------------------------- Toolchain ----------------------------") - message("CMake version: ${CMAKE_VERSION} (${CMAKE_COMMAND})") - message("Host system: ${CMAKE_HOST_SYSTEM}") - message("Host processor: ${CMAKE_HOST_SYSTEM_PROCESSOR}") - #[[message("C compiler: ${CMAKE_C_COMPILER_ID} (${CMAKE_C_COMPILER})") # Currently we are not using any C compilers. - message("C compiler version: ${CMAKE_C_COMPILER_VERSION}") - message("C common flags: ${CMAKE_C_FLAGS}") - message("C debug flags: ${CMAKE_C_FLAGS_DEBUG}") - message("C release flags: ${CMAKE_C_FLAGS_RELEASE}") - message("C minsizerel flags: ${CMAKE_C_FLAGS_MINSIZEREL}") - message("C relwithdebinfo flags: ${CMAKE_C_FLAGS_RELWITHDEBINFO}")]] - message("C++ compiler: ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER})") - message("C++ compiler version: ${CMAKE_CXX_COMPILER_VERSION}") - message("C++ common flags: ${CMAKE_CXX_FLAGS}") - message("C++ debug flags: ${CMAKE_CXX_FLAGS_DEBUG}") - message("C++ release flags: ${CMAKE_CXX_FLAGS_RELEASE}") - message("C++ minsizerel flags: ${CMAKE_CXX_FLAGS_MINSIZEREL}") - message("C++ relwithdebinfo flags: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") - message("Linker: ${CMAKE_LINKER}") - message("Linker exe common flags: ${CMAKE_EXE_LINKER_FLAGS}") - message("Linker exe debug flags: ${CMAKE_EXE_LINKER_FLAGS_DEBUG}") - message("Linker exe release flags: ${CMAKE_EXE_LINKER_FLAGS_RELEASE}") - message("Linker exe minsizerel flags: ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL}") - message("Linker exe relwithdebinfo flags: ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}") - message("Linker dll common flags: ${CMAKE_SHARED_LINKER_FLAGS}") - message("Linker dll debug flags: ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}") - message("Linker dll release flags: ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") - message("Linker dll minsizerel flags: ${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL}") - message("Linker dll relwithdebinfo flags: ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO}") - message("Make program: ${CMAKE_MAKE_PROGRAM}") - message("Generator: ${CMAKE_GENERATOR}") - message("Build type: ${CMAKE_BUILD_TYPE}") - message("Configuration types: ${CMAKE_CONFIGURATION_TYPES}") - message("Install prefix: ${CMAKE_INSTALL_PREFIX}") - message("Prefix paths: ${CMAKE_PREFIX_PATH}") - message("Toolchain file: ${CMAKE_TOOLCHAIN_FILE}") - message("------------------------------ Qt -------------------------------") - query_qt_paths(SDK_DIR __qt_inst_dir) - query_qt_library_info(STATIC __qt_static_lib) - message("Qt SDK installation directory: ${__qt_inst_dir}") - message("Qt SDK version: ${QT_VERSION}") - if(__qt_static_lib) - message("Qt SDK library type: static") - else() - message("Qt SDK library type: shared") - endif() - message("------------------------ FramelessHelper ------------------------") - message("FramelessHelper version: ${PROJECT_VERSION}") - message("Build the static version of FramelessHelper: ${FRAMELESSHELPER_BUILD_STATIC}") - message("Build the FramelessHelper::Widgets module: ${FRAMELESSHELPER_BUILD_WIDGETS}") - message("Build the FramelessHelper::Quick module: ${FRAMELESSHELPER_BUILD_QUICK}") - message("Build the FramelessHelper demo applications: ${FRAMELESSHELPER_BUILD_EXAMPLES}") - message("Deploy Qt libraries after compilation: ${FRAMELESSHELPER_EXAMPLES_DEPLOYQT}") - message("Suppress debug messages from FramelessHelper: ${FRAMELESSHELPER_NO_DEBUG_OUTPUT}") - message("Do not bundle any resources within FramelessHelper: ${FRAMELESSHELPER_NO_BUNDLE_RESOURCE}") - message("Do not use any private functionalities from Qt: ${FRAMELESSHELPER_NO_PRIVATE}") - message("[MSVC] Link to system C runtime library: ${FRAMELESSHELPER_ENABLE_VCLTL}") - message("[MSVC] Thunk system APIs for old system: ${FRAMELESSHELPER_ENABLE_YYTHUNKS}") - message("[MSVC] Disable permissive checks: ${FRAMELESSHELPER_NO_PERMISSIVE_CHECKS}") - message("Do not install anything for CMake install: ${FRAMELESSHELPER_NO_INSTALL}") - message("Mitigate Spectre security vulnerabilities: ${FRAMELESSHELPER_ENABLE_SPECTRE}") - message("[MSVC] Enable EH Continuation (EHCONT) Metadata: ${FRAMELESSHELPER_ENABLE_EHCONTGUARD}") - message("Enable Intel CET: ${FRAMELESSHELPER_ENABLE_INTELCET}") - #message("Enable Intel JCC: ${FRAMELESSHELPER_ENABLE_INTELJCC}") - message("Enable Control Flow Guard (CFG): ${FRAMELESSHELPER_ENABLE_CFGUARD}") - message("Build standalone demo projects: ${FRAMELESSHELPER_EXAMPLES_STANDALONE}") - message("[macOS]: Build universal library/example: ${FRAMELESSHELPER_ENABLE_UNIVERSAL_BUILD}") - message("Force enable LTO: ${FRAMELESSHELPER_FORCE_LTO}") - #message("Make output reproducible: ${FRAMELESSHELPER_REPRODUCIBLE_OUTPUT}") - message("Disable the FramelessWindow class (to reduce file size): ${FRAMELESSHELPER_NO_WINDOW}") - message("Disable the StandardTitleBar class (to reduce file size): ${FRAMELESSHELPER_NO_TITLEBAR}") - message("Don't embed the I18N resources (to reduce file size): ${FRAMELESSHELPER_NO_TRANSLATION}") - message("Disable the MicaMaterial class (to reduce file size): ${FRAMELESSHELPER_NO_MICA_MATERIAL}") - message("Disable the WindowBorderPainter class (to reduce file size): ${FRAMELESSHELPER_NO_BORDER_PAINTER}") - message("Disable the StandardSystemButton class (to reduce file size): ${FRAMELESSHELPER_NO_SYSTEM_BUTTON}") - message("-----------------------------------------------------------------") -endif() diff --git a/src/SARibbonBar/3rdparty/framelesshelper/FramelessHelperConfig.cmake.in b/src/SARibbonBar/3rdparty/framelesshelper/FramelessHelperConfig.cmake.in deleted file mode 100644 index cb4e4873..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/FramelessHelperConfig.cmake.in +++ /dev/null @@ -1,80 +0,0 @@ -#[[ - MIT License - - Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -]] - -@PACKAGE_INIT@ - -include(CMakeFindDependencyMacro) - -set(_@PROJECT_NAME@_supported_components Core Widgets Quick) -set(_@PROJECT_NAME@_available_components Core Gui) - -foreach(_component ${@PROJECT_NAME@_FIND_COMPONENTS}) - if(_component IN_LIST _@PROJECT_NAME@_supported_components) - set(__target @PROJECT_NAME@::${_component}) - if(TARGET ${__target}) - continue() - else() - set(__target_full @PROJECT_NAME@${_component}) - set(__targets_file "${CMAKE_CURRENT_LIST_DIR}/${__target_full}Targets.cmake") - if(EXISTS "${__targets_file}") - include("${__targets_file}") - add_library(${__target} ALIAS @PROJECT_NAME@::${__target_full}) - list(APPEND _@PROJECT_NAME@_available_components ${_component}) - else() - set(@PROJECT_NAME@_FOUND FALSE) - set(@PROJECT_NAME@_NOT_FOUND_MESSAGE "Can't find necessary configuration file for ${__target}, please make sure this component is built successfully and installed properly.") - break() - endif() - endif() - else() - set(@PROJECT_NAME@_FOUND FALSE) - set(@PROJECT_NAME@_NOT_FOUND_MESSAGE "Unknown component: ${__target}.") - break() - endif() -endforeach() - -if(NOT DEFINED @PROJECT_NAME@_FOUND) - set(@PROJECT_NAME@_FOUND TRUE) - set(@PROJECT_NAME@_VERSION "@PROJECT_VERSION@") - set(@PROJECT_NAME@_VERSION_MAJOR "@PROJECT_VERSION_MAJOR@") - set(@PROJECT_NAME@_VERSION_MINOR "@PROJECT_VERSION_MINOR@") - set(@PROJECT_NAME@_VERSION_PATCH "@PROJECT_VERSION_PATCH@") - #set(@PROJECT_NAME@_VERSION_TWEAK "@PROJECT_VERSION_TWEAK@") - set(@PROJECT_NAME@_DESCRIPTION "@PROJECT_DESCRIPTION@") - set(@PROJECT_NAME@_HOMEPAGE_URL "@PROJECT_HOMEPAGE_URL@") - set(@PROJECT_NAME@_COMMIT "@PROJECT_VERSION_COMMIT@") - set(@PROJECT_NAME@_COMPILE_DATETIME "@PROJECT_COMPILE_DATETIME@") -endif() - -include(FeatureSummary) -set_package_properties(@PROJECT_NAME@ PROPERTIES - DESCRIPTION "@PROJECT_DESCRIPTION@" - URL "@PROJECT_HOMEPAGE_URL@" -) - -if(${@PROJECT_NAME@_FOUND}) - list(REMOVE_DUPLICATES _@PROJECT_NAME@_available_components) - find_dependency(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS ${_@PROJECT_NAME@_available_components}) - find_dependency(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS ${_@PROJECT_NAME@_available_components}) -endif() diff --git a/src/SARibbonBar/3rdparty/framelesshelper/LICENSE b/src/SARibbonBar/3rdparty/framelesshelper/LICENSE deleted file mode 100644 index b6ae6bf3..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/src/SARibbonBar/3rdparty/framelesshelper/README.md b/src/SARibbonBar/3rdparty/framelesshelper/README.md deleted file mode 100644 index 0677367c..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/README.md +++ /dev/null @@ -1,453 +0,0 @@ -# FramelessHelper 2.x - -[![CI: Build Test](https://github.com/wangwenx190/framelesshelper/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/wangwenx190/framelesshelper/actions/workflows/ci.yml) - -Cross-platform window customization framework for Qt Widgets and Qt Quick. Supports Windows, Linux and macOS. - -## Join with Us :triangular_flag_on_post: - -You can join our [Discord channel](https://discord.gg/grrM4Tmesy) to communicate with us. You can share your findings, thoughts and ideas on improving / implementing FramelessHelper functionalities on more platforms and apps! - -## TODO - -- Common: Add cross-platform customizable system menu for both Qt Widgets and Qt Quick. Also supports both light and dark theme. -- 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 have transparent background and doesn't have rectangular window frame. -- Examples: Add demo projects based on QRhiWidget and QRhiQuickItem. -- Feature requests are welcome! - -## Highlights v2.5 - -- General: The file size of FramelessHelper binaries should be smaller than before, due to most static string literals and some internal structures are constexpr now, this change may also help to improve the general performance. -- General: The performance should be improved quite some bit, due to most double lookups of Qt container types and unnecessary data copies are avoided now. -- Snap Layout: The snap layout implementation has been COMPLETELY rewritten. It now behaves almost exactly the same with native windows! -- Mica Material: FramelessHelper now prefers speed over quality. This change will lower the image quality but since the image is highly blurred anyway, there should not be any significant differences in the final user experience. -- Build system: Improved RPATH support (UNIX systems). -- Build system: Support modular build. -- Routine bug fixes and internal refactorings. - -## Highlights v2.4 - -- Widgets: Nested frameless windows are supported now! -- Linux: There have been many improvements to the Linux/X11 implementation! Most of them won't be directly visible to the user, but the code quality has been greatly improved. -- macOS: The frameless windows will now use native window frame and buttons, only the title bar itself is hidden, which also means the window will have round corners as all other native windows on macOS. -- Mica Material: It is now possible to load wallpaper images with very large file size or resolution, for example, 4K pictures. However, if the images have larger resolution than 1920x1080, they will be shrinked to reduce memory usage, and this process will also lower the image quality and break the aspect ratio of them. -- Mica Material: FramelessHelper will now use a seperate thread to load and apply special effects to the wallpaper image, to speed up application startup performance and avoid such process block the main thread. -- Window management: It is now possible to close the window (the dtor is executed) and show it again without breaking the frameless functionalities. -- Theme: It is now possible to force a desired theme instead of always respecting the system theme. -- Build system: The [**Ninja Multi-Config**](https://cmake.org/cmake/help/latest/generator/Ninja%20Multi-Config.html) generator is fully supported now, finally! -- Docs: There have been some improvements of the build instructions. -- Routine bug fixes and internal refactorings. - -## Highlights v2.3 - -- Widgets & Quick: When you clicks the window icon, the system menu will now popup, and when you double clicks it, the window will be closed. This emulates the traditional window behavior on Windows. -- Widgets & Quick: The StandardSystemButton's icon size can't be changed due to I forgot to implement such funtionality, it's implemented now. -- Widgets: Added `FramelessDialog` class. You can use it in case a `QDialog` is preferred over a general `QWidget`. -- Widgets: The StandardSystemButton's size can't be changed due to a FramelessHelper bug, it's fixed now. -- Widgets: Added public interface to change the title label font (family, point size, style, etc...). -- Widgets: The window borders are now drawn by the newly introduced `WindowBorderPainter` class, and it's also exposed publicly, so you'll be able to change how we draw the window border easily. -- Quick: Added `WindowBorder` element. It's a cross-platform window border decorator, and can work without the `FramelessHelper` element. -- Quick: Added `FramelessApplicationWindow` element. It's a simple wrapper of the standard `ApplicationWindow` element, just removes the title bar and adds the window border. -- Windows: Added support for dark theme system menu. The system menu triggered by right-clicking on the title bar will now use the same theme with the current system theme, and will switch between light and dark theme automatically. -- macOS: Added support for old macOS versions and old Qt versions, in theory. -- Common: Internal code improvements & bug fixes. - -## Highlights v2.2 - -- Common: Added blur behind window feature for Windows (7\~11), Linux and macOS. On Windows 11 and macOS, FramelessHelper will make use of the blur effect provided by the OS to get the best appearance and performance, while on Windows 7\~10 and Linux, FramelessHelper will use a homemade blur effect to provide as much consistent experience as possible. -- Common: Added window icon support. It's now possible to set the window icon's image, size and visibility for the standard title bar control. -- Windows: If you are using Qt 6.4+, your Qt Widgets applications will now automatically switch to light/dark theme if the OS theme changes. It requires you are using the default palette provided by Qt. Qt Quick applications will not be affected. -- Linux: FramelessHelper is now theme-aware. If you change your OS theme, FramelessHelper will now emit the theme change signal and refresh it's internal palette. -- Build system: Implemented CMake package support. It's now possible to use `find_package` to find FramelessHelper. -- Build system: Implemented limited QMake support. FramelessHelper doesn't provide complete QMake project, to decrease the maintainance burden, but you can use the .pri files to directly embed FramelessHelper into your own application. -- Examples: Enabled blur behind window and round window corner by default. -- Common: Migrated to categorized logging output. You can now enable or disable some specific debug messages using QLoggingCategory. -- Common: Internal code improvements & bug fixes. - -## Highlights v2.1 - -- Windows: Added support for the snap layout feature introduced in Windows 11. -- Widgets: Redesigned the public interface, the use of FramelessHelper is now more elegant. -- Quick: Redesigned the public interface, the use of FramelessHelper is now more elegant. -- Common: Redesigned the standard title bar interface, it's now possible to customize it from outside. Previously there's no standard title bar in the widgets module, it's now added and exported. -- Doc: Add initial simple documentation to show how to use this library for both Qt Widgets and Qt Quick. -- Misc: Removed bundled Qt internal classes that are licensed under Commercial/GPL/LGPL. This library is now pure MIT licensed. -- Misc: Bug fixes and internal refactorings. - -## Highlights v2.0 - -- Windows: Gained the ability to only remove the title bar but preserve the window frame at the same time. -- Windows: The flicker and jitter during window resizing is completely gone. -- Windows: The system menu will be opened if you right-click on your custom title bar. -- Windows: Replaced Qt's original system menu with FramelessHelper's homemade one, which looks a lot better than the original one. -- Linux: Removed the limitation of the Qt version. The minimum supported version is lowered to Qt 5.6 now (previously was 5.15). -- macOS: Removed the limitation of the Qt version. The minimum supported version is lowered to Qt 5.6 now (previously was 5.15). -- macOS: The frameless window now supports native resizing. -- Common: Almost completely rewritten of the whole library, it's now a lot more easier to setup your own custom title bar than before. -- Common: Added many more helper functions to allow creating your own custom window easier. -- Misc: Reorganized the project structure to be more like a modern library, it's now a lot more friendly to the library users. -- Misc: Many bugs from the 1.x times are fixed (they were not fixable in 1.x due to technical reasons). - -## Screenshots - -### Windows - -![Light](./doc/win_light.png) - -![Dark](./doc/win_dark.png) - -### Linux - -![Light](./doc/linux_light.png) - -![Dark](./doc/linux_dark.png) - -### macOS - -![Light](./doc/mac_light.png) - -![Dark](./doc/mac_dark.png) - -## Use Cases - -### QVogenClient - -![QVogenClient](./doc/QVogenClient.png) - -Vogen editor using **QSynthesis** framework. Repository URL: . - -## Requiredments - -- Compiler: a modern compiler which supports C++17 at least. Tested on MSVC 2022 (Windows), GCC 11 (Linux) and Clang 13 (macOS). -- Qt version: using the latest stable version of Qt is highly recommended, the minimum supported version is Qt 5.6. However, if you are using some old Qt versions (such as older than 5.12), some features may not be available. Only Qt 5.15 and Qt 6 are actively tested. -- Qt modules: QtCore and QtGui for the core module; QtWidgets for the widgets module; QtQuick, QtQuickControls2 and QtQuickTemplates2 for the quick module. -- CMake & ninja: the newer, the better. Other build systems are not tested. - -## Supported Platforms - -- Windows: Windows Vista \~ 11 (only actively tested on Windows 10 & 11) -- Linux: any modern Linux distros should work, but only tested on Ubuntu 20.04 and Ubuntu 22.04 -- macOS: only tested on macOS 12 & 13 due to lack of Apple devices - -There are some additional restrictions for each platform, please refer to the _Platform notes_ section below. - -## Build - -```bash -git clone --recursive https://github.com/wangwenx190/framelesshelper.git # "--recursive" is necessary to clone the submodules. -mkdir build # Please change to your own build directory! -cd build -cmake -DCMAKE_PREFIX_PATH= -DCMAKE_INSTALL_PREFIX= -DCMAKE_BUILD_TYPE=Release -GNinja -cmake --build . --config Release --target all --parallel -cmake --install . --config Release --strip # Don't add "--strip" for MSVC/Clang-CL/Intel-CL toolchains! -# YOUR_QT_SDK_DIR_PATH: the Qt SDK directory, something like "C:/Qt/6.5.1/msvc2019_64" or "/opt/Qt/6.5.1/gcc_64". Please change to your own path! -# WHERE_YOU_WANT_TO_INSTALL: the install directory of FramelessHelper, something like "../install". You can ignore this setting if you don't need to install the CMake package. Please change to your own path! -# PATH_TO_THE_REPOSITORY: the source code directory of FramelessHelper, something like "../framelesshelper". Please change to your own path! -``` - -You can also use `Qt6_DIR` or `Qt5_DIR` to replace `CMAKE_PREFIX_PATH`: - -```bash -cmake -DQt6_DIR=C:/Qt/6.5.1/msvc2019_64/lib/cmake/Qt6 [other parameters ...] -# Or -cmake -DQt5_DIR=C:/Qt/5.15.2/msvc2019_64/lib/cmake/Qt5 [other parameters ...] -``` - -If there are any errors when cloning the submodules, try run `git submodule update --init --recursive --remote` in the project directory, that command will download & update all the submodules. If it fails again, try execute it multiple times until it finally succeeds. - -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` or `FramelessHelper_DIR` variable to it. For example: `-DCMAKE_PREFIX_PATH=C:/my-cmake-packages;C:/my-toolchain;etc...` or `-DFramelessHelper_DIR=C:/Projects/FramelessHelper/lib64/cmake/FramelessHelper`. Build FramelessHelper as a sub-directory of your CMake project is of course also supported. The supported FramelessHelper target names are `FramelessHelper::Core`, `FramelessHelper::Widgets` and `FramelessHelper::Quick`. Example code: - -```cmake -# Find Qt: -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) -# Find FramelessHelper: -find_package(FramelessHelper REQUIRED COMPONENTS Core Widgets) -# Create your target: -add_executable(demo) -# Add your source code: -target_sources(demo PRIVATE main.cpp) -# Link to Qt and FramelessHelper: -target_link_libraries(demo PRIVATE - Qt${QT_VERSION_MAJOR}::Widgets - FramelessHelper::Core - FramelessHelper::Widgets -) -``` - -If you need the syntax highlighting of FramelessHelper's Quick module, please set up the `QML_IMPORT_PATH` variable. Example code: - -```cmake -# This is the path where you want FramelessHelper's Quick plugin (it only contains the QML meta -# info and an optional dummy library, for QtCreator's QML tooling purpose, it's not the Quick -# module) to place. Please change to your own path! -# If you are using add_subdirectory() to include FramelessHelper directly, you can change it to -# "${PROJECT_BINARY_DIR}/imports" instead of the install location. -set(FRAMELESSHELPER_IMPORT_DIR "C:/packages/FramelessHelper/qml") -list(APPEND QML_IMPORT_PATH "${FRAMELESSHELPER_IMPORT_DIR}") -list(REMOVE_DUPLICATES QML_IMPORT_PATH) -# Force cache refresh: -set(QML_IMPORT_PATH ${QML_IMPORT_PATH} CACHE STRING "Qt Creator extra QML import paths" FORCE) -``` - -## Use - -### Qt Widgets - -To customize the window frame of a QWidget, you need to instantiate a `FramelessWidgetsHelper` object and then attach it to the widget's top level widget, and then `FramelessWidgetsHelper` will do all the rest work for you: the window frame will be removed automatically once it has been attached to the top level widget successfully. In theory you can instantiate multiple `FramelessWidgetsHelper` objects for a same widget, in this case there will be only one object that keeps functional, all other objects will become a wrapper of that one. But to make sure everything goes smoothly and normally, you should not do that in any case. The simplest way to instantiate a `FramelessWidgetsHelper` -object is to call the static method `FramelessWidgetsHelper *FramelessWidgetsHelper::get(QObject *)`. It will return the handle of the previously instantiated object if any, or it will instantiate a new object if it can't find one. It's safe to call this method multiple times for a same widget, it won't instantiate any new objects if there is one already. It also does not matter when and where you call that function as long as the top level widget is the same. The internally created objects will always be parented to the top level widget. Once you get the handle of the `FramelessWidgetsHelper` object, you can call `void FramelessWidgetsHelper::extendsContentIntoTitleBar()` to let it hide the default title bar provided by the operating system. In order to make sure `FramelessWidgetsHelper` can find the correct top level widget, you should call the `FramelessWidgetsHelper *FramelessWidgetsHelper::get(QObject *)` function on a widget which has a complete parent-chain whose root parent is the top level widget. To make the frameless window draggable, you should provide a homemade title bar widget yourself, the title bar widget doesn't need to be in rectangular shape, it also doesn't need to be placed on the first row of the window. Call `void FramelessWidgetsHelper::setTitleBarWidget(QWidget *)` to let `FramelessHelper` know what's your title bar widget. By default, all the widgets in the title bar area won't be responsible to any mouse and keyboard events due to they have been intercepted by FramelessHelper. To make them recover the responsible state, you should make them visible to hit test. Call `void FramelessWidgetsHelper::setHitTestVisible(QWidget* )` to do that. You can of course call it on a widget that is not inside the title bar at all, it won't have any effect though. Due to Qt's own limitations, you need to make sure your widget has a complete parent-chain whose root parent is the top level widget. Do not ever try to delete the `FramelessWidgetsHelper` object, it may still be monitoring and controlling your widget, and Qt will delete it for you automatically. No need to worry about memory leaks. - -There are also two classes called `FramelessWidget` and `FramelessMainWindow`, they are only simple wrappers of `FramelessWidgetsHelper`, which just saves the call of the `void FramelessWidgetsHelper::extendsContentIntoTitleBar()` function for you. You can absolutely use plain `QWidget` instead. - -#### Code Snippet - -First of all, call `void FramelessHelper::Widgets::initialize()` in your `main` function in a very early stage (**MUST** before the construction of any `Q(Gui|Core)Application` objects): - -```cpp -int main(int, char **) -{ - FramelessHelper::Widgets::initialize(); - // ... -} -``` - -Then hide the standard title bar provided by the OS: - -```cpp -MyWidget::MyWidget(QWidget *parent) : QWidget(parent) -{ - // You should do this early enough. - FramelessWidgetsHelper::get(this)->extendsContentIntoTitleBar(); - // ... -} -``` - -Then let `FramelessHelper` know what should be the title bar: - -```cpp -void MyWidget::myFunction() -{ - // ... - FramelessWidgetsHelper::get(this)->setTitleBarWidget(m_myTitleBarWidget); - // ... -} -``` - -Then make some widgets inside your title bar visible to hit test: - -```cpp -void MyWidget::myFunction2() -{ - // ... - FramelessWidgetsHelper::get(this)->setHitTestVisible(m_someSearchBox); - FramelessWidgetsHelper::get(this)->setHitTestVisible(m_someButton); - FramelessWidgetsHelper::get(this)->setHitTestVisible(m_someMenuItem); - // ... -} -``` - -**IMPORTANT NOTE for Qt Widgets applications**: Some functionalities may only be available when `FramelessHelper` has finished the window customization process, such as changing window geometry/flags/state. In this case you can connect to the public `void ready()` signal of `FramelessHelper` to get the accurate time point and do your rest initialization process afterwards. - -### Qt Quick - -#### Code Snippet - -First of all, you should call `void FramelessHelper::Quick::initialize()` in your `main` function in a very early stage (**MUST** before the construction of any `Q(Gui|Core)Application` objects): - -```cpp -int main(int, char **) -{ - FramelessHelper::Quick::initialize(); - // ... -} -``` - -Then you need to register the custom types provided by `FramelessHelper` by calling `void FramelessHelper::Quick::registerTypes(QQmlEngine *)`, before the QML engine loads any QML documents: - -```cpp -int main(int, char **) -{ - // ... - QQmlApplicationEngine engine; - FramelessHelper::Quick::registerTypes(&engine); - // ... -} -``` - -Now you can write your QML documents. You should import `FramelessHelper` from the URI `org.wangwenx190.FramelessHelper`. You should specify a version number right after it if you are using Qt5: - -```qml -import org.wangwenx190.FramelessHelper 1.0 // You can use "auto" or omit the version number in Qt6. -``` - -And then you can use the attached properties from the QML type `FramelessHelper`: - -```qml -Window { - Item { - id: myTitleBar - Item { id: someControl1 } - Item { id: someControl2 } - Item { id: someControl3 } - Component.onCompleted: { - // Don't access FramelessHelper too early, otherwise it may not be able to find the root window! - FramelessHelper.titleBarItem = myTitleBar; - FramelessHelper.setHitTestVisible(someControl1); - FramelessHelper.setHitTestVisible(someControl2); - FramelessHelper.setHitTestVisible(someControl3); - } - } -} -``` - -It's the same with the `FramelessWidgetsHelper` interface, the QML type `FramelessHelper` will be instantiated only once for each `Window`, no matter when and where you use attached properties from it. However, due to the special design of the `FramelessHelper` type, you can also use it just like a normal QML type: - -```qml -Window { - Item { - id: myTitleBar - Item { id: someControl1 } - Item { id: someControl2 } - Item { id: someControl3 } - Component.onCompleted: { - framelessHelper.setHitTestVisible(someControl1); - framelessHelper.setHitTestVisible(someControl2); - framelessHelper.setHitTestVisible(someControl3); - } - } - FramelessHelper { - id: framelessHelper - titleBarItem: myTitleBar - } -} -``` - -In theory it's possible to instantiate multiple `FramelessHelper` objects for a same `Window`, in this case only one of them will keep functional, all other objects will become a wrapper of it, but doing so is not recommended and may cause unexpected behavior or bugs, so please avoid trying to do that in any case. - -If you find any of `FramelessHelper` functions have no effect after calling, the most possible reason is by the time you call the function/change the property of `FramelessHelper`, the root window has not finished its initialization process and thus `FramelessHelper` can't get the handle of it, so any action from the user will be ignored until the root window finished initialization. - -There's also a QML type called `FramelessWindow`, it's only a simple wrapper of `FramelessHelper`, you can absolutely use plain `Window` instead. - -**IMPORTANT NOTE for Qt Quick applications**: Some functionalities may only be available when `FramelessHelper` has finished the window customization process, such as changing window geometry/flags/state. In this case you can connect to the public `void ready()` signal of `FramelessHelper` to get the accurate time point and do your rest initialization process afterwards: - -```qml -Window { - FramelessHelper.onReady: { - // do something here ... - } -} -``` - -```qml -Window { - FramelessHelper { - onReady: { - // do something here ... - } - } -} -``` - -### More - -Please refer to the demo projects to see more detailed usages: [examples](./examples/) - -### Title Bar Design Guidance - -- Microsoft: -- KDE: -- GNOME: -- Apple: - -## Platform Notes - -### Windows - -- If DWM composition is disabled in some very rare cases (only possible on Windows 7), the top-left corner and top-right corner will appear in round shape. The round corners can be restored to square if you re-enable DWM composition. -- There's an OpenGL driver bug which will cause some frameless windows have a strange black bar right on top of your homemade title bar, and it also makes the controls in your windows shifted to the bottom-right corner for some pixels. It's a bug of your graphics card driver, specifically, your OpenGL driver, not FramelessHelper. There are some solutions provided by our users but some of them may not work in all conditions, you can pick one from them: - - Solution | Principle - -------- | --------- - Upgrade the graphics driver | Try to use a newer driver which may ship with the fix - Change the system theme to "Basic" (in contrary to "Windows Aero") | Let Windows use pure software rendering - If there are multiple graphics cards, use another one instead | Try to use a different driver which may don't have such bug at all - Upgrade the system to at least Windows 11 | Windows 11 redesigned the windowing system so the bug can no longer be triggered - Remove the `WS_THICKFRAME` and `WS_OVERLAPPED` styles from the window, and maybe also add the `WS_POPUP` style at the same time, and don't do anything inside the `WM_NCCALCSIZE` block (just return `false` directly or remove/comment out the whole block) | Try to mirror Qt's `FramelessWindowHint`'s behavior - Use `Qt::FramelessWindowHint` instead of doing the `WM_NCCALCSIZE` trick | Qt's rendering code path is totally different between these two solutions - Force Qt to use the ANGLE backend instead of the Desktop OpenGL | ANGLE will translate OpenGL directives into D3D ones - Force Qt to use pure software rendering instead of rendering through OpenGL | Qt is not using OpenGL at all - Force Qt to use the Mesa 3D libraries instead of normal OpenGL | Try to use a different OpenGL implementation - Use Direct3D/Vulkan/Metal instead of OpenGL | Just don't use the buggy OpenGL - - If you are lucky enough, one of them may fix the issue for you. If not, you may try to use multiple solutions together. **But I can't guarantee the issue can 100% be fixed.** -- Due to there are many sub-versions of Windows 10, it's highly recommended to use the latest version of Windows 10, at least **no older than Windows 10 1809**. If you try to use this framework on some very old Windows 10 versions such as 1507 or 1607, there may be some compatibility issues. Using this framework on Windows 7 is also supported but not recommended. To get the most stable behavior and the best appearance, you should use it on the latest version of Windows 10 or Windows 11. -- To make the snap layout work as expected, there are some additional rules for your homemade system buttons to follow: - - **Add a manifest file to your application. In the manifest file, you need to claim your application supports Windows 11 explicitly. This step is VERY VERY IMPORTANT. Without this step, the snap layout feature can't be enabled.** - - Call `setSystemButton()` for each button (it can be any *QWidget* or *QQuickItem*) to let FramelessHelper know which is the minimize/maximize/close button. - -### Linux - -- FramelessHelper will force your application to use the _XCB_ platform plugin when running on Wayland. -- The resize area is inside of the window. - -### macOS - -- Some users reported that the window is not resizable on some old macOS versions. - -## FAQs - -### `When running on Win10, it seems the top border is missing? But the demo applications still have it?` - -`FramelessHelper` hides the system title bar by removing the whole top part of the window frame, including the top border. There's no way to only remove the system title bar but still preserve the top border at the same time, even Microsoft themself can't do that either. The exact reason is unknown to non-Microsoft developers, and I have no interest in digging into all the magic behind it. So you'll have to draw one manually yourself to pretend the top border is still there. You can retrieve it's height and color through official DWM APIs. Please refer to the documentation of [`DwmGetWindowAttribute()`](https://docs.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmgetwindowattribute) and [`DwmGetColorizationColor()`](https://docs.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmgetcolorizationcolor). The demo applications still have the top border because their main windows all inherit from `FramelessWidget` or `FramelessMainWindow`, which will draw the top border for you internally. As for Qt Quick, the QML type `FramelessWindow` will also draw the top border. - -### `When running on Wayland, dragging the title bar causes crash?` - -You need to force Qt to use the **XCB** QPA when running on Wayland. Try setting the environment variable `QT_QPA_PLATFORM` (case sensitive) to `xcb` (case sensitive) before instantiating any `Q(Gui)Application` instances. Or just call `void FramelessHelper::Widgets/Quick::initialize()` in your `main` function, this function will take care of it for you. - -### `I can see the black background during window resizing?` - -First of all, it's a Qt issue, not caused by FramelessHelper. And it should not be possible for Qt Widgets applications. It's a common issue for Qt Quick applications. Most of the time it's caused by D3D11/Vulkan/Metal because they are not good at dealing with texture resizing operations. If you really want to fix this issue, you can try to change Qt's RHI backend to **OpenGL** (be careful of the bug of your graphics card driver) or **Software** (if you don't care about performance). And please keep in mind that this issue is not fixable from outside of Qt. - -### `Can I preserve the window frame border even on Win7? How does Google Chrome/Microsoft Edge's installer achieve that?` - -Short answer: it's impossible. Full explaination: of course we can use the same technique we use on Win10 to remove the whole top part of the window and preserve the other three frame borders at the same time, but on Win10 we can bring the top border back, either by doing some black magic in the `WM_PAINT` handler or draw a thin frame border manually ourself, however, it's impossible to do this on Win7. I've tried it on Win7 already and sadly the result is the `WM_PAINT` trick won't work on Win7, and we also can't draw a frame border which looks very similar to the original one (a semi-transparent rectangle, blended with system's accent color and the visual content behind the window, also with some blur effect applied). But it seems Google Chrome/Microsoft Edge's installer have achieved what we wanted to do, how? Well, their installer is open source and I've read it's code already. They achieve that by overlapping two windows, one normal window on the bottom, another border-less window on the top to cover the bottom window's title bar. They draw their homemade title bar on the border-less window and use it to emulate the standard title bar's behavior. The original title bar provided by the system is still there, but it can't be seen by anyone just because it's covered by another window. I admit it's a good solution in such cases but for our library it's not appropriate because the code complexity will blow up. - -## Special Thanks - -*Ordered by first contribution time (it may not be very accurate, sorry)* - -- [Yuhang Zhao](https://github.com/wangwenx190): Help me create this project. This project is mainly based on his code. -- [Julien](https://github.com/JulienMaille): Help me test this library on many various environments and help me fix the bugs we found. Contributed many code to improve this library. The MainWindow example is mostly based on his code. -- [Altair Wei](https://github.com/altairwei): Help me fix quite some small bugs and give me many important suggestions, the 2.x version is also inspired by his idea during our discussions. -- [Kenji Mouri](https://github.com/MouriNaruto): Give me a lot of help on Win32 native developing. -- [Dylan Liu](https://github.com/mentalfl0w): Help me improve the build process on macOS. -- [SineStriker](https://github.com/SineStriker): Spent over a whole week helping me improve the Snap Layout implementation, fixing potential bugs and also give me a lot of professional and useful suggestions. Without his great effort, the new implementation may never come. -- And also thanks to other contributors not listed here! Without their valuable help, this library wouldn't have such good quality and user experience! - -## License - -```text -MIT License - -Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -``` diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/ChromePalette b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/ChromePalette deleted file mode 100644 index 2cc2eee1..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/ChromePalette +++ /dev/null @@ -1 +0,0 @@ -#include "chromepalette.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/FramelessHelper_Linux b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/FramelessHelper_Linux deleted file mode 100644 index 09825565..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/FramelessHelper_Linux +++ /dev/null @@ -1 +0,0 @@ -#include "framelesshelper_linux.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/FramelessHelper_Qt b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/FramelessHelper_Qt deleted file mode 100644 index 9bc8967c..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/FramelessHelper_Qt +++ /dev/null @@ -1 +0,0 @@ -#include "framelesshelper_qt.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/FramelessHelper_Win b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/FramelessHelper_Win deleted file mode 100644 index 118ce16f..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/FramelessHelper_Win +++ /dev/null @@ -1 +0,0 @@ -#include "framelesshelper_win.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/FramelessHelper_Windows b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/FramelessHelper_Windows deleted file mode 100644 index be2542a8..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/FramelessHelper_Windows +++ /dev/null @@ -1 +0,0 @@ -#include "framelesshelper_windows.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/FramelessManager b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/FramelessManager deleted file mode 100644 index 9283b6b3..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/FramelessManager +++ /dev/null @@ -1 +0,0 @@ -#include "framelessmanager.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/Global b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/Global deleted file mode 100644 index 5f99275b..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/Global +++ /dev/null @@ -1 +0,0 @@ -#include "framelesshelpercore_global.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/MicaMaterial b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/MicaMaterial deleted file mode 100644 index b9bd471f..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/MicaMaterial +++ /dev/null @@ -1 +0,0 @@ -#include "micamaterial.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/Utils b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/Utils deleted file mode 100644 index 6a9dd984..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/Utils +++ /dev/null @@ -1 +0,0 @@ -#include "utils.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/WindowBorderPainter b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/WindowBorderPainter deleted file mode 100644 index 95b20bce..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/WindowBorderPainter +++ /dev/null @@ -1 +0,0 @@ -#include "windowborderpainter.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/chromepalette.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/chromepalette.h deleted file mode 100644 index ac20da87..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/chromepalette.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include - -#if FRAMELESSHELPER_CONFIG(titlebar) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class ChromePalettePrivate; -class FRAMELESSHELPER_CORE_API ChromePalette : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_PUBLIC_QT_CLASS(ChromePalette) - - Q_PROPERTY(QColor titleBarActiveBackgroundColor READ titleBarActiveBackgroundColor - WRITE setTitleBarActiveBackgroundColor RESET resetTitleBarActiveBackgroundColor - NOTIFY titleBarActiveBackgroundColorChanged FINAL) - Q_PROPERTY(QColor titleBarInactiveBackgroundColor READ titleBarInactiveBackgroundColor - WRITE setTitleBarInactiveBackgroundColor RESET resetTitleBarInactiveBackgroundColor - NOTIFY titleBarInactiveBackgroundColorChanged FINAL) - Q_PROPERTY(QColor titleBarActiveForegroundColor READ titleBarActiveForegroundColor - WRITE setTitleBarActiveForegroundColor RESET resetTitleBarActiveForegroundColor - NOTIFY titleBarActiveForegroundColorChanged FINAL) - Q_PROPERTY(QColor titleBarInactiveForegroundColor READ titleBarInactiveForegroundColor - WRITE setTitleBarInactiveForegroundColor RESET resetTitleBarInactiveForegroundColor - NOTIFY titleBarInactiveForegroundColorChanged FINAL) - Q_PROPERTY(QColor chromeButtonNormalColor READ chromeButtonNormalColor - WRITE setChromeButtonNormalColor RESET resetChromeButtonNormalColor - NOTIFY chromeButtonNormalColorChanged FINAL) - Q_PROPERTY(QColor chromeButtonHoverColor READ chromeButtonHoverColor - WRITE setChromeButtonHoverColor RESET resetChromeButtonHoverColor - NOTIFY chromeButtonHoverColorChanged FINAL) - Q_PROPERTY(QColor chromeButtonPressColor READ chromeButtonPressColor - WRITE setChromeButtonPressColor RESET resetChromeButtonPressColor - NOTIFY chromeButtonPressColorChanged FINAL) - Q_PROPERTY(QColor closeButtonNormalColor READ closeButtonNormalColor - WRITE setCloseButtonNormalColor RESET resetCloseButtonNormalColor - NOTIFY closeButtonNormalColorChanged FINAL) - Q_PROPERTY(QColor closeButtonHoverColor READ closeButtonHoverColor - WRITE setCloseButtonHoverColor RESET resetCloseButtonHoverColor - NOTIFY closeButtonHoverColorChanged FINAL) - Q_PROPERTY(QColor closeButtonPressColor READ closeButtonPressColor - WRITE setCloseButtonPressColor RESET resetCloseButtonPressColor - NOTIFY closeButtonPressColorChanged FINAL) - -public: - explicit ChromePalette(QObject *parent = nullptr); - ~ChromePalette() override; - - Q_NODISCARD QColor titleBarActiveBackgroundColor() const; - Q_NODISCARD QColor titleBarInactiveBackgroundColor() const; - Q_NODISCARD QColor titleBarActiveForegroundColor() const; - Q_NODISCARD QColor titleBarInactiveForegroundColor() const; - Q_NODISCARD QColor chromeButtonNormalColor() const; - Q_NODISCARD QColor chromeButtonHoverColor() const; - Q_NODISCARD QColor chromeButtonPressColor() const; - Q_NODISCARD QColor closeButtonNormalColor() const; - Q_NODISCARD QColor closeButtonHoverColor() const; - Q_NODISCARD QColor closeButtonPressColor() const; - -public Q_SLOTS: - void setTitleBarActiveBackgroundColor(const QColor &value); - void resetTitleBarActiveBackgroundColor(); - void setTitleBarInactiveBackgroundColor(const QColor &value); - void resetTitleBarInactiveBackgroundColor(); - void setTitleBarActiveForegroundColor(const QColor &value); - void resetTitleBarActiveForegroundColor(); - void setTitleBarInactiveForegroundColor(const QColor &value); - void resetTitleBarInactiveForegroundColor(); - void setChromeButtonNormalColor(const QColor &value); - void resetChromeButtonNormalColor(); - void setChromeButtonHoverColor(const QColor &value); - void resetChromeButtonHoverColor(); - void setChromeButtonPressColor(const QColor &value); - void resetChromeButtonPressColor(); - void setCloseButtonNormalColor(const QColor &value); - void resetCloseButtonNormalColor(); - void setCloseButtonHoverColor(const QColor &value); - void resetCloseButtonHoverColor(); - void setCloseButtonPressColor(const QColor &value); - void resetCloseButtonPressColor(); - -Q_SIGNALS: - void titleBarActiveBackgroundColorChanged(); - void titleBarInactiveBackgroundColorChanged(); - void titleBarActiveForegroundColorChanged(); - void titleBarInactiveForegroundColorChanged(); - void chromeButtonNormalColorChanged(); - void chromeButtonHoverColorChanged(); - void chromeButtonPressColorChanged(); - void closeButtonNormalColorChanged(); - void closeButtonHoverColorChanged(); - void closeButtonPressColorChanged(); - void titleBarColorChanged(); - void chromeButtonColorChanged(); -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/framelesshelper_linux.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/framelesshelper_linux.h deleted file mode 100644 index 3e0af7fd..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/framelesshelper_linux.h +++ /dev/null @@ -1,526 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include - -/* - * Copyright (C) 2001-2006 Bart Massey, Jamey Sharp, and Josh Triplett. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the names of the authors or their - * institutions shall not be used in advertising or otherwise to promote the - * sale, use or other dealings in this Software without prior written - * authorization from the authors. - */ - -// This one is not included in any public headers. -using Display = struct _XDisplay; - -#if 0 // Causes segfault -#ifndef FRAMELESSHELPER_HAS_XLIB -extern "C" -{ - -FRAMELESSHELPER_CORE_API int -XInitThreads( - void -); - -} // extern "C" -#endif // FRAMELESSHELPER_HAS_XLIB -#endif - -#if __has_include() -# include -# define FRAMELESSHELPER_HAS_XCB -#else // !__has_include() - -using xcb_connection_t = struct xcb_connection_t; -using xcb_button_t = uint8_t; -using xcb_window_t = uint32_t; -using xcb_timestamp_t = uint32_t; -using xcb_atom_t = uint32_t; - -using xcb_generic_error_t = struct xcb_generic_error_t -{ - uint8_t response_type; - uint8_t error_code; - uint16_t sequence; - uint32_t resource_id; - uint16_t minor_code; - uint8_t major_code; - uint8_t pad0; - uint32_t pad[5]; - uint32_t full_sequence; -}; - -using xcb_client_message_data_t = union xcb_client_message_data_t -{ - uint8_t data8[20]; - uint16_t data16[10]; - uint32_t data32[5]; -}; - -using xcb_button_press_event_t = struct xcb_button_press_event_t -{ - uint8_t response_type; - xcb_button_t detail; - uint16_t sequence; - xcb_timestamp_t time; - xcb_window_t root; - xcb_window_t event; - xcb_window_t child; - int16_t root_x; - int16_t root_y; - int16_t event_x; - int16_t event_y; - uint16_t state; - uint8_t same_screen; - uint8_t pad0; -}; -using xcb_button_release_event_t = xcb_button_press_event_t; - -using xcb_void_cookie_t = struct xcb_void_cookie_t -{ - unsigned int sequence; -}; - -using xcb_intern_atom_cookie_t = struct xcb_intern_atom_cookie_t -{ - unsigned int sequence; -}; - -using xcb_intern_atom_reply_t = struct xcb_intern_atom_reply_t -{ - uint8_t response_type; - uint8_t pad0; - uint16_t sequence; - uint32_t length; - xcb_atom_t atom; -}; - -using xcb_client_message_event_t = struct xcb_client_message_event_t -{ - uint8_t response_type; - uint8_t format; - uint16_t sequence; - xcb_window_t window; - xcb_atom_t type; - xcb_client_message_data_t data; -}; - -using xcb_get_property_reply_t = struct xcb_get_property_reply_t -{ - uint8_t response_type; - uint8_t format; - uint16_t sequence; - uint32_t length; - xcb_atom_t type; - uint32_t bytes_after; - uint32_t value_len; - uint8_t pad0[12]; -}; - -using xcb_get_property_cookie_t = struct xcb_get_property_cookie_t -{ - unsigned int sequence; -}; - -using xcb_list_properties_cookie_t = struct xcb_list_properties_cookie_t -{ - unsigned int sequence; -}; - -using xcb_list_properties_reply_t = struct xcb_list_properties_reply_t -{ - uint8_t response_type; - uint8_t pad0; - uint16_t sequence; - uint32_t length; - uint16_t atoms_len; - uint8_t pad1[22]; -}; - -[[maybe_unused]] inline constexpr const auto XCB_NONE = 0; -[[maybe_unused]] inline constexpr const auto XCB_WINDOW_NONE = 0; -[[maybe_unused]] inline constexpr const auto XCB_CURRENT_TIME = 0; -[[maybe_unused]] inline constexpr const auto XCB_PROP_MODE_REPLACE = 0; -[[maybe_unused]] inline constexpr const auto XCB_ATOM_ATOM = 4; -[[maybe_unused]] inline constexpr const auto XCB_ATOM_CARDINAL = 6; -[[maybe_unused]] inline constexpr const auto XCB_ATOM_WINDOW = 33; -[[maybe_unused]] inline constexpr const auto XCB_BUTTON_INDEX_ANY = 0; -[[maybe_unused]] inline constexpr const auto XCB_BUTTON_INDEX_1 = 1; -[[maybe_unused]] inline constexpr const auto XCB_BUTTON_INDEX_2 = 2; -[[maybe_unused]] inline constexpr const auto XCB_BUTTON_INDEX_3 = 3; -[[maybe_unused]] inline constexpr const auto XCB_BUTTON_RELEASE = 5; -[[maybe_unused]] inline constexpr const auto XCB_CLIENT_MESSAGE = 33; -[[maybe_unused]] inline constexpr const auto XCB_EVENT_MASK_STRUCTURE_NOTIFY = 131072; -[[maybe_unused]] inline constexpr const auto XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT = 1048576; -[[maybe_unused]] inline constexpr const auto XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY = 524288; -#endif // __has_include() - -[[maybe_unused]] inline constexpr const auto _NET_WM_MOVERESIZE_SIZE_TOPLEFT = 0; -[[maybe_unused]] inline constexpr const auto _NET_WM_MOVERESIZE_SIZE_TOP = 1; -[[maybe_unused]] inline constexpr const auto _NET_WM_MOVERESIZE_SIZE_TOPRIGHT = 2; -[[maybe_unused]] inline constexpr const auto _NET_WM_MOVERESIZE_SIZE_RIGHT = 3; -[[maybe_unused]] inline constexpr const auto _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT = 4; -[[maybe_unused]] inline constexpr const auto _NET_WM_MOVERESIZE_SIZE_BOTTOM = 5; -[[maybe_unused]] inline constexpr const auto _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT = 6; -[[maybe_unused]] inline constexpr const auto _NET_WM_MOVERESIZE_SIZE_LEFT = 7; -[[maybe_unused]] inline constexpr const auto _NET_WM_MOVERESIZE_MOVE = 8; -[[maybe_unused]] inline constexpr const auto _NET_WM_MOVERESIZE_SIZE_KEYBOARD = 9; -[[maybe_unused]] inline constexpr const auto _NET_WM_MOVERESIZE_MOVE_KEYBOARD = 10; -[[maybe_unused]] inline constexpr const auto _NET_WM_MOVERESIZE_CANCEL = 11; - -[[maybe_unused]] inline constexpr const char ATOM_NET_SUPPORTED[] = "_NET_SUPPORTED"; -[[maybe_unused]] inline constexpr const char ATOM_NET_WM_NAME[] = "_NET_WM_NAME"; -[[maybe_unused]] inline constexpr const char ATOM_NET_WM_MOVERESIZE[] = "_NET_WM_MOVERESIZE"; -[[maybe_unused]] inline constexpr const char ATOM_NET_SUPPORTING_WM_CHECK[] = "_NET_SUPPORTING_WM_CHECK"; -[[maybe_unused]] inline constexpr const char ATOM_NET_KDE_COMPOSITE_TOGGLING[] = "_NET_KDE_COMPOSITE_TOGGLING"; -[[maybe_unused]] inline constexpr const char ATOM_KDE_NET_WM_BLUR_BEHIND_REGION[] = "_KDE_NET_WM_BLUR_BEHIND_REGION"; -[[maybe_unused]] inline constexpr const char ATOM_GTK_SHOW_WINDOW_MENU[] = "_GTK_SHOW_WINDOW_MENU"; -[[maybe_unused]] inline constexpr const char ATOM_DEEPIN_NO_TITLEBAR[] = "_DEEPIN_NO_TITLEBAR"; -[[maybe_unused]] inline constexpr const char ATOM_DEEPIN_FORCE_DECORATE[] = "_DEEPIN_FORCE_DECORATE"; -[[maybe_unused]] inline constexpr const char ATOM_NET_WM_DEEPIN_BLUR_REGION_MASK[] = "_NET_WM_DEEPIN_BLUR_REGION_MASK"; -[[maybe_unused]] inline constexpr const char ATOM_NET_WM_DEEPIN_BLUR_REGION_ROUNDED[] = "_NET_WM_DEEPIN_BLUR_REGION_ROUNDED"; -[[maybe_unused]] inline constexpr const char ATOM_UTF8_STRING[] = "UTF8_STRING"; - -#ifndef FRAMELESSHELPER_HAS_XCB -extern "C" -{ - -FRAMELESSHELPER_CORE_API xcb_void_cookie_t -xcb_send_event( - xcb_connection_t *connection, - uint8_t propagate, - xcb_window_t destination, - uint32_t event_mask, - const char *event -); - -FRAMELESSHELPER_CORE_API int -xcb_flush( - xcb_connection_t *connection -); - -FRAMELESSHELPER_CORE_API xcb_intern_atom_cookie_t -xcb_intern_atom( - xcb_connection_t *connection, - uint8_t only_if_exists, - uint16_t name_len, - const char *name -); - -FRAMELESSHELPER_CORE_API xcb_intern_atom_reply_t * -xcb_intern_atom_reply( - xcb_connection_t *connection, - xcb_intern_atom_cookie_t cookie, - xcb_generic_error_t **error -); - -FRAMELESSHELPER_CORE_API xcb_void_cookie_t -xcb_ungrab_pointer( - xcb_connection_t *connection, - xcb_timestamp_t time -); - -FRAMELESSHELPER_CORE_API xcb_void_cookie_t -xcb_change_property( - xcb_connection_t *connection, - uint8_t mode, - xcb_window_t window, - xcb_atom_t property, - xcb_atom_t type, - uint8_t format, - uint32_t data_len, - const void *data -); - -FRAMELESSHELPER_CORE_API xcb_void_cookie_t -xcb_delete_property_checked( - xcb_connection_t *connection, - xcb_window_t window, - xcb_atom_t property -); - -FRAMELESSHELPER_CORE_API xcb_get_property_cookie_t -xcb_get_property( - xcb_connection_t *connection, - uint8_t _delete, - xcb_window_t window, - xcb_atom_t property, - xcb_atom_t type, - uint32_t long_offset, - uint32_t long_length -); - -FRAMELESSHELPER_CORE_API xcb_get_property_reply_t * -xcb_get_property_reply( - xcb_connection_t *connection, - xcb_get_property_cookie_t cookie, - xcb_generic_error_t **error -); - -FRAMELESSHELPER_CORE_API void * -xcb_get_property_value( - const xcb_get_property_reply_t *reply -); - -FRAMELESSHELPER_CORE_API int -xcb_get_property_value_length( - const xcb_get_property_reply_t *reply -); - -FRAMELESSHELPER_CORE_API xcb_list_properties_cookie_t -xcb_list_properties( - xcb_connection_t *connection, - xcb_window_t window -); - -FRAMELESSHELPER_CORE_API xcb_list_properties_reply_t * -xcb_list_properties_reply( - xcb_connection_t *connection, - xcb_list_properties_cookie_t cookie, - xcb_generic_error_t **error -); - -FRAMELESSHELPER_CORE_API int -xcb_list_properties_atoms_length( - const xcb_list_properties_reply_t *atom -); - -FRAMELESSHELPER_CORE_API xcb_atom_t * -xcb_list_properties_atoms( - const xcb_list_properties_reply_t *atom -); - -FRAMELESSHELPER_CORE_API xcb_get_property_cookie_t -xcb_get_property_unchecked( - xcb_connection_t *connection, - uint8_t _delete, - xcb_window_t window, - xcb_atom_t property, - xcb_atom_t type, - uint32_t long_offset, - uint32_t long_length -); - -} // extern "C" -#endif // FRAMELESSHELPER_HAS_XCB - -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#if __has_include() -# undef signals // Workaround a compilation issue caused by GTK. -# include -# define FRAMELESSHELPER_HAS_GTK -#else // !__has_include() - -#define G_VALUE_INIT { 0, { { 0 } } } -#define g_signal_connect(instance, detailed_signal, c_handler, data) \ - g_signal_connect_data((instance), (detailed_signal), (c_handler), (data), nullptr, G_CONNECT_DEFAULT) - -using gint = int; -using glong = long; -using gshort = short; -using gboolean = int; -using gushort = unsigned short; -using guint = unsigned int; -using gulong = unsigned long; -using gfloat = float; -using gdouble = double; -using gchar = char; -using guchar = unsigned char; -using gchararray = char *; -using gpointer = void *; -using gint64 = signed long; -using guint64 = unsigned long; -using gsize = unsigned int; - -using GType = unsigned long; // TODO: or unsigned int? -using GValue = struct _GValue; -using GObject = struct _GObject; -using GClosure = struct _GClosure; -using GtkSettings = struct _GtkSettings; - -using GConnectFlags = enum GConnectFlags -{ - G_CONNECT_DEFAULT = 0, - G_CONNECT_AFTER = 1 << 0, - G_CONNECT_SWAPPED = 1 << 1 -}; - -using GCallback = void(*)(void); -using GClosureNotify = void(*)(gpointer data, GClosure *closure); - -struct _GValue -{ - GType g_type; - - union - { - gint v_int; - guint v_uint; - glong v_long; - gulong v_ulong; - gint64 v_int64; - guint64 v_uint64; - gfloat v_float; - gdouble v_double; - gpointer v_pointer; - } data[2]; -}; -#endif // __has_include() - -[[maybe_unused]] inline constexpr const char GTK_THEME_NAME_ENV_VAR[] = "GTK_THEME"; -[[maybe_unused]] inline constexpr const char GTK_THEME_NAME_PROP[] = "gtk-theme-name"; -[[maybe_unused]] inline constexpr const char GTK_THEME_PREFER_DARK_PROP[] = "gtk-application-prefer-dark-theme"; - -#ifndef FRAMELESSHELPER_HAS_GTK -extern "C" -{ - -FRAMELESSHELPER_CORE_API void -gtk_init( - int *argc, - char ***argv -); - -FRAMELESSHELPER_CORE_API GValue * -g_value_init( - GValue *value, - GType g_type -); - -FRAMELESSHELPER_CORE_API GValue * -g_value_reset( - GValue *value -); - -FRAMELESSHELPER_CORE_API void -g_value_unset( - GValue *value -); - -FRAMELESSHELPER_CORE_API gboolean -g_value_get_boolean( - const GValue *value -); - -FRAMELESSHELPER_CORE_API const gchar * -g_value_get_string( - const GValue *value -); - -FRAMELESSHELPER_CORE_API GtkSettings * -gtk_settings_get_default( - void -); - -FRAMELESSHELPER_CORE_API void -g_object_get_property( - GObject *object, - const gchar *property_name, - GValue *value -); - -FRAMELESSHELPER_CORE_API gulong -g_signal_connect_data( - gpointer instance, - const gchar *detailed_signal, - GCallback c_handler, - gpointer data, - GClosureNotify destroy_data, - GConnectFlags connect_flags -); - -FRAMELESSHELPER_CORE_API void -g_free( - gpointer mem -); - -FRAMELESSHELPER_CORE_API void -g_object_unref( - GObject *object -); - -FRAMELESSHELPER_CORE_API void -g_clear_object( - GObject **object_ptr -); - -} // extern "C" -#endif // FRAMELESSHELPER_HAS_GTK - -FRAMELESSHELPER_BEGIN_NAMESPACE -template -[[nodiscard]] T gtkSettings(const gchar *property); - -#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) -using x11_return_type = quint32; -#else // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) -using x11_return_type = unsigned long; -#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/framelesshelper_qt.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/framelesshelper_qt.h deleted file mode 100644 index 6be319c9..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/framelesshelper_qt.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include - -#if !FRAMELESSHELPER_CONFIG(native_impl) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FramelessHelperQtPrivate; -class FRAMELESSHELPER_CORE_API FramelessHelperQt : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_PUBLIC_QT_CLASS(FramelessHelperQt) - -public: - explicit FramelessHelperQt(QObject *parent = nullptr); - ~FramelessHelperQt() override; - - static void addWindow(const QObject *window); - static void removeWindow(const QObject *window); - -protected: - Q_NODISCARD bool eventFilter(QObject *object, QEvent *event) override; -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif // !native_impl diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/framelesshelper_win.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/framelesshelper_win.h deleted file mode 100644 index 7237b8f7..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/framelesshelper_win.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include - -#ifdef Q_OS_WINDOWS - -#if FRAMELESSHELPER_CONFIG(native_impl) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FRAMELESSHELPER_CORE_API FramelessHelperWin : public QAbstractNativeEventFilter -{ - FRAMELESSHELPER_CLASS(FramelessHelperWin) - -public: - explicit FramelessHelperWin(); - ~FramelessHelperWin() override; - - static void addWindow(const QObject *window); - static void removeWindow(const QObject *window); - - Q_NODISCARD bool nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result) override; -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif // native_impl - -#endif // Q_OS_WINDOWS diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/framelesshelper_windows.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/framelesshelper_windows.h deleted file mode 100644 index 2c7ced47..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/framelesshelper_windows.h +++ /dev/null @@ -1,1487 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// Copyright (C) Microsoft Corporation. -// Licensed under the MIT license. - -#pragma once - -#ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -#endif - -#ifndef WINRT_LEAN_AND_MEAN -# define WINRT_LEAN_AND_MEAN -#endif - -#ifndef UNICODE -# define UNICODE -#endif - -#ifndef _UNICODE -# define _UNICODE -#endif - -#ifndef _CRT_NON_CONFORMING_SWPRINTFS -# define _CRT_NON_CONFORMING_SWPRINTFS -#endif - -#ifndef _CRT_SECURE_NO_WARNINGS -# define _CRT_SECURE_NO_WARNINGS -#endif - -#ifndef NOMINMAX -# define NOMINMAX -#endif - -#if __has_include() -# include -#endif - -#ifndef _WIN32_WINNT_NT4 -# define _WIN32_WINNT_NT4 0x0400 -#endif - -#ifndef _WIN32_WINNT_WIN2K -# define _WIN32_WINNT_WIN2K 0x0500 -#endif - -#ifndef _WIN32_WINNT_WINXP -# define _WIN32_WINNT_WINXP 0x0501 -#endif - -#ifndef _WIN32_WINNT_WS03 -# define _WIN32_WINNT_WS03 0x0502 -#endif - -#ifndef _WIN32_WINNT_LONGHORN -# define _WIN32_WINNT_LONGHORN 0x0600 -#endif - -#ifndef _WIN32_WINNT_WS08 -# define _WIN32_WINNT_WS08 _WIN32_WINNT_LONGHORN -#endif - -#ifndef _WIN32_WINNT_WIN6 -# define _WIN32_WINNT_WIN6 _WIN32_WINNT_LONGHORN -#endif - -#ifndef _WIN32_WINNT_VISTA -# define _WIN32_WINNT_VISTA _WIN32_WINNT_LONGHORN -#endif - -#ifndef _WIN32_WINNT_WIN7 -# define _WIN32_WINNT_WIN7 0x0601 -#endif - -#ifndef _WIN32_WINNT_WIN8 -# define _WIN32_WINNT_WIN8 0x0602 -#endif - -#ifndef _WIN32_WINNT_WINBLUE -# define _WIN32_WINNT_WINBLUE 0x0603 -#endif - -#ifndef _WIN32_WINNT_WIN10 -# define _WIN32_WINNT_WIN10 0x0A00 -#endif - -#ifndef NTDDI_WIN4 -# define NTDDI_WIN4 0x04000000 -#endif - -#ifndef NTDDI_WIN2K -# define NTDDI_WIN2K 0x05000000 -#endif - -#ifndef NTDDI_WIN2KSP1 -# define NTDDI_WIN2KSP1 0x05000100 -#endif - -#ifndef NTDDI_WIN2KSP2 -# define NTDDI_WIN2KSP2 0x05000200 -#endif - -#ifndef NTDDI_WIN2KSP3 -# define NTDDI_WIN2KSP3 0x05000300 -#endif - -#ifndef NTDDI_WIN2KSP4 -# define NTDDI_WIN2KSP4 0x05000400 -#endif - -#ifndef NTDDI_WINXP -# define NTDDI_WINXP 0x05010000 -#endif - -#ifndef NTDDI_WINXPSP1 -# define NTDDI_WINXPSP1 0x05010100 -#endif - -#ifndef NTDDI_WINXPSP2 -# define NTDDI_WINXPSP2 0x05010200 -#endif - -#ifndef NTDDI_WINXPSP3 -# define NTDDI_WINXPSP3 0x05010300 -#endif - -#ifndef NTDDI_WINXPSP4 -# define NTDDI_WINXPSP4 0x05010400 -#endif - -#ifndef NTDDI_WS03 -# define NTDDI_WS03 0x05020000 -#endif - -#ifndef NTDDI_WS03SP1 -# define NTDDI_WS03SP1 0x05020100 -#endif - -#ifndef NTDDI_WS03SP2 -# define NTDDI_WS03SP2 0x05020200 -#endif - -#ifndef NTDDI_WS03SP3 -# define NTDDI_WS03SP3 0x05020300 -#endif - -#ifndef NTDDI_WS03SP4 -# define NTDDI_WS03SP4 0x05020400 -#endif - -#ifndef NTDDI_LONGHORN -# define NTDDI_LONGHORN 0x06000000 -#endif - -#ifndef NTDDI_WIN6 -# define NTDDI_WIN6 NTDDI_LONGHORN -#endif - -#ifndef NTDDI_VISTA -# define NTDDI_VISTA NTDDI_LONGHORN -#endif - -#ifndef NTDDI_WIN6SP1 -# define NTDDI_WIN6SP1 0x06000100 -#endif - -#ifndef NTDDI_VISTASP1 -# define NTDDI_VISTASP1 NTDDI_WIN6SP1 -#endif - -#ifndef NTDDI_WS08 -# define NTDDI_WS08 NTDDI_WIN6SP1 -#endif - -#ifndef NTDDI_WIN6SP2 -# define NTDDI_WIN6SP2 0x06000200 -#endif - -#ifndef NTDDI_VISTASP2 -# define NTDDI_VISTASP2 NTDDI_WIN6SP2 -#endif - -#ifndef NTDDI_WS08SP2 -# define NTDDI_WS08SP2 NTDDI_WIN6SP2 -#endif - -#ifndef NTDDI_WIN6SP3 -# define NTDDI_WIN6SP3 0x06000300 -#endif - -#ifndef NTDDI_VISTASP3 -# define NTDDI_VISTASP3 NTDDI_WIN6SP3 -#endif - -#ifndef NTDDI_WS08SP3 -# define NTDDI_WS08SP3 NTDDI_WIN6SP3 -#endif - -#ifndef NTDDI_WIN6SP4 -# define NTDDI_WIN6SP4 0x06000400 -#endif - -#ifndef NTDDI_VISTASP4 -# define NTDDI_VISTASP4 NTDDI_WIN6SP4 -#endif - -#ifndef NTDDI_WS08SP4 -# define NTDDI_WS08SP4 NTDDI_WIN6SP4 -#endif - -#ifndef NTDDI_WIN7 -# define NTDDI_WIN7 0x06010000 -#endif - -#ifndef NTDDI_WIN8 -# define NTDDI_WIN8 0x06020000 -#endif - -#ifndef NTDDI_WINBLUE -# define NTDDI_WINBLUE 0x06030000 -#endif - -#ifndef NTDDI_WINTHRESHOLD -# define NTDDI_WINTHRESHOLD 0x0A000000 -#endif - -#ifndef NTDDI_WIN10 -# define NTDDI_WIN10 NTDDI_WINTHRESHOLD -#endif - -#ifndef NTDDI_WIN10_TH2 -# define NTDDI_WIN10_TH2 0x0A000001 -#endif - -#ifndef NTDDI_WIN10_RS1 -# define NTDDI_WIN10_RS1 0x0A000002 -#endif - -#ifndef NTDDI_WIN10_RS2 -# define NTDDI_WIN10_RS2 0x0A000003 -#endif - -#ifndef NTDDI_WIN10_RS3 -# define NTDDI_WIN10_RS3 0x0A000004 -#endif - -#ifndef NTDDI_WIN10_RS4 -# define NTDDI_WIN10_RS4 0x0A000005 -#endif - -#ifndef NTDDI_WIN10_RS5 -# define NTDDI_WIN10_RS5 0x0A000006 -#endif - -#ifndef NTDDI_WIN10_19H1 -# define NTDDI_WIN10_19H1 0x0A000007 -#endif - -#ifndef NTDDI_WIN10_VB -# define NTDDI_WIN10_VB 0x0A000008 -#endif - -#ifndef NTDDI_WIN10_MN -# define NTDDI_WIN10_MN 0x0A000009 -#endif - -#ifndef NTDDI_WIN10_FE -# define NTDDI_WIN10_FE 0x0A00000A -#endif - -#ifndef NTDDI_WIN10_CO -# define NTDDI_WIN10_CO 0x0A00000B -#endif - -#ifndef NTDDI_WIN10_NI -# define NTDDI_WIN10_NI 0x0A00000C -#endif - -#ifndef WINVER -# define WINVER _WIN32_WINNT_WIN10 -#endif - -#ifndef _WIN32_WINNT -# define _WIN32_WINNT _WIN32_WINNT_WIN10 -#endif - -#ifndef NTDDI_VERSION -# define NTDDI_VERSION NTDDI_WIN10_NI -#endif - -#if (_WIN32_WINNT < _WIN32_WINNT_WIN10) -# undef _WIN32_WINNT -# define _WIN32_WINNT _WIN32_WINNT_WIN10 -#endif - -#if (WINVER < _WIN32_WINNT_WIN10) -# undef WINVER -# define WINVER _WIN32_WINNT_WIN10 -#endif - -#include -#include -#include -#include - -#include - -#ifndef SC_SIZE -# define SC_SIZE (0xF000) -#endif - -#ifndef SC_SIZELEFT -# define SC_SIZELEFT (0xF001) -#endif - -#ifndef SC_SIZERIGHT -# define SC_SIZERIGHT (0xF002) -#endif - -#ifndef SC_SIZETOP -# define SC_SIZETOP (0xF003) -#endif - -#ifndef SC_SIZETOPLEFT -# define SC_SIZETOPLEFT (0xF004) -#endif - -#ifndef SC_SIZETOPRIGHT -# define SC_SIZETOPRIGHT (0xF005) -#endif - -#ifndef SC_SIZEBOTTOM -# define SC_SIZEBOTTOM (0xF006) -#endif - -#ifndef SC_SIZEBOTTOMLEFT -# define SC_SIZEBOTTOMLEFT (0xF007) -#endif - -#ifndef SC_SIZEBOTTOMRIGHT -# define SC_SIZEBOTTOMRIGHT (0xF008) -#endif - -#ifndef SC_DRAGMOVE -# define SC_DRAGMOVE (0xF012) -#endif - -#ifndef WM_SIZEWAIT -# define WM_SIZEWAIT (0x0004) -#endif - -#ifndef WM_SETVISIBLE -# define WM_SETVISIBLE (0x0009) -#endif - -#ifndef WM_SYSTEMERROR -# define WM_SYSTEMERROR (0x0017) -#endif - -#ifndef WM_CTLCOLOR -# define WM_CTLCOLOR (0x0019) -#endif - -#ifndef WM_LOGOFF -# define WM_LOGOFF (0x0025) -#endif - -#ifndef WM_ALTTABACTIVE -# define WM_ALTTABACTIVE (0x0029) -#endif - -#ifndef WM_SHELLNOTIFY -# define WM_SHELLNOTIFY (0x0034) -#endif - -#ifndef WM_ISACTIVEICON -# define WM_ISACTIVEICON (0x0035) -#endif - -#ifndef WM_QUERYPARKICON -# define WM_QUERYPARKICON (0x0036) -#endif - -#ifndef WM_WINHELP -# define WM_WINHELP (0x0038) -#endif - -#ifndef WM_FULLSCREEN -# define WM_FULLSCREEN (0x003A) -#endif - -#ifndef WM_CLIENTSHUTDOWN -# define WM_CLIENTSHUTDOWN (0x003B) -#endif - -#ifndef WM_DDEMLEVENT -# define WM_DDEMLEVENT (0x003C) -#endif - -#ifndef WM_TESTING -# define WM_TESTING (0x0040) -#endif - -#ifndef WM_OTHERWINDOWCREATED -# define WM_OTHERWINDOWCREATED (0x0042) -#endif - -#ifndef WM_OTHERWINDOWDESTROYED -# define WM_OTHERWINDOWDESTROYED (0x0043) -#endif - -#ifndef WM_COPYGLOBALDATA -# define WM_COPYGLOBALDATA (0x0049) -#endif - -#ifndef WM_KEYF1 -# define WM_KEYF1 (0x004D) -#endif - -#ifndef WM_ACCESS_WINDOW -# define WM_ACCESS_WINDOW (0x004F) -#endif - -#ifndef WM_FINALDESTROY -# define WM_FINALDESTROY (0x0070) -#endif - -#ifndef WM_MEASUREITEM_CLIENTDATA -# define WM_MEASUREITEM_CLIENTDATA (0x0071) -#endif - -#ifndef WM_SYNCTASK -# define WM_SYNCTASK (0x0089) -#endif - -#ifndef WM_KLUDGEMINRECT -# define WM_KLUDGEMINRECT (0x008B) -#endif - -#ifndef WM_LPKDRAWSWITCHWND -# define WM_LPKDRAWSWITCHWND (0x008C) -#endif - -#ifndef WM_UAHDESTROYWINDOW -# define WM_UAHDESTROYWINDOW (0x0090) -#endif - -#ifndef WM_UAHDRAWMENU -# define WM_UAHDRAWMENU (0x0091) -#endif - -#ifndef WM_UAHDRAWMENUITEM -# define WM_UAHDRAWMENUITEM (0x0092) -#endif - -#ifndef WM_UAHINITMENU -# define WM_UAHINITMENU (0x0093) -#endif - -#ifndef WM_UAHMEASUREMENUITEM -# define WM_UAHMEASUREMENUITEM (0x0094) -#endif - -#ifndef WM_UAHNCPAINTMENUPOPUP -# define WM_UAHNCPAINTMENUPOPUP (0x0095) -#endif - -#ifndef WM_UAHUPDATE -# define WM_UAHUPDATE (0x0096) -#endif - -#ifndef WM_NCUAHDRAWCAPTION -# define WM_NCUAHDRAWCAPTION (0x00AE) -#endif - -#ifndef WM_NCUAHDRAWFRAME -# define WM_NCUAHDRAWFRAME (0x00AF) -#endif - -#ifndef WM_YOMICHAR -# define WM_YOMICHAR (0x0108) -#endif - -#ifndef WM_CONVERTREQUEST -# define WM_CONVERTREQUEST (0x010A) -#endif - -#ifndef WM_CONVERTRESULT -# define WM_CONVERTRESULT (0x010B) -#endif - -#ifndef WM_INTERIM -# define WM_INTERIM (0x010C) -#endif - -#ifndef WM_SYSTIMER -# define WM_SYSTIMER (0x0118) -#endif - -#ifndef WM_GESTUREINPUT -# define WM_GESTUREINPUT (0x011B) -#endif - -#ifndef WM_GESTURENOTIFIED -# define WM_GESTURENOTIFIED (0x011C) -#endif - -#ifndef WM_LBTRACKPOINT -# define WM_LBTRACKPOINT (0x0131) -#endif - -#ifndef WM_DROPOBJECT -# define WM_DROPOBJECT (0x022A) -#endif - -#ifndef WM_QUERYDROPOBJECT -# define WM_QUERYDROPOBJECT (0x022B) -#endif - -#ifndef WM_BEGINDRAG -# define WM_BEGINDRAG (0x022C) -#endif - -#ifndef WM_DRAGLOOP -# define WM_DRAGLOOP (0x022D) -#endif - -#ifndef WM_DRAGSELECT -# define WM_DRAGSELECT (0x022E) -#endif - -#ifndef WM_DRAGMOVE -# define WM_DRAGMOVE (0x022F) -#endif - -#ifndef WM_STOPINERTIA -# define WM_STOPINERTIA (0x023B) -#endif - -#ifndef WM_ENDINERTIA -# define WM_ENDINERTIA (0x023C) -#endif - -#ifndef WM_EDGYINERTIA -# define WM_EDGYINERTIA (0x023D) -#endif - -#ifndef WM_VISIBILITYCHANGED -# define WM_VISIBILITYCHANGED (0x0270) -#endif - -#ifndef WM_VIEWSTATECHANGED -# define WM_VIEWSTATECHANGED (0x0271) -#endif - -#ifndef WM_UNREGISTER_WINDOW_SERVICES -# define WM_UNREGISTER_WINDOW_SERVICES (0x0272) -#endif - -#ifndef WM_CONSOLIDATED -# define WM_CONSOLIDATED (0x0273) -#endif - -#ifndef WM_IME_REPORT -# define WM_IME_REPORT (0x0280) -#endif - -#ifndef WM_IME_SYSTEM -# define WM_IME_SYSTEM (0x0287) -#endif - -#ifndef WM_POINTERDEVICEADDED -# define WM_POINTERDEVICEADDED (0x02C8) -#endif - -#ifndef WM_POINTERDEVICEDELETED -# define WM_POINTERDEVICEDELETED (0x02C9) -#endif - -#ifndef WM_FLICK -# define WM_FLICK (0x02CB) -#endif - -#ifndef WM_FLICKINTERNAL -# define WM_FLICKINTERNAL (0x02CD) -#endif - -#ifndef WM_BRIGHTNESSCHANGED -# define WM_BRIGHTNESSCHANGED (0x02CE) -#endif - -#ifndef WM_SYSMENU -# define WM_SYSMENU (0x0313) -#endif - -#ifndef WM_HOOKMSG -# define WM_HOOKMSG (0x0314) -#endif - -#ifndef WM_EXITPROCESS -# define WM_EXITPROCESS (0x0315) -#endif - -#ifndef WM_WAKETHREAD -# define WM_WAKETHREAD (0x0316) -#endif - -#ifndef WM_UAHINIT -# define WM_UAHINIT (0x031B) -#endif - -#ifndef WM_DESKTOPNOTIFY -# define WM_DESKTOPNOTIFY (0x031C) -#endif - -#ifndef WM_DWMEXILEFRAME -# define WM_DWMEXILEFRAME (0x0322) -#endif - -#ifndef WM_MAGNIFICATION_STARTED -# define WM_MAGNIFICATION_STARTED (0x0324) -#endif - -#ifndef WM_MAGNIFICATION_ENDED -# define WM_MAGNIFICATION_ENDED (0x0325) -#endif - -#ifndef WM_DWMTHUMBNAILSIZECHANGED -# define WM_DWMTHUMBNAILSIZECHANGED (0x0327) -#endif - -#ifndef WM_MAGNIFICATION_OUTPUT -# define WM_MAGNIFICATION_OUTPUT (0x0328) -#endif - -#ifndef WM_BSDRDATA -# define WM_BSDRDATA (0x0329) -#endif - -#ifndef WM_DWMTRANSITIONSTATECHANGED -# define WM_DWMTRANSITIONSTATECHANGED (0x032A) -#endif - -#ifndef WM_KEYBOARDCORRECTIONCALLOUT -# define WM_KEYBOARDCORRECTIONCALLOUT (0x032C) -#endif - -#ifndef WM_KEYBOARDCORRECTIONACTION -# define WM_KEYBOARDCORRECTIONACTION (0x032D) -#endif - -#ifndef WM_UIACTION -# define WM_UIACTION (0x032E) -#endif - -#ifndef WM_ROUTED_UI_EVENT -# define WM_ROUTED_UI_EVENT (0x032F) -#endif - -#ifndef WM_MEASURECONTROL -# define WM_MEASURECONTROL (0x0330) -#endif - -#ifndef WM_GETACTIONTEXT -# define WM_GETACTIONTEXT (0x0331) -#endif - -#ifndef WM_FORWARDKEYDOWN -# define WM_FORWARDKEYDOWN (0x0333) -#endif - -#ifndef WM_FORWARDKEYUP -# define WM_FORWARDKEYUP (0x0334) -#endif - -#ifndef WM_NOTIFYWOW -# define WM_NOTIFYWOW (0x0340) -#endif - -#ifndef WM_DWMCOMPOSITIONCHANGED -# define WM_DWMCOMPOSITIONCHANGED (0x031E) -#endif - -#ifndef WM_DWMCOLORIZATIONCOLORCHANGED -# define WM_DWMCOLORIZATIONCOLORCHANGED (0x0320) -#endif - -#ifndef WM_DPICHANGED -# define WM_DPICHANGED (0x02E0) -#endif - -#ifndef WM_GETDPISCALEDSIZE -# define WM_GETDPISCALEDSIZE (0x02E4) -#endif - -#ifndef SM_CXPADDEDBORDER -# define SM_CXPADDEDBORDER (92) -#endif - -#ifndef SM_CYPADDEDBORDER -# define SM_CYPADDEDBORDER SM_CXPADDEDBORDER -#endif - -#ifndef ABM_GETAUTOHIDEBAREX -# define ABM_GETAUTOHIDEBAREX (0x0000000b) -#endif - -#ifndef MAKEWORD -# define MAKEWORD(a, b) ((WORD)(((BYTE)(((DWORD_PTR)(a)) & 0xff)) | ((WORD)((BYTE)(((DWORD_PTR)(b)) & 0xff))) << 8)) -#endif - -#ifndef MAKELONG -# define MAKELONG(a, b) ((LONG)(((WORD)(((DWORD_PTR)(a)) & 0xffff)) | ((DWORD)((WORD)(((DWORD_PTR)(b)) & 0xffff))) << 16)) -#endif - -#ifndef LOWORD -# define LOWORD(l) ((WORD)(((DWORD_PTR)(l)) & 0xffff)) -#endif - -#ifndef HIWORD -# define HIWORD(l) ((WORD)((((DWORD_PTR)(l)) >> 16) & 0xffff)) -#endif - -#ifndef LOBYTE -# define LOBYTE(w) ((BYTE)(((DWORD_PTR)(w)) & 0xff)) -#endif - -#ifndef HIBYTE -# define HIBYTE(w) ((BYTE)((((DWORD_PTR)(w)) >> 8) & 0xff)) -#endif - -#ifndef GET_X_LPARAM -# define GET_X_LPARAM(lp) (static_cast(static_cast(LOWORD(lp)))) -#endif - -#ifndef GET_Y_LPARAM -# define GET_Y_LPARAM(lp) (static_cast(static_cast(HIWORD(lp)))) -#endif - -#ifndef GET_KEYSTATE_WPARAM -# define GET_KEYSTATE_WPARAM(wParam) (LOWORD(wParam)) -#endif - -#ifndef GET_NCHITTEST_WPARAM -# define GET_NCHITTEST_WPARAM(wParam) (static_cast(LOWORD(wParam))) -#endif - -#ifndef GET_XBUTTON_WPARAM -# define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam)) -#endif - -#ifndef POINTSTOPOINT -# define POINTSTOPOINT(pt, pts) \ - { \ - (pt).x = static_cast(static_cast(LOWORD(*(LONG*)&pts))); \ - (pt).y = static_cast(static_cast(HIWORD(*(LONG*)&pts))); \ - } -#endif - -#ifndef POINTTOPOINTS -# define POINTTOPOINTS(pt) (MAKELONG(static_cast((pt).x), static_cast((pt).y))) -#endif - -#ifndef MAKEWPARAM -# define MAKEWPARAM(l, h) (static_cast(static_cast(MAKELONG(l, h)))) -#endif - -#ifndef MAKELPARAM -# define MAKELPARAM(l, h) (static_cast(static_cast(MAKELONG(l, h)))) -#endif - -#ifndef MAKELRESULT -# define MAKELRESULT(l, h) (static_cast(static_cast(MAKELONG(l, h)))) -#endif - -#ifndef IsMinimized -# define IsMinimized(hwnd) (::IsIconic(hwnd) != FALSE) -#endif - -#ifndef IsMaximized -# define IsMaximized(hwnd) (::IsZoomed(hwnd) != FALSE) -#endif - -#ifndef RECT_WIDTH -# define RECT_WIDTH(rect) ((rect).right - (rect).left) -#endif - -#ifndef RECT_HEIGHT -# define RECT_HEIGHT(rect) ((rect).bottom - (rect).top) -#endif - -#ifndef MMSYSERR_NOERROR -# define MMSYSERR_NOERROR (0) -#endif - -#ifndef TIMERR_NOERROR -# define TIMERR_NOERROR (0) -#endif - -#ifndef WS_EX_NOREDIRECTIONBITMAP -# define WS_EX_NOREDIRECTIONBITMAP (0x00200000L) -#endif - -#ifndef USER_DEFAULT_SCREEN_DPI -# define USER_DEFAULT_SCREEN_DPI (96) -#endif - -DECLARE_HANDLE(_DPI_AWARENESS_CONTEXT); - -#ifndef _DPI_AWARENESS_CONTEXT_UNAWARE -# define _DPI_AWARENESS_CONTEXT_UNAWARE (reinterpret_cast<_DPI_AWARENESS_CONTEXT>(-1)) -#endif - -#ifndef _DPI_AWARENESS_CONTEXT_SYSTEM_AWARE -# define _DPI_AWARENESS_CONTEXT_SYSTEM_AWARE (reinterpret_cast<_DPI_AWARENESS_CONTEXT>(-2)) -#endif - -#ifndef _DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE -# define _DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE (reinterpret_cast<_DPI_AWARENESS_CONTEXT>(-3)) -#endif - -#ifndef _DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 -# define _DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 (reinterpret_cast<_DPI_AWARENESS_CONTEXT>(-4)) -#endif - -#ifndef _DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED -# define _DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED (reinterpret_cast<_DPI_AWARENESS_CONTEXT>(-5)) -#endif - -#ifndef HKEY_CLASSES_ROOT -# define HKEY_CLASSES_ROOT (reinterpret_cast(static_cast(static_cast(0x80000000)))) -#endif - -#ifndef HKEY_CURRENT_USER -# define HKEY_CURRENT_USER (reinterpret_cast(static_cast(static_cast(0x80000001)))) -#endif - -#ifndef HKEY_LOCAL_MACHINE -# define HKEY_LOCAL_MACHINE (reinterpret_cast(static_cast(static_cast(0x80000002)))) -#endif - -#ifndef HKEY_USERS -# define HKEY_USERS (reinterpret_cast(static_cast(static_cast(0x80000003)))) -#endif - -#ifndef HKEY_PERFORMANCE_DATA -# define HKEY_PERFORMANCE_DATA (reinterpret_cast(static_cast(static_cast(0x80000004)))) -#endif - -#ifndef HKEY_CURRENT_CONFIG -# define HKEY_CURRENT_CONFIG (reinterpret_cast(static_cast(static_cast(0x80000005)))) -#endif - -#ifndef HKEY_DYN_DATA -# define HKEY_DYN_DATA (reinterpret_cast(static_cast(static_cast(0x80000006)))) -#endif - -#ifndef HKEY_CURRENT_USER_LOCAL_SETTINGS -# define HKEY_CURRENT_USER_LOCAL_SETTINGS (reinterpret_cast(static_cast(static_cast(0x80000007)))) -#endif - -#ifndef HKEY_PERFORMANCE_TEXT -# define HKEY_PERFORMANCE_TEXT (reinterpret_cast(static_cast(static_cast(0x80000050)))) -#endif - -#ifndef HKEY_PERFORMANCE_NLSTEXT -# define HKEY_PERFORMANCE_NLSTEXT (reinterpret_cast(static_cast(static_cast(0x80000060)))) -#endif - -#ifndef _STATUS_SUCCESS -# define _STATUS_SUCCESS (static_cast<_NTSTATUS>(0x00000000L)) -#endif - -#ifndef WTNCA_NODRAWCAPTION -# define WTNCA_NODRAWCAPTION (0x00000001) // don't draw the window caption -#endif - -#ifndef WTNCA_NODRAWICON -# define WTNCA_NODRAWICON (0x00000002) // don't draw the system icon -#endif - -#ifndef WTNCA_NOSYSMENU -# define WTNCA_NOSYSMENU (0x00000004) // don't expose the system menu icon functionality -#endif - -#ifndef WTNCA_NOMIRRORHELP -# define WTNCA_NOMIRRORHELP (0x00000008) // don't mirror the question mark, even in RTL layout -#endif - -#ifndef WTNCA_VALIDBITS -# define WTNCA_VALIDBITS (WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON | WTNCA_NOSYSMENU | WTNCA_NOMIRRORHELP) -#endif - -#ifndef EXTERN_C -# define EXTERN_C extern "C" -#endif - -#ifndef EXTERN_C_START -# define EXTERN_C_START EXTERN_C { -#endif - -#ifndef EXTERN_C_END -# define EXTERN_C_END } -#endif - -using _NTSTATUS = LONG; - -using _MMRESULT = UINT; -using _TIMECAPS = struct _TIMECAPS -{ - UINT wPeriodMin; // minimum period supported - UINT wPeriodMax; // maximum period supported -}; -using _PTIMECAPS = _TIMECAPS *; - -using _PROCESS_DPI_AWARENESS = enum _PROCESS_DPI_AWARENESS -{ - _PROCESS_DPI_UNAWARE = 0, - _PROCESS_SYSTEM_DPI_AWARE = 1, - _PROCESS_PER_MONITOR_DPI_AWARE = 2, - _PROCESS_PER_MONITOR_V2_DPI_AWARE = 3, - _PROCESS_DPI_UNAWARE_GDISCALED = 4 -}; - -using _MONITOR_DPI_TYPE = enum _MONITOR_DPI_TYPE -{ - _MDT_EFFECTIVE_DPI = 0, - _MDT_ANGULAR_DPI = 1, - _MDT_RAW_DPI = 2, - _MDT_DEFAULT = _MDT_EFFECTIVE_DPI -}; - -using _DEVICE_SCALE_FACTOR = enum _DEVICE_SCALE_FACTOR -{ - _DEVICE_SCALE_FACTOR_INVALID = 0, - _SCALE_100_PERCENT = 100, - _SCALE_120_PERCENT = 120, - _SCALE_125_PERCENT = 125, - _SCALE_140_PERCENT = 140, - _SCALE_150_PERCENT = 150, - _SCALE_160_PERCENT = 160, - _SCALE_175_PERCENT = 175, - _SCALE_180_PERCENT = 180, - _SCALE_200_PERCENT = 200, - _SCALE_225_PERCENT = 225, - _SCALE_250_PERCENT = 250, - _SCALE_300_PERCENT = 300, - _SCALE_350_PERCENT = 350, - _SCALE_400_PERCENT = 400, - _SCALE_450_PERCENT = 450, - _SCALE_500_PERCENT = 500 -}; - -using _DPI_AWARENESS = enum _DPI_AWARENESS -{ - _DPI_AWARENESS_INVALID = -1, - _DPI_AWARENESS_UNAWARE = 0, - _DPI_AWARENESS_SYSTEM_AWARE = 1, - _DPI_AWARENESS_PER_MONITOR_AWARE = 2, - _DPI_AWARENESS_PER_MONITOR_V2_AWARE = 3, - _DPI_AWARENESS_UNAWARE_GDISCALED = 4 -}; - -using _DWMWINDOWATTRIBUTE = enum _DWMWINDOWATTRIBUTE -{ - _DWMWA_USE_HOSTBACKDROPBRUSH = 17, // [set] BOOL, Allows the use of host backdrop brushes for the window. - _DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19, // Undocumented, the same with DWMWA_USE_IMMERSIVE_DARK_MODE, but available on systems before Win10 20H1. - _DWMWA_USE_IMMERSIVE_DARK_MODE = 20, // [set] BOOL, Allows a window to either use the accent color, or dark, according to the user Color Mode preferences. - _DWMWA_WINDOW_CORNER_PREFERENCE = 33, // [set] WINDOW_CORNER_PREFERENCE, Controls the policy that rounds top-level window corners - _DWMWA_VISIBLE_FRAME_BORDER_THICKNESS = 37, // [get] UINT, width of the visible border around a thick frame window - _DWMWA_SYSTEMBACKDROP_TYPE = 38, // [get, set] SYSTEMBACKDROP_TYPE, Controls the system-drawn backdrop material of a window, including behind the non-client area. - _DWMWA_MICA_EFFECT = 1029 // Undocumented, use this value to enable Mica material on Win11 21H2. You should use DWMWA_SYSTEMBACKDROP_TYPE instead on Win11 22H2 and newer. -}; - -using _DWM_WINDOW_CORNER_PREFERENCE = enum _DWM_WINDOW_CORNER_PREFERENCE -{ - _DWMWCP_DEFAULT = 0, // Let the system decide whether or not to round window corners - _DWMWCP_DONOTROUND = 1, // Never round window corners - _DWMWCP_ROUND = 2, // Round the corners if appropriate - _DWMWCP_ROUNDSMALL = 3 // Round the corners if appropriate, with a small radius -}; - -using _DWM_SYSTEMBACKDROP_TYPE = enum _DWM_SYSTEMBACKDROP_TYPE -{ - _DWMSBT_AUTO = 0, // [Default] Let DWM automatically decide the system-drawn backdrop for this window. - _DWMSBT_NONE = 1, // Do not draw any system backdrop. - _DWMSBT_MAINWINDOW = 2, /* Mica */ // Draw the backdrop material effect corresponding to a long-lived window. - _DWMSBT_TRANSIENTWINDOW = 3, /* Acrylic */ // Draw the backdrop material effect corresponding to a transient window. - _DWMSBT_TABBEDWINDOW = 4 /* Mica Alt */ // Draw the backdrop material effect corresponding to a window with a tabbed title bar. -}; - -using WINDOWCOMPOSITIONATTRIB = enum WINDOWCOMPOSITIONATTRIB -{ - WCA_UNDEFINED = 0, - WCA_NCRENDERING_ENABLED = 1, - WCA_NCRENDERING_POLICY = 2, - WCA_TRANSITIONS_FORCEDISABLED = 3, - WCA_ALLOW_NCPAINT = 4, - WCA_CAPTION_BUTTON_BOUNDS = 5, - WCA_NONCLIENT_RTL_LAYOUT = 6, - WCA_FORCE_ICONIC_REPRESENTATION = 7, - WCA_EXTENDED_FRAME_BOUNDS = 8, - WCA_HAS_ICONIC_BITMAP = 9, - WCA_THEME_ATTRIBUTES = 10, - WCA_NCRENDERING_EXILED = 11, - WCA_NCADORNMENTINFO = 12, - WCA_EXCLUDED_FROM_LIVEPREVIEW = 13, - WCA_VIDEO_OVERLAY_ACTIVE = 14, - WCA_FORCE_ACTIVEWINDOW_APPEARANCE = 15, - WCA_DISALLOW_PEEK = 16, - WCA_CLOAK = 17, - WCA_CLOAKED = 18, - WCA_ACCENT_POLICY = 19, - WCA_FREEZE_REPRESENTATION = 20, - WCA_EVER_UNCLOAKED = 21, - WCA_VISUAL_OWNER = 22, - WCA_HOLOGRAPHIC = 23, - WCA_EXCLUDED_FROM_DDA = 24, - WCA_PASSIVEUPDATEMODE = 25, - WCA_USEDARKMODECOLORS = 26, - WCA_CORNER_STYLE = 27, - WCA_PART_COLOR = 28, - WCA_DISABLE_MOVESIZE_FEEDBACK = 29, - WCA_LAST = 30 -}; - -using ACCENT_STATE = enum ACCENT_STATE -{ - ACCENT_DISABLED = 0, - ACCENT_ENABLE_GRADIENT = 1, - ACCENT_ENABLE_TRANSPARENTGRADIENT = 2, - ACCENT_ENABLE_BLURBEHIND = 3, // Traditional DWM blur - ACCENT_ENABLE_ACRYLICBLURBEHIND = 4, // RS4 1803 - ACCENT_ENABLE_HOST_BACKDROP = 5, // RS5 1809 - ACCENT_INVALID_STATE = 6 // Using this value will remove the window background -}; - -using ACCENT_FLAG = enum ACCENT_FLAG -{ - ACCENT_NONE = 0, - ACCENT_ENABLE_ACRYLIC = 1, - ACCENT_ENABLE_ACRYLIC_WITH_LUMINOSITY = 482 -}; - -using ACCENT_POLICY = struct ACCENT_POLICY -{ - DWORD dwAccentState; - DWORD dwAccentFlags; - DWORD dwGradientColor; // #AABBGGRR - DWORD dwAnimationId; -}; -using PACCENT_POLICY = ACCENT_POLICY *; - -using WINDOWCOMPOSITIONATTRIBDATA = struct WINDOWCOMPOSITIONATTRIBDATA -{ - WINDOWCOMPOSITIONATTRIB Attrib; - PVOID pvData; - SIZE_T cbData; -}; -using PWINDOWCOMPOSITIONATTRIBDATA = WINDOWCOMPOSITIONATTRIBDATA *; - -using _WINDOWTHEMEATTRIBUTETYPE = enum _WINDOWTHEMEATTRIBUTETYPE -{ - _WTA_NONCLIENT = 1 -}; - -using WTA_OPTIONS2 = struct WTA_OPTIONS2 -{ - DWORD dwFlags; // Values for each style option specified in the bitmask. - DWORD dwMask; // Bitmask for flags that are changing. -}; -using PWTA_OPTIONS2 = WTA_OPTIONS2 *; - -using IMMERSIVE_HC_CACHE_MODE = enum IMMERSIVE_HC_CACHE_MODE -{ - IHCM_USE_CACHED_VALUE = 0, - IHCM_REFRESH = 1 -}; - -using PREFERRED_APP_MODE = enum PREFERRED_APP_MODE -{ - PAM_DEFAULT = 0, // Default behavior on systems before Win10 1809. It indicates the application doesn't support dark mode at all. - PAM_AUTO = 1, // Available since Win10 1809, let system decide whether to enable dark mode or not. - PAM_DARK = 2, // Available since Win10 1903, force dark mode regardless of the system theme. - PAM_LIGHT = 3, // Available since Win10 1903, force light mode regardless of the system theme. - PAM_MAX = 4 -}; - -using GetWindowCompositionAttributePtr = BOOL(WINAPI *)(HWND, PWINDOWCOMPOSITIONATTRIBDATA); -using SetWindowCompositionAttributePtr = BOOL(WINAPI *)(HWND, PWINDOWCOMPOSITIONATTRIBDATA); -// Win10 1809 (10.0.17763) -using ShouldAppsUseDarkModePtr = BOOL(WINAPI *)(VOID); // Ordinal 132 -using AllowDarkModeForWindowPtr = BOOL(WINAPI *)(HWND, BOOL); // Ordinal 133 -using AllowDarkModeForAppPtr = BOOL(WINAPI *)(BOOL); // Ordinal 135 -using FlushMenuThemesPtr = VOID(WINAPI *)(VOID); // Ordinal 136 -using RefreshImmersiveColorPolicyStatePtr = VOID(WINAPI *)(VOID); // Ordinal 104 -using IsDarkModeAllowedForWindowPtr = BOOL(WINAPI *)(HWND); // Ordinal 137 -using GetIsImmersiveColorUsingHighContrastPtr = BOOL(WINAPI *)(IMMERSIVE_HC_CACHE_MODE); // Ordinal 106 -using OpenNcThemeDataPtr = HTHEME(WINAPI *)(HWND, LPCWSTR); // Ordinal 49 -// Win10 1903 (10.0.18362) -using ShouldSystemUseDarkModePtr = BOOL(WINAPI *)(VOID); // Ordinal 138 -using SetPreferredAppModePtr = PREFERRED_APP_MODE(WINAPI *)(PREFERRED_APP_MODE); // Ordinal 135 -using IsDarkModeAllowedForAppPtr = BOOL(WINAPI *)(VOID); // Ordinal 139 - -EXTERN_C_START - -/////////////////////////////////////////////// -// Function prototypes - -_MMRESULT WINAPI -_timeGetDevCaps( - _PTIMECAPS ptc, - UINT cbtc -); - -_MMRESULT WINAPI -_timeBeginPeriod( - UINT uPeriod -); - -_MMRESULT WINAPI -_timeEndPeriod( - UINT uPeriod -); - -HRESULT WINAPI -_SetProcessDpiAwareness( - _PROCESS_DPI_AWARENESS value -); - -HRESULT WINAPI -_GetProcessDpiAwareness( - HANDLE hProcess, - _PROCESS_DPI_AWARENESS *value -); - -HRESULT WINAPI -_GetDpiForMonitor( - HMONITOR hMonitor, - _MONITOR_DPI_TYPE dpiType, - UINT *dpiX, - UINT *dpiY -); - -int WINAPI -_GetSystemMetricsForDpi( - int nIndex, - UINT dpi -); - -UINT WINAPI -_GetWindowDPI( - HWND hWnd -); - -UINT WINAPI -_GetDpiForWindow( - HWND hWnd -); - -UINT WINAPI -_GetDpiForSystem( - VOID -); - -UINT WINAPI -_GetSystemDpiForProcess( - HANDLE hProcess -); - -BOOL WINAPI -_SetProcessDpiAwarenessContext( - _DPI_AWARENESS_CONTEXT value -); - -BOOL WINAPI -_SetProcessDPIAware( - VOID -); - -HRESULT WINAPI -_GetScaleFactorForMonitor( - HMONITOR hMon, - _DEVICE_SCALE_FACTOR *pScale -); - -BOOL WINAPI -_EnableNonClientDpiScaling( - HWND hWnd -); - -_DPI_AWARENESS_CONTEXT WINAPI -_GetThreadDpiAwarenessContext( - VOID -); - -_DPI_AWARENESS_CONTEXT WINAPI -_GetWindowDpiAwarenessContext( - HWND hWnd -); - -_DPI_AWARENESS WINAPI -_GetAwarenessFromDpiAwarenessContext( - _DPI_AWARENESS_CONTEXT value -); - -_DPI_AWARENESS_CONTEXT WINAPI -_GetDpiAwarenessContextForProcess( - HANDLE hProcess -); - -BOOL WINAPI -_AreDpiAwarenessContextsEqual( - _DPI_AWARENESS_CONTEXT dpiContextA, - _DPI_AWARENESS_CONTEXT dpiContextB -); - -BOOL WINAPI -_EnableChildWindowDpiMessage( - HWND hWnd, - BOOL fEnable -); - -BOOL WINAPI -_EnablePerMonitorDialogScaling( - VOID -); - -int WINAPI -_GetDpiMetrics( - int nIndex, - UINT dpi -); - -BOOL WINAPI -_AdjustWindowRectExForDpi( - LPRECT lpRect, - DWORD dwStyle, - BOOL bMenu, - DWORD dwExStyle, - UINT dpi -); - -/////////////////////////////////////////////// -// API thunks - -FRAMELESSHELPER_CORE_API BOOL WINAPI -_GetWindowCompositionAttribute( - const HWND hWnd, - PWINDOWCOMPOSITIONATTRIBDATA pvData -); - -FRAMELESSHELPER_CORE_API BOOL WINAPI -_SetWindowCompositionAttribute( - const HWND hWnd, - PWINDOWCOMPOSITIONATTRIBDATA pvData -); - -FRAMELESSHELPER_CORE_API HRESULT WINAPI -_SetWindowThemeAttribute( - const HWND hWnd, - const _WINDOWTHEMEATTRIBUTETYPE attrib, - PVOID pvData, - const DWORD cbData -); - -FRAMELESSHELPER_CORE_API HRESULT WINAPI -_SetWindowThemeNonClientAttributes( - const HWND hWnd, - const DWORD dwMask, - const DWORD dwAttributes -); - -FRAMELESSHELPER_CORE_API BOOL WINAPI -_ShouldAppsUseDarkMode( - VOID -); - -FRAMELESSHELPER_CORE_API BOOL WINAPI -_AllowDarkModeForWindow( - const HWND hWnd, - const BOOL bAllow -); - -FRAMELESSHELPER_CORE_API BOOL WINAPI -_AllowDarkModeForApp( - const BOOL bAllow -); - -FRAMELESSHELPER_CORE_API VOID WINAPI -_FlushMenuThemes( - VOID -); - -FRAMELESSHELPER_CORE_API VOID WINAPI -_RefreshImmersiveColorPolicyState( - VOID -); - -FRAMELESSHELPER_CORE_API BOOL WINAPI -_IsDarkModeAllowedForWindow( - const HWND hWnd -); - -FRAMELESSHELPER_CORE_API BOOL WINAPI -_GetIsImmersiveColorUsingHighContrast( - const IMMERSIVE_HC_CACHE_MODE mode -); - -FRAMELESSHELPER_CORE_API HTHEME WINAPI -_OpenNcThemeData( - const HWND hWnd, - LPCWSTR pszClassList -); - -FRAMELESSHELPER_CORE_API BOOL WINAPI -_ShouldSystemUseDarkMode( - VOID -); - -FRAMELESSHELPER_CORE_API PREFERRED_APP_MODE WINAPI -_SetPreferredAppMode( - const PREFERRED_APP_MODE mode -); - -FRAMELESSHELPER_CORE_API BOOL WINAPI -_IsDarkModeAllowedForApp( - VOID -); - -FRAMELESSHELPER_CORE_API BOOL WINAPI -_EnableChildWindowDpiMessage2( - const HWND hWnd, - const BOOL fEnable -); - -FRAMELESSHELPER_CORE_API BOOL WINAPI -_EnablePerMonitorDialogScaling2( - VOID -); - -FRAMELESSHELPER_CORE_API UINT WINAPI -_GetDpiForWindow2( - const HWND hWnd -); - -FRAMELESSHELPER_CORE_API int WINAPI -_GetSystemMetricsForDpi2( - const int nIndex, - const UINT dpi -); - -FRAMELESSHELPER_CORE_API BOOL WINAPI -_AdjustWindowRectExForDpi2( - LPRECT lpRect, - const DWORD dwStyle, - const BOOL bMenu, - const DWORD dwExStyle, - const UINT dpi -); - -EXTERN_C_END - -[[maybe_unused]] inline constexpr const unsigned char kAutoHideTaskBarThickness = 2; // The thickness of an auto-hide taskbar in pixels. -[[maybe_unused]] inline constexpr const wchar_t kDwmRegistryKey[] = LR"(Software\Microsoft\Windows\DWM)"; -[[maybe_unused]] inline constexpr const wchar_t kPersonalizeRegistryKey[] = LR"(Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)"; -[[maybe_unused]] inline constexpr const wchar_t kThemeSettingChangeEventName[] = L"ImmersiveColorSet"; -[[maybe_unused]] inline constexpr const wchar_t kDwmColorKeyName[] = L"ColorPrevalence"; -[[maybe_unused]] inline constexpr const wchar_t kSystemDarkThemeResourceName[] = L"DarkMode_Explorer"; -[[maybe_unused]] inline constexpr const wchar_t kSystemLightThemeResourceName[] = L"Explorer"; -[[maybe_unused]] inline constexpr const wchar_t kDesktopRegistryKey[] = LR"(Control Panel\Desktop)"; -[[maybe_unused]] inline constexpr const wchar_t kDarkModePropertyName[] = L"UseImmersiveDarkModeColors"; - -[[maybe_unused]] [[nodiscard]] inline constexpr bool operator==(const POINT &lhs, const POINT &rhs) noexcept -{ - return ((lhs.x == rhs.x) && (lhs.y == rhs.y)); -} - -[[maybe_unused]] [[nodiscard]] inline constexpr bool operator!=(const POINT &lhs, const POINT &rhs) noexcept -{ - return !operator==(lhs, rhs); -} - -[[maybe_unused]] [[nodiscard]] inline constexpr bool operator==(const SIZE &lhs, const SIZE &rhs) noexcept -{ - return ((lhs.cx == rhs.cx) && (lhs.cy == rhs.cy)); -} - -[[maybe_unused]] [[nodiscard]] inline constexpr bool operator!=(const SIZE &lhs, const SIZE &rhs) noexcept -{ - return !operator==(lhs, rhs); -} - -[[maybe_unused]] [[nodiscard]] inline constexpr bool operator>(const SIZE &lhs, const SIZE &rhs) noexcept -{ - return ((lhs.cx * lhs.cy) > (rhs.cx * rhs.cy)); -} - -[[maybe_unused]] [[nodiscard]] inline constexpr bool operator>=(const SIZE &lhs, const SIZE &rhs) noexcept -{ - return (operator>(lhs, rhs) || operator==(lhs, rhs)); -} - -[[maybe_unused]] [[nodiscard]] inline constexpr bool operator<(const SIZE &lhs, const SIZE &rhs) noexcept -{ - return (operator!=(lhs, rhs) && !operator>(lhs, rhs)); -} - -[[maybe_unused]] [[nodiscard]] inline constexpr bool operator<=(const SIZE &lhs, const SIZE &rhs) noexcept -{ - return (operator<(lhs, rhs) || operator==(lhs, rhs)); -} - -[[maybe_unused]] [[nodiscard]] inline constexpr bool operator==(const RECT &lhs, const RECT &rhs) noexcept -{ - return ((lhs.left == rhs.left) && (lhs.top == rhs.top) && (lhs.right == rhs.right) && (lhs.bottom == rhs.bottom)); -} - -[[maybe_unused]] [[nodiscard]] inline constexpr bool operator!=(const RECT &lhs, const RECT &rhs) noexcept -{ - return !operator==(lhs, rhs); -} - -[[nodiscard]] inline constexpr QPoint point2qpoint(const POINT &point) -{ - return QPoint{ int(point.x), int(point.y) }; -} - -[[nodiscard]] inline constexpr POINT qpoint2point(const QPoint &point) -{ - return POINT{ LONG(point.x()), LONG(point.y()) }; -} - -[[nodiscard]] inline constexpr QSize size2qsize(const SIZE &size) -{ - return QSize{ int(size.cx), int(size.cy) }; -} - -[[nodiscard]] inline constexpr SIZE qsize2size(const QSize &size) -{ - return SIZE{ LONG(size.width()), LONG(size.height()) }; -} - -[[nodiscard]] inline constexpr QRect rect2qrect(const RECT &rect) -{ - return QRect{ QPoint{ int(rect.left), int(rect.top) }, QSize{ int(RECT_WIDTH(rect)), int(RECT_HEIGHT(rect)) } }; -} - -[[nodiscard]] inline constexpr RECT qrect2rect(const QRect &qrect) -{ - return RECT{ LONG(qrect.left()), LONG(qrect.top()), LONG(qrect.right()), LONG(qrect.bottom()) }; -} - -[[nodiscard]] inline /*constexpr*/ QString hwnd2str(const WId windowId) -{ - // NULL handle is allowed here. - return FRAMELESSHELPER_STRING_LITERAL("0x") + QString::number(windowId, 16).toUpper().rightJustified(8, u'0'); -} - -[[nodiscard]] inline /*constexpr*/ QString hwnd2str(const HWND hwnd) -{ - // NULL handle is allowed here. - return hwnd2str(reinterpret_cast(hwnd)); -} diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/framelesshelpercore_global.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/framelesshelpercore_global.h deleted file mode 100644 index bcd815aa..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/framelesshelpercore_global.h +++ /dev/null @@ -1,671 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include "framelesshelper.config" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QEvent; -class QEnterEvent; -QT_END_NAMESPACE - -/* - The FRAMELESSHELPER_CONFIG macro implements a safe compile time check for features of FramelessHelper. - Features can be in three states: - 0 or undefined: This will lead to a compile error when testing for it - -1: The feature is not available - 1: The feature is available -*/ -#ifndef FRAMELESSHELPER_CONFIG -# define FRAMELESSHELPER_CONFIG(feature) ((1 / FRAMELESSHELPER_FEATURE_##feature) == 1) -#endif - -#ifndef FRAMELESSHELPER_CORE_API -# if FRAMELESSHELPER_CONFIG(static_build) -# define FRAMELESSHELPER_CORE_API -# else // !FRAMELESSHELPER_CORE_STATIC -# ifdef FRAMELESSHELPER_CORE_LIBRARY -# define FRAMELESSHELPER_CORE_API Q_DECL_EXPORT -# else // !FRAMELESSHELPER_CORE_LIBRARY -# define FRAMELESSHELPER_CORE_API Q_DECL_IMPORT -# endif // FRAMELESSHELPER_CORE_LIBRARY -# endif // FRAMELESSHELPER_CORE_STATIC -#endif // FRAMELESSHELPER_CORE_API - -#if (defined(Q_OS_WIN) && !defined(Q_OS_WINDOWS)) -# define Q_OS_WINDOWS // Since 5.14 -#endif - -#ifndef Q_DISABLE_MOVE -# define Q_DISABLE_MOVE(Class) \ - Class(Class &&) = delete; \ - Class &operator=(Class &&) = delete; -#endif - -#ifndef Q_DISABLE_COPY_MOVE // Since 5.13 -# define Q_DISABLE_COPY_MOVE(Class) \ - Q_DISABLE_COPY(Class) \ - Q_DISABLE_MOVE(Class) -#endif - -#if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0)) - using QStringView = const QString &; -#endif - -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) -# define qExchange(a, b) std::exchange(a, b) -#endif - -#ifndef Q_NAMESPACE_EXPORT // Since 5.14 -# define Q_NAMESPACE_EXPORT(...) Q_NAMESPACE -#endif - -// QColor can't be constexpr before 5.14 -#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) -# define Q_COLOR_CONSTEXPR constexpr -#else -# define Q_COLOR_CONSTEXPR -#endif - -// MOC can't handle C++ attributes before 5.15. -#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) -# define Q_NODISCARD [[nodiscard]] -# define Q_MAYBE_UNUSED [[maybe_unused]] -#else -# define Q_NODISCARD -# define Q_MAYBE_UNUSED -#endif - -#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - using QT_NATIVE_EVENT_RESULT_TYPE = qintptr; - using QT_ENTER_EVENT_TYPE = QEnterEvent; -#else - using QT_NATIVE_EVENT_RESULT_TYPE = long; - using QT_ENTER_EVENT_TYPE = QEvent; -#endif - -// QLatin1StringView can't be constexpr until Qt6? -#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)) -# define Q_STRING_CONSTEXPR constexpr -#else -# define Q_STRING_CONSTEXPR -#endif - -#ifndef QUtf8String -# define QUtf8String(str) QString::fromUtf8(str) -#endif - -#ifndef Q_GADGET_EXPORT // Since 6.3 -# define Q_GADGET_EXPORT(...) Q_GADGET -#endif - -#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)) - using namespace Qt::Literals::StringLiterals; -#endif - -#ifndef FRAMELESSHELPER_BYTEARRAY_LITERAL -# if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)) -# define FRAMELESSHELPER_BYTEARRAY_LITERAL(ba) ba##_ba -# elif (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)) -# define FRAMELESSHELPER_BYTEARRAY_LITERAL(ba) ba##_qba -# else -# define FRAMELESSHELPER_BYTEARRAY_LITERAL(ba) QByteArrayLiteral(ba) -# endif -#endif - -#ifndef FRAMELESSHELPER_STRING_LITERAL -# if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)) -# define FRAMELESSHELPER_STRING_LITERAL(str) u##str##_s -# elif (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)) -# define FRAMELESSHELPER_STRING_LITERAL(str) u##str##_qs -# else -# define FRAMELESSHELPER_STRING_LITERAL(str) QStringLiteral(str) -# endif -#endif - -#ifndef FRAMELESSHELPER_BYTEARRAY -# define FRAMELESSHELPER_BYTEARRAY(ba) ba -#endif - -#ifndef FRAMELESSHELPER_STRING -# if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)) -# define FRAMELESSHELPER_STRING(str) str##_L1 -# else -# define FRAMELESSHELPER_STRING(str) QLatin1String(str) -# endif -#endif - -#ifndef FRAMELESSHELPER_STRING_TYPE -# if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)) -# define FRAMELESSHELPER_STRING_TYPE QLatin1StringView -# else -# define FRAMELESSHELPER_STRING_TYPE QLatin1String -# endif -#endif - -#ifndef Q_UNREACHABLE_RETURN // Since 6.5 -# define Q_UNREACHABLE_RETURN(...) \ - do { \ - Q_UNREACHABLE(); \ - return __VA_ARGS__; \ - } while (false) -#endif - -#ifndef FRAMELESSHELPER_QUOTE -# define FRAMELESSHELPER_QUOTE(x) #x -#endif - -#ifndef FRAMELESSHELPER_QUOTE2 -# define FRAMELESSHELPER_QUOTE2(x) FRAMELESSHELPER_QUOTE(x) -#endif - -#ifndef FRAMELESSHELPER_CONCAT -# define FRAMELESSHELPER_CONCAT(a, b) a##b -#endif - -#ifndef FRAMELESSHELPER_CONCAT2 -# define FRAMELESSHELPER_CONCAT2(a, b) FRAMELESSHELPER_CONCAT(a, b) -#endif - -#ifndef FRAMELESSHELPER_REQUIRE_CONFIG -# define FRAMELESSHELPER_REQUIRE_CONFIG(feature) static_assert(FRAMELESSHELPER_FEATURE_##feature == 1, "Required feature " #feature " for file " __FILE__ " is not available!"); -#endif - -#ifndef FRAMELESSHELPER_CLASS_INFO -# define FRAMELESSHELPER_CLASS_INFO Q_CLASSINFO("__FRAMELESSHELPER__", FRAMELESSHELPER_QUOTE2(__FRAMELESSHELPER__)) -#endif - -#ifndef FRAMELESSHELPER_BYTEARRAY_CONSTANT2 -# define FRAMELESSHELPER_BYTEARRAY_CONSTANT2(name, ba) \ - [[maybe_unused]] static constexpr const auto k##name = FRAMELESSHELPER_BYTEARRAY(ba); -#endif - -#ifndef FRAMELESSHELPER_STRING_CONSTANT2 -# define FRAMELESSHELPER_STRING_CONSTANT2(name, str) \ - [[maybe_unused]] static Q_STRING_CONSTEXPR const auto k##name = FRAMELESSHELPER_STRING(str); -#endif - -#ifndef FRAMELESSHELPER_BYTEARRAY_CONSTANT -# define FRAMELESSHELPER_BYTEARRAY_CONSTANT(ba) FRAMELESSHELPER_BYTEARRAY_CONSTANT2(ba, #ba) -#endif - -#ifndef FRAMELESSHELPER_STRING_CONSTANT -# define FRAMELESSHELPER_STRING_CONSTANT(str) FRAMELESSHELPER_STRING_CONSTANT2(str, #str) -#endif - -#ifndef FRAMELESSHELPER_NAMESPACE -# define FRAMELESSHELPER_NAMESPACE wangwenx190::FramelessHelper -#endif - -#ifndef FRAMELESSHELPER_BEGIN_NAMESPACE -# define FRAMELESSHELPER_BEGIN_NAMESPACE namespace FRAMELESSHELPER_NAMESPACE { -#endif - -#ifndef FRAMELESSHELPER_END_NAMESPACE -# define FRAMELESSHELPER_END_NAMESPACE } -#endif - -#ifndef FRAMELESSHELPER_USE_NAMESPACE -# define FRAMELESSHELPER_USE_NAMESPACE using namespace FRAMELESSHELPER_NAMESPACE; -#endif - -#ifndef FRAMELESSHELPER_PREPEND_NAMESPACE -# define FRAMELESSHELPER_PREPEND_NAMESPACE(X) ::FRAMELESSHELPER_NAMESPACE::X -#endif - -#ifndef FRAMELESSHELPER_MAKE_VERSION -# define FRAMELESSHELPER_MAKE_VERSION(Major, Minor, Patch) \ - ((((Major) & 0xff) << 24) | (((Minor) & 0xff) << 16) | (((Patch) & 0xff) << 8)) -#endif - -#ifndef FRAMELESSHELPER_EXTRACT_VERSION -# define FRAMELESSHELPER_EXTRACT_VERSION(Version, Major, Minor, Patch) \ - { \ - (Major) = (((Version) & 0xff) >> 24); \ - (Minor) = (((Version) & 0xff) >> 16); \ - (Patch) = (((Version) & 0xff) >> 8); \ - } -#endif - -#ifndef FRAMELESSHELPER_CLASS -# define FRAMELESSHELPER_CLASS(Class) \ - private: \ - Q_DISABLE_COPY(Class) -#endif - -#ifndef FRAMELESSHELPER_CLASS_DPTR -# define FRAMELESSHELPER_CLASS_DPTR(Class) \ - private: \ - Q_DECLARE_PRIVATE(Class) \ - const std::unique_ptr d_ptr; -#endif - -#ifndef FRAMELESSHELPER_CLASS_QPTR -# define FRAMELESSHELPER_CLASS_QPTR(Class) \ - private: \ - Q_DECLARE_PUBLIC(Class) \ - public: \ - Class *q_ptr = nullptr; -#endif - -#ifndef FRAMELESSHELPER_PRIVATE_CLASS_GETTER -# define FRAMELESSHELPER_PRIVATE_CLASS_GETTER(Class) \ - public: \ - Q_NODISCARD static Class##Private *get(Class *q); \ - Q_NODISCARD static const Class##Private *get(const Class *q); -#endif - -#ifndef FRAMELESSHELPER_PRIVATE_CLASS_GETTER_IMPL -# define FRAMELESSHELPER_PRIVATE_CLASS_GETTER_IMPL(Class) \ - Class##Private *Class##Private::get(Class *q) { \ - Q_ASSERT(q); \ - return (q ? q->d_func() : nullptr); \ - } \ - const Class##Private *Class##Private::get(const Class *q) { \ - Q_ASSERT(q); \ - return (q ? q->d_func() : nullptr); \ - } -#endif - -#ifndef FRAMELESSHELPER_PUBLIC_CLASS -# define FRAMELESSHELPER_PUBLIC_CLASS(Class) \ - private: \ - FRAMELESSHELPER_CLASS(Class) \ - FRAMELESSHELPER_CLASS_DPTR(Class) -#endif - -#ifndef FRAMELESSHELPER_PRIVATE_CLASS -# define FRAMELESSHELPER_PRIVATE_CLASS(Class) \ - private: \ - FRAMELESSHELPER_CLASS(Class##Private) \ - FRAMELESSHELPER_CLASS_QPTR(Class) \ - FRAMELESSHELPER_PRIVATE_CLASS_GETTER(Class) -#endif - -#ifndef FRAMELESSHELPER_QT_CLASS -# define FRAMELESSHELPER_QT_CLASS(Class) \ - private: \ - FRAMELESSHELPER_CLASS_INFO \ - FRAMELESSHELPER_CLASS(Class) -#endif - -#ifndef FRAMELESSHELPER_PUBLIC_QT_CLASS -# define FRAMELESSHELPER_PUBLIC_QT_CLASS(Class) \ - private: \ - FRAMELESSHELPER_QT_CLASS(Class) \ - FRAMELESSHELPER_CLASS_DPTR(Class) -#endif - -#ifndef FRAMELESSHELPER_PRIVATE_QT_CLASS -# define FRAMELESSHELPER_PRIVATE_QT_CLASS(Class) \ - private: \ - FRAMELESSHELPER_QT_CLASS(Class##Private) \ - FRAMELESSHELPER_CLASS_QPTR(Class) \ - FRAMELESSHELPER_PRIVATE_CLASS_GETTER(Class) -#endif - -#if FRAMELESSHELPER_CONFIG(bundle_resource) -// Call this function in your main() function if you are using FramelessHelper as a static library, -// it can make sure the resources bundled in the static library are correctly initialized. -// NOTE: This function is intentionally not inside any namespaces. -FRAMELESSHELPER_CORE_API void FramelessHelperCoreInitResource(); -inline void framelesshelpercore_initResource() { FramelessHelperCoreInitResource(); } -#endif // FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#include "framelesshelper.version" - -#ifndef __FRAMELESSHELPER__ -# define __FRAMELESSHELPER__ __FRAMELESSHELPER_VERSION__ -#endif // __FRAMELESSHELPER__ - -namespace Global -{ - -Q_NAMESPACE_EXPORT(FRAMELESSHELPER_CORE_API) - -[[maybe_unused]] inline constexpr const int kDefaultResizeBorderThickness = 8; -[[maybe_unused]] inline constexpr const int kDefaultCaptionHeight = 23; -[[maybe_unused]] inline constexpr const int kDefaultTitleBarHeight = 32; -[[maybe_unused]] inline constexpr const int kDefaultExtendedTitleBarHeight = 48; -[[maybe_unused]] inline constexpr const int kDefaultWindowFrameBorderThickness = 1; -[[maybe_unused]] inline constexpr const int kDefaultTitleBarFontPointSize = 11; -[[maybe_unused]] inline constexpr const int kDefaultTitleBarContentsMargin = 10; -[[maybe_unused]] inline constexpr const int kMacOSChromeButtonAreaWidth = 60; -[[maybe_unused]] inline constexpr const QSize kDefaultWindowIconSize = {16, 16}; -// We have to use "qRound()" here because "std::round()" is not constexpr, yet. -[[maybe_unused]] inline constexpr const QSize kDefaultSystemButtonSize = {qRound(qreal(kDefaultTitleBarHeight) * 1.5), kDefaultTitleBarHeight}; -[[maybe_unused]] inline constexpr const QSize kDefaultSystemButtonIconSize = kDefaultWindowIconSize; -[[maybe_unused]] inline constexpr const QSize kDefaultWindowSize = {160, 160}; // Value taken from Windows QPA. - -#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) -# define kDefaultWhiteColor QColorConstants::White -# define kDefaultBlackColor QColorConstants::Black -# define kDefaultTransparentColor QColorConstants::Transparent -# define kDefaultLightGrayColor QColorConstants::LightGray -# define kDefaultDarkGrayColor QColorConstants::DarkGray -#else // (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) - [[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultWhiteColor = {255, 255, 255}; // #FFFFFF - [[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultBlackColor = {0, 0, 0}; // #000000 - [[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultTransparentColor = {0, 0, 0, 0}; - [[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultLightGrayColor = {211, 211, 211}; // #D3D3D3 - [[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultDarkGrayColor = {169, 169, 169}; // #A9A9A9 -#endif // (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) - -[[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultSystemLightColor = {240, 240, 240}; // #F0F0F0 -[[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultSystemDarkColor = {32, 32, 32}; // #202020 -[[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultFrameBorderActiveColorLight = {110, 110, 110}; // #6E6E6E -[[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultFrameBorderActiveColorDark = {51, 51, 51}; // #333333 -[[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultFrameBorderInactiveColorLight = {167, 167, 167}; // #A7A7A7 -[[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultFrameBorderInactiveColorDark = {61, 61, 62}; // #3D3D3E -[[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultSystemButtonBackgroundColor = {204, 204, 204}; // #CCCCCC -[[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultSystemCloseButtonBackgroundColor = {232, 17, 35}; // #E81123 - -[[maybe_unused]] inline constexpr const char kDontOverrideCursorVar[] = "FRAMELESSHELPER_DONT_OVERRIDE_CURSOR"; -[[maybe_unused]] inline constexpr const char kDontToggleMaximizeVar[] = "FRAMELESSHELPER_DONT_TOGGLE_MAXIMIZE"; -[[maybe_unused]] inline constexpr const char kSysMenuDisableMoveVar[] = "FRAMELESSHELPER_SYSTEM_MENU_DISABLE_MOVE"; -[[maybe_unused]] inline constexpr const char kSysMenuDisableSizeVar[] = "FRAMELESSHELPER_SYSTEM_MENU_DISABLE_SIZE"; -[[maybe_unused]] inline constexpr const char kSysMenuDisableMinimizeVar[] = "FRAMELESSHELPER_SYSTEM_MENU_DISABLE_MINIMIZE"; -[[maybe_unused]] inline constexpr const char kSysMenuDisableMaximizeVar[] = "FRAMELESSHELPER_SYSTEM_MENU_DISABLE_MAXIMIZE"; -[[maybe_unused]] inline constexpr const char kSysMenuDisableRestoreVar[] = "FRAMELESSHELPER_SYSTEM_MENU_DISABLE_RESTORE"; -[[maybe_unused]] inline constexpr const char kSysMenuDisableCloseVar[] = "FRAMELESSHELPER_SYSTEM_MENU_DISABLE_CLOSE"; -[[maybe_unused]] inline constexpr const char kSysMenuRemoveMoveVar[] = "FRAMELESSHELPER_SYSTEM_MENU_REMOVE_MOVE"; -[[maybe_unused]] inline constexpr const char kSysMenuRemoveSizeVar[] = "FRAMELESSHELPER_SYSTEM_MENU_REMOVE_SIZE"; -[[maybe_unused]] inline constexpr const char kSysMenuRemoveMinimizeVar[] = "FRAMELESSHELPER_SYSTEM_MENU_REMOVE_MINIMIZE"; -[[maybe_unused]] inline constexpr const char kSysMenuRemoveMaximizeVar[] = "FRAMELESSHELPER_SYSTEM_MENU_REMOVE_MAXIMIZE"; -[[maybe_unused]] inline constexpr const char kSysMenuRemoveRestoreVar[] = "FRAMELESSHELPER_SYSTEM_MENU_REMOVE_RESTORE"; -[[maybe_unused]] inline constexpr const char kSysMenuRemoveSeparatorVar[] = "FRAMELESSHELPER_SYSTEM_MENU_REMOVE_SEPARATOR"; -[[maybe_unused]] inline constexpr const char kSysMenuRemoveCloseVar[] = "FRAMELESSHELPER_SYSTEM_MENU_REMOVE_CLOSE"; - -enum class Option : quint8 -{ - UseCrossPlatformQtImplementation, - ForceHideWindowFrameBorder, - ForceShowWindowFrameBorder, - DisableWindowsSnapLayout, - WindowUseRoundCorners, - CenterWindowBeforeShow, - EnableBlurBehindWindow, - ForceNonNativeBackgroundBlur, - DisableLazyInitializationForMicaMaterial, - ForceNativeBackgroundBlur, - WindowUseSquareCorners, - Last = WindowUseSquareCorners -}; -Q_ENUM_NS(Option) - -enum class SystemTheme : quint8 -{ - Unknown, - Light, - Dark, - HighContrast -}; -Q_ENUM_NS(SystemTheme) - -enum class SystemButtonType : quint8 -{ - Unknown, - WindowIcon, - Help, - Minimize, - Maximize, - Restore, - Close, - Last = Close -}; -Q_ENUM_NS(SystemButtonType) - -#ifdef Q_OS_WINDOWS -enum class DwmColorizationArea : quint8 -{ - None, - StartMenu_TaskBar_ActionCenter, - TitleBar_WindowBorder, - All -}; -Q_ENUM_NS(DwmColorizationArea) -#endif // Q_OS_WINDOWS - -enum class ButtonState : quint8 -{ - Normal, - Hovered, - Pressed, - Released -}; -Q_ENUM_NS(ButtonState) - -#ifdef Q_OS_WINDOWS -enum class WindowsVersion : quint8 -{ - _2000, - _XP, - _XP_64, - _Vista, - _Vista_SP1, - _Vista_SP2, - _7, - _7_SP1, - _8, - _8_1, - _8_1_Update1, - _10_1507, - _10_1511, - _10_1607, - _10_1703, - _10_1709, - _10_1803, - _10_1809, - _10_1903, - _10_1909, - _10_2004, - _10_20H2, - _10_21H1, - _10_21H2, - _10_22H2, - _11_21H2, - _11_22H2, - - _WS_03 = _XP_64, // Windows Server 2003 - _10 = _10_1507, - _11 = _11_21H2, - - Latest = _11_22H2 -}; -Q_ENUM_NS(WindowsVersion) -#endif // Q_OS_WINDOWS - -enum class BlurMode : quint8 -{ - Disable, // Do not enable blur behind window - Default, // Use platform default blur mode - Windows_Aero, // Windows only, use the traditional DWM blur - Windows_Acrylic, // Windows only, use the Acrylic blur - Windows_Mica, // Windows only, use the Mica material - Windows_MicaAlt // Windows only, use the Mica Alt material -}; -Q_ENUM_NS(BlurMode) - -enum class WallpaperAspectStyle : quint8 -{ - Fill, // Keep aspect ratio to fill, expand/crop if necessary. - Fit, // Keep aspect ratio to fill, but don't expand/crop. - Stretch, // Ignore aspect ratio to fill. - Tile, - Center, - Span // ??? -}; -Q_ENUM_NS(WallpaperAspectStyle) - -#ifdef Q_OS_WINDOWS -enum class RegistryRootKey : quint8 -{ - ClassesRoot, - CurrentUser, - LocalMachine, - Users, - PerformanceData, - CurrentConfig, - DynData, - CurrentUserLocalSettings, - PerformanceText, - PerformanceNlsText -}; -Q_ENUM_NS(RegistryRootKey) -#endif // Q_OS_WINDOWS - -enum class WindowEdge : quint8 -{ - Left = 1 << 0, - Top = 1 << 1, - Right = 1 << 2, - Bottom = 1 << 3 -}; -Q_ENUM_NS(WindowEdge) -Q_DECLARE_FLAGS(WindowEdges, WindowEdge) -Q_FLAG_NS(WindowEdges) -Q_DECLARE_OPERATORS_FOR_FLAGS(WindowEdges) - -#ifdef Q_OS_WINDOWS -enum class DpiAwareness : quint8 -{ - Unknown, - Unaware, - System, - PerMonitor, - PerMonitorVersion2, - Unaware_GdiScaled -}; -Q_ENUM_NS(DpiAwareness) -#endif // Q_OS_WINDOWS - -enum class WindowCornerStyle : quint8 -{ - Default, - Square, - Round -}; -Q_ENUM_NS(WindowCornerStyle) - -struct VersionInfo -{ - struct { - unsigned long num = 0; - const char *str = nullptr; - } version = {}; - struct { - const char *hash = nullptr; - const char *subject = nullptr; - const char *author = nullptr; - const char *datetime = nullptr; - const char *branch = nullptr; - } commit = {}; - struct { - const char *name = nullptr; - const char *version = nullptr; - const char *vendor = nullptr; - } compiler = {}; - struct { - const char *cmake_version = nullptr; - const char *configure_datetime = nullptr; - const char *generator = nullptr; - const char *architecture = nullptr; - bool is_debug = false; - bool is_static = false; - } build = {}; -}; - -struct Dpi -{ - quint32 x = 0; - quint32 y = 0; - - [[nodiscard]] friend constexpr bool operator==(const Dpi &lhs, const Dpi &rhs) noexcept - { - return ((lhs.x == rhs.x) && (lhs.y == rhs.y)); - } - - [[nodiscard]] friend constexpr bool operator!=(const Dpi &lhs, const Dpi &rhs) noexcept - { - return !operator==(lhs, rhs); - } - - [[nodiscard]] friend constexpr bool operator>(const Dpi &lhs, const Dpi &rhs) noexcept - { - return ((lhs.x * lhs.y) > (rhs.x * rhs.y)); - } - - [[nodiscard]] friend constexpr bool operator>=(const Dpi &lhs, const Dpi &rhs) noexcept - { - return (operator>(lhs, rhs) || operator==(lhs, rhs)); - } - - [[nodiscard]] friend constexpr bool operator<(const Dpi &lhs, const Dpi &rhs) noexcept - { - return (operator!=(lhs, rhs) && !operator>(lhs, rhs)); - } - - [[nodiscard]] friend constexpr bool operator<=(const Dpi &lhs, const Dpi &rhs) noexcept - { - return (operator<(lhs, rhs) || operator==(lhs, rhs)); - } -}; - -} // namespace Global - -FRAMELESSHELPER_CORE_API void FramelessHelperCoreInitialize(); -FRAMELESSHELPER_CORE_API void FramelessHelperCoreUninitialize(); -[[nodiscard]] FRAMELESSHELPER_CORE_API Global::VersionInfo FramelessHelperVersion(); -FRAMELESSHELPER_CORE_API void FramelessHelperEnableThemeAware(); -FRAMELESSHELPER_CORE_API void FramelessHelperPrintLogo(); - -namespace FramelessHelper::Core -{ -inline void initialize() { FramelessHelperCoreInitialize(); } -inline void uninitialize() { FramelessHelperCoreUninitialize(); } -[[nodiscard]] inline Global::VersionInfo version() { return FramelessHelperVersion(); } -inline void setApplicationOSThemeAware() { FramelessHelperEnableThemeAware(); } -inline void outputLogo() { FramelessHelperPrintLogo(); } -} // namespace FramelessHelper::Core - -FRAMELESSHELPER_END_NAMESPACE - -#ifndef QT_NO_DEBUG_STREAM -QT_BEGIN_NAMESPACE -FRAMELESSHELPER_CORE_API QDebug operator<<(QDebug, const FRAMELESSHELPER_PREPEND_NAMESPACE(Global)::VersionInfo &); -FRAMELESSHELPER_CORE_API QDebug operator<<(QDebug, const FRAMELESSHELPER_PREPEND_NAMESPACE(Global)::Dpi &); -QT_END_NAMESPACE -#endif // QT_NO_DEBUG_STREAM diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/framelessmanager.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/framelessmanager.h deleted file mode 100644 index a254a423..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/framelessmanager.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FramelessManagerPrivate; -class FRAMELESSHELPER_CORE_API FramelessManager : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_PUBLIC_QT_CLASS(FramelessManager) - Q_PROPERTY(Global::SystemTheme systemTheme READ systemTheme WRITE setOverrideTheme NOTIFY systemThemeChanged FINAL) - Q_PROPERTY(QColor systemAccentColor READ systemAccentColor NOTIFY systemThemeChanged FINAL) - Q_PROPERTY(QString wallpaper READ wallpaper NOTIFY wallpaperChanged FINAL) - Q_PROPERTY(Global::WallpaperAspectStyle wallpaperAspectStyle READ wallpaperAspectStyle NOTIFY wallpaperChanged FINAL) - -public: - Q_NODISCARD static FramelessManager *instance(); - - Q_NODISCARD Global::SystemTheme systemTheme() const; - Q_NODISCARD QColor systemAccentColor() const; - Q_NODISCARD QString wallpaper() const; - Q_NODISCARD Global::WallpaperAspectStyle wallpaperAspectStyle() const; - -public Q_SLOTS: - Q_NODISCARD bool addWindow(const QObject *window, const WId windowId); - Q_NODISCARD bool removeWindow(const QObject *window); - void setOverrideTheme(const Global::SystemTheme theme); - -Q_SIGNALS: - void systemThemeChanged(); - void wallpaperChanged(); - -private: - explicit FramelessManager(QObject *parent = nullptr); - ~FramelessManager() override; -}; - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/micamaterial.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/micamaterial.h deleted file mode 100644 index 5d244931..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/micamaterial.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include - -#if FRAMELESSHELPER_CONFIG(mica_material) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class MicaMaterialPrivate; -class FRAMELESSHELPER_CORE_API MicaMaterial : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_PUBLIC_QT_CLASS(MicaMaterial) - - Q_PROPERTY(QColor tintColor READ tintColor WRITE setTintColor NOTIFY tintColorChanged FINAL) - Q_PROPERTY(qreal tintOpacity READ tintOpacity WRITE setTintOpacity NOTIFY tintOpacityChanged FINAL) - Q_PROPERTY(QColor fallbackColor READ fallbackColor WRITE setFallbackColor NOTIFY fallbackColorChanged FINAL) - Q_PROPERTY(qreal noiseOpacity READ noiseOpacity WRITE setNoiseOpacity NOTIFY noiseOpacityChanged FINAL) - Q_PROPERTY(bool fallbackEnabled READ isFallbackEnabled WRITE setFallbackEnabled NOTIFY fallbackEnabledChanged FINAL) - -public: - explicit MicaMaterial(QObject *parent = nullptr); - ~MicaMaterial() override; - - Q_NODISCARD QColor tintColor() const; - void setTintColor(const QColor &value); - - Q_NODISCARD qreal tintOpacity() const; - void setTintOpacity(const qreal value); - - Q_NODISCARD QColor fallbackColor() const; - void setFallbackColor(const QColor &value); - - Q_NODISCARD qreal noiseOpacity() const; - void setNoiseOpacity(const qreal value); - - Q_NODISCARD bool isFallbackEnabled() const; - void setFallbackEnabled(const bool value); - -public Q_SLOTS: - void paint(QPainter *painter, const QRect &rect, const bool active = true); - - [[deprecated("Use another overload instead.")]] - void paint(QPainter *painter, const QSize &size, const QPoint &pos, const bool active = true) - { - paint(painter, QRect{ pos, size }, active); - } - -Q_SIGNALS: - void tintColorChanged(); - void tintOpacityChanged(); - void fallbackColorChanged(); - void noiseOpacityChanged(); - void fallbackEnabledChanged(); - void shouldRedraw(); -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/chromepalette_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/chromepalette_p.h deleted file mode 100644 index f18cc5b9..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/chromepalette_p.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include - -#if FRAMELESSHELPER_CONFIG(titlebar) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class ChromePalette; -class FRAMELESSHELPER_CORE_API ChromePalettePrivate : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_PRIVATE_QT_CLASS(ChromePalette) - -public: - explicit ChromePalettePrivate(ChromePalette *q); - ~ChromePalettePrivate() override; - - Q_SLOT void refresh(); - - // System-defined ones: - QColor titleBarActiveBackgroundColor_sys = {}; - QColor titleBarInactiveBackgroundColor_sys = {}; - QColor titleBarActiveForegroundColor_sys = {}; - QColor titleBarInactiveForegroundColor_sys = {}; - QColor chromeButtonNormalColor_sys = {}; - QColor chromeButtonHoverColor_sys = {}; - QColor chromeButtonPressColor_sys = {}; - QColor closeButtonNormalColor_sys = {}; - QColor closeButtonHoverColor_sys = {}; - QColor closeButtonPressColor_sys = {}; - // User-defined ones: - std::optional titleBarActiveBackgroundColor = std::nullopt; - std::optional titleBarInactiveBackgroundColor = std::nullopt; - std::optional titleBarActiveForegroundColor = std::nullopt; - std::optional titleBarInactiveForegroundColor = std::nullopt; - std::optional chromeButtonNormalColor = std::nullopt; - std::optional chromeButtonHoverColor = std::nullopt; - std::optional chromeButtonPressColor = std::nullopt; - std::optional closeButtonNormalColor = std::nullopt; - std::optional closeButtonHoverColor = std::nullopt; - std::optional closeButtonPressColor = std::nullopt; -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/framelessconfig_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/framelessconfig_p.h deleted file mode 100644 index 1f330e71..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/framelessconfig_p.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FRAMELESSHELPER_CORE_API FramelessConfig : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_QT_CLASS(FramelessConfig) - -public: - Q_NODISCARD static FramelessConfig *instance(); - - void reload(const bool force = false); - - void set(const Global::Option option, const bool on = true); - Q_NODISCARD bool isSet(const Global::Option option) const; - - static void setLoadFromEnvironmentVariablesDisabled(const bool on = true); - static void setLoadFromConfigurationFileDisabled(const bool on = true); - -private: - explicit FramelessConfig(QObject *parent = nullptr); - ~FramelessConfig() override; -}; - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/framelesshelpercore_global_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/framelesshelpercore_global_p.h deleted file mode 100644 index 26ad76af..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/framelesshelpercore_global_p.h +++ /dev/null @@ -1,184 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QScreen; -QT_END_NAMESPACE - -FRAMELESSHELPER_BEGIN_NAMESPACE - -using GetWindowFlagsCallback = std::function; -using SetWindowFlagsCallback = std::function; -using GetWindowSizeCallback = std::function; -using SetWindowSizeCallback = std::function; -using GetWindowPositionCallback = std::function; -using SetWindowPositionCallback = std::function; -using GetWindowScreenCallback = std::function; -using IsWindowFixedSizeCallback = std::function; -using SetWindowFixedSizeCallback = std::function; -using GetWindowStateCallback = std::function; -using SetWindowStateCallback = std::function; -using GetWindowHandleCallback = std::function; -using WindowToScreenCallback = std::function; -using ScreenToWindowCallback = std::function; -using IsInsideSystemButtonsCallback = std::function; -using IsInsideTitleBarDraggableAreaCallback = std::function; -using GetWindowDevicePixelRatioCallback = std::function; -using SetSystemButtonStateCallback = std::function; -using GetWindowIdCallback = std::function; -using ShouldIgnoreMouseEventsCallback = std::function; -using ShowSystemMenuCallback = std::function; -using SetPropertyCallback = std::function; -using GetPropertyCallback = std::function; -using SetCursorCallback = std::function; -using UnsetCursorCallback = std::function; -using GetWidgetHandleCallback = std::function; -using ForceChildrenRepaintCallback = std::function; -using ResetQtGrabbedControlCallback = std::function; - -struct FRAMELESSHELPER_CORE_API FramelessCallbacks -{ - GetWindowFlagsCallback getWindowFlags = nullptr; - SetWindowFlagsCallback setWindowFlags = nullptr; - GetWindowSizeCallback getWindowSize = nullptr; - SetWindowSizeCallback setWindowSize = nullptr; - GetWindowPositionCallback getWindowPosition = nullptr; - SetWindowPositionCallback setWindowPosition = nullptr; - GetWindowScreenCallback getWindowScreen = nullptr; - IsWindowFixedSizeCallback isWindowFixedSize = nullptr; - SetWindowFixedSizeCallback setWindowFixedSize = nullptr; - GetWindowStateCallback getWindowState = nullptr; - SetWindowStateCallback setWindowState = nullptr; - GetWindowHandleCallback getWindowHandle = nullptr; - WindowToScreenCallback windowToScreen = nullptr; - ScreenToWindowCallback screenToWindow = nullptr; - IsInsideSystemButtonsCallback isInsideSystemButtons = nullptr; - IsInsideTitleBarDraggableAreaCallback isInsideTitleBarDraggableArea = nullptr; - GetWindowDevicePixelRatioCallback getWindowDevicePixelRatio = nullptr; - SetSystemButtonStateCallback setSystemButtonState = nullptr; - GetWindowIdCallback getWindowId = nullptr; - ShouldIgnoreMouseEventsCallback shouldIgnoreMouseEvents = nullptr; - ShowSystemMenuCallback showSystemMenu = nullptr; - SetPropertyCallback setProperty = nullptr; - GetPropertyCallback getProperty = nullptr; - SetCursorCallback setCursor = nullptr; - UnsetCursorCallback unsetCursor = nullptr; - GetWidgetHandleCallback getWidgetHandle = nullptr; - ForceChildrenRepaintCallback forceChildrenRepaint = nullptr; - ResetQtGrabbedControlCallback resetQtGrabbedControl = nullptr; - - FramelessCallbacks(); - virtual ~FramelessCallbacks(); - - using PtrType = std::shared_ptr; - [[nodiscard]] static PtrType create(); - -private: - FRAMELESSHELPER_CLASS(FramelessCallbacks) -}; -using FramelessCallbacksPtr = FramelessCallbacks::PtrType; - -enum class ExtraDataType : quint8 -{ - WindowsUtilities, - LinuxUtilities, - MacOSUtilities, - FramelessWidgetsHelper, - FramelessQuickHelper -}; - -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) -inline uint qHash(const ExtraDataType key, const uint seed = 0) noexcept { - return ::qHash(static_cast(key), seed); -} -#endif - -struct FRAMELESSHELPER_CORE_API FramelessExtraData -{ - FramelessExtraData(); - virtual ~FramelessExtraData(); - - using PtrType = std::shared_ptr; - -private: - FRAMELESSHELPER_CLASS(FramelessExtraData) -}; -using FramelessExtraDataPtr = FramelessExtraData::PtrType; -using FramelessExtraDataPtrs = QList; -using FramelessExtraDataHash = QHash; - -struct FRAMELESSHELPER_CORE_API FramelessData -{ - QObject *window = nullptr; - WId windowId = 0; - QObject *internalEventHandler = nullptr; - bool frameless = false; - FramelessCallbacksPtr callbacks = nullptr; - FramelessExtraDataHash extraData = {}; - - FramelessData(); - virtual ~FramelessData(); - - using PtrType = std::shared_ptr; - [[nodiscard]] static PtrType create(); - -private: - FRAMELESSHELPER_CLASS(FramelessData) -}; -using FramelessDataPtr = FramelessData::PtrType; -using FramelessDataPtrs = QList; -using FramelessDataHash = QHash; - -FRAMELESSHELPER_END_NAMESPACE - -#define DECLARE_SIZE_COMPARE_OPERATORS(Type1, Type2) \ - [[maybe_unused]] [[nodiscard]] inline constexpr bool operator>(const Type1 &lhs, const Type2 &rhs) noexcept \ - { \ - return ((lhs.width() * lhs.height()) > (rhs.width() * rhs.height())); \ - } \ - [[maybe_unused]] [[nodiscard]] inline constexpr bool operator>=(const Type1 &lhs, const Type2 &rhs) noexcept \ - { \ - return (operator>(lhs, rhs) || operator==(lhs, rhs)); \ - } \ - [[maybe_unused]] [[nodiscard]] inline constexpr bool operator<(const Type1 &lhs, const Type2 &rhs) noexcept \ - { \ - return (operator!=(lhs, rhs) && !operator>(lhs, rhs)); \ - } \ - [[maybe_unused]] [[nodiscard]] inline constexpr bool operator<=(const Type1 &lhs, const Type2 &rhs) noexcept \ - { \ - return (operator<(lhs, rhs) || operator==(lhs, rhs)); \ - } - -DECLARE_SIZE_COMPARE_OPERATORS(QSize, QSize) -DECLARE_SIZE_COMPARE_OPERATORS(QSizeF, QSizeF) -DECLARE_SIZE_COMPARE_OPERATORS(QSize, QSizeF) -DECLARE_SIZE_COMPARE_OPERATORS(QSizeF, QSize) diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/framelessmanager_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/framelessmanager_p.h deleted file mode 100644 index 1954749e..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/framelessmanager_p.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -struct FramelessData; -using FramelessDataPtr = std::shared_ptr; - -class FramelessManager; -class FRAMELESSHELPER_CORE_API FramelessManagerPrivate : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessManager) - -public: - explicit FramelessManagerPrivate(FramelessManager *q); - ~FramelessManagerPrivate() override; - - static void initializeIconFont(); - Q_NODISCARD static QFont getIconFont(); - - Q_SLOT void notifySystemThemeHasChangedOrNot(); - Q_SLOT void notifyWallpaperHasChangedOrNot(); - - Q_NODISCARD bool isThemeOverrided() const; - - void initialize(); - - void doNotifySystemThemeHasChangedOrNot(); - void doNotifyWallpaperHasChangedOrNot(); - - Q_NODISCARD static FramelessDataPtr getData(const QObject *window); - Q_NODISCARD static FramelessDataPtr createData(const QObject *window, const WId windowId); - Q_NODISCARD static WId getWindowId(const QObject *window); - Q_NODISCARD static QObject *getWindow(const WId windowId); - static void updateWindowId(const QObject *window, const WId newWindowId); - - Global::SystemTheme systemTheme = Global::SystemTheme::Unknown; - std::optional overrideTheme = std::nullopt; - QColor accentColor = {}; -#ifdef Q_OS_WINDOWS - Global::DwmColorizationArea colorizationArea = Global::DwmColorizationArea::None; -#endif - QString wallpaper = {}; - Global::WallpaperAspectStyle wallpaperAspectStyle = Global::WallpaperAspectStyle::Fill; - QTimer themeTimer{}; - QTimer wallpaperTimer{}; -}; - -class InternalEventFilter : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_QT_CLASS(InternalEventFilter) - -public: - explicit InternalEventFilter(const QObject *window, QObject *parent = nullptr); - ~InternalEventFilter() override; - -protected: - Q_NODISCARD bool eventFilter(QObject *object, QEvent *event) override; - -private: - const QObject *m_window = nullptr; -}; - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/micamaterial_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/micamaterial_p.h deleted file mode 100644 index 7ff0de93..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/micamaterial_p.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include -#ifdef FRAMELESSHELPER_HAS_THREAD -# undef FRAMELESSHELPER_HAS_THREAD -#endif -#if QT_CONFIG(thread) -# define FRAMELESSHELPER_HAS_THREAD 1 -# include -#else // !QT_CONFIG(thread) -# define FRAMELESSHELPER_HAS_THREAD 0 -#endif // QT_CONFIG(thread) - -#if FRAMELESSHELPER_CONFIG(mica_material) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_HAS_THREAD -using FramelessHelperThreadClass = QThread; -#else -using FramelessHelperThreadClass = QObject; -#endif - -class MicaMaterial; -class FRAMELESSHELPER_CORE_API MicaMaterialPrivate : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_PRIVATE_QT_CLASS(MicaMaterial) - -public: - explicit MicaMaterialPrivate(MicaMaterial *q); - ~MicaMaterialPrivate() override; - - Q_NODISCARD static QColor systemFallbackColor(); - - Q_NODISCARD QPoint mapToWallpaper(const QPoint &pos) const; - Q_NODISCARD QSize mapToWallpaper(const QSize &size) const; - Q_NODISCARD QRect mapToWallpaper(const QRect &rect) const; - - Q_SLOT void maybeGenerateBlurredWallpaper(const bool force = false); - Q_SLOT void updateMaterialBrush(); - Q_SLOT void forceRebuildWallpaper(); - - void initialize(); - void prepareGraphicsResources(); - - QColor tintColor = {}; - qreal tintOpacity = qreal(0); - QColor fallbackColor = {}; - qreal noiseOpacity = qreal(0); - bool fallbackEnabled = true; - QBrush micaBrush = {}; - bool initialized = false; - QSize wallpaperSize = {}; -}; - -class WallpaperThread : public FramelessHelperThreadClass -{ - Q_OBJECT - FRAMELESSHELPER_QT_CLASS(WallpaperThread) - -public: - explicit WallpaperThread(QObject *parent = nullptr); - ~WallpaperThread() override; - -Q_SIGNALS: - void imageUpdated(); - -#if FRAMELESSHELPER_HAS_THREAD -protected: - void run() override; -#else -public: - void start(); -#endif -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/registrykey_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/registrykey_p.h deleted file mode 100644 index 8290bacf..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/registrykey_p.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include -#include -#include - -#ifdef Q_OS_WINDOWS - -#ifndef REGISTRYKEY_FORCE_QSETTINGS -# define REGISTRYKEY_FORCE_QSETTINGS (0) -#endif // REGISTRYKEY_FORCE_QSETTINGS - -#ifndef REGISTRYKEY_IMPL -# if ((QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) && !(REGISTRYKEY_FORCE_QSETTINGS) && !defined(FRAMELESSHELPER_CORE_NO_PRIVATE)) -# define REGISTRYKEY_IMPL (1) -# else // ((QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) || REGISTRYKEY_FORCE_QSETTINGS || defined(FRAMELESSHELPER_CORE_NO_PRIVATE)) -# define REGISTRYKEY_IMPL (2) -# endif // ((QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) && !REGISTRYKEY_FORCE_QSETTINGS && !defined(FRAMELESSHELPER_CORE_NO_PRIVATE)) -#endif // REGISTRYKEY_IMPL - -#ifndef REGISTRYKEY_QWINREGISTRYKEY -# define REGISTRYKEY_QWINREGISTRYKEY ((REGISTRYKEY_IMPL) == 1) -#endif // REGISTRYKEY_QWINREGISTRYKEY - -#ifndef REGISTRYKEY_QSETTINGS -# define REGISTRYKEY_QSETTINGS ((REGISTRYKEY_IMPL) == 2) -#endif // REGISTRYKEY_QSETTINGS - -QT_BEGIN_NAMESPACE -class QWinRegistryKey; -class QSettings; -QT_END_NAMESPACE - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FRAMELESSHELPER_CORE_API RegistryKey : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_QT_CLASS(RegistryKey) - -public: - explicit RegistryKey(const Global::RegistryRootKey root, const QString &key, QObject *parent = nullptr); - ~RegistryKey() override; - - Q_NODISCARD Global::RegistryRootKey rootKey() const; - Q_NODISCARD QString subKey() const; - - Q_NODISCARD bool isValid() const; - - Q_NODISCARD QVariant value(const QString &name) const; - template - Q_NODISCARD std::optional value(const QString &name) const - { - const QVariant var = value(name); - if (var.isValid() && !var.isNull()) { - return qvariant_cast(var); - } - return std::nullopt; - } - -private: - Global::RegistryRootKey m_rootKey = Global::RegistryRootKey::CurrentUser; - QString m_subKey = {}; -#if REGISTRYKEY_QWINREGISTRYKEY - std::unique_ptr m_registryKey; -#else - std::unique_ptr m_settings; -#endif -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif // Q_OS_WINDOWS diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/scopeguard_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/scopeguard_p.h deleted file mode 100644 index 0f1cb76a..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/scopeguard_p.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include - -#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) -# include -#else // (QT_VERSION < QT_VERSION_CHECK(5, 12, 0)) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -using ScopeGuardCallback = std::function; - -class [[nodiscard]] ScopeGuard -{ - FRAMELESSHELPER_CLASS(ScopeGuard) - -public: - ScopeGuard() - { - } - - explicit ScopeGuard(const ScopeGuardCallback &cb) - { - // For the ctor, we require a non-null function. - Q_ASSERT(cb); - if (!cb) { - return; - } - m_callback = cb; - } - - explicit ScopeGuard(ScopeGuardCallback &&cb) - { - // For the ctor, we require a non-null function. - Q_ASSERT(cb); - if (!cb) { - return; - } - m_callback = std::move(cb); - } - - ScopeGuard(ScopeGuard &&other) : m_callback(std::move(other.m_callback)) - { - } - - ~ScopeGuard() - { - if (m_callback) { - m_callback(); - } - } - - [[nodiscard]] ScopeGuardCallback callback() const - { - return m_callback; - } - - void setCallback(const ScopeGuardCallback &cb) - { - // But we allow null functions here. - m_callback = cb; - } - -private: - ScopeGuardCallback m_callback = nullptr; -}; - -[[nodiscard]] inline ScopeGuard make_guard(ScopeGuardCallback &&cb) -{ - return ScopeGuard(cb); -} - -#define qScopeGuard make_guard - -FRAMELESSHELPER_END_NAMESPACE - -#endif // (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/sysapiloader_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/sysapiloader_p.h deleted file mode 100644 index e855047e..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/sysapiloader_p.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FRAMELESSHELPER_CORE_API SysApiLoader : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_QT_CLASS(SysApiLoader) - -public: - Q_NODISCARD static SysApiLoader *instance(); - - Q_NODISCARD static QString platformSharedLibrarySuffixName(); - Q_NODISCARD static QString platformSystemLibraryDirectory(); - Q_NODISCARD static QString generateUniqueKey(const QString &library, const QString &function); - - Q_NODISCARD static QFunctionPointer resolve(const QString &library, const char *function); - Q_NODISCARD static QFunctionPointer resolve(const QString &library, const QString &function); - - Q_NODISCARD bool isAvailable(const QString &library, const QString &function); - - Q_NODISCARD QFunctionPointer get(const QString &library, const QString &function); - - template - Q_NODISCARD T get(const QString &library, const QString &function) - { - return reinterpret_cast(get(library, function)); - } - -private: - explicit SysApiLoader(QObject *parent = nullptr); - ~SysApiLoader() override; -}; - -FRAMELESSHELPER_END_NAMESPACE - -#define API_AVAILABLE(lib, func) \ - (FRAMELESSHELPER_PREPEND_NAMESPACE(SysApiLoader)::instance()->isAvailable(k##lib, k##func)) - -#define API_CALL_FUNCTION(lib, func, ...) \ - ((FRAMELESSHELPER_PREPEND_NAMESPACE(SysApiLoader)::instance()->get(k##lib, k##func))(__VA_ARGS__)) - -#define API_CALL_FUNCTION2(lib, func, type, ...) \ - ((FRAMELESSHELPER_PREPEND_NAMESPACE(SysApiLoader)::instance()->get(k##lib, k##func))(__VA_ARGS__)) - -#define API_CALL_FUNCTION3(lib, func, name, ...) \ - ((FRAMELESSHELPER_PREPEND_NAMESPACE(SysApiLoader)::instance()->get(k##lib, k##name))(__VA_ARGS__)) - -#define API_CALL_FUNCTION4(lib, func, ...) API_CALL_FUNCTION3(lib, _##func, func, __VA_ARGS__) - -#define API_CALL_FUNCTION5(lib, func, ...) API_CALL_FUNCTION3(lib, func##2, func, __VA_ARGS__) - -#ifdef Q_OS_WINDOWS -# define API_USER_AVAILABLE(func) API_AVAILABLE(user32, func) -# define API_THEME_AVAILABLE(func) API_AVAILABLE(uxtheme, func) -# define API_DWM_AVAILABLE(func) API_AVAILABLE(dwmapi, func) -# define API_SHCORE_AVAILABLE(func) API_AVAILABLE(shcore, func) -# define API_WINMM_AVAILABLE(func) API_AVAILABLE(winmm, func) -# define API_D2D_AVAILABLE(func) API_AVAILABLE(d2d1, func) -# define API_NT_AVAILABLE(func) API_AVAILABLE(ntdll, func) -#endif // Q_OS_WINDOWS - -#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) -# define API_XLIB_AVAILABLE(func) API_AVAILABLE(libX11, func) -# define API_XCB_AVAILABLE(func) API_AVAILABLE(libxcb, func) -# define API_GTK_AVAILABLE(func) API_AVAILABLE(libgtk, func) -#endif // Q_OS_LINUX diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/versionnumber_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/versionnumber_p.h deleted file mode 100644 index df950fc4..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/versionnumber_p.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -struct VersionNumber -{ - unsigned long Major = 0; - unsigned long Minor = 0; - unsigned long Patch = 0; - unsigned long Tweak = 0; - - [[nodiscard]] friend constexpr bool operator==(const VersionNumber &lhs, const VersionNumber &rhs) noexcept - { - return ((lhs.Major == rhs.Major) && (lhs.Minor == rhs.Minor) && (lhs.Patch == rhs.Patch) && (lhs.Tweak == rhs.Tweak)); - } - - [[nodiscard]] friend constexpr bool operator!=(const VersionNumber &lhs, const VersionNumber &rhs) noexcept - { - return !operator==(lhs, rhs); - } - - [[nodiscard]] friend constexpr bool operator>(const VersionNumber &lhs, const VersionNumber &rhs) noexcept - { - if (operator==(lhs, rhs)) { - return false; - } - if (lhs.Major > rhs.Major) { - return true; - } - if (lhs.Major < rhs.Major) { - return false; - } - if (lhs.Minor > rhs.Minor) { - return true; - } - if (lhs.Minor < rhs.Minor) { - return false; - } - if (lhs.Patch > rhs.Patch) { - return true; - } - if (lhs.Patch < rhs.Patch) { - return false; - } - return (lhs.Tweak > rhs.Tweak); - } - - [[nodiscard]] friend constexpr bool operator<(const VersionNumber &lhs, const VersionNumber &rhs) noexcept - { - return (operator!=(lhs, rhs) && !operator>(lhs, rhs)); - } - - [[nodiscard]] friend constexpr bool operator>=(const VersionNumber &lhs, const VersionNumber &rhs) noexcept - { - return (operator>(lhs, rhs) || operator==(lhs, rhs)); - } - - [[nodiscard]] friend constexpr bool operator<=(const VersionNumber &lhs, const VersionNumber &rhs) noexcept - { - return (operator<(lhs, rhs) || operator==(lhs, rhs)); - } -}; - -#ifdef Q_OS_WINDOWS -[[maybe_unused]] inline constexpr const std::array(Global::WindowsVersion::Latest) + 1> WindowsVersions = -{ - VersionNumber{ 5, 0, 2195 }, // Windows 2000 - VersionNumber{ 5, 1, 2600 }, // Windows XP - VersionNumber{ 5, 2, 3790 }, // Windows XP x64 Edition or Windows Server 2003 - VersionNumber{ 6, 0, 6000 }, // Windows Vista - VersionNumber{ 6, 0, 6001 }, // Windows Vista with Service Pack 1 or Windows Server 2008 - VersionNumber{ 6, 0, 6002 }, // Windows Vista with Service Pack 2 - VersionNumber{ 6, 1, 7600 }, // Windows 7 or Windows Server 2008 R2 - VersionNumber{ 6, 1, 7601 }, // Windows 7 with Service Pack 1 or Windows Server 2008 R2 with Service Pack 1 - VersionNumber{ 6, 2, 9200 }, // Windows 8 or Windows Server 2012 - VersionNumber{ 6, 3, 9200 }, // Windows 8.1 or Windows Server 2012 R2 - VersionNumber{ 6, 3, 9600 }, // Windows 8.1 with Update 1 - VersionNumber{ 10, 0, 10240 }, // Windows 10 Version 1507 (TH1) - VersionNumber{ 10, 0, 10586 }, // Windows 10 Version 1511 (November Update) (TH2) - VersionNumber{ 10, 0, 14393 }, // Windows 10 Version 1607 (Anniversary Update) (RS1) or Windows Server 2016 - VersionNumber{ 10, 0, 15063 }, // Windows 10 Version 1703 (Creators Update) (RS2) - VersionNumber{ 10, 0, 16299 }, // Windows 10 Version 1709 (Fall Creators Update) (RS3) - VersionNumber{ 10, 0, 17134 }, // Windows 10 Version 1803 (April 2018 Update) (RS4) - VersionNumber{ 10, 0, 17763 }, // Windows 10 Version 1809 (October 2018 Update) (RS5) or Windows Server 2019 - VersionNumber{ 10, 0, 18362 }, // Windows 10 Version 1903 (May 2019 Update) (19H1) - VersionNumber{ 10, 0, 18363 }, // Windows 10 Version 1909 (November 2019 Update) (19H2) - VersionNumber{ 10, 0, 19041 }, // Windows 10 Version 2004 (May 2020 Update) (20H1) - VersionNumber{ 10, 0, 19042 }, // Windows 10 Version 20H2 (October 2020 Update) (20H2) - VersionNumber{ 10, 0, 19043 }, // Windows 10 Version 21H1 (May 2021 Update) (21H1) - VersionNumber{ 10, 0, 19044 }, // Windows 10 Version 21H2 (November 2021 Update) (21H2) - VersionNumber{ 10, 0, 19045 }, // Windows 10 Version 22H2 (October 2022 Update) (22H2) - VersionNumber{ 10, 0, 22000 }, // Windows 11 Version 21H2 (21H2) - VersionNumber{ 10, 0, 22621 } // Windows 11 Version 22H2 (October 2022 Update) (22H2) -}; -#endif // Q_OS_WINDOWS - -FRAMELESSHELPER_END_NAMESPACE - -#ifndef QT_NO_DEBUG_STREAM -QT_BEGIN_NAMESPACE -FRAMELESSHELPER_CORE_API QDebug operator<<(QDebug, const FRAMELESSHELPER_PREPEND_NAMESPACE(VersionNumber) &); -QT_END_NAMESPACE -#endif // QT_NO_DEBUG_STREAM diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/windowborderpainter_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/windowborderpainter_p.h deleted file mode 100644 index a494ef46..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/windowborderpainter_p.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include - -#if FRAMELESSHELPER_CONFIG(border_painter) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class WindowBorderPainter; -class FRAMELESSHELPER_CORE_API WindowBorderPainterPrivate : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_PRIVATE_QT_CLASS(WindowBorderPainter) - -public: - explicit WindowBorderPainterPrivate(WindowBorderPainter *q); - ~WindowBorderPainterPrivate() override; - - std::optional thickness = std::nullopt; - std::optional edges = std::nullopt; - std::optional activeColor = std::nullopt; - std::optional inactiveColor = std::nullopt; -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/winverhelper_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/winverhelper_p.h deleted file mode 100644 index 6986353c..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/private/winverhelper_p.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include - -#ifdef Q_OS_WINDOWS - -FRAMELESSHELPER_BEGIN_NAMESPACE - -namespace WindowsVersionHelper -{ - -#define DECL(Name) [[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin##Name##OrGreater(); - -DECL(2K) -DECL(XP) -DECL(XP64) -DECL(Vista) -DECL(VistaSP1) -DECL(VistaSP2) -DECL(7) -DECL(7SP1) -DECL(8) -DECL(8Point1) -DECL(8Point1Update1) -DECL(10) -DECL(10TH1) -DECL(10TH2) -DECL(10RS1) -DECL(10RS2) -DECL(10RS3) -DECL(10RS4) -DECL(10RS5) -DECL(1019H1) -DECL(1019H2) -DECL(1020H1) -DECL(1020H2) -DECL(1021H1) -DECL(1021H2) -DECL(1022H2) -DECL(11) -DECL(1121H2) -DECL(1122H2) - -#undef DECL - -} // namespace WindowsVersionHelper - -FRAMELESSHELPER_END_NAMESPACE - -#endif // Q_OS_WINDOWS diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/utils.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/utils.h deleted file mode 100644 index fd87aaf2..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/utils.h +++ /dev/null @@ -1,175 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) -# include -#endif // Q_OS_LINUX - -#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) -QT_BEGIN_NAMESPACE -class QScreen; -QT_END_NAMESPACE -#endif // Q_OS_LINUX - -FRAMELESSHELPER_BEGIN_NAMESPACE - -namespace Utils -{ - -[[nodiscard]] FRAMELESSHELPER_CORE_API Qt::CursorShape calculateCursorShape(const QWindow *window, const QPoint &pos); -[[nodiscard]] FRAMELESSHELPER_CORE_API Qt::Edges calculateWindowEdges(const QWindow *window, const QPoint &pos); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool startSystemMove(QWindow *window, const QPoint &globalPos); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool startSystemResize(QWindow *window, const Qt::Edges edges, const QPoint &globalPos); -[[nodiscard]] FRAMELESSHELPER_CORE_API QString getSystemButtonGlyph(const Global::SystemButtonType button); -[[nodiscard]] FRAMELESSHELPER_CORE_API QWindow *findWindow(const WId windowId); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool moveWindowToDesktopCenter(const WId windowId, const bool considerTaskBar); -[[nodiscard]] FRAMELESSHELPER_CORE_API Qt::WindowState windowStatesToWindowState(const Qt::WindowStates states); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isThemeChangeEvent(const QEvent * const event); -[[nodiscard]] FRAMELESSHELPER_CORE_API QColor calculateSystemButtonBackgroundColor(const Global::SystemButtonType button, const Global::ButtonState state); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool shouldAppsUseDarkMode(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isTitleBarColorized(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool setBlurBehindWindowEnabled(const WId windowId, const Global::BlurMode mode, const QColor &color); -[[nodiscard]] FRAMELESSHELPER_CORE_API QString getWallpaperFilePath(); -[[nodiscard]] FRAMELESSHELPER_CORE_API Global::WallpaperAspectStyle getWallpaperAspectStyle(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isBlurBehindWindowSupported(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool registerThemeChangeNotification(); -[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getFrameBorderColor(const bool active); -[[nodiscard]] FRAMELESSHELPER_CORE_API qreal roundScaleFactor(const qreal factor); -[[nodiscard]] FRAMELESSHELPER_CORE_API int toNativePixels(const QWindow *window, const int value); -[[nodiscard]] FRAMELESSHELPER_CORE_API QPoint toNativePixels(const QWindow *window, const QPoint &point); -[[nodiscard]] FRAMELESSHELPER_CORE_API QSize toNativePixels(const QWindow *window, const QSize &size); -[[nodiscard]] FRAMELESSHELPER_CORE_API QRect toNativePixels(const QWindow *window, const QRect &rect); -[[nodiscard]] FRAMELESSHELPER_CORE_API int fromNativePixels(const QWindow *window, const int value); -[[nodiscard]] FRAMELESSHELPER_CORE_API QPoint fromNativePixels(const QWindow *window, const QPoint &point); -[[nodiscard]] FRAMELESSHELPER_CORE_API QSize fromNativePixels(const QWindow *window, const QSize &size); -[[nodiscard]] FRAMELESSHELPER_CORE_API QRect fromNativePixels(const QWindow *window, const QRect &rect); -[[nodiscard]] FRAMELESSHELPER_CORE_API QPoint toNativeLocalPosition(const QWindow *window, const QPoint &point); -[[nodiscard]] FRAMELESSHELPER_CORE_API QPoint toNativeGlobalPosition(const QWindow *window, const QPoint &point); -[[nodiscard]] FRAMELESSHELPER_CORE_API QPoint fromNativeLocalPosition(const QWindow *window, const QPoint &point); -[[nodiscard]] FRAMELESSHELPER_CORE_API QPoint fromNativeGlobalPosition(const QWindow *window, const QPoint &point); -[[nodiscard]] FRAMELESSHELPER_CORE_API int horizontalAdvance(const QFontMetrics &fm, const QString &str); -[[nodiscard]] FRAMELESSHELPER_CORE_API qreal getRelativeScaleFactor(const quint32 oldDpi, const quint32 newDpi); -[[nodiscard]] FRAMELESSHELPER_CORE_API QSizeF rescaleSize(const QSizeF &oldSize, const quint32 oldDpi, const quint32 newDpi); -[[nodiscard]] FRAMELESSHELPER_CORE_API QSize rescaleSize(const QSize &oldSize, const quint32 oldDpi, const quint32 newDpi); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isValidGeometry(const QRectF &rect); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isValidGeometry(const QRect &rect); -[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getAccentColor(); -[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 defaultScreenDpi(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowAccelerated(const QWindow *window); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowTransparent(const QWindow *window); -[[nodiscard]] FRAMELESSHELPER_CORE_API QColor calculateForegroundColor(const QColor &backgroundColor); - -#ifdef Q_OS_WINDOWS -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowsVersionOrGreater(const Global::WindowsVersion version); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isDwmCompositionEnabled(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool triggerFrameChange(const WId windowId); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateWindowFrameMargins(const WId windowId, const bool reset); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateInternalWindowFrameMargins(QWindow *window, const bool enable); -[[nodiscard]] FRAMELESSHELPER_CORE_API QString getSystemErrorMessage(const QString &function); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isFullScreen(const WId windowId); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowNoState(const WId windowId); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool syncWmPaintWithDwm(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool showSystemMenu(const WId windowId, const QPoint &pos, const bool selectFirstEntry); -[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getDwmColorizationColor(bool *opaque = nullptr, bool *ok = nullptr); -[[nodiscard]] FRAMELESSHELPER_CORE_API Global::DwmColorizationArea getDwmColorizationArea(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isHighContrastModeEnabled(); -[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getPrimaryScreenDpi(const bool horizontal); -[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getWindowDpi(const WId windowId, const bool horizontal); -[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getResizeBorderThicknessForDpi(const bool horizontal, const quint32 dpi); -[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getResizeBorderThickness(const WId windowId, const bool horizontal, const bool scaled); -[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getCaptionBarHeightForDpi(const quint32 dpi); -[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getCaptionBarHeight(const WId windowId, const bool scaled); -[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getTitleBarHeightForDpi(const quint32 dpi); -[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getTitleBarHeight(const WId windowId, const bool scaled); -[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getFrameBorderThicknessForDpi(const quint32 dpi); -[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getFrameBorderThickness(const WId windowId, const bool scaled); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool maybeFixupQtInternals(const WId windowId); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowFrameBorderVisible(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isFrameBorderColorized(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool installWindowProcHook(const WId windowId); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool uninstallWindowProcHook(const WId windowId); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool setAeroSnappingEnabled(const WId windowId, const bool enable); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool tryToEnableHighestDpiAwarenessLevel(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateGlobalWin32ControlsTheme(const WId windowId, const bool dark); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool shouldAppsUseDarkMode_windows(); -[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getAccentColor_windows(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool setCornerStyleForWindow(const WId windowId, const Global::WindowCornerStyle style); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool hideOriginalTitleBarElements(const WId windowId, const bool disable = true); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool setQtDarkModeAwareEnabled(const bool enable); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool refreshWin32ThemeResources(const WId windowId, const bool dark); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool enableNonClientAreaDpiScalingForWindow(const WId windowId); -[[nodiscard]] FRAMELESSHELPER_CORE_API Global::DpiAwareness getDpiAwarenessForCurrentProcess(bool *highest = nullptr); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool fixupChildWindowsDpiMessage(const WId windowId); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool fixupDialogsDpiScaling(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool setDarkModeAllowedForApp(const bool allow = true); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool bringWindowToFront(const WId windowId); -[[nodiscard]] FRAMELESSHELPER_CORE_API QPoint getWindowPlacementOffset(const WId windowId); -[[nodiscard]] FRAMELESSHELPER_CORE_API QRect getWindowRestoreGeometry(const WId windowId); -[[nodiscard]] FRAMELESSHELPER_CORE_API quint64 getKeyState(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isValidWindow(const WId windowId, const bool checkVisible, const bool checkTopLevel); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateFramebufferTransparency(const WId windowId); -[[nodiscard]] FRAMELESSHELPER_CORE_API QMargins getWindowSystemFrameMargins(const WId windowId); -[[nodiscard]] FRAMELESSHELPER_CORE_API QMargins getWindowCustomFrameMargins(const QWindow *window); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateAllDirectXSurfaces(); -FRAMELESSHELPER_CORE_API void printWin32Message(void *msg); -#endif // Q_OS_WINDOWS - -#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) -[[nodiscard]] FRAMELESSHELPER_CORE_API QScreen *x11_findScreenForVirtualDesktop(const int virtualDesktopNumber); -[[nodiscard]] FRAMELESSHELPER_CORE_API x11_return_type x11_appRootWindow(const int screen); -[[nodiscard]] FRAMELESSHELPER_CORE_API int x11_appScreen(); -[[nodiscard]] FRAMELESSHELPER_CORE_API x11_return_type x11_appTime(); -[[nodiscard]] FRAMELESSHELPER_CORE_API x11_return_type x11_appUserTime(); -[[nodiscard]] FRAMELESSHELPER_CORE_API x11_return_type x11_getTimestamp(); -[[nodiscard]] FRAMELESSHELPER_CORE_API QByteArray x11_nextStartupId(); -[[nodiscard]] FRAMELESSHELPER_CORE_API Display *x11_display(); -[[nodiscard]] FRAMELESSHELPER_CORE_API xcb_connection_t *x11_connection(); -[[nodiscard]] FRAMELESSHELPER_CORE_API QByteArray getWindowProperty(const WId windowId, const xcb_atom_t prop, const xcb_atom_t type, const quint32 data_len); -FRAMELESSHELPER_CORE_API void setWindowProperty(const WId windowId, const xcb_atom_t prop, const xcb_atom_t type, const void *data, const quint32 data_len, const uint8_t format); -FRAMELESSHELPER_CORE_API void clearWindowProperty(const WId windowId, const xcb_atom_t prop); -[[nodiscard]] FRAMELESSHELPER_CORE_API xcb_atom_t internAtom(const char *name); -[[nodiscard]] FRAMELESSHELPER_CORE_API QString getWindowManagerName(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isSupportedByWindowManager(const xcb_atom_t atom); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isSupportedByRootWindow(const xcb_atom_t atom); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool tryHideSystemTitleBar(const WId windowId, const bool hide = true); -FRAMELESSHELPER_CORE_API void openSystemMenu(const WId windowId, const QPoint &globalPos); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool shouldAppsUseDarkMode_linux(); -[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getAccentColor_linux(); -FRAMELESSHELPER_CORE_API void sendMoveResizeMessage(const WId windowId, const uint32_t action, const QPoint &globalPos, const Qt::MouseButton button = Qt::LeftButton); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isCustomDecorationSupported(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool setPlatformPropertiesForWindow(QWindow *window, const QVariantHash &props); -#endif // Q_OS_LINUX - -#ifdef Q_OS_MACOS -[[nodiscard]] FRAMELESSHELPER_CORE_API bool shouldAppsUseDarkMode_macos(); -[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getAccentColor_macos(); -FRAMELESSHELPER_CORE_API void setSystemTitleBarVisible(const WId windowId, const bool visible); -FRAMELESSHELPER_CORE_API void removeWindowProxy(const WId windowId); -#endif // Q_OS_MACOS -} // namespace Utils - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/windowborderpainter.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/windowborderpainter.h deleted file mode 100644 index 62eb0493..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Core/windowborderpainter.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include - -#if FRAMELESSHELPER_CONFIG(border_painter) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class WindowBorderPainterPrivate; -class FRAMELESSHELPER_CORE_API WindowBorderPainter : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_PUBLIC_QT_CLASS(WindowBorderPainter) - - Q_PROPERTY(int thickness READ thickness WRITE setThickness NOTIFY thicknessChanged FINAL) - Q_PROPERTY(Global::WindowEdges edges READ edges WRITE setEdges NOTIFY edgesChanged FINAL) - Q_PROPERTY(QColor activeColor READ activeColor WRITE setActiveColor NOTIFY activeColorChanged FINAL) - Q_PROPERTY(QColor inactiveColor READ inactiveColor WRITE setInactiveColor NOTIFY inactiveColorChanged FINAL) - - Q_PROPERTY(int nativeThickness READ nativeThickness NOTIFY nativeBorderChanged FINAL) - Q_PROPERTY(Global::WindowEdges nativeEdges READ nativeEdges NOTIFY nativeBorderChanged FINAL) - Q_PROPERTY(QColor nativeActiveColor READ nativeActiveColor NOTIFY nativeBorderChanged FINAL) - Q_PROPERTY(QColor nativeInactiveColor READ nativeInactiveColor NOTIFY nativeBorderChanged FINAL) - -public: - explicit WindowBorderPainter(QObject *parent = nullptr); - ~WindowBorderPainter() override; - - Q_NODISCARD int thickness() const; - Q_NODISCARD Global::WindowEdges edges() const; - Q_NODISCARD QColor activeColor() const; - Q_NODISCARD QColor inactiveColor() const; - - Q_NODISCARD int nativeThickness() const; - Q_NODISCARD Global::WindowEdges nativeEdges() const; - Q_NODISCARD QColor nativeActiveColor() const; - Q_NODISCARD QColor nativeInactiveColor() const; - -public Q_SLOTS: - void paint(QPainter *painter, const QSize &size, const bool active); - void setThickness(const int value); - void setEdges(const Global::WindowEdges value); - void setActiveColor(const QColor &value); - void setInactiveColor(const QColor &value); - -Q_SIGNALS: - void thicknessChanged(); - void edgesChanged(); - void activeColorChanged(); - void inactiveColorChanged(); - void nativeBorderChanged(); - void shouldRepaint(); -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/FramelessQuickHelper b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/FramelessQuickHelper deleted file mode 100644 index e6fe43e7..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/FramelessQuickHelper +++ /dev/null @@ -1 +0,0 @@ -#include "framelessquickhelper.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/FramelessQuickModule b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/FramelessQuickModule deleted file mode 100644 index 4b5e529c..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/FramelessQuickModule +++ /dev/null @@ -1 +0,0 @@ -#include "framelessquickmodule.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/FramelessQuickUtils b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/FramelessQuickUtils deleted file mode 100644 index 0b30bc53..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/FramelessQuickUtils +++ /dev/null @@ -1 +0,0 @@ -#include "framelessquickutils.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/Global b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/Global deleted file mode 100644 index 7251fa6a..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/Global +++ /dev/null @@ -1 +0,0 @@ -#include "framelesshelperquick_global.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/QuickChromePalette b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/QuickChromePalette deleted file mode 100644 index d0a84770..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/QuickChromePalette +++ /dev/null @@ -1 +0,0 @@ -#include "quickchromepalette.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/QuickMicaMaterial b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/QuickMicaMaterial deleted file mode 100644 index 9b55579a..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/QuickMicaMaterial +++ /dev/null @@ -1 +0,0 @@ -#include "quickmicamaterial.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/QuickWindowBorder b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/QuickWindowBorder deleted file mode 100644 index 016afe4c..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/QuickWindowBorder +++ /dev/null @@ -1 +0,0 @@ -#include "quickwindowborder.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/framelesshelperquick_global.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/framelesshelperquick_global.h deleted file mode 100644 index 4c922a53..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/framelesshelperquick_global.h +++ /dev/null @@ -1,163 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include -#if __has_include() -# include -#endif - -#ifndef FRAMELESSHELPER_QUICK_API -# if FRAMELESSHELPER_CONFIG(static_build) -# define FRAMELESSHELPER_QUICK_API -# else // FRAMELESSHELPER_QUICK_STATIC -# ifdef FRAMELESSHELPER_QUICK_LIBRARY -# define FRAMELESSHELPER_QUICK_API Q_DECL_EXPORT -# else // FRAMELESSHELPER_QUICK_LIBRARY -# define FRAMELESSHELPER_QUICK_API Q_DECL_IMPORT -# endif // FRAMELESSHELPER_QUICK_LIBRARY -# endif // FRAMELESSHELPER_QUICK_STATIC -#endif // FRAMELESSHELPER_QUICK_API - -#ifndef FRAMELESSHELPER_QUICK_ENUM_VALUE -# define FRAMELESSHELPER_QUICK_ENUM_VALUE(Enum, Value) \ - Value = static_cast(FRAMELESSHELPER_PREPEND_NAMESPACE(Global)::Enum::Value), -#endif - -#ifndef FRAMELESSHELPER_ENUM_CORE_TO_QUICK -# define FRAMELESSHELPER_ENUM_CORE_TO_QUICK(Enum, Value) \ - static_cast(static_cast(Value)) -#endif - -#ifndef FRAMELESSHELPER_ENUM_QUICK_TO_CORE -# define FRAMELESSHELPER_ENUM_QUICK_TO_CORE(Enum, Value) \ - static_cast(static_cast(Value)) -#endif - -#ifndef FRAMELESSHELPER_FLAGS_CORE_TO_QUICK -# define FRAMELESSHELPER_FLAGS_CORE_TO_QUICK(Enum, Value, In, Out) \ - if (In & FRAMELESSHELPER_PREPEND_NAMESPACE(Global)::Enum::Value) { \ - Out |= FRAMELESSHELPER_PREPEND_NAMESPACE(QuickGlobal)::Enum::Value; \ - } -#endif - -#ifndef FRAMELESSHELPER_FLAGS_QUICK_TO_CORE -# define FRAMELESSHELPER_FLAGS_QUICK_TO_CORE(Enum, Value, In, Out) \ - if (In & FRAMELESSHELPER_PREPEND_NAMESPACE(QuickGlobal)::Enum::Value) { \ - Out |= FRAMELESSHELPER_PREPEND_NAMESPACE(Global)::Enum::Value; \ - } -#endif - -#ifndef FRAMELESSHELPER_IMPORT_QUICK_PLUGIN -# define FRAMELESSHELPER_IMPORT_QUICK_PLUGIN Q_IMPORT_PLUGIN(org_wangwenx190_FramelessHelperPlugin) -#endif - -FRAMELESSHELPER_BEGIN_NAMESPACE - -[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_QUICK_URI[] = "org.wangwenx190.FramelessHelper"; -[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_QUICK_VERSION_MAJOR = 1; -[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_QUICK_VERSION_MINOR = 0; - -FRAMELESSHELPER_QUICK_API void FramelessHelperQuickInitialize(); -FRAMELESSHELPER_QUICK_API void FramelessHelperQuickUninitialize(); -FRAMELESSHELPER_QUICK_API void FramelessHelperQuickRegisterTypes(QQmlEngine *); - -class FRAMELESSHELPER_QUICK_API QuickGlobal : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_QT_CLASS(QuickGlobal) -#ifdef QML_NAMED_ELEMENT - QML_NAMED_ELEMENT(FramelessHelperConstants) -#endif -#ifdef QML_UNCREATABLE - QML_UNCREATABLE("The FramelessHelperConstants namespace is not creatable, you can only use it to access it's enums.") -#endif - -public: - explicit QuickGlobal(QObject *parent = nullptr); - ~QuickGlobal() override; - - enum class SystemTheme : quint8 - { - FRAMELESSHELPER_QUICK_ENUM_VALUE(SystemTheme, Unknown) - FRAMELESSHELPER_QUICK_ENUM_VALUE(SystemTheme, Light) - FRAMELESSHELPER_QUICK_ENUM_VALUE(SystemTheme, Dark) - FRAMELESSHELPER_QUICK_ENUM_VALUE(SystemTheme, HighContrast) - }; - Q_ENUM(SystemTheme) - - enum class SystemButtonType : quint8 - { - FRAMELESSHELPER_QUICK_ENUM_VALUE(SystemButtonType, Unknown) - FRAMELESSHELPER_QUICK_ENUM_VALUE(SystemButtonType, WindowIcon) - FRAMELESSHELPER_QUICK_ENUM_VALUE(SystemButtonType, Help) - FRAMELESSHELPER_QUICK_ENUM_VALUE(SystemButtonType, Minimize) - FRAMELESSHELPER_QUICK_ENUM_VALUE(SystemButtonType, Maximize) - FRAMELESSHELPER_QUICK_ENUM_VALUE(SystemButtonType, Restore) - FRAMELESSHELPER_QUICK_ENUM_VALUE(SystemButtonType, Close) - }; - Q_ENUM(SystemButtonType) - - enum class ButtonState : quint8 - { - FRAMELESSHELPER_QUICK_ENUM_VALUE(ButtonState, Normal) - FRAMELESSHELPER_QUICK_ENUM_VALUE(ButtonState, Hovered) - FRAMELESSHELPER_QUICK_ENUM_VALUE(ButtonState, Pressed) - FRAMELESSHELPER_QUICK_ENUM_VALUE(ButtonState, Released) - }; - Q_ENUM(ButtonState) - - enum class BlurMode : quint8 - { - FRAMELESSHELPER_QUICK_ENUM_VALUE(BlurMode, Disable) - FRAMELESSHELPER_QUICK_ENUM_VALUE(BlurMode, Default) - FRAMELESSHELPER_QUICK_ENUM_VALUE(BlurMode, Windows_Aero) - FRAMELESSHELPER_QUICK_ENUM_VALUE(BlurMode, Windows_Acrylic) - FRAMELESSHELPER_QUICK_ENUM_VALUE(BlurMode, Windows_Mica) - FRAMELESSHELPER_QUICK_ENUM_VALUE(BlurMode, Windows_MicaAlt) - }; - Q_ENUM(BlurMode) - - enum class WindowEdge : quint8 - { - FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowEdge, Left) - FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowEdge, Top) - FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowEdge, Right) - FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowEdge, Bottom) - }; - Q_ENUM(WindowEdge) - Q_DECLARE_FLAGS(WindowEdges, WindowEdge) - Q_FLAG(WindowEdges) -}; -Q_DECLARE_OPERATORS_FOR_FLAGS(QuickGlobal::WindowEdges) - -namespace FramelessHelper::Quick -{ -inline void initialize() { FramelessHelperQuickInitialize(); } -inline void uninitialize() { FramelessHelperQuickUninitialize(); } -} // namespace FramelessHelper::Quick - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/framelessquickhelper.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/framelessquickhelper.h deleted file mode 100644 index 77a2dcef..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/framelessquickhelper.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(mica_material) -class QuickMicaMaterial; -#endif -#if FRAMELESSHELPER_CONFIG(border_painter) -class QuickWindowBorder; -#endif - -class FramelessQuickHelperPrivate; -class FRAMELESSHELPER_QUICK_API FramelessQuickHelper : public QQuickItem -{ - Q_OBJECT - FRAMELESSHELPER_PUBLIC_QT_CLASS(FramelessQuickHelper) -#ifdef QML_NAMED_ELEMENT - QML_NAMED_ELEMENT(FramelessHelper) -#endif -#ifdef QML_ATTACHED - QML_ATTACHED(FramelessQuickHelper) -#endif - Q_PROPERTY(QQuickItem* titleBarItem READ titleBarItem WRITE setTitleBarItem NOTIFY titleBarItemChanged FINAL) - Q_PROPERTY(bool windowFixedSize READ isWindowFixedSize WRITE setWindowFixedSize NOTIFY windowFixedSizeChanged FINAL) - Q_PROPERTY(bool blurBehindWindowEnabled READ isBlurBehindWindowEnabled WRITE setBlurBehindWindowEnabled NOTIFY blurBehindWindowEnabledChanged FINAL) - Q_PROPERTY(QQuickWindow* window READ window NOTIFY windowChanged2 FINAL) - Q_PROPERTY(bool extendsContentIntoTitleBar READ isContentExtendedIntoTitleBar WRITE extendsContentIntoTitleBar NOTIFY extendsContentIntoTitleBarChanged FINAL) - -public: - explicit FramelessQuickHelper(QQuickItem *parent = nullptr); - ~FramelessQuickHelper() override; - - Q_NODISCARD static FramelessQuickHelper *get(QObject *object); - Q_NODISCARD static FramelessQuickHelper *qmlAttachedProperties(QObject *parentObject); - - Q_NODISCARD QQuickItem *titleBarItem() const; - Q_NODISCARD bool isWindowFixedSize() const; - Q_NODISCARD bool isBlurBehindWindowEnabled() const; - Q_NODISCARD bool isContentExtendedIntoTitleBar() const; - -#if FRAMELESSHELPER_CONFIG(mica_material) - Q_NODISCARD QuickMicaMaterial *micaMaterial() const; -#endif -#if FRAMELESSHELPER_CONFIG(border_painter) - Q_NODISCARD QuickWindowBorder *windowBorder() const; -#endif - - Q_NODISCARD bool isReady() const; - void waitForReady(); - -public Q_SLOTS: - void extendsContentIntoTitleBar(const bool value = true); - - void setTitleBarItem(QQuickItem *value); - void setSystemButton(QQuickItem *item, const QuickGlobal::SystemButtonType buttonType); - void setHitTestVisible(QQuickItem *item, const bool visible = true); - void setHitTestVisible_rect(const QRect &rect, const bool visible = true); - void setHitTestVisible_object(QObject *object, const bool visible = true); - void setHitTestVisible_item(QQuickItem *item, const bool visible = true); - - void showSystemMenu(const QPoint &pos); - void windowStartSystemMove2(const QPoint &pos); - void windowStartSystemResize2(const Qt::Edges edges, const QPoint &pos); - - void moveWindowToDesktopCenter(); - void bringWindowToFront(); - void setWindowFixedSize(const bool value); - void setBlurBehindWindowEnabled(const bool value); - -protected: - void itemChange(const ItemChange change, const ItemChangeData &value) override; - void classBegin() override; - void componentComplete() override; - -Q_SIGNALS: - void extendsContentIntoTitleBarChanged(); - void titleBarItemChanged(); - void windowFixedSizeChanged(); - void blurBehindWindowEnabledChanged(); - void windowChanged2(); - void ready(); -}; - -FRAMELESSHELPER_END_NAMESPACE - -QML_DECLARE_TYPEINFO(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickHelper), QML_HAS_ATTACHED_PROPERTIES) diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/framelessquickmodule.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/framelessquickmodule.h deleted file mode 100644 index 7703ed40..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/framelessquickmodule.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include - -QT_BEGIN_NAMESPACE -class QQmlEngine; -QT_END_NAMESPACE - -FRAMELESSHELPER_BEGIN_NAMESPACE - -namespace FramelessHelper::Quick -{ -inline void registerTypes(QQmlEngine *engine) { FramelessHelperQuickRegisterTypes(engine); } -} // namespace FramelessHelper::Quick - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/framelessquickutils.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/framelessquickutils.h deleted file mode 100644 index a2851ff0..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/framelessquickutils.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include - -QT_BEGIN_NAMESPACE -class QQuickWindow; -QT_END_NAMESPACE - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FRAMELESSHELPER_QUICK_API FramelessQuickUtils : public QObject, public QQmlParserStatus -{ - Q_OBJECT - FRAMELESSHELPER_QT_CLASS(FramelessQuickUtils) - Q_INTERFACES(QQmlParserStatus) -#ifdef QML_NAMED_ELEMENT - QML_NAMED_ELEMENT(FramelessUtils) -#endif -#ifdef QML_SINGLETON - QML_SINGLETON -#endif - Q_PROPERTY(qreal titleBarHeight READ titleBarHeight CONSTANT FINAL) - Q_PROPERTY(bool frameBorderVisible READ frameBorderVisible CONSTANT FINAL) - Q_PROPERTY(qreal frameBorderThickness READ frameBorderThickness CONSTANT FINAL) - Q_PROPERTY(QuickGlobal::SystemTheme systemTheme READ systemTheme WRITE setOverrideTheme NOTIFY systemThemeChanged FINAL) - Q_PROPERTY(QColor systemAccentColor READ systemAccentColor NOTIFY systemAccentColorChanged FINAL) - Q_PROPERTY(bool titleBarColorized READ titleBarColorized NOTIFY titleBarColorizedChanged FINAL) - Q_PROPERTY(QColor defaultSystemLightColor READ defaultSystemLightColor CONSTANT FINAL) - Q_PROPERTY(QColor defaultSystemDarkColor READ defaultSystemDarkColor CONSTANT FINAL) - Q_PROPERTY(QSizeF defaultSystemButtonSize READ defaultSystemButtonSize CONSTANT FINAL) - Q_PROPERTY(QSizeF defaultSystemButtonIconSize READ defaultSystemButtonIconSize CONSTANT FINAL) - Q_PROPERTY(QColor defaultSystemButtonBackgroundColor READ defaultSystemButtonBackgroundColor CONSTANT FINAL) - Q_PROPERTY(QColor defaultSystemCloseButtonBackgroundColor READ defaultSystemCloseButtonBackgroundColor CONSTANT FINAL) - Q_PROPERTY(bool blurBehindWindowSupported READ blurBehindWindowSupported CONSTANT FINAL) - -public: - explicit FramelessQuickUtils(QObject *parent = nullptr); - ~FramelessQuickUtils() override; - - Q_NODISCARD qreal titleBarHeight() const; - Q_NODISCARD bool frameBorderVisible() const; - Q_NODISCARD qreal frameBorderThickness() const; - Q_NODISCARD QuickGlobal::SystemTheme systemTheme() const; - void setOverrideTheme(const QuickGlobal::SystemTheme theme); - Q_NODISCARD QColor systemAccentColor() const; - Q_NODISCARD bool titleBarColorized() const; - Q_NODISCARD QColor defaultSystemLightColor() const; - Q_NODISCARD QColor defaultSystemDarkColor() const; - Q_NODISCARD QSizeF defaultSystemButtonSize() const; - Q_NODISCARD QSizeF defaultSystemButtonIconSize() const; - Q_NODISCARD QColor defaultSystemButtonBackgroundColor() const; - Q_NODISCARD QColor defaultSystemCloseButtonBackgroundColor() const; - Q_NODISCARD bool blurBehindWindowSupported() const; - - Q_NODISCARD Q_SLOT QColor getSystemButtonBackgroundColor( - const QuickGlobal::SystemButtonType button, const QuickGlobal::ButtonState state); - -protected: - void classBegin() override; - void componentComplete() override; - -Q_SIGNALS: - void systemThemeChanged(); - void systemAccentColorChanged(); - void titleBarColorizedChanged(); -}; - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p.h deleted file mode 100644 index bb8499b3..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include - -#if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(window) && (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))) - -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FramelessQuickApplicationWindowPrivate; -class FRAMELESSHELPER_QUICK_API FramelessQuickApplicationWindow : public QQuickApplicationWindow -{ - Q_OBJECT - FRAMELESSHELPER_PUBLIC_QT_CLASS(FramelessQuickApplicationWindow) -#ifdef QML_NAMED_ELEMENT - QML_NAMED_ELEMENT(FramelessApplicationWindow) -#endif - Q_PROPERTY(bool hidden READ isHidden NOTIFY hiddenChanged FINAL) - Q_PROPERTY(bool normal READ isNormal NOTIFY normalChanged FINAL) - Q_PROPERTY(bool minimized READ isMinimized NOTIFY minimizedChanged FINAL) - Q_PROPERTY(bool maximized READ isMaximized NOTIFY maximizedChanged FINAL) - Q_PROPERTY(bool zoomed READ isZoomed NOTIFY zoomedChanged FINAL) - Q_PROPERTY(bool fullScreen READ isFullScreen NOTIFY fullScreenChanged FINAL) - -public: - explicit FramelessQuickApplicationWindow(QWindow *parent = nullptr); - ~FramelessQuickApplicationWindow() override; - - Q_NODISCARD bool isHidden() const; - Q_NODISCARD bool isNormal() const; - Q_NODISCARD bool isMinimized() const; - Q_NODISCARD bool isMaximized() const; - Q_NODISCARD bool isZoomed() const; - Q_NODISCARD bool isFullScreen() const; - -public Q_SLOTS: - void showMinimized2(); - void toggleMaximized(); - void toggleFullScreen(); - -protected: - void classBegin() override; - void componentComplete() override; - -Q_SIGNALS: - void hiddenChanged(); - void normalChanged(); - void minimizedChanged(); - void maximizedChanged(); - void zoomedChanged(); - void fullScreenChanged(); -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p_p.h deleted file mode 100644 index ab9a9762..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p_p.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include - -#if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(window) && (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))) - -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(border_painter) -class QuickWindowBorder; -#endif - -class FramelessQuickApplicationWindow; -class FRAMELESSHELPER_QUICK_API FramelessQuickApplicationWindowPrivate : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessQuickApplicationWindow) - -public: - explicit FramelessQuickApplicationWindowPrivate(FramelessQuickApplicationWindow *q); - ~FramelessQuickApplicationWindowPrivate() override; - - QQuickWindow::Visibility savedVisibility = QQuickWindow::Windowed; -#if FRAMELESSHELPER_CONFIG(border_painter) - QuickWindowBorder *windowBorder = nullptr; -#endif -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/framelessquickhelper_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/framelessquickhelper_p.h deleted file mode 100644 index 03cce3c3..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/framelessquickhelper_p.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QQuickItem; -QT_END_NAMESPACE - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(mica_material) -class QuickMicaMaterial; -#endif -#if FRAMELESSHELPER_CONFIG(border_painter) -class QuickWindowBorder; -#endif - -class FramelessQuickHelper; -class FRAMELESSHELPER_QUICK_API FramelessQuickHelperPrivate : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessQuickHelper) - -public: - explicit FramelessQuickHelperPrivate(FramelessQuickHelper *q); - ~FramelessQuickHelperPrivate() override; - - void attach(); - void detach(); - - void emitSignalForAllInstances(const char *signal); - - void setProperty(const char *name, const QVariant &value); - Q_NODISCARD QVariant getProperty(const char *name, const QVariant &defaultValue = {}); - -#if FRAMELESSHELPER_CONFIG(mica_material) - Q_NODISCARD QuickMicaMaterial *findOrCreateMicaMaterial() const; -#endif -#if FRAMELESSHELPER_CONFIG(border_painter) - Q_NODISCARD QuickWindowBorder *findOrCreateWindowBorder() const; -#endif - - Q_NODISCARD static FramelessQuickHelper *findOrCreateFramelessHelper(QObject *object); - - void repaintAllChildren(); - Q_INVOKABLE void doRepaintAllChildren(); - - Q_NODISCARD quint32 readyWaitTime() const; - void setReadyWaitTime(const quint32 time); - - Q_NODISCARD QRect mapItemGeometryToScene(const QQuickItem * const item) const; - Q_NODISCARD bool isInSystemButtons(const QPoint &pos, QuickGlobal::SystemButtonType *button) const; - Q_NODISCARD bool isInTitleBarDraggableArea(const QPoint &pos) const; - Q_NODISCARD bool shouldIgnoreMouseEvents(const QPoint &pos) const; - void setSystemButtonState(const QuickGlobal::SystemButtonType button, const QuickGlobal::ButtonState state); - void rebindWindow(); - - QColor savedWindowBackgroundColor = {}; - bool blurBehindWindowEnabled = false; - std::optional extendIntoTitleBar = std::nullopt; - bool qpaReady = false; - quint32 qpaWaitTime = 0; - QTimer repaintTimer{}; -}; - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/framelessquickwindow_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/framelessquickwindow_p.h deleted file mode 100644 index 9052cd0e..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/framelessquickwindow_p.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include - -#if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(window)) - -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FramelessQuickWindowPrivate; -class FRAMELESSHELPER_QUICK_API FramelessQuickWindow : public QQuickWindowQmlImpl -{ - Q_OBJECT - FRAMELESSHELPER_PUBLIC_QT_CLASS(FramelessQuickWindow) -#ifdef QML_NAMED_ELEMENT - QML_NAMED_ELEMENT(FramelessWindow) -#endif - Q_PROPERTY(bool hidden READ isHidden NOTIFY hiddenChanged FINAL) - Q_PROPERTY(bool normal READ isNormal NOTIFY normalChanged FINAL) - Q_PROPERTY(bool minimized READ isMinimized NOTIFY minimizedChanged FINAL) - Q_PROPERTY(bool maximized READ isMaximized NOTIFY maximizedChanged FINAL) - Q_PROPERTY(bool zoomed READ isZoomed NOTIFY zoomedChanged FINAL) - Q_PROPERTY(bool fullScreen READ isFullScreen NOTIFY fullScreenChanged FINAL) - -public: - explicit FramelessQuickWindow(QWindow *parent = nullptr); - ~FramelessQuickWindow() override; - - Q_NODISCARD bool isHidden() const; - Q_NODISCARD bool isNormal() const; - Q_NODISCARD bool isMinimized() const; - Q_NODISCARD bool isMaximized() const; - Q_NODISCARD bool isZoomed() const; - Q_NODISCARD bool isFullScreen() const; - -public Q_SLOTS: - void showMinimized2(); - void toggleMaximized(); - void toggleFullScreen(); - -protected: - void classBegin() override; - void componentComplete() override; - -Q_SIGNALS: - void hiddenChanged(); - void normalChanged(); - void minimizedChanged(); - void maximizedChanged(); - void zoomedChanged(); - void fullScreenChanged(); -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/framelessquickwindow_p_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/framelessquickwindow_p_p.h deleted file mode 100644 index e645be54..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/framelessquickwindow_p_p.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include - -#if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(window)) - -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(border_painter) -class QuickWindowBorder; -#endif - -class FramelessQuickWindow; -class FRAMELESSHELPER_QUICK_API FramelessQuickWindowPrivate : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessQuickWindow) - -public: - explicit FramelessQuickWindowPrivate(FramelessQuickWindow *q); - ~FramelessQuickWindowPrivate() override; - - QQuickWindow::Visibility savedVisibility = QQuickWindow::Windowed; -#if FRAMELESSHELPER_CONFIG(border_painter) - QuickWindowBorder *windowBorder = nullptr; -#endif -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/quickimageitem_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/quickimageitem_p.h deleted file mode 100644 index 9e0a5f9c..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/quickimageitem_p.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FRAMELESSHELPER_QUICK_API QuickImageItem : public QQuickPaintedItem -{ - Q_OBJECT - FRAMELESSHELPER_QT_CLASS(QuickImageItem) -#ifdef QML_NAMED_ELEMENT - QML_NAMED_ELEMENT(ImageItem) -#endif - - Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged FINAL) - -public: - explicit QuickImageItem(QQuickItem *parent = nullptr); - ~QuickImageItem() override; - - void paint(QPainter *painter) override; - - Q_NODISCARD QVariant source() const; - void setSource(const QVariant &value); - -Q_SIGNALS: - void sourceChanged(); - -protected: - void classBegin() override; - void componentComplete() override; - -private: - void fromUrl(const QUrl &value, QPainter *painter) const; - void fromString(const QString &value, QPainter *painter) const; - void fromImage(const QImage &value, QPainter *painter) const; - void fromPixmap(const QPixmap &value, QPainter *painter) const; - void fromIcon(const QIcon &value, QPainter *painter) const; - Q_NODISCARD QRectF paintArea() const; - -private: - QVariant m_source = {}; -}; - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/quickmicamaterial_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/quickmicamaterial_p.h deleted file mode 100644 index ea56a117..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/quickmicamaterial_p.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include - -#if FRAMELESSHELPER_CONFIG(mica_material) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class MicaMaterial; - -class QuickMicaMaterial; -class FRAMELESSHELPER_QUICK_API QuickMicaMaterialPrivate : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_PRIVATE_QT_CLASS(QuickMicaMaterial) - -public: - explicit QuickMicaMaterialPrivate(QuickMicaMaterial *q); - ~QuickMicaMaterialPrivate() override; - - Q_SLOT void rebindWindow(); - - void initialize(); - - QMetaObject::Connection rootWindowXChangedConnection = {}; - QMetaObject::Connection rootWindowYChangedConnection = {}; - QMetaObject::Connection rootWindowActiveChangedConnection = {}; - MicaMaterial *micaMaterial = nullptr; -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/quickstandardsystembutton_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/quickstandardsystembutton_p.h deleted file mode 100644 index b0bc75dd..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/quickstandardsystembutton_p.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include - -#if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(system_button) && (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))) - -#include - -QT_BEGIN_NAMESPACE -class QQuickText; -class QQuickRectangle; -QT_END_NAMESPACE - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FRAMELESSHELPER_QUICK_API QuickStandardSystemButton : public QQuickButton -{ - Q_OBJECT - FRAMELESSHELPER_QT_CLASS(QuickStandardSystemButton) -#ifdef QML_NAMED_ELEMENT - QML_NAMED_ELEMENT(StandardSystemButton) -#endif - Q_PROPERTY(QuickGlobal::SystemButtonType buttonType READ buttonType WRITE setButtonType NOTIFY buttonTypeChanged FINAL) - Q_PROPERTY(QString glyph READ glyph WRITE setGlyph NOTIFY glyphChanged FINAL) - Q_PROPERTY(QColor hoverColor READ hoverColor WRITE setHoverColor NOTIFY hoverColorChanged FINAL) - Q_PROPERTY(QColor pressColor READ pressColor WRITE setPressColor NOTIFY pressColorChanged FINAL) - Q_PROPERTY(QColor normalColor READ normalColor WRITE setNormalColor NOTIFY normalColorChanged FINAL) - Q_PROPERTY(QColor activeForegroundColor READ activeForegroundColor WRITE setActiveForegroundColor NOTIFY activeForegroundColorChanged FINAL) - Q_PROPERTY(QColor inactiveForegroundColor READ inactiveForegroundColor WRITE setInactiveForegroundColor NOTIFY inactiveForegroundColorChanged FINAL) - Q_PROPERTY(qreal glyphSize READ glyphSize WRITE setGlyphSize NOTIFY glyphChanged FINAL) - -public: - explicit QuickStandardSystemButton(QQuickItem *parent = nullptr); - explicit QuickStandardSystemButton(const QuickGlobal::SystemButtonType type, QQuickItem *parent = nullptr); - ~QuickStandardSystemButton() override; - - Q_NODISCARD QuickGlobal::SystemButtonType buttonType() const; - Q_NODISCARD QString glyph() const; - Q_NODISCARD QColor normalColor() const; - Q_NODISCARD QColor hoverColor() const; - Q_NODISCARD QColor pressColor() const; - Q_NODISCARD QColor activeForegroundColor() const; - Q_NODISCARD QColor inactiveForegroundColor() const; - Q_NODISCARD qreal glyphSize() const; - -public Q_SLOTS: - void updateColor(); - void setButtonType(const QuickGlobal::SystemButtonType type); - void setGlyph(const QString &value); - void setNormalColor(const QColor &value); - void setHoverColor(const QColor &value); - void setPressColor(const QColor &value); - void setActiveForegroundColor(const QColor &value); - void setInactiveForegroundColor(const QColor &value); - void setGlyphSize(const qreal value); - -protected: - void classBegin() override; - void componentComplete() override; - -private: - void initialize(); - -Q_SIGNALS: - void buttonTypeChanged(); - void glyphChanged(); - void normalColorChanged(); - void hoverColorChanged(); - void pressColorChanged(); - void activeForegroundColorChanged(); - void inactiveForegroundColorChanged(); - void glyphSizeChanged(); - -private: - QQuickText *m_contentItem = nullptr; - QQuickRectangle *m_backgroundItem = nullptr; - QuickGlobal::SystemButtonType m_buttonType = QuickGlobal::SystemButtonType::Unknown; - QString m_glyph = {}; - QColor m_normalColor = {}; - QColor m_hoverColor = {}; - QColor m_pressColor = {}; - QColor m_activeForegroundColor = {}; - QColor m_inactiveForegroundColor = {}; -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/quickstandardtitlebar_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/quickstandardtitlebar_p.h deleted file mode 100644 index 2d8681f8..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/quickstandardtitlebar_p.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include - -#if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(titlebar) && (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))) - -#include -#if FRAMELESSHELPER_CONFIG(system_button) -# include -#endif -#include -#include - -QT_BEGIN_NAMESPACE -class QQuickRow; -QT_END_NAMESPACE - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class QuickImageItem; - -class FRAMELESSHELPER_QUICK_API QuickStandardTitleBar : public QQuickRectangle -{ - Q_OBJECT - FRAMELESSHELPER_QT_CLASS(QuickStandardTitleBar) -#ifdef QML_NAMED_ELEMENT - QML_NAMED_ELEMENT(StandardTitleBar) -#endif // QML_NAMED_ELEMENT - Q_PROPERTY(Qt::Alignment titleLabelAlignment READ titleLabelAlignment WRITE setTitleLabelAlignment NOTIFY titleLabelAlignmentChanged FINAL) - Q_PROPERTY(QQuickLabel* titleLabel READ titleLabel CONSTANT FINAL) -#if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button)) - Q_PROPERTY(QuickStandardSystemButton* minimizeButton READ minimizeButton CONSTANT FINAL) - Q_PROPERTY(QuickStandardSystemButton* maximizeButton READ maximizeButton CONSTANT FINAL) - Q_PROPERTY(QuickStandardSystemButton* closeButton READ closeButton CONSTANT FINAL) -#endif // Q_OS_MACOS - Q_PROPERTY(bool extended READ isExtended WRITE setExtended NOTIFY extendedChanged FINAL) - Q_PROPERTY(bool hideWhenClose READ isHideWhenClose WRITE setHideWhenClose NOTIFY hideWhenCloseChanged FINAL) - Q_PROPERTY(QuickChromePalette* chromePalette READ chromePalette CONSTANT FINAL) - Q_PROPERTY(QSizeF windowIconSize READ windowIconSize WRITE setWindowIconSize NOTIFY windowIconSizeChanged FINAL) - Q_PROPERTY(bool windowIconVisible READ windowIconVisible WRITE setWindowIconVisible NOTIFY windowIconVisibleChanged FINAL) - Q_PROPERTY(QVariant windowIcon READ windowIcon WRITE setWindowIcon NOTIFY windowIconChanged FINAL) - -public: - explicit QuickStandardTitleBar(QQuickItem *parent = nullptr); - ~QuickStandardTitleBar() override; - - Q_NODISCARD Qt::Alignment titleLabelAlignment() const; - void setTitleLabelAlignment(const Qt::Alignment value); - - Q_NODISCARD QQuickLabel *titleLabel() const; -#if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button)) - Q_NODISCARD QuickStandardSystemButton *minimizeButton() const; - Q_NODISCARD QuickStandardSystemButton *maximizeButton() const; - Q_NODISCARD QuickStandardSystemButton *closeButton() const; -#endif // Q_OS_MACOS - - Q_NODISCARD bool isExtended() const; - void setExtended(const bool value); - - Q_NODISCARD bool isHideWhenClose() const; - void setHideWhenClose(const bool value); - - Q_NODISCARD QuickChromePalette *chromePalette() const; - - Q_NODISCARD QSizeF windowIconSize() const; - void setWindowIconSize(const QSizeF &value); - - Q_NODISCARD bool windowIconVisible() const; - void setWindowIconVisible(const bool value); - - Q_NODISCARD QVariant windowIcon() const; - void setWindowIcon(const QVariant &value); - -protected: - void itemChange(const ItemChange change, const ItemChangeData &value) override; - Q_NODISCARD bool eventFilter(QObject *object, QEvent *event) override; - void classBegin() override; - void componentComplete() override; - -private Q_SLOTS: - void updateMaximizeButton(); - void updateTitleLabelText(); - void updateTitleBarColor(); - void updateChromeButtonColor(); - void clickMinimizeButton(); - void clickMaximizeButton(); - void clickCloseButton(); - void retranslateUi(); - void updateWindowIcon(); - -Q_SIGNALS: - void titleLabelAlignmentChanged(); - void extendedChanged(); - void hideWhenCloseChanged(); - void windowIconSizeChanged(); - void windowIconVisibleChanged(); - void windowIconChanged(); - -private: - void initialize(); - void updateAll(); - Q_NODISCARD bool mouseEventHandler(QMouseEvent *event); - Q_NODISCARD QRect windowIconRect() const; - Q_NODISCARD bool isInTitleBarIconArea(const QPoint &pos) const; - Q_NODISCARD bool windowIconVisible_real() const; - -private: - Qt::Alignment m_labelAlignment = {}; - QuickImageItem *m_windowIcon = nullptr; - QQuickLabel *m_windowTitleLabel = nullptr; -#if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button)) - QQuickRow *m_systemButtonsRow = nullptr; - QuickStandardSystemButton *m_minimizeButton = nullptr; - QuickStandardSystemButton *m_maximizeButton = nullptr; - QuickStandardSystemButton *m_closeButton = nullptr; -#endif // Q_OS_MACOS - QMetaObject::Connection m_windowStateChangeConnection = {}; - QMetaObject::Connection m_windowActiveChangeConnection = {}; - QMetaObject::Connection m_windowTitleChangeConnection = {}; - bool m_extended = false; - bool m_hideWhenClose = false; - QuickChromePalette *m_chromePalette = nullptr; - bool m_closeTriggered = false; -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/quickwindowborder_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/quickwindowborder_p.h deleted file mode 100644 index 74dd31fd..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/private/quickwindowborder_p.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include - -#if FRAMELESSHELPER_CONFIG(border_painter) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class WindowBorderPainter; - -class QuickWindowBorder; -class FRAMELESSHELPER_QUICK_API QuickWindowBorderPrivate : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_PRIVATE_QT_CLASS(QuickWindowBorder) - -public: - explicit QuickWindowBorderPrivate(QuickWindowBorder *q); - ~QuickWindowBorderPrivate() override; - - Q_SLOT void update(); - - void initialize(); - void rebindWindow(); - - WindowBorderPainter *borderPainter = nullptr; - QMetaObject::Connection activeChangeConnection = {}; - QMetaObject::Connection visibilityChangeConnection = {}; -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/quickchromepalette.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/quickchromepalette.h deleted file mode 100644 index 2d1c91b8..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/quickchromepalette.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include -#include - -#if FRAMELESSHELPER_CONFIG(titlebar) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FRAMELESSHELPER_QUICK_API QuickChromePalette : public ChromePalette, public QQmlParserStatus -{ - Q_OBJECT - FRAMELESSHELPER_QT_CLASS(QuickChromePalette) - Q_INTERFACES(QQmlParserStatus) -#ifdef QML_ANONYMOUS - QML_ANONYMOUS -#endif - -public: - explicit QuickChromePalette(QObject *parent = nullptr); - ~QuickChromePalette() override; - -protected: - void classBegin() override; - void componentComplete() override; -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/quickmicamaterial.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/quickmicamaterial.h deleted file mode 100644 index 69abe6ef..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/quickmicamaterial.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include -#include - -#if FRAMELESSHELPER_CONFIG(mica_material) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class QuickMicaMaterialPrivate; -class FRAMELESSHELPER_QUICK_API QuickMicaMaterial : public QQuickPaintedItem -{ - Q_OBJECT - FRAMELESSHELPER_PUBLIC_QT_CLASS(QuickMicaMaterial) -#ifdef QML_NAMED_ELEMENT - QML_NAMED_ELEMENT(MicaMaterial) -#endif - - Q_PROPERTY(QColor tintColor READ tintColor WRITE setTintColor NOTIFY tintColorChanged FINAL) - Q_PROPERTY(qreal tintOpacity READ tintOpacity WRITE setTintOpacity NOTIFY tintOpacityChanged FINAL) - Q_PROPERTY(QColor fallbackColor READ fallbackColor WRITE setFallbackColor NOTIFY fallbackColorChanged FINAL) - Q_PROPERTY(qreal noiseOpacity READ noiseOpacity WRITE setNoiseOpacity NOTIFY noiseOpacityChanged FINAL) - Q_PROPERTY(bool fallbackEnabled READ isFallbackEnabled WRITE setFallbackEnabled NOTIFY fallbackEnabledChanged FINAL) - -public: - explicit QuickMicaMaterial(QQuickItem *parent = nullptr); - ~QuickMicaMaterial() override; - - void paint(QPainter *painter) override; - - Q_NODISCARD QColor tintColor() const; - void setTintColor(const QColor &value); - - Q_NODISCARD qreal tintOpacity() const; - void setTintOpacity(const qreal value); - - Q_NODISCARD QColor fallbackColor() const; - void setFallbackColor(const QColor &value); - - Q_NODISCARD qreal noiseOpacity() const; - void setNoiseOpacity(const qreal value); - - Q_NODISCARD bool isFallbackEnabled() const; - void setFallbackEnabled(const bool value); - -Q_SIGNALS: - void tintColorChanged(); - void tintOpacityChanged(); - void fallbackColorChanged(); - void noiseOpacityChanged(); - void fallbackEnabledChanged(); - -protected: - void itemChange(const ItemChange change, const ItemChangeData &value) override; - void classBegin() override; - void componentComplete() override; -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/quickwindowborder.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/quickwindowborder.h deleted file mode 100644 index d3a61460..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Quick/quickwindowborder.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include -#include - -#if FRAMELESSHELPER_CONFIG(border_painter) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class QuickWindowBorderPrivate; -class FRAMELESSHELPER_QUICK_API QuickWindowBorder : public QQuickPaintedItem -{ - Q_OBJECT - FRAMELESSHELPER_PUBLIC_QT_CLASS(QuickWindowBorder) -#ifdef QML_NAMED_ELEMENT - QML_NAMED_ELEMENT(WindowBorder) -#endif - - Q_PROPERTY(qreal thickness READ thickness WRITE setThickness NOTIFY thicknessChanged FINAL) - Q_PROPERTY(QuickGlobal::WindowEdges edges READ edges WRITE setEdges NOTIFY edgesChanged FINAL) - Q_PROPERTY(QColor activeColor READ activeColor WRITE setActiveColor NOTIFY activeColorChanged FINAL) - Q_PROPERTY(QColor inactiveColor READ inactiveColor WRITE setInactiveColor NOTIFY inactiveColorChanged FINAL) - - Q_PROPERTY(qreal nativeThickness READ nativeThickness NOTIFY nativeBorderChanged FINAL) - Q_PROPERTY(QuickGlobal::WindowEdges nativeEdges READ nativeEdges NOTIFY nativeBorderChanged FINAL) - Q_PROPERTY(QColor nativeActiveColor READ nativeActiveColor NOTIFY nativeBorderChanged FINAL) - Q_PROPERTY(QColor nativeInactiveColor READ nativeInactiveColor NOTIFY nativeBorderChanged FINAL) - -public: - explicit QuickWindowBorder(QQuickItem *parent = nullptr); - ~QuickWindowBorder() override; - - void paint(QPainter *painter) override; - - Q_NODISCARD qreal thickness() const; - Q_NODISCARD QuickGlobal::WindowEdges edges() const; - Q_NODISCARD QColor activeColor() const; - Q_NODISCARD QColor inactiveColor() const; - - Q_NODISCARD qreal nativeThickness() const; - Q_NODISCARD QuickGlobal::WindowEdges nativeEdges() const; - Q_NODISCARD QColor nativeActiveColor() const; - Q_NODISCARD QColor nativeInactiveColor() const; - -public Q_SLOTS: - void setThickness(const qreal value); - void setEdges(const QuickGlobal::WindowEdges value); - void setActiveColor(const QColor &value); - void setInactiveColor(const QColor &value); - -protected: - void itemChange(const ItemChange change, const ItemChangeData &value) override; - void classBegin() override; - void componentComplete() override; - -Q_SIGNALS: - void thicknessChanged(); - void edgesChanged(); - void activeColorChanged(); - void inactiveColorChanged(); - void nativeBorderChanged(); -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/FramelessDialog b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/FramelessDialog deleted file mode 100644 index cae195b1..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/FramelessDialog +++ /dev/null @@ -1 +0,0 @@ -#include "framelessdialog.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/FramelessMainWindow b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/FramelessMainWindow deleted file mode 100644 index 2e81926b..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/FramelessMainWindow +++ /dev/null @@ -1 +0,0 @@ -#include "framelessmainwindow.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/FramelessWidget b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/FramelessWidget deleted file mode 100644 index d2787844..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/FramelessWidget +++ /dev/null @@ -1 +0,0 @@ -#include "framelesswidget.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/FramelessWidgetsHelper b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/FramelessWidgetsHelper deleted file mode 100644 index 5dd54dfe..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/FramelessWidgetsHelper +++ /dev/null @@ -1 +0,0 @@ -#include "framelesswidgetshelper.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/Global b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/Global deleted file mode 100644 index 9737cb63..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/Global +++ /dev/null @@ -1 +0,0 @@ -#include "framelesshelperwidgets_global.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/StandardSystemButton b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/StandardSystemButton deleted file mode 100644 index 43b04569..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/StandardSystemButton +++ /dev/null @@ -1 +0,0 @@ -#include "standardsystembutton.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/StandardTitleBar b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/StandardTitleBar deleted file mode 100644 index b693cafd..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/StandardTitleBar +++ /dev/null @@ -1 +0,0 @@ -#include "standardtitlebar.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/framelessdialog.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/framelessdialog.h deleted file mode 100644 index 1060969a..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/framelessdialog.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include -#include - -#if FRAMELESSHELPER_CONFIG(window) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FramelessDialogPrivate; -class FRAMELESSHELPER_WIDGETS_API FramelessDialog : public QDialog -{ - Q_OBJECT - FRAMELESSHELPER_PUBLIC_QT_CLASS(FramelessDialog) - -public: - explicit FramelessDialog(QWidget *parent = nullptr); - ~FramelessDialog() override; -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/framelesshelperwidgets_global.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/framelesshelperwidgets_global.h deleted file mode 100644 index db8aa84d..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/framelesshelperwidgets_global.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include - -#ifndef FRAMELESSHELPER_WIDGETS_API -# if FRAMELESSHELPER_CONFIG(static_build) -# define FRAMELESSHELPER_WIDGETS_API -# else -# ifdef FRAMELESSHELPER_WIDGETS_LIBRARY -# define FRAMELESSHELPER_WIDGETS_API Q_DECL_EXPORT -# else -# define FRAMELESSHELPER_WIDGETS_API Q_DECL_IMPORT -# endif -# endif -#endif - -FRAMELESSHELPER_BEGIN_NAMESPACE - -FRAMELESSHELPER_WIDGETS_API void FramelessHelperWidgetsInitialize(); -FRAMELESSHELPER_WIDGETS_API void FramelessHelperWidgetsUninitialize(); - -namespace FramelessHelper::Widgets -{ -inline void initialize() { FramelessHelperWidgetsInitialize(); } -inline void uninitialize() { FramelessHelperWidgetsUninitialize(); } -} // namespace FramelessHelper::Widgets - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/framelessmainwindow.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/framelessmainwindow.h deleted file mode 100644 index 36913405..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/framelessmainwindow.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include -#include - -#if FRAMELESSHELPER_CONFIG(window) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FramelessMainWindowPrivate; -class FRAMELESSHELPER_WIDGETS_API FramelessMainWindow : public QMainWindow -{ - Q_OBJECT - FRAMELESSHELPER_PUBLIC_QT_CLASS(FramelessMainWindow) - Q_PROPERTY(bool hidden READ isHidden NOTIFY hiddenChanged FINAL) - Q_PROPERTY(bool normal READ isNormal NOTIFY normalChanged FINAL) - Q_PROPERTY(bool zoomed READ isZoomed NOTIFY zoomedChanged FINAL) - -public: - explicit FramelessMainWindow(QWidget *parent = nullptr, const Qt::WindowFlags flags = {}); - ~FramelessMainWindow() override; - - Q_NODISCARD bool isNormal() const; - Q_NODISCARD bool isZoomed() const; - -public Q_SLOTS: - void toggleMaximized(); - void toggleFullScreen(); - -Q_SIGNALS: - void hiddenChanged(); - void normalChanged(); - void zoomedChanged(); -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/framelesswidget.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/framelesswidget.h deleted file mode 100644 index cc55c165..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/framelesswidget.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include -#include - -#if FRAMELESSHELPER_CONFIG(window) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FramelessWidgetPrivate; -class FRAMELESSHELPER_WIDGETS_API FramelessWidget : public QWidget -{ - Q_OBJECT - FRAMELESSHELPER_PUBLIC_QT_CLASS(FramelessWidget) - Q_PROPERTY(bool hidden READ isHidden NOTIFY hiddenChanged FINAL) - Q_PROPERTY(bool normal READ isNormal NOTIFY normalChanged FINAL) - Q_PROPERTY(bool zoomed READ isZoomed NOTIFY zoomedChanged FINAL) - -public: - explicit FramelessWidget(QWidget *parent = nullptr); - ~FramelessWidget() override; - - Q_NODISCARD bool isNormal() const; - Q_NODISCARD bool isZoomed() const; - -public Q_SLOTS: - void toggleMaximized(); - void toggleFullScreen(); - -Q_SIGNALS: - void hiddenChanged(); - void normalChanged(); - void zoomedChanged(); -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/framelesswidgetshelper.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/framelesswidgetshelper.h deleted file mode 100644 index 16f68cd8..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/framelesswidgetshelper.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(mica_material) -class MicaMaterial; -#endif -#if FRAMELESSHELPER_CONFIG(border_painter) -class WindowBorderPainter; -#endif - -class FramelessWidgetsHelperPrivate; -class FRAMELESSHELPER_WIDGETS_API FramelessWidgetsHelper : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_PUBLIC_QT_CLASS(FramelessWidgetsHelper) - Q_PROPERTY(QWidget* titleBarWidget READ titleBarWidget WRITE setTitleBarWidget NOTIFY titleBarWidgetChanged FINAL) - Q_PROPERTY(bool windowFixedSize READ isWindowFixedSize WRITE setWindowFixedSize NOTIFY windowFixedSizeChanged FINAL) - Q_PROPERTY(bool blurBehindWindowEnabled READ isBlurBehindWindowEnabled WRITE setBlurBehindWindowEnabled NOTIFY blurBehindWindowEnabledChanged FINAL) - Q_PROPERTY(QWidget* window READ window NOTIFY windowChanged FINAL) - Q_PROPERTY(bool extendsContentIntoTitleBar READ isContentExtendedIntoTitleBar WRITE extendsContentIntoTitleBar NOTIFY extendsContentIntoTitleBarChanged FINAL) - -public: - explicit FramelessWidgetsHelper(QObject *parent = nullptr); - ~FramelessWidgetsHelper() override; - - Q_NODISCARD static FramelessWidgetsHelper *get(QObject *object); - - Q_NODISCARD QWidget *titleBarWidget() const; - Q_NODISCARD bool isWindowFixedSize() const; - Q_NODISCARD bool isBlurBehindWindowEnabled() const; - Q_NODISCARD QWidget *window() const; - Q_NODISCARD bool isContentExtendedIntoTitleBar() const; - -#if FRAMELESSHELPER_CONFIG(mica_material) - Q_NODISCARD MicaMaterial *micaMaterial() const; -#endif -#if FRAMELESSHELPER_CONFIG(border_painter) - Q_NODISCARD WindowBorderPainter *windowBorder() const; -#endif - - Q_NODISCARD bool isReady() const; - void waitForReady(); - -public Q_SLOTS: - void extendsContentIntoTitleBar(const bool value = true); - - void setTitleBarWidget(QWidget *widget); - void setSystemButton(QWidget *widget, const Global::SystemButtonType buttonType); - void setHitTestVisible(QWidget *widget, const bool visible = true); - void setHitTestVisible(const QRect &rect, const bool visible = true); - void setHitTestVisible(QObject *object, const bool visible = true); - - void showSystemMenu(const QPoint &pos); - void windowStartSystemMove2(const QPoint &pos); - void windowStartSystemResize2(const Qt::Edges edges, const QPoint &pos); - - void moveWindowToDesktopCenter(); - void bringWindowToFront(); - void setWindowFixedSize(const bool value); - void setBlurBehindWindowEnabled(const bool value); - -Q_SIGNALS: - void extendsContentIntoTitleBarChanged(); - void titleBarWidgetChanged(); - void windowFixedSizeChanged(); - void blurBehindWindowEnabledChanged(); - void windowChanged(); - void ready(); -}; - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/private/framelessdialog_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/private/framelessdialog_p.h deleted file mode 100644 index 4ca5789e..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/private/framelessdialog_p.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include - -#if FRAMELESSHELPER_CONFIG(window) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class WidgetsSharedHelper; - -class FramelessDialog; -class FRAMELESSHELPER_WIDGETS_API FramelessDialogPrivate : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessDialog) - -public: - explicit FramelessDialogPrivate(FramelessDialog *q); - ~FramelessDialogPrivate() override; - - WidgetsSharedHelper *sharedHelper = nullptr; -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/private/framelessmainwindow_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/private/framelessmainwindow_p.h deleted file mode 100644 index 0beff06d..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/private/framelessmainwindow_p.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include - -#if FRAMELESSHELPER_CONFIG(window) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class WidgetsSharedHelper; - -class FramelessMainWindow; -class FRAMELESSHELPER_WIDGETS_API FramelessMainWindowPrivate : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessMainWindow) - -public: - explicit FramelessMainWindowPrivate(FramelessMainWindow *q); - ~FramelessMainWindowPrivate() override; - - Qt::WindowState savedWindowState = Qt::WindowNoState; - WidgetsSharedHelper *sharedHelper = nullptr; -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/private/framelesswidget_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/private/framelesswidget_p.h deleted file mode 100644 index aebb0545..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/private/framelesswidget_p.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include - -#if FRAMELESSHELPER_CONFIG(window) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class WidgetsSharedHelper; - -class FramelessWidget; -class FRAMELESSHELPER_WIDGETS_API FramelessWidgetPrivate : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessWidget) - -public: - explicit FramelessWidgetPrivate(FramelessWidget *q); - ~FramelessWidgetPrivate() override; - - Qt::WindowState savedWindowState = Qt::WindowNoState; - WidgetsSharedHelper *sharedHelper = nullptr; -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/private/framelesswidgetshelper_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/private/framelesswidgetshelper_p.h deleted file mode 100644 index 43e50fac..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/private/framelesswidgetshelper_p.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(mica_material) -class MicaMaterial; -#endif -#if FRAMELESSHELPER_CONFIG(border_painter) -class WindowBorderPainter; -#endif -class WidgetsSharedHelper; - -class FramelessWidgetsHelper; -class FRAMELESSHELPER_WIDGETS_API FramelessWidgetsHelperPrivate : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessWidgetsHelper) - -public: - explicit FramelessWidgetsHelperPrivate(FramelessWidgetsHelper *q); - ~FramelessWidgetsHelperPrivate() override; - - void attach(); - void detach(); - - void emitSignalForAllInstances(const char *signal); - - void setProperty(const char *name, const QVariant &value); - Q_NODISCARD QVariant getProperty(const char *name, const QVariant &defaultValue = {}); - -#if FRAMELESSHELPER_CONFIG(mica_material) - Q_NODISCARD MicaMaterial *getMicaMaterialIfAny() const; -#endif -#if FRAMELESSHELPER_CONFIG(border_painter) - Q_NODISCARD WindowBorderPainter *getWindowBorderIfAny() const; -#endif - - Q_NODISCARD static WidgetsSharedHelper *findOrCreateSharedHelper(QWidget *window); - Q_NODISCARD static FramelessWidgetsHelper *findOrCreateFramelessHelper(QObject *object); - - void repaintAllChildren(); - Q_INVOKABLE void doRepaintAllChildren(); - - Q_NODISCARD quint32 readyWaitTime() const; - void setReadyWaitTime(const quint32 time); - - Q_NODISCARD QRect mapWidgetGeometryToScene(const QWidget * const widget) const; - Q_NODISCARD bool isInSystemButtons(const QPoint &pos, Global::SystemButtonType *button) const; - Q_NODISCARD bool isInTitleBarDraggableArea(const QPoint &pos) const; - Q_NODISCARD bool shouldIgnoreMouseEvents(const QPoint &pos) const; - void setSystemButtonState(const Global::SystemButtonType button, const Global::ButtonState state); - Q_NODISCARD QWidget *findTopLevelWindow() const; - - QColor savedWindowBackgroundColor = {}; - bool blurBehindWindowEnabled = false; - QPointer window; // Initializing it with nullptr causes compilation errors on MinGW toolchain and old Qt versions (< 5.15). - bool qpaReady = false; - QSizePolicy savedSizePolicy = {}; - quint32 qpaWaitTime = 0; - QTimer repaintTimer{}; -}; - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/private/standardsystembutton_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/private/standardsystembutton_p.h deleted file mode 100644 index 976c56f5..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/private/standardsystembutton_p.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include - -#if FRAMELESSHELPER_CONFIG(system_button) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class StandardSystemButton; -class FRAMELESSHELPER_WIDGETS_API StandardSystemButtonPrivate : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_PRIVATE_QT_CLASS(StandardSystemButton) - -public: - explicit StandardSystemButtonPrivate(StandardSystemButton *q); - ~StandardSystemButtonPrivate() override; - - Q_NODISCARD static QSize getRecommendedButtonSize(); - - Global::SystemButtonType buttonType = Global::SystemButtonType::Unknown; - QString glyph = {}; - QColor hoverColor = {}; - QColor pressColor = {}; - QColor normalColor = {}; - QColor activeForegroundColor = {}; - QColor inactiveForegroundColor = {}; - bool active = false; - std::optional glyphSize = std::nullopt; -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/private/standardtitlebar_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/private/standardtitlebar_p.h deleted file mode 100644 index 0ea8bcd5..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/private/standardtitlebar_p.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QMouseEvent; -QT_END_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(titlebar) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(system_button) -class StandardSystemButton; -#endif -class ChromePalette; - -class StandardTitleBar; -class FRAMELESSHELPER_WIDGETS_API StandardTitleBarPrivate : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_PRIVATE_QT_CLASS(StandardTitleBar) - -public: - struct FontMetrics - { - int width = 0; - int height = 0; - int ascent = 0; - }; - - explicit StandardTitleBarPrivate(StandardTitleBar *q); - ~StandardTitleBarPrivate() override; - - Q_NODISCARD QRect windowIconRect() const; - Q_NODISCARD bool windowIconVisible_real() const; - Q_NODISCARD bool isInTitleBarIconArea(const QPoint &pos) const; - - Q_NODISCARD QFont defaultFont() const; - Q_NODISCARD FontMetrics titleLabelSize() const; - Q_NODISCARD int titleLabelMaxWidth() const; - - Q_SLOT void updateMaximizeButton(); - Q_SLOT void updateTitleBarColor(); - Q_SLOT void updateChromeButtonColor(); - Q_SLOT void retranslateUi(); - - Q_NODISCARD bool mouseEventHandler(QMouseEvent *event); - - void initialize(); - -#if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button)) - StandardSystemButton *minimizeButton = nullptr; - StandardSystemButton *maximizeButton = nullptr; - StandardSystemButton *closeButton = nullptr; -#endif - QPointer window; // Initializing it with nullptr causes compilation errors on MinGW toolchain and old Qt versions (< 5.15). - bool extended = false; - Qt::Alignment labelAlignment = {}; - bool hideWhenClose = false; - ChromePalette *chromePalette = nullptr; - bool titleLabelVisible = true; - std::optional windowIconSize = std::nullopt; - bool windowIconVisible = false; - std::optional titleFont = std::nullopt; - bool closeTriggered = false; - -protected: - bool eventFilter(QObject *object, QEvent *event) override; -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/private/widgetssharedhelper_p.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/private/widgetssharedhelper_p.h deleted file mode 100644 index 6b567789..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/private/widgetssharedhelper_p.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(mica_material) -class MicaMaterial; -#endif -#if FRAMELESSHELPER_CONFIG(border_painter) -class WindowBorderPainter; -#endif - -class FRAMELESSHELPER_WIDGETS_API WidgetsSharedHelper : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_QT_CLASS(WidgetsSharedHelper) -#if FRAMELESSHELPER_CONFIG(mica_material) - Q_PROPERTY(bool micaEnabled READ isMicaEnabled WRITE setMicaEnabled NOTIFY micaEnabledChanged FINAL) -#endif - -public: - explicit WidgetsSharedHelper(QObject *parent = nullptr); - ~WidgetsSharedHelper() override; - - void setup(QWidget *widget); - -#if FRAMELESSHELPER_CONFIG(mica_material) - Q_NODISCARD bool isMicaEnabled() const; - void setMicaEnabled(const bool value); - Q_NODISCARD MicaMaterial *rawMicaMaterial() const; -#endif -#if FRAMELESSHELPER_CONFIG(border_painter) - Q_NODISCARD WindowBorderPainter *rawWindowBorder() const; -#endif - -protected: - Q_NODISCARD bool eventFilter(QObject *object, QEvent *event) override; - -private Q_SLOTS: - void updateContentsMargins(); - void handleScreenChanged(QScreen *screen); - -private: -#if FRAMELESSHELPER_CONFIG(mica_material) - void repaintMica(); -#endif -#if FRAMELESSHELPER_CONFIG(border_painter) - void repaintBorder(); -#endif - void emitCustomWindowStateSignals(); - -Q_SIGNALS: -#if FRAMELESSHELPER_CONFIG(mica_material) - void micaEnabledChanged(); -#endif - -private: - QPointer m_targetWidget; - QPointer m_screen; - qreal m_screenDpr = qreal(0); - QMetaObject::Connection m_screenDpiChangeConnection = {}; - QMetaObject::Connection m_screenChangeConnection = {}; -#if FRAMELESSHELPER_CONFIG(mica_material) - bool m_micaEnabled = false; - MicaMaterial *m_micaMaterial = nullptr; - QMetaObject::Connection m_micaRedrawConnection = {}; -#endif -#if FRAMELESSHELPER_CONFIG(border_painter) - WindowBorderPainter *m_borderPainter = nullptr; - QMetaObject::Connection m_borderRepaintConnection = {}; -#endif -}; - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/standardsystembutton.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/standardsystembutton.h deleted file mode 100644 index e8cc8cbb..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/standardsystembutton.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include -#include - -#if FRAMELESSHELPER_CONFIG(system_button) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class StandardSystemButtonPrivate; -class FRAMELESSHELPER_WIDGETS_API StandardSystemButton : public QPushButton -{ - Q_OBJECT - FRAMELESSHELPER_PUBLIC_QT_CLASS(StandardSystemButton) - Q_PROPERTY(Global::SystemButtonType buttonType READ buttonType WRITE setButtonType NOTIFY buttonTypeChanged FINAL) - Q_PROPERTY(QString glyph READ glyph WRITE setGlyph NOTIFY glyphChanged FINAL) - Q_PROPERTY(QColor hoverColor READ hoverColor WRITE setHoverColor NOTIFY hoverColorChanged FINAL) - Q_PROPERTY(QColor pressColor READ pressColor WRITE setPressColor NOTIFY pressColorChanged FINAL) - Q_PROPERTY(QColor normalColor READ normalColor WRITE setNormalColor NOTIFY normalColorChanged FINAL) - Q_PROPERTY(QColor activeForegroundColor READ activeForegroundColor WRITE setActiveForegroundColor NOTIFY activeForegroundColorChanged FINAL) - Q_PROPERTY(QColor inactiveForegroundColor READ inactiveForegroundColor WRITE setInactiveForegroundColor NOTIFY inactiveForegroundColorChanged FINAL) - Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged FINAL) - Q_PROPERTY(int glyphSize READ glyphSize WRITE setGlyphSize NOTIFY glyphSizeChanged FINAL) - -public: - explicit StandardSystemButton(QWidget *parent = nullptr); - explicit StandardSystemButton(const Global::SystemButtonType type, QWidget *parent = nullptr); - ~StandardSystemButton() override; - - Q_NODISCARD QSize sizeHint() const override; - Q_NODISCARD Global::SystemButtonType buttonType() const; - Q_NODISCARD QString glyph() const; - Q_NODISCARD QColor hoverColor() const; - Q_NODISCARD QColor pressColor() const; - Q_NODISCARD QColor normalColor() const; - Q_NODISCARD QColor activeForegroundColor() const; - Q_NODISCARD QColor inactiveForegroundColor() const; - Q_NODISCARD bool isActive() const; - Q_NODISCARD int glyphSize() const; - -public Q_SLOTS: - void setButtonType(const Global::SystemButtonType value); - void setGlyph(const QString &glyph); - void setHoverColor(const QColor &value); - void setPressColor(const QColor &value); - void setNormalColor(const QColor &value); - void setActiveForegroundColor(const QColor &value); - void setInactiveForegroundColor(const QColor &value); - void setActive(const bool value); - void setGlyphSize(const int value); - -protected: - void paintEvent(QPaintEvent *event) override; - -Q_SIGNALS: - void buttonTypeChanged(); - void glyphChanged(); - void hoverColorChanged(); - void pressColorChanged(); - void normalColorChanged(); - void activeForegroundColorChanged(); - void inactiveForegroundColorChanged(); - void activeChanged(); - void glyphSizeChanged(); -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/standardtitlebar.h b/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/standardtitlebar.h deleted file mode 100644 index 050e6e37..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/include/FramelessHelper/Widgets/standardtitlebar.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include - -#if FRAMELESSHELPER_CONFIG(titlebar) - -#include -#if FRAMELESSHELPER_CONFIG(system_button) -# include -#endif -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class StandardTitleBarPrivate; -class FRAMELESSHELPER_WIDGETS_API StandardTitleBar : public QWidget -{ - Q_OBJECT - FRAMELESSHELPER_PUBLIC_QT_CLASS(StandardTitleBar) - Q_PROPERTY(Qt::Alignment titleLabelAlignment READ titleLabelAlignment WRITE setTitleLabelAlignment NOTIFY titleLabelAlignmentChanged FINAL) -#if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button)) - Q_PROPERTY(StandardSystemButton* minimizeButton READ minimizeButton CONSTANT FINAL) - Q_PROPERTY(StandardSystemButton* maximizeButton READ maximizeButton CONSTANT FINAL) - Q_PROPERTY(StandardSystemButton* closeButton READ closeButton CONSTANT FINAL) -#endif - Q_PROPERTY(bool extended READ isExtended WRITE setExtended NOTIFY extendedChanged FINAL) - Q_PROPERTY(bool hideWhenClose READ isHideWhenClose WRITE setHideWhenClose NOTIFY hideWhenCloseChanged FINAL) - Q_PROPERTY(ChromePalette* chromePalette READ chromePalette CONSTANT FINAL) - Q_PROPERTY(bool titleLabelVisible READ titleLabelVisible WRITE setTitleLabelVisible NOTIFY titleLabelVisibleChanged FINAL) - Q_PROPERTY(QSize windowIconSize READ windowIconSize WRITE setWindowIconSize NOTIFY windowIconSizeChanged FINAL) - Q_PROPERTY(bool windowIconVisible READ windowIconVisible WRITE setWindowIconVisible NOTIFY windowIconVisibleChanged FINAL) - Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont NOTIFY titleFontChanged FINAL) - -public: - explicit StandardTitleBar(QWidget *parent = nullptr); - ~StandardTitleBar() override; - - Q_NODISCARD Qt::Alignment titleLabelAlignment() const; - void setTitleLabelAlignment(const Qt::Alignment value); - -#if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button)) - Q_NODISCARD StandardSystemButton *minimizeButton() const; - Q_NODISCARD StandardSystemButton *maximizeButton() const; - Q_NODISCARD StandardSystemButton *closeButton() const; -#endif // Q_OS_MACOS - - Q_NODISCARD bool isExtended() const; - void setExtended(const bool value); - - Q_NODISCARD bool isHideWhenClose() const; - void setHideWhenClose(const bool value); - - Q_NODISCARD ChromePalette *chromePalette() const; - - Q_NODISCARD bool titleLabelVisible() const; - void setTitleLabelVisible(const bool value); - - Q_NODISCARD QSize windowIconSize() const; - void setWindowIconSize(const QSize &value); - - Q_NODISCARD bool windowIconVisible() const; - void setWindowIconVisible(const bool value); - - Q_NODISCARD QFont titleFont() const; - void setTitleFont(const QFont &value); - -protected: - void paintEvent(QPaintEvent *event) override; - void mouseReleaseEvent(QMouseEvent *event) override; - void mouseDoubleClickEvent(QMouseEvent *event) override; - -Q_SIGNALS: - void extendedChanged(); - void titleLabelAlignmentChanged(); - void hideWhenCloseChanged(); - void titleLabelVisibleChanged(); - void windowIconSizeChanged(); - void windowIconVisibleChanged(); - void titleFontChanged(); -}; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/msbuild/FramelessHelper.props b/src/SARibbonBar/3rdparty/framelesshelper/msbuild/FramelessHelper.props deleted file mode 100644 index 1adf0176..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/msbuild/FramelessHelper.props +++ /dev/null @@ -1,18 +0,0 @@ - - - - $(MSBuildThisFileDirectory)..\lib;$(MSBuildThisFileDirectory)..\lib\debug;$(MSBuildThisFileDirectory)..\lib\release;$(LibraryPath) - - - $(MSBuildThisFileDirectory)..\include;$(MSBuildThisFileDirectory)..\include\FramelessHelper;$(MSBuildThisFileDirectory)..\include\FramelessHelper\Core;$(MSBuildThisFileDirectory)..\include\FramelessHelper\Core\private;$(MSBuildThisFileDirectory)..\include\FramelessHelper\Widgets;$(MSBuildThisFileDirectory)..\include\FramelessHelper\Widgets\private;$(MSBuildThisFileDirectory)..\include\FramelessHelper\Quick;$(MSBuildThisFileDirectory)..\include\FramelessHelper\Quick\private;$(QtHeaderSearchPath) - - - - %(PreprocessorDefinitions) - - - FramelessHelperCore64d.lib;FramelessHelperWidgets64d.lib;FramelessHelperQuick64d.lib;%(AdditionalDependencies); - FramelessHelperCore64.lib;FramelessHelperWidgets64.lib;FramelessHelperQuick64.lib;%(AdditionalDependencies); - - - diff --git a/src/SARibbonBar/3rdparty/framelesshelper/qmake/core.pri b/src/SARibbonBar/3rdparty/framelesshelper/qmake/core.pri deleted file mode 100644 index 835ac4da..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/qmake/core.pri +++ /dev/null @@ -1,87 +0,0 @@ -QT += core core-private gui gui-private - -BASE_INC_DIR = $$PWD/../include -COMMON_INC_DIR = $$BASE_INC_DIR/FramelessHelper -CORE_PUB_INC_DIR = $$COMMON_INC_DIR/Core -CORE_PRIV_INC_DIR = $$CORE_PUB_INC_DIR/private -CORE_EXTRA_INC_DIR = $$PWD/inc/core -CORE_SRC_DIR = $$PWD/../src/core - -INCLUDEPATH += \ - $$BASE_INC_DIR \ - $$COMMON_INC_DIR \ - $$CORE_PUB_INC_DIR \ - $$CORE_PRIV_INC_DIR \ - $$CORE_EXTRA_INC_DIR - -DEPENDPATH += \ - $$BASE_INC_DIR \ - $$COMMON_INC_DIR \ - $$CORE_PUB_INC_DIR \ - $$CORE_PRIV_INC_DIR \ - $$CORE_EXTRA_INC_DIR - -HEADERS += \ - $$CORE_EXTRA_INC_DIR/framelesshelper.version \ - $$CORE_EXTRA_INC_DIR/framelesshelper.config \ - $$CORE_PUB_INC_DIR/chromepalette.h \ - $$CORE_PUB_INC_DIR/framelesshelper_qt.h \ - $$CORE_PUB_INC_DIR/framelesshelpercore_global.h \ - $$CORE_PUB_INC_DIR/framelessmanager.h \ - $$CORE_PUB_INC_DIR/micamaterial.h \ - $$CORE_PUB_INC_DIR/utils.h \ - $$CORE_PUB_INC_DIR/windowborderpainter.h \ - $$CORE_PRIV_INC_DIR/chromepalette_p.h \ - $$CORE_PRIV_INC_DIR/framelessconfig_p.h \ - $$CORE_PRIV_INC_DIR/framelessmanager_p.h \ - $$CORE_PRIV_INC_DIR/micamaterial_p.h \ - $$CORE_PRIV_INC_DIR/sysapiloader_p.h \ - $$CORE_PRIV_INC_DIR/windowborderpainter_p.h \ - $$CORE_PRIV_INC_DIR/framelesshelpercore_global_p.h \ - $$CORE_PRIV_INC_DIR/versionnumber_p.h \ - $$CORE_PRIV_INC_DIR/scopeguard_p.h - -SOURCES += \ - $$CORE_SRC_DIR/chromepalette.cpp \ - $$CORE_SRC_DIR/framelessconfig.cpp \ - $$CORE_SRC_DIR/framelesshelper_qt.cpp \ - $$CORE_SRC_DIR/framelessmanager.cpp \ - $$CORE_SRC_DIR/framelesshelpercore_global.cpp \ - $$CORE_SRC_DIR/micamaterial.cpp \ - $$CORE_SRC_DIR/sysapiloader.cpp \ - $$CORE_SRC_DIR/utils.cpp \ - $$CORE_SRC_DIR/windowborderpainter.cpp - -RESOURCES += \ - $$CORE_SRC_DIR/framelesshelpercore.qrc - -win32 { - HEADERS += \ - $$CORE_PUB_INC_DIR/framelesshelper_win.h \ - $$CORE_PUB_INC_DIR/framelesshelper_windows.h \ - $$CORE_PRIV_INC_DIR/registrykey_p.h \ - $$CORE_PRIV_INC_DIR/winverhelper_p.h - SOURCES += \ - $$CORE_SRC_DIR/framelesshelper_win.cpp \ - $$CORE_SRC_DIR/utils_win.cpp \ - $$CORE_SRC_DIR/registrykey.cpp \ - $$CORE_SRC_DIR/winverhelper.cpp \ - $$CORE_SRC_DIR/platformsupport_win.cpp - LIBS += -luser32 -lgdi32 -lshell32 -} - -unix:!macx { - CONFIG += link_pkgconfig - PKGCONFIG += xcb gtk+-3.0 - DEFINES += GDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_6 - HEADERS += \ - $$CORE_PUB_INC_DIR/framelesshelper_linux.h - SOURCES += \ - $$CORE_SRC_DIR/utils_linux.cpp \ - $$CORE_SRC_DIR/platformsupport_linux.cpp -} - -macx { - SOURCES += $$CORE_SRC_DIR/utils_mac.mm - #LIBS += "-framework AppKit" "-framework Cocoa" "-framework Foundation" # TODO -} diff --git a/src/SARibbonBar/3rdparty/framelesshelper/qmake/inc/core/framelesshelper.config b/src/SARibbonBar/3rdparty/framelesshelper/qmake/inc/core/framelesshelper.config deleted file mode 100644 index 977b36e1..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/qmake/inc/core/framelesshelper.config +++ /dev/null @@ -1,52 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// Caution: This file is generated by CMake automatically during configure. -// WARNING!!! DO NOT EDIT THIS FILE MANUALLY!!! -// ALL YOUR MODIFICATIONS HERE WILL GET LOST AFTER RE-CONFIGURING!!! - -#pragma once - -#ifndef _FRAMELESSHELPER_CONFIG_INCLUDE_GUARD_ -#define _FRAMELESSHELPER_CONFIG_INCLUDE_GUARD_ - -//#define FRAMELESSHELPER_FEATURE_static_build -1 -#define FRAMELESSHELPER_FEATURE_widgets 1 -#define FRAMELESSHELPER_FEATURE_quick 1 -#define FRAMELESSHELPER_FEATURE_debug_output -1 -#define FRAMELESSHELPER_FEATURE_bundle_resource 1 -#define FRAMELESSHELPER_FEATURE_private_qt 1 -#define FRAMELESSHELPER_FEATURE_window 1 -#define FRAMELESSHELPER_FEATURE_titlebar 1 -#define FRAMELESSHELPER_FEATURE_translation 1 -#define FRAMELESSHELPER_FEATURE_mica_material 1 -#define FRAMELESSHELPER_FEATURE_border_painter 1 -#define FRAMELESSHELPER_FEATURE_system_button 1 -#if (defined(WIN32) || defined(_WIN32)) -# define FRAMELESSHELPER_FEATURE_native_impl 1 -#else -# define FRAMELESSHELPER_FEATURE_native_impl -1 -#endif - -#endif // _FRAMELESSHELPER_CONFIG_INCLUDE_GUARD_ diff --git a/src/SARibbonBar/3rdparty/framelesshelper/qmake/inc/core/framelesshelper.version b/src/SARibbonBar/3rdparty/framelesshelper/qmake/inc/core/framelesshelper.version deleted file mode 100644 index afc38f4b..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/qmake/inc/core/framelesshelper.version +++ /dev/null @@ -1,59 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// Caution: This file is generated by CMake automatically during configure. -// WARNING!!! DO NOT EDIT THIS FILE MANUALLY!!! -// ALL YOUR MODIFICATIONS HERE WILL GET LOST AFTER RE-CONFIGURING!!! - -#pragma once - -#ifndef _FRAMELESSHELPER_VERSION_INCLUDE_GUARD_ -#define _FRAMELESSHELPER_VERSION_INCLUDE_GUARD_ - -#define __FRAMELESSHELPER_VERSION_MAJOR__ 2 -#define __FRAMELESSHELPER_VERSION_MINOR__ 5 -#define __FRAMELESSHELPER_VERSION_PATCH__ 0 -#define __FRAMELESSHELPER_VERSION_TWEAK__ 0 -#define __FRAMELESSHELPER_VERSION__ 0x02050000 - -[[maybe_unused]] inline constexpr const unsigned long FRAMELESSHELPER_VERSION_MAJOR = 2; -[[maybe_unused]] inline constexpr const unsigned long FRAMELESSHELPER_VERSION_MINOR = 5; -[[maybe_unused]] inline constexpr const unsigned long FRAMELESSHELPER_VERSION_PATCH = 0; -[[maybe_unused]] inline constexpr const unsigned long FRAMELESSHELPER_VERSION_TWEAK = 0; -[[maybe_unused]] inline constexpr const unsigned long FRAMELESSHELPER_VERSION = 0x02050000; -[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_VERSION_STR[] = "2.5.0"; -[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_HASH_STR[] = "UNKNOWN"; -[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_SUBJECT_STR[] = "UNKNOWN"; -[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_AUTHOR_STR[] = "UNKNOWN"; -[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_DATETIME_STR[] = "UNKNOWN"; -[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_BRANCH_STR[] = "UNKNOWN"; -[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMPILER_NAME_STR[] = "UNKNOWN"; -[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMPILER_VERSION_STR[] = "UNKNOWN"; -[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMPILER_VENDOR_STR[] = "UNKNOWN"; -[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_BUILD_DATETIME_STR[] = "UNKNOWN"; -[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_ARCHITECTURE_STR[] = "UNKNOWN"; -[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_CMAKE_VERSION_STR[] = "UNKNOWN"; -[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_CMAKE_GENERATOR_STR[] = "UNKNOWN"; - -#endif // _FRAMELESSHELPER_VERSION_INCLUDE_GUARD_ diff --git a/src/SARibbonBar/3rdparty/framelesshelper/qmake/quick.pri b/src/SARibbonBar/3rdparty/framelesshelper/qmake/quick.pri deleted file mode 100644 index 2092d166..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/qmake/quick.pri +++ /dev/null @@ -1,56 +0,0 @@ -QT += \ - quick quick-private \ - quicktemplates2 quicktemplates2-private \ - quickcontrols2 quickcontrols2-private - -BASE_INC_DIR = $$PWD/../include -COMMON_INC_DIR = $$BASE_INC_DIR/FramelessHelper -QUICK_PUB_INC_DIR = $$COMMON_INC_DIR/Quick -QUICK_PRIV_INC_DIR = $$QUICK_PUB_INC_DIR/private -QUICK_SRC_DIR = $$PWD/../src/quick - -INCLUDEPATH += \ - $$BASE_INC_DIR \ - $$COMMON_INC_DIR \ - $$QUICK_PUB_INC_DIR \ - $$QUICK_PRIV_INC_DIR - -DEPENDPATH += \ - $$BASE_INC_DIR \ - $$COMMON_INC_DIR \ - $$QUICK_PUB_INC_DIR \ - $$QUICK_PRIV_INC_DIR - -HEADERS += \ - $$QUICK_PUB_INC_DIR/framelesshelperquick_global.h \ - $$QUICK_PUB_INC_DIR/framelessquickmodule.h \ - $$QUICK_PUB_INC_DIR/framelessquickhelper.h \ - $$QUICK_PUB_INC_DIR/framelessquickutils.h \ - $$QUICK_PUB_INC_DIR/quickchromepalette.h \ - $$QUICK_PUB_INC_DIR/quickmicamaterial.h \ - $$QUICK_PUB_INC_DIR/quickimageitem.h \ - $$QUICK_PUB_INC_DIR/quickwindowborder.h \ - $$QUICK_PRIV_INC_DIR/quickstandardsystembutton_p.h \ - $$QUICK_PRIV_INC_DIR/quickstandardtitlebar_p.h \ - $$QUICK_PRIV_INC_DIR/framelessquickhelper_p.h \ - $$QUICK_PRIV_INC_DIR/framelessquickwindow_p.h \ - $$QUICK_PRIV_INC_DIR/framelessquickwindow_p_p.h \ - $$QUICK_PRIV_INC_DIR/framelessquickapplicationwindow_p.h \ - $$QUICK_PRIV_INC_DIR/framelessquickapplicationwindow_p_p.h \ - $$QUICK_PRIV_INC_DIR/quickmicamaterial_p.h \ - $$QUICK_PRIV_INC_DIR/quickimageitem_p.h \ - $$QUICK_PRIV_INC_DIR/quickwindowborder_p.h - -SOURCES += \ - $$QUICK_SRC_DIR/quickstandardsystembutton.cpp \ - $$QUICK_SRC_DIR/quickstandardtitlebar.cpp \ - $$QUICK_SRC_DIR/framelessquickutils.cpp \ - $$QUICK_SRC_DIR/framelessquickmodule.cpp \ - $$QUICK_SRC_DIR/framelessquickwindow.cpp \ - $$QUICK_SRC_DIR/framelessquickapplicationwindow.cpp \ - $$QUICK_SRC_DIR/framelessquickhelper.cpp \ - $$QUICK_SRC_DIR/quickchromepalette.cpp \ - $$QUICK_SRC_DIR/framelesshelperquick_global.cpp \ - $$QUICK_SRC_DIR/quickmicamaterial.cpp \ - $$QUICK_SRC_DIR/quickimageitem.cpp \ - $$QUICK_SRC_DIR/quickwindowborder.cpp diff --git a/src/SARibbonBar/3rdparty/framelesshelper/qmake/widgets.pri b/src/SARibbonBar/3rdparty/framelesshelper/qmake/widgets.pri deleted file mode 100644 index aef1d920..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/qmake/widgets.pri +++ /dev/null @@ -1,45 +0,0 @@ -QT += widgets - -BASE_INC_DIR = $$PWD/../include -COMMON_INC_DIR = $$BASE_INC_DIR/FramelessHelper -WIDGETS_PUB_INC_DIR = $$COMMON_INC_DIR/Widgets -WIDGETS_PRIV_INC_DIR = $$WIDGETS_PUB_INC_DIR/private -WIDGETS_SRC_DIR = $$PWD/../src/widgets - -INCLUDEPATH += \ - $$BASE_INC_DIR \ - $$COMMON_INC_DIR \ - $$WIDGETS_PUB_INC_DIR \ - $$WIDGETS_PRIV_INC_DIR - -DEPENDPATH += \ - $$BASE_INC_DIR \ - $$COMMON_INC_DIR \ - $$WIDGETS_PUB_INC_DIR \ - $$WIDGETS_PRIV_INC_DIR - -HEADERS += \ - $$WIDGETS_PUB_INC_DIR/framelesshelperwidgets_global.h \ - $$WIDGETS_PUB_INC_DIR/framelesswidget.h \ - $$WIDGETS_PUB_INC_DIR/framelessmainwindow.h \ - $$WIDGETS_PUB_INC_DIR/standardsystembutton.h \ - $$WIDGETS_PUB_INC_DIR/framelesswidgetshelper.h \ - $$WIDGETS_PUB_INC_DIR/standardtitlebar.h \ - $$WIDGETS_PUB_INC_DIR/framelessdialog.h \ - $$WIDGETS_PRIV_INC_DIR/framelesswidgetshelper_p.h \ - $$WIDGETS_PRIV_INC_DIR/standardsystembutton_p.h \ - $$WIDGETS_PRIV_INC_DIR/standardtitlebar_p.h \ - $$WIDGETS_PRIV_INC_DIR/framelesswidget_p.h \ - $$WIDGETS_PRIV_INC_DIR/framelessmainwindow_p.h \ - $$WIDGETS_PRIV_INC_DIR/widgetssharedhelper_p.h \ - $$WIDGETS_PRIV_INC_DIR/framelessdialog_p.h - -SOURCES += \ - $$WIDGETS_SRC_DIR/framelessmainwindow.cpp \ - $$WIDGETS_SRC_DIR/framelesswidgetshelper.cpp \ - $$WIDGETS_SRC_DIR/framelesswidget.cpp \ - $$WIDGETS_SRC_DIR/standardsystembutton.cpp \ - $$WIDGETS_SRC_DIR/standardtitlebar.cpp \ - $$WIDGETS_SRC_DIR/widgetssharedhelper.cpp \ - $$WIDGETS_SRC_DIR/framelesshelperwidgets_global.cpp \ - $$WIDGETS_SRC_DIR/framelessdialog.cpp diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/CMakeLists.txt b/src/SARibbonBar/3rdparty/framelesshelper/src/CMakeLists.txt deleted file mode 100644 index 0cb29204..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -#[[ - MIT License - - Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -]] - -if(TARGET Qt${QT_VERSION_MAJOR}::Core AND TARGET Qt${QT_VERSION_MAJOR}::Gui) - add_subdirectory(core) -endif() - -if(FRAMELESSHELPER_BUILD_WIDGETS AND TARGET Qt${QT_VERSION_MAJOR}::Widgets) - add_subdirectory(widgets) -endif() - -if(FRAMELESSHELPER_BUILD_QUICK AND TARGET Qt${QT_VERSION_MAJOR}::Quick) - add_subdirectory(quick) -endif() diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/CMakeLists.txt b/src/SARibbonBar/3rdparty/framelesshelper/src/core/CMakeLists.txt deleted file mode 100644 index c0009475..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/CMakeLists.txt +++ /dev/null @@ -1,321 +0,0 @@ -#[[ - MIT License - - Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -]] - -if(FRAMELESSHELPER_ENABLE_UNIVERSAL_BUILD) - set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE) -endif() - -if(UNIX AND NOT APPLE) - if(FRAMELESSHELPER_NO_PRIVATE) - # Qt X11Extras is only available in Qt5. - if(QT_VERSION_MAJOR LESS 6) - find_package(Qt5 QUIET COMPONENTS X11Extras) - endif() - endif() - find_package(X11 QUIET COMPONENTS xcb) - if(TARGET X11::xcb) - message(STATUS "--- Found system XCB. The XCB wrapper will be disabled.") - else() - message(STATUS "--- System XCB not found. The XCB wrapper will be used instead.") - endif() - find_package(PkgConfig QUIET) - if(PkgConfig_FOUND) - pkg_check_modules(GTK3 QUIET IMPORTED_TARGET gtk+-3.0) - endif() - if(TARGET PkgConfig::GTK3) - message(STATUS "--- Found system GTK. The GTK wrapper will be disabled.") - else() - message(STATUS "--- System GTK not found. The GTK wrapper will be used instead.") - endif() -endif() - -set(SUB_MODULE Core) -set(SUB_MODULE_FULL_NAME ${PROJECT_NAME}${SUB_MODULE}) -set(SUB_MODULE_TARGET ${SUB_MODULE_FULL_NAME}) -set(SUB_MODULE_PATH ${PROJECT_NAME}/${SUB_MODULE}) - -set(INCLUDE_PREFIX ../../include/${SUB_MODULE_PATH}) - -set(PUBLIC_HEADERS - ${FRAMELESSHELPER_VERSION_FILE} - ${FRAMELESSHELPER_CONFIG_FILE} - ${INCLUDE_PREFIX}/framelesshelpercore_global.h - ${INCLUDE_PREFIX}/framelessmanager.h - ${INCLUDE_PREFIX}/utils.h -) - -set(PUBLIC_HEADERS_ALIAS - ${INCLUDE_PREFIX}/Global - ${INCLUDE_PREFIX}/FramelessManager - ${INCLUDE_PREFIX}/Utils -) - -set(PRIVATE_HEADERS - ${INCLUDE_PREFIX}/private/framelessmanager_p.h - ${INCLUDE_PREFIX}/private/framelessconfig_p.h - ${INCLUDE_PREFIX}/private/sysapiloader_p.h - ${INCLUDE_PREFIX}/private/framelesshelpercore_global_p.h - ${INCLUDE_PREFIX}/private/versionnumber_p.h - ${INCLUDE_PREFIX}/private/scopeguard_p.h -) - -set(SOURCES - utils.cpp - framelessmanager.cpp - framelessconfig.cpp - sysapiloader.cpp - framelesshelpercore_global.cpp -) - -if(WIN32) - list(APPEND PUBLIC_HEADERS ${INCLUDE_PREFIX}/framelesshelper_windows.h) - list(APPEND PUBLIC_HEADERS_ALIAS ${INCLUDE_PREFIX}/FramelessHelper_Windows) - list(APPEND PRIVATE_HEADERS - ${INCLUDE_PREFIX}/private/registrykey_p.h - ${INCLUDE_PREFIX}/private/winverhelper_p.h - ) - list(APPEND SOURCES - registrykey.cpp - utils_win.cpp - winverhelper.cpp - platformsupport_win.cpp - ) -elseif(APPLE) - list(APPEND SOURCES utils_mac.mm) -elseif(UNIX) - list(APPEND PUBLIC_HEADERS ${INCLUDE_PREFIX}/framelesshelper_linux.h) - list(APPEND PUBLIC_HEADERS_ALIAS ${INCLUDE_PREFIX}/FramelessHelper_Linux) - list(APPEND SOURCES - utils_linux.cpp - platformsupport_linux.cpp - ) -endif() - -if(FRAMELESSHELPER_NATIVE_IMPL) - if(WIN32) - list(APPEND PUBLIC_HEADERS ${INCLUDE_PREFIX}/framelesshelper_win.h) - list(APPEND PUBLIC_HEADERS_ALIAS ${INCLUDE_PREFIX}/FramelessHelper_Win) - list(APPEND SOURCES framelesshelper_win.cpp) - elseif(APPLE) - elseif(UNIX) - else() - endif() -else() - list(APPEND PUBLIC_HEADERS ${INCLUDE_PREFIX}/framelesshelper_qt.h) - list(APPEND PUBLIC_HEADERS_ALIAS ${INCLUDE_PREFIX}/FramelessHelper_Qt) - list(APPEND SOURCES framelesshelper_qt.cpp) -endif() - -if(NOT FRAMELESSHELPER_NO_TITLEBAR) - list(APPEND PUBLIC_HEADERS ${INCLUDE_PREFIX}/chromepalette.h) - list(APPEND PUBLIC_HEADERS_ALIAS ${INCLUDE_PREFIX}/ChromePalette) - list(APPEND PRIVATE_HEADERS ${INCLUDE_PREFIX}/private/chromepalette_p.h) - list(APPEND SOURCES chromepalette.cpp) -endif() - -if(NOT FRAMELESSHELPER_NO_MICA_MATERIAL) - list(APPEND PUBLIC_HEADERS ${INCLUDE_PREFIX}/micamaterial.h) - list(APPEND PUBLIC_HEADERS_ALIAS ${INCLUDE_PREFIX}/MicaMaterial) - list(APPEND PRIVATE_HEADERS ${INCLUDE_PREFIX}/private/micamaterial_p.h) - list(APPEND SOURCES micamaterial.cpp) -endif() - -if(NOT FRAMELESSHELPER_NO_BORDER_PAINTER) - list(APPEND PUBLIC_HEADERS ${INCLUDE_PREFIX}/windowborderpainter.h) - list(APPEND PUBLIC_HEADERS_ALIAS ${INCLUDE_PREFIX}/WindowBorderPainter) - list(APPEND PRIVATE_HEADERS ${INCLUDE_PREFIX}/private/windowborderpainter_p.h) - list(APPEND SOURCES windowborderpainter.cpp) -endif() - -if(WIN32 AND NOT FRAMELESSHELPER_BUILD_STATIC) - set(__rc_path "${CMAKE_CURRENT_BINARY_DIR}/${SUB_MODULE_FULL_NAME}.rc") - if(NOT EXISTS "${__rc_path}") - generate_win32_rc_file( - PATH "${__rc_path}" - VERSION "${PROJECT_VERSION}" - COMPANY "wangwenx190" - DESCRIPTION "${PROJECT_NAME} ${SUB_MODULE} Module" - COPYRIGHT "MIT License" - ORIGINAL_FILENAME "${SUB_MODULE_FULL_NAME}.dll" - PRODUCT "${PROJECT_NAME}" - COMMENTS "Who don't love Raiden Shogun ?" - LIBRARY - ) - endif() - list(APPEND SOURCES "${__rc_path}") -endif() - -set(ALL_SOURCES ${PUBLIC_HEADERS} ${PRIVATE_HEADERS} ${SOURCES}) - -if(FRAMELESSHELPER_BUILD_STATIC) - set(SUB_MOD_LIB_TYPE "STATIC") -else() - set(SUB_MOD_LIB_TYPE "SHARED") -endif() -add_library(${SUB_MODULE_TARGET} ${SUB_MOD_LIB_TYPE} ${ALL_SOURCES}) -add_library(${PROJECT_NAME}::${SUB_MODULE} ALIAS ${SUB_MODULE_TARGET}) -add_library(${PROJECT_NAME}::${SUB_MODULE_FULL_NAME} ALIAS ${SUB_MODULE_TARGET}) - -set_target_properties(${SUB_MODULE_TARGET} PROPERTIES - VERSION "${PROJECT_VERSION}" - SOVERSION "${PROJECT_VERSION_MAJOR}" - OUTPUT_NAME "${SUB_MODULE_TARGET}${FRAMELESSHELPER_64BIT_POSTFIX}" -) - -set(__export_targets ${SUB_MODULE_TARGET}) - -if(NOT FRAMELESSHELPER_NO_BUNDLE_RESOURCE) - if(QT_VERSION VERSION_GREATER_EQUAL "6.2") - qt_add_resources(${SUB_MODULE_TARGET} framelesshelpercore - PREFIX - "/org.wangwenx190.${PROJECT_NAME}" - FILES - "resources/fonts/iconfont.ttf" - "resources/images/noise.png" - OUTPUT_TARGETS __qrc_targets - ) - if(__qrc_targets) - list(APPEND __export_targets ${__qrc_targets}) - if(FRAMELESSHELPER_BUILD_STATIC) - foreach(__target ${__qrc_targets}) - target_sources(${SUB_MODULE_TARGET} PRIVATE - $ - ) - endforeach() - endif() - endif() - else() - target_sources(${SUB_MODULE_TARGET} PRIVATE - framelesshelpercore.qrc - ) - endif() -endif() - -if(DEFINED FRAMELESSHELPER_NAMESPACE) - if("x${FRAMELESSHELPER_NAMESPACE}" STREQUAL "x") - message(FATAL_ERROR "FRAMELESSHELPER_NAMESPACE can't be empty!") - endif() - target_compile_definitions(${SUB_MODULE_TARGET} PUBLIC FRAMELESSHELPER_NAMESPACE=${FRAMELESSHELPER_NAMESPACE}) -endif() - -target_compile_definitions(${SUB_MODULE_TARGET} PRIVATE - FRAMELESSHELPER_CORE_LIBRARY -) - -if(APPLE) - target_link_libraries(${SUB_MODULE_TARGET} PRIVATE - "-framework Foundation" - "-framework Cocoa" - "-framework AppKit" - ) -elseif(UNIX) - if(TARGET X11::xcb) - target_link_libraries(${SUB_MODULE_TARGET} PRIVATE - X11::xcb - ) - endif() - if(TARGET PkgConfig::GTK3) - target_link_libraries(${SUB_MODULE_TARGET} PRIVATE - PkgConfig::GTK3 - ) - target_compile_definitions(${SUB_MODULE_TARGET} PRIVATE - GDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_6 - ) - endif() -endif() - -if(FRAMELESSHELPER_NO_PRIVATE) - target_link_libraries(${SUB_MODULE_TARGET} PRIVATE - Qt${QT_VERSION_MAJOR}::Core - Qt${QT_VERSION_MAJOR}::Gui - ) - # Qt X11Extras was first introduced in 5.1 and got removed in 6.0 - # But it was again brought back as a private feature of QtGui in 6.2 - if(TARGET Qt5::X11Extras) - target_link_libraries(${SUB_MODULE_TARGET} PRIVATE - Qt5::X11Extras - ) - endif() -else() - target_link_libraries(${SUB_MODULE_TARGET} PRIVATE - Qt${QT_VERSION_MAJOR}::CorePrivate - Qt${QT_VERSION_MAJOR}::GuiPrivate - ) -endif() - -include(GNUInstallDirs) -target_include_directories(${SUB_MODULE_TARGET} PUBLIC - "$" - "$" - "$" - "$" - "$" - "$" - "$" - "$" -) - -if(NOT FRAMELESSHELPER_BUILD_STATIC) - setup_target_rpaths(TARGETS ${SUB_MODULE_TARGET}) -endif() - -setup_qt_stuff(TARGETS ${SUB_MODULE_TARGET}) -setup_custom_moc_macros(TARGETS ${SUB_MODULE_TARGET}) - -set(__extra_flags "") -if(NOT FRAMELESSHELPER_NO_PERMISSIVE_CHECKS) - list(APPEND __extra_flags PERMISSIVE) -endif() -if(FRAMELESSHELPER_ENABLE_SPECTRE) - list(APPEND __extra_flags SPECTRE) -endif() -if(FRAMELESSHELPER_ENABLE_EHCONTGUARD) - list(APPEND __extra_flags EHCONTGUARD) -endif() -if(FRAMELESSHELPER_ENABLE_INTELCET) - list(APPEND __extra_flags INTELCET) -endif() -if(FRAMELESSHELPER_ENABLE_CFGUARD) - list(APPEND __extra_flags CFGUARD) -endif() -if(FRAMELESSHELPER_FORCE_LTO) - list(APPEND __extra_flags FORCE_LTO) -endif() -setup_compile_params(TARGETS ${SUB_MODULE_TARGET} ${__extra_flags}) - -if(NOT FRAMELESSHELPER_NO_INSTALL) - setup_package_export( - TARGETS ${__export_targets} - NAMESPACE ${PROJECT_NAME} - PACKAGE_NAME ${PROJECT_NAME} - COMPONENT ${SUB_MODULE} - PUBLIC_HEADERS ${PUBLIC_HEADERS} - ALIAS_HEADERS ${PUBLIC_HEADERS_ALIAS} - PRIVATE_HEADERS ${PRIVATE_HEADERS} - ) -endif() - -if(NOT FRAMELESSHELPER_NO_SUMMARY) - dump_target_info(TARGETS ${SUB_MODULE_TARGET}) -endif() diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/chromepalette.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/core/chromepalette.cpp deleted file mode 100644 index a82b894e..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/chromepalette.cpp +++ /dev/null @@ -1,425 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chromepalette.h" -#include "chromepalette_p.h" - -#if FRAMELESSHELPER_CONFIG(titlebar) - -#include "framelessmanager.h" -#include "utils.h" -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcChromePalette, "wangwenx190.framelesshelper.core.chromepalette") -# define INFO qCInfo(lcChromePalette) -# define DEBUG qCDebug(lcChromePalette) -# define WARNING qCWarning(lcChromePalette) -# define CRITICAL qCCritical(lcChromePalette) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -ChromePalettePrivate::ChromePalettePrivate(ChromePalette *q) : QObject(q) -{ - Q_ASSERT(q); - if (!q) { - return; - } - q_ptr = q; - connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged, this, &ChromePalettePrivate::refresh); - refresh(); -} - -ChromePalettePrivate::~ChromePalettePrivate() = default; - -ChromePalettePrivate *ChromePalettePrivate::get(ChromePalette *q) -{ - Q_ASSERT(q); - if (!q) { - return nullptr; - } - return q->d_func(); -} - -const ChromePalettePrivate *ChromePalettePrivate::get(const ChromePalette *q) -{ - Q_ASSERT(q); - if (!q) { - return nullptr; - } - return q->d_func(); -} - -void ChromePalettePrivate::refresh() -{ - const bool colorized = Utils::isTitleBarColorized(); - const bool dark = (FramelessManager::instance()->systemTheme() == SystemTheme::Dark); - titleBarActiveBackgroundColor_sys = [colorized, dark]() -> QColor { - if (colorized) { - return Utils::getAccentColor(); - } else { - return (dark ? kDefaultBlackColor : kDefaultWhiteColor); - } - }(); - titleBarInactiveBackgroundColor_sys = (dark ? kDefaultSystemDarkColor : kDefaultWhiteColor); - titleBarActiveForegroundColor_sys = [this, dark, colorized]() -> QColor { - if (dark || colorized) { - return Utils::calculateForegroundColor(titleBarActiveBackgroundColor_sys); - } - return kDefaultBlackColor; - }(); - titleBarInactiveForegroundColor_sys = kDefaultDarkGrayColor; - chromeButtonNormalColor_sys = kDefaultTransparentColor; - chromeButtonHoverColor_sys = - Utils::calculateSystemButtonBackgroundColor(SystemButtonType::Minimize, ButtonState::Hovered); - chromeButtonPressColor_sys = - Utils::calculateSystemButtonBackgroundColor(SystemButtonType::Minimize, ButtonState::Pressed); - closeButtonNormalColor_sys = kDefaultTransparentColor; - closeButtonHoverColor_sys = - Utils::calculateSystemButtonBackgroundColor(SystemButtonType::Close, ButtonState::Hovered); - closeButtonPressColor_sys = - Utils::calculateSystemButtonBackgroundColor(SystemButtonType::Close, ButtonState::Pressed); - Q_Q(ChromePalette); - Q_EMIT q->titleBarActiveBackgroundColorChanged(); - Q_EMIT q->titleBarInactiveBackgroundColorChanged(); - Q_EMIT q->titleBarActiveForegroundColorChanged(); - Q_EMIT q->titleBarInactiveForegroundColorChanged(); - Q_EMIT q->chromeButtonNormalColorChanged(); - Q_EMIT q->chromeButtonHoverColorChanged(); - Q_EMIT q->chromeButtonPressColorChanged(); - Q_EMIT q->closeButtonNormalColorChanged(); - Q_EMIT q->closeButtonHoverColorChanged(); - Q_EMIT q->closeButtonPressColorChanged(); - Q_EMIT q->titleBarColorChanged(); - Q_EMIT q->chromeButtonColorChanged(); -} - -ChromePalette::ChromePalette(QObject *parent) : - QObject(parent), d_ptr(std::make_unique(this)) -{ -} - -ChromePalette::~ChromePalette() = default; - -QColor ChromePalette::titleBarActiveBackgroundColor() const -{ - Q_D(const ChromePalette); - return d->titleBarActiveBackgroundColor.value_or(d->titleBarActiveBackgroundColor_sys); -} - -QColor ChromePalette::titleBarInactiveBackgroundColor() const -{ - Q_D(const ChromePalette); - return d->titleBarInactiveBackgroundColor.value_or(d->titleBarInactiveBackgroundColor_sys); -} - -QColor ChromePalette::titleBarActiveForegroundColor() const -{ - Q_D(const ChromePalette); - return d->titleBarActiveForegroundColor.value_or(d->titleBarActiveForegroundColor_sys); -} - -QColor ChromePalette::titleBarInactiveForegroundColor() const -{ - Q_D(const ChromePalette); - return d->titleBarInactiveForegroundColor.value_or(d->titleBarInactiveForegroundColor_sys); -} - -QColor ChromePalette::chromeButtonNormalColor() const -{ - Q_D(const ChromePalette); - return d->chromeButtonNormalColor.value_or(d->chromeButtonNormalColor_sys); -} - -QColor ChromePalette::chromeButtonHoverColor() const -{ - Q_D(const ChromePalette); - return d->chromeButtonHoverColor.value_or(d->chromeButtonHoverColor_sys); -} - -QColor ChromePalette::chromeButtonPressColor() const -{ - Q_D(const ChromePalette); - return d->chromeButtonPressColor.value_or(d->chromeButtonPressColor_sys); -} - -QColor ChromePalette::closeButtonNormalColor() const -{ - Q_D(const ChromePalette); - return d->closeButtonNormalColor.value_or(d->closeButtonNormalColor_sys); -} - -QColor ChromePalette::closeButtonHoverColor() const -{ - Q_D(const ChromePalette); - return d->closeButtonHoverColor.value_or(d->closeButtonHoverColor_sys); -} - -QColor ChromePalette::closeButtonPressColor() const -{ - Q_D(const ChromePalette); - return d->closeButtonPressColor.value_or(d->closeButtonPressColor_sys); -} - -void ChromePalette::setTitleBarActiveBackgroundColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - Q_D(ChromePalette); - if (d->titleBarActiveBackgroundColor.value_or(QColor()) == value) { - return; - } - d->titleBarActiveBackgroundColor = value; - Q_EMIT titleBarActiveBackgroundColorChanged(); - Q_EMIT titleBarColorChanged(); -} - -void ChromePalette::resetTitleBarActiveBackgroundColor() -{ - Q_D(ChromePalette); - d->titleBarActiveBackgroundColor = std::nullopt; - Q_EMIT titleBarActiveBackgroundColorChanged(); - Q_EMIT titleBarColorChanged(); -} - -void ChromePalette::setTitleBarInactiveBackgroundColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - Q_D(ChromePalette); - if (d->titleBarInactiveBackgroundColor.value_or(QColor()) == value) { - return; - } - d->titleBarInactiveBackgroundColor = value; - Q_EMIT titleBarInactiveBackgroundColorChanged(); - Q_EMIT titleBarColorChanged(); -} - -void ChromePalette::resetTitleBarInactiveBackgroundColor() -{ - Q_D(ChromePalette); - d->titleBarInactiveBackgroundColor = std::nullopt; - Q_EMIT titleBarInactiveBackgroundColorChanged(); - Q_EMIT titleBarColorChanged(); -} - -void ChromePalette::setTitleBarActiveForegroundColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - Q_D(ChromePalette); - if (d->titleBarActiveForegroundColor.value_or(QColor()) == value) { - return; - } - d->titleBarActiveForegroundColor = value; - Q_EMIT titleBarActiveForegroundColorChanged(); - Q_EMIT titleBarColorChanged(); -} - -void ChromePalette::resetTitleBarActiveForegroundColor() -{ - Q_D(ChromePalette); - d->titleBarActiveForegroundColor = std::nullopt; - Q_EMIT titleBarActiveForegroundColorChanged(); - Q_EMIT titleBarColorChanged(); -} - -void ChromePalette::setTitleBarInactiveForegroundColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - Q_D(ChromePalette); - if (d->titleBarInactiveForegroundColor.value_or(QColor()) == value) { - return; - } - d->titleBarInactiveForegroundColor = value; - Q_EMIT titleBarInactiveForegroundColorChanged(); - Q_EMIT titleBarColorChanged(); -} - -void ChromePalette::resetTitleBarInactiveForegroundColor() -{ - Q_D(ChromePalette); - d->titleBarInactiveForegroundColor = std::nullopt; - Q_EMIT titleBarInactiveForegroundColorChanged(); - Q_EMIT titleBarColorChanged(); -} - -void ChromePalette::setChromeButtonNormalColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - Q_D(ChromePalette); - if (d->chromeButtonNormalColor.value_or(QColor()) == value) { - return; - } - d->chromeButtonNormalColor = value; - Q_EMIT chromeButtonNormalColorChanged(); - Q_EMIT chromeButtonColorChanged(); -} - -void ChromePalette::resetChromeButtonNormalColor() -{ - Q_D(ChromePalette); - d->chromeButtonNormalColor = std::nullopt; - Q_EMIT chromeButtonNormalColorChanged(); - Q_EMIT chromeButtonColorChanged(); -} - -void ChromePalette::setChromeButtonHoverColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - Q_D(ChromePalette); - if (d->chromeButtonHoverColor.value_or(QColor()) == value) { - return; - } - d->chromeButtonHoverColor = value; - Q_EMIT chromeButtonHoverColorChanged(); - Q_EMIT chromeButtonColorChanged(); -} - -void ChromePalette::resetChromeButtonHoverColor() -{ - Q_D(ChromePalette); - d->chromeButtonHoverColor = std::nullopt; - Q_EMIT chromeButtonHoverColorChanged(); - Q_EMIT chromeButtonColorChanged(); -} - -void ChromePalette::setChromeButtonPressColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - Q_D(ChromePalette); - if (d->chromeButtonPressColor.value_or(QColor()) == value) { - return; - } - d->chromeButtonPressColor = value; - Q_EMIT chromeButtonPressColorChanged(); - Q_EMIT chromeButtonColorChanged(); -} - -void ChromePalette::resetChromeButtonPressColor() -{ - Q_D(ChromePalette); - d->chromeButtonPressColor = std::nullopt; - Q_EMIT chromeButtonPressColorChanged(); - Q_EMIT chromeButtonColorChanged(); -} - -void ChromePalette::setCloseButtonNormalColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - Q_D(ChromePalette); - if (d->closeButtonNormalColor.value_or(QColor()) == value) { - return; - } - d->closeButtonNormalColor = value; - Q_EMIT closeButtonNormalColorChanged(); - Q_EMIT chromeButtonColorChanged(); -} - -void ChromePalette::resetCloseButtonNormalColor() -{ - Q_D(ChromePalette); - d->closeButtonNormalColor = std::nullopt; - Q_EMIT closeButtonNormalColorChanged(); - Q_EMIT chromeButtonColorChanged(); -} - -void ChromePalette::setCloseButtonHoverColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - Q_D(ChromePalette); - if (d->closeButtonHoverColor.value_or(QColor()) == value) { - return; - } - d->closeButtonHoverColor = value; - Q_EMIT closeButtonHoverColorChanged(); - Q_EMIT chromeButtonColorChanged(); -} - -void ChromePalette::resetCloseButtonHoverColor() -{ - Q_D(ChromePalette); - d->closeButtonHoverColor = std::nullopt; - Q_EMIT closeButtonHoverColorChanged(); - Q_EMIT chromeButtonColorChanged(); -} - -void ChromePalette::setCloseButtonPressColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - Q_D(ChromePalette); - if (d->closeButtonPressColor.value_or(QColor()) == value) { - return; - } - d->closeButtonPressColor = value; - Q_EMIT closeButtonPressColorChanged(); - Q_EMIT chromeButtonColorChanged(); -} - -void ChromePalette::resetCloseButtonPressColor() -{ - Q_D(ChromePalette); - d->closeButtonPressColor = std::nullopt; - Q_EMIT closeButtonPressColorChanged(); - Q_EMIT chromeButtonColorChanged(); -} - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/chromepalette.h b/src/SARibbonBar/3rdparty/framelesshelper/src/core/chromepalette.h deleted file mode 100644 index 68f6ff73..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/chromepalette.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Core/chromepalette.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/chromepalette_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/core/chromepalette_p.h deleted file mode 100644 index 4202da22..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/chromepalette_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Core/private/chromepalette_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelessconfig.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelessconfig.cpp deleted file mode 100644 index 575ebaa8..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelessconfig.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "framelessconfig_p.h" -#include -#include -#include -#include -#include -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcFramelessConfig, "wangwenx190.framelesshelper.core.framelessconfig") -# define INFO qCInfo(lcFramelessConfig) -# define DEBUG qCDebug(lcFramelessConfig) -# define WARNING qCWarning(lcFramelessConfig) -# define CRITICAL qCCritical(lcFramelessConfig) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -struct FramelessConfigEntry -{ - const char *env = nullptr; - const char *cfg = nullptr; -}; - -static constexpr const std::array(Option::Last) + 1> FramelessOptionsTable = -{ - FramelessConfigEntry{ "FRAMELESSHELPER_USE_CROSS_PLATFORM_QT_IMPLEMENTATION", "Options/UseCrossPlatformQtImplementation" }, - FramelessConfigEntry{ "FRAMELESSHELPER_FORCE_HIDE_WINDOW_FRAME_BORDER", "Options/ForceHideWindowFrameBorder" }, - FramelessConfigEntry{ "FRAMELESSHELPER_FORCE_SHOW_WINDOW_FRAME_BORDER", "Options/ForceShowWindowFrameBorder" }, - FramelessConfigEntry{ "FRAMELESSHELPER_DISABLE_WINDOWS_SNAP_LAYOUT", "Options/DisableWindowsSnapLayout" }, - FramelessConfigEntry{ "FRAMELESSHELPER_WINDOW_USE_ROUND_CORNERS", "Options/WindowUseRoundCorners" }, - FramelessConfigEntry{ "FRAMELESSHELPER_CENTER_WINDOW_BEFORE_SHOW", "Options/CenterWindowBeforeShow" }, - FramelessConfigEntry{ "FRAMELESSHELPER_ENABLE_BLUR_BEHIND_WINDOW", "Options/EnableBlurBehindWindow" }, - FramelessConfigEntry{ "FRAMELESSHELPER_FORCE_NON_NATIVE_BACKGROUND_BLUR", "Options/ForceNonNativeBackgroundBlur" }, - FramelessConfigEntry{ "FRAMELESSHELPER_DISABLE_LAZY_INITIALIZATION_FOR_MICA_MATERIAL", "Options/DisableLazyInitializationForMicaMaterial" }, - FramelessConfigEntry{ "FRAMELESSHELPER_FORCE_NATIVE_BACKGROUND_BLUR", "Options/ForceNativeBackgroundBlur" }, - FramelessConfigEntry{ "FRAMELESSHELPER_WINDOW_USE_SQUARE_CORNERS", "Options/WindowUseSquareCorners" } -}; - -static constexpr const auto OptionCount = std::size(FramelessOptionsTable); - -struct FramelessConfigData -{ - bool loaded = false; - std::array options = {}; - bool disableEnvVar = false; - bool disableCfgFile = false; -}; - -Q_GLOBAL_STATIC(FramelessConfigData, g_framelessConfigData) - -#if FRAMELESSHELPER_CONFIG(debug_output) -static inline void warnInappropriateOptions() -{ - const FramelessConfig * const cfg = FramelessConfig::instance(); - if (cfg->isSet(Option::UseCrossPlatformQtImplementation)) { - WARNING << "Option::UseCrossPlatformQtImplementation is deprecated and has no effect now. It will be removed in a future version."; - } -#ifdef Q_OS_WINDOWS - if (cfg->isSet(Option::DisableWindowsSnapLayout)) { - WARNING << "Option::DisableWindowsSnapLayout is deprecated and has no effect now. It will be removed in a future version."; - } -#else - if (cfg->isSet(Option::ForceHideWindowFrameBorder)) { - WARNING << "Option::ForceHideWindowFrameBorder is only available on Windows."; - } - if (cfg->isSet(Option::ForceShowWindowFrameBorder)) { - WARNING << "Option::ForceShowWindowFrameBorder is only available on Windows."; - } - if (cfg->isSet(Option::DisableWindowsSnapLayout)) { - WARNING << "Option::DisableWindowsSnapLayout is only available on Windows."; - } -#endif // Q_OS_WINDOWS - if (cfg->isSet(Option::ForceHideWindowFrameBorder) && cfg->isSet(Option::ForceShowWindowFrameBorder)) { - WARNING << "Option::ForceHideWindowFrameBorder and Option::ForceShowWindowFrameBorder can't be both enabled."; - } - if (cfg->isSet(Option::ForceNonNativeBackgroundBlur) && cfg->isSet(Option::ForceNativeBackgroundBlur)) { - WARNING << "Option::ForceNonNativeBackgroundBlur and Option::ForceNativeBackgroundBlur can't be both enabled."; - } - if (cfg->isSet(Option::WindowUseRoundCorners)) { - WARNING << "Option::WindowUseRoundCorners has not been implemented yet."; - } -} -#endif - -FramelessConfig::FramelessConfig(QObject *parent) : QObject(parent) -{ - reload(); -} - -FramelessConfig::~FramelessConfig() = default; - -FramelessConfig *FramelessConfig::instance() -{ - static FramelessConfig config; - return &config; -} - -void FramelessConfig::reload(const bool force) -{ - if (g_framelessConfigData()->loaded && !force) { - return; - } - const auto configFile = []() -> std::unique_ptr { - if (!qApp) { - return nullptr; - } - const QDir appDir(QCoreApplication::applicationDirPath()); - return std::make_unique(appDir.filePath(FRAMELESSHELPER_STRING_LITERAL(".framelesshelper.ini")), QSettings::IniFormat); - }(); - for (int i = 0; i != OptionCount; ++i) { - const bool envVar = (!g_framelessConfigData()->disableEnvVar - && qEnvironmentVariableIsSet(FramelessOptionsTable.at(i).env) - && (qEnvironmentVariableIntValue(FramelessOptionsTable.at(i).env) > 0)); - const bool cfgFile = (!g_framelessConfigData()->disableCfgFile && configFile - && configFile->value(QUtf8String(FramelessOptionsTable.at(i).cfg), false).toBool()); - g_framelessConfigData()->options.at(i) = (envVar || cfgFile); - } - g_framelessConfigData()->loaded = true; -#if FRAMELESSHELPER_CONFIG(debug_output) - QTimer::singleShot(0, this, [](){ warnInappropriateOptions(); }); -#endif -} - -void FramelessConfig::set(const Option option, const bool on) -{ - g_framelessConfigData()->options.at(static_cast(option)) = on; -} - -bool FramelessConfig::isSet(const Option option) const -{ - return g_framelessConfigData()->options.at(static_cast(option)); -} - -void FramelessConfig::setLoadFromEnvironmentVariablesDisabled(const bool on) -{ - g_framelessConfigData()->disableEnvVar = on; -} - -void FramelessConfig::setLoadFromConfigurationFileDisabled(const bool on) -{ - g_framelessConfigData()->disableCfgFile = on; -} - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelessconfig_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelessconfig_p.h deleted file mode 100644 index cb7acd63..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelessconfig_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Core/private/framelessconfig_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelper_linux.h b/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelper_linux.h deleted file mode 100644 index 7bd7db95..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelper_linux.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Core/framelesshelper_linux.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelper_qt.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelper_qt.cpp deleted file mode 100644 index 2e6f2b59..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelper_qt.cpp +++ /dev/null @@ -1,308 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "framelesshelper_qt.h" - -#if !FRAMELESSHELPER_CONFIG(native_impl) - -#include "framelessmanager.h" -#include "framelessmanager_p.h" -#include "framelessconfig_p.h" -#include "framelesshelpercore_global_p.h" -#include "utils.h" -#include -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcFramelessHelperQt, "wangwenx190.framelesshelper.core.impl.qt") -# define INFO qCInfo(lcFramelessHelperQt) -# define DEBUG qCDebug(lcFramelessHelperQt) -# define WARNING qCWarning(lcFramelessHelperQt) -# define CRITICAL qCCritical(lcFramelessHelperQt) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -struct FramelessDataQt : public FramelessData -{ - FramelessHelperQt *framelessHelperImpl = nullptr; - bool cursorShapeChanged = false; - bool leftButtonPressed = false; - - FramelessDataQt(); - ~FramelessDataQt() override; -}; -using FramelessDataQtPtr = std::shared_ptr; - -[[nodiscard]] static inline FramelessDataQtPtr tryGetData(const QObject *window) -{ - Q_ASSERT(window); - if (!window) { - return nullptr; - } - const FramelessDataPtr data = FramelessManagerPrivate::getData(window); - if (!data) { - return nullptr; - } - return std::dynamic_pointer_cast(data); -} - -class FramelessHelperQtPrivate -{ - FRAMELESSHELPER_PRIVATE_CLASS(FramelessHelperQt) - -public: - explicit FramelessHelperQtPrivate(FramelessHelperQt *q); - ~FramelessHelperQtPrivate(); - - const QObject *window = nullptr; -}; - -FramelessDataQt::FramelessDataQt() = default; - -FramelessDataQt::~FramelessDataQt() = default; - -[[nodiscard]] FramelessDataPtr FramelessData::create() -{ - return std::make_shared(); -} - -FramelessHelperQtPrivate::FramelessHelperQtPrivate(FramelessHelperQt *q) : q_ptr(q) -{ - Q_ASSERT(q_ptr); -} - -FramelessHelperQtPrivate::~FramelessHelperQtPrivate() = default; - -FramelessHelperQt::FramelessHelperQt(QObject *parent) : QObject(parent), d_ptr(std::make_unique(this)) -{ -} - -FramelessHelperQt::~FramelessHelperQt() = default; - -void FramelessHelperQt::addWindow(const QObject *window) -{ - Q_ASSERT(window); - if (!window) { - return; - } - const FramelessDataQtPtr data = tryGetData(window); - if (!data || data->frameless || !data->callbacks) { - return; - } - QWindow *qWindow = data->callbacks->getWindowHandle(); - Q_ASSERT(qWindow); - if (!qWindow) { - return; - } - data->frameless = true; - static const auto shouldApplyFramelessFlag = []() -> bool { -#ifdef Q_OS_MACOS - return false; -#elif (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) - return !Utils::isCustomDecorationSupported(); -#elif defined(Q_OS_WINDOWS) - return true; -#endif // Q_OS_MACOS - }(); -#if (defined(Q_OS_MACOS) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))) - qWindow->setProperty("_q_mac_wantsLayer", 1); -#endif // (defined(Q_OS_MACOS) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))) - if (shouldApplyFramelessFlag) { - data->callbacks->setWindowFlags(data->callbacks->getWindowFlags() | Qt::FramelessWindowHint); - } else { -#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) - std::ignore = Utils::tryHideSystemTitleBar(data->callbacks->getWindowId(), true); -#elif defined(Q_OS_MACOS) - Utils::setSystemTitleBarVisible(data->callbacks->getWindowId(), false); -#endif // Q_OS_LINUX - } - if (!data->framelessHelperImpl) { - data->framelessHelperImpl = new FramelessHelperQt(qWindow); - data->framelessHelperImpl->d_func()->window = window; - qWindow->installEventFilter(data->framelessHelperImpl); - } - FramelessHelperEnableThemeAware(); -} - -void FramelessHelperQt::removeWindow(const QObject *window) -{ - Q_ASSERT(window); - if (!window) { - return; - } - const FramelessDataQtPtr data = tryGetData(window); - if (!data || !data->frameless || !data->callbacks) { - return; - } - if (data->framelessHelperImpl) { - QWindow *qWindow = data->callbacks->getWindowHandle(); - Q_ASSERT(qWindow); - if (qWindow) { - qWindow->removeEventFilter(data->framelessHelperImpl); - delete data->framelessHelperImpl; - data->framelessHelperImpl = nullptr; - } - } -#ifdef Q_OS_MACOS - Utils::removeWindowProxy(data->callbacks->getWindowId()); -#endif // Q_OS_MACOS -} - -bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event) -{ - Q_ASSERT(object); - Q_ASSERT(event); - if (!object || !event) { - return false; - } -#if (QT_VERSION < QT_VERSION_CHECK(6, 5, 0)) - if (Utils::isThemeChangeEvent(event)) { - // Sometimes the FramelessManager instance may be destroyed already. - if (FramelessManager *manager = FramelessManager::instance()) { - if (FramelessManagerPrivate *managerPriv = FramelessManagerPrivate::get(manager)) { - managerPriv->notifySystemThemeHasChangedOrNot(); - } - } - return false; - } -#endif // (QT_VERSION < QT_VERSION_CHECK(6, 5, 0)) - Q_D(FramelessHelperQt); - if (!d->window || !object->isWindowType()) { - return false; - } - const QEvent::Type type = event->type(); - // We are only interested in some specific mouse events (plus the DPR change event). - if ((type != QEvent::MouseButtonPress) && (type != QEvent::MouseButtonRelease) - && (type != QEvent::MouseButtonDblClick) && (type != QEvent::MouseMove) -#if (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)) - && (type != QEvent::DevicePixelRatioChange) -#else // QT_VERSION < QT_VERSION_CHECK(6, 6, 0) - && (type != QEvent::ScreenChangeInternal) // Qt's internal event to notify screen change and DPR change. -#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)) - ) { - return false; - } - const FramelessDataQtPtr data = tryGetData(d->window); - if (!data || !data->frameless || !data->callbacks) { - return false; - } -#if (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)) - if (type == QEvent::DevicePixelRatioChange) -#else // QT_VERSION < QT_VERSION_CHECK(6, 6, 0) - if (type == QEvent::ScreenChangeInternal) -#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)) - { - data->callbacks->forceChildrenRepaint(); - return false; - } - const auto qWindow = qobject_cast(object); - const auto mouseEvent = static_cast(event); - const Qt::MouseButton button = mouseEvent->button(); -#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - const QPoint scenePos = mouseEvent->scenePosition().toPoint(); - const QPoint globalPos = mouseEvent->globalPosition().toPoint(); -#else - const QPoint scenePos = mouseEvent->windowPos().toPoint(); - const QPoint globalPos = mouseEvent->screenPos().toPoint(); -#endif - const bool windowFixedSize = data->callbacks->isWindowFixedSize(); - const bool ignoreThisEvent = data->callbacks->shouldIgnoreMouseEvents(scenePos); - const bool insideTitleBar = data->callbacks->isInsideTitleBarDraggableArea(scenePos); - const bool dontOverrideCursor = data->callbacks->getProperty(kDontOverrideCursorVar, false).toBool(); - const bool dontToggleMaximize = data->callbacks->getProperty(kDontToggleMaximizeVar, false).toBool(); - switch (type) { - case QEvent::MouseButtonPress: - if (button == Qt::LeftButton) { - data->leftButtonPressed = true; - if (!windowFixedSize) { - const Qt::Edges edges = Utils::calculateWindowEdges(qWindow, scenePos); - if (edges != Qt::Edges{}) { - std::ignore = Utils::startSystemResize(qWindow, edges, globalPos); - event->accept(); - return true; - } - } - } - break; - case QEvent::MouseButtonRelease: - if (button == Qt::LeftButton) { - data->leftButtonPressed = false; - } else if (button == Qt::RightButton) { - if (!ignoreThisEvent && insideTitleBar) { - data->callbacks->showSystemMenu(globalPos); - event->accept(); - return true; - } - } - break; - case QEvent::MouseButtonDblClick: - if (!dontToggleMaximize && (button == Qt::LeftButton) && !windowFixedSize && !ignoreThisEvent && insideTitleBar) { - Qt::WindowState newWindowState = Qt::WindowNoState; - if (data->callbacks->getWindowState() != Qt::WindowMaximized) { - newWindowState = Qt::WindowMaximized; - } - data->callbacks->setWindowState(newWindowState); - event->accept(); - return true; - } - break; - case QEvent::MouseMove: { - if (!dontOverrideCursor && !windowFixedSize) { - const Qt::CursorShape cs = Utils::calculateCursorShape(qWindow, scenePos); - if (cs == Qt::ArrowCursor) { - if (data->cursorShapeChanged) { - data->callbacks->unsetCursor(); - data->cursorShapeChanged = false; - } - } else { - data->callbacks->setCursor(cs); - data->cursorShapeChanged = true; - } - } - if (data->leftButtonPressed) { - if (!ignoreThisEvent && insideTitleBar) { - std::ignore = Utils::startSystemMove(qWindow, globalPos); - event->accept(); - return true; - } - } - } break; - default: - break; - } - return false; -} - -FRAMELESSHELPER_END_NAMESPACE - -#endif // !native_impl diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelper_qt.h b/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelper_qt.h deleted file mode 100644 index 8f36da7c..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelper_qt.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Core/framelesshelper_qt.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelper_win.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelper_win.cpp deleted file mode 100644 index 381b5df1..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelper_win.cpp +++ /dev/null @@ -1,1413 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "framelesshelper_win.h" - -#ifdef Q_OS_WINDOWS - -#if FRAMELESSHELPER_CONFIG(native_impl) - -#include "framelessmanager.h" -#include "framelessmanager_p.h" -#include "framelessconfig_p.h" -#include "utils.h" -#include "winverhelper_p.h" -#include "framelesshelper_windows.h" -#include "framelesshelpercore_global_p.h" -#include "scopeguard_p.h" -#include -#include -#include -#include -#include -#include -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcFramelessHelperWin, "wangwenx190.framelesshelper.core.impl.win") -# define INFO qCInfo(lcFramelessHelperWin) -# define DEBUG qCDebug(lcFramelessHelperWin) -# define WARNING qCWarning(lcFramelessHelperWin) -# define CRITICAL qCCritical(lcFramelessHelperWin) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -static constexpr const auto kMessageTag = WPARAM(0x97CCEA99); - -FRAMELESSHELPER_STRING_CONSTANT(MonitorFromWindow) -FRAMELESSHELPER_STRING_CONSTANT(GetMonitorInfoW) -FRAMELESSHELPER_STRING_CONSTANT(ScreenToClient) -FRAMELESSHELPER_STRING_CONSTANT(ClientToScreen) -FRAMELESSHELPER_STRING_CONSTANT(GetClientRect) -#ifdef Q_PROCESSOR_X86_64 - FRAMELESSHELPER_STRING_CONSTANT(GetWindowLongPtrW) - FRAMELESSHELPER_STRING_CONSTANT(SetWindowLongPtrW) -#else // !Q_PROCESSOR_X86_64 - // WinUser.h defines G/SetClassLongPtr as G/SetClassLong due to the - // "Ptr" suffixed APIs are not available on 32-bit platforms, so we - // have to add the following workaround. Undefine the macros and then - // redefine them is also an option but the following solution is more simple. - FRAMELESSHELPER_STRING_CONSTANT2(GetWindowLongPtrW, "GetWindowLongW") - FRAMELESSHELPER_STRING_CONSTANT2(SetWindowLongPtrW, "SetWindowLongW") -#endif // Q_PROCESSOR_X86_64 -FRAMELESSHELPER_STRING_CONSTANT(RegisterClassExW) -FRAMELESSHELPER_STRING_CONSTANT(GetModuleHandleW) -FRAMELESSHELPER_STRING_CONSTANT(CreateWindowExW) -FRAMELESSHELPER_STRING_CONSTANT(SetLayeredWindowAttributes) -FRAMELESSHELPER_STRING_CONSTANT(SetWindowPos) -FRAMELESSHELPER_STRING_CONSTANT(TrackMouseEvent) -FRAMELESSHELPER_STRING_CONSTANT(FindWindowW) -FRAMELESSHELPER_STRING_CONSTANT(UnregisterClassW) -FRAMELESSHELPER_STRING_CONSTANT(DestroyWindow) -FRAMELESSHELPER_STRING_CONSTANT(GetWindowPlacement) -FRAMELESSHELPER_STRING_CONSTANT(SetWindowPlacement) - -enum class WindowPart : quint8 -{ - Outside, - ClientArea, - ChromeButton, - ResizeBorder, - FixedBorder, - TitleBar -}; - -struct FramelessDataWin : public FramelessData -{ - // Store the last hit test result, it's helpful to handle WM_MOUSEMOVE and WM_NCMOUSELEAVE. - WindowPart lastHitTestResult = WindowPart::Outside; - // True if we blocked a WM_MOUSELEAVE when mouse moves on chrome button, false when a - // WM_MOUSELEAVE comes or we manually call TrackMouseEvent(). - bool mouseLeaveBlocked = false; - Dpi dpi = {}; - HMONITOR monitor = nullptr; -#if (QT_VERSION < QT_VERSION_CHECK(6, 5, 1)) - QRect restoreGeometry = {}; -#endif // (QT_VERSION < QT_VERSION_CHECK(6, 5, 1)) - - FramelessDataWin(); - ~FramelessDataWin() override; -}; -using FramelessDataWinPtr = std::shared_ptr; - -FramelessDataWin::FramelessDataWin() = default; - -FramelessDataWin::~FramelessDataWin() = default; - -[[nodiscard]] FramelessDataPtr FramelessData::create() -{ - return std::make_shared(); -} - -[[nodiscard]] static inline FramelessDataWinPtr tryGetData(const QObject *window) -{ - Q_ASSERT(window); - if (!window) { - return nullptr; - } - const FramelessDataPtr data = FramelessManagerPrivate::getData(window); - if (!data) { - return nullptr; - } - return std::dynamic_pointer_cast(data); -} - -struct FramelessHelperWinInternal -{ - std::unique_ptr eventFilter = nullptr; -}; -Q_GLOBAL_STATIC(FramelessHelperWinInternal, g_internalData) - -[[nodiscard]] extern std::optional getMonitorForWindow(const HWND hwnd); - -[[nodiscard]] static inline QByteArray qtNativeEventType() -{ - static const auto result = FRAMELESSHELPER_BYTEARRAY_LITERAL("windows_generic_MSG"); - return result; -} - -[[nodiscard]] static inline WindowPart getHittedWindowPart(const int hitTestResult) -{ - switch (hitTestResult) { - case HTCLIENT: - return WindowPart::ClientArea; - case HTCAPTION: - return WindowPart::TitleBar; - case HTSYSMENU: - case HTHELP: - case HTREDUCE: - case HTZOOM: - case HTCLOSE: - return WindowPart::ChromeButton; - case HTLEFT: - case HTRIGHT: - case HTTOP: - case HTTOPLEFT: - case HTTOPRIGHT: - case HTBOTTOM: - case HTBOTTOMLEFT: - case HTBOTTOMRIGHT: - return WindowPart::ResizeBorder; - case HTBORDER: - return WindowPart::FixedBorder; - default: - break; - } - return WindowPart::Outside; -} - -[[nodiscard]] static inline constexpr bool isTaggedMessage(const WPARAM wParam) -{ - return (wParam == kMessageTag); -} - -[[nodiscard]] static inline bool requestForMouseLeaveMessage(const HWND hWnd, const bool nonClient) -{ - Q_ASSERT(hWnd); - if (!hWnd) { - return false; - } - TRACKMOUSEEVENT tme; - SecureZeroMemory(&tme, sizeof(tme)); - tme.cbSize = sizeof(tme); - tme.dwFlags = TME_LEAVE; - if (nonClient) { - tme.dwFlags |= TME_NONCLIENT; - } - tme.hwndTrack = hWnd; - tme.dwHoverTime = HOVER_DEFAULT; - if (::TrackMouseEvent(&tme) == FALSE) { - WARNING << Utils::getSystemErrorMessage(kTrackMouseEvent); - return false; - } - return true; -} - -FramelessHelperWin::FramelessHelperWin() : QAbstractNativeEventFilter() {} - -FramelessHelperWin::~FramelessHelperWin() = default; - -void FramelessHelperWin::addWindow(const QObject *window) -{ - Q_ASSERT(window); - if (!window) { - return; - } - const FramelessDataWinPtr data = tryGetData(window); - if (!data || data->frameless || !data->callbacks) { - return; - } - QWindow *qWindow = data->callbacks->getWindowHandle(); - Q_ASSERT(qWindow); - if (!qWindow) { - return; - } - data->frameless = true; - data->dpi = Dpi{ Utils::getWindowDpi(data->windowId, true), Utils::getWindowDpi(data->windowId, false) }; - DEBUG.noquote() << "The DPI of window" << hwnd2str(data->windowId) << "is" << data->dpi; - data->monitor = ::MonitorFromWindow(reinterpret_cast(data->windowId), MONITOR_DEFAULTTONEAREST); - Q_ASSERT(data->monitor); - if (!data->monitor) { - WARNING << Utils::getSystemErrorMessage(kMonitorFromWindow); - } - // Remove the bad window styles added by Qt (it's not that "bad" though). - std::ignore = Utils::maybeFixupQtInternals(data->windowId); -#if 0 - data->callbacks->setWindowFlags(data->callbacks->getWindowFlags() | Qt::FramelessWindowHint); -#else -# if ((QT_VERSION != QT_VERSION_CHECK(6, 5, 3)) && (QT_VERSION != QT_VERSION_CHECK(6, 6, 0))) - // Qt maintains a frame margin internally, we need to update it accordingly - // otherwise we'll get lots of warning messages when we change the window - // geometry, it will also affect the final window geometry because QPA will - // always take it into account when setting window size and position. - std::ignore = Utils::updateInternalWindowFrameMargins(qWindow, true); -# endif -#endif - // Tell DWM our preferred frame margin. - std::ignore = Utils::updateWindowFrameMargins(data->windowId, false); - // Tell DWM we don't use the window icon/caption/sysmenu, don't draw them. - std::ignore = Utils::hideOriginalTitleBarElements(data->windowId); - // Without this hack, the child windows can't get DPI change messages from - // Windows, which means only the top level windows can be scaled to the correct - // size, we of course don't want such thing from happening. - std::ignore = Utils::fixupChildWindowsDpiMessage(data->windowId); -#if 0 // Conflicts with our blur mode setting. - // If we are using 3D APIs (D3D, Vulkan, OpenGL, etc) to draw the window content, - // we need to setup the DWM rendering policy as well. - if (Utils::isWindowAccelerated(qWindow) && Utils::isWindowTransparent(qWindow)) { - std::ignore = Utils::updateFramebufferTransparency(data->windowId); - } -#endif - if (WindowsVersionHelper::isWin10RS1OrGreater()) { - // Tell DWM we may need dark theme non-client area (title bar & frame border). - FramelessHelperEnableThemeAware(); - if (WindowsVersionHelper::isWin10RS5OrGreater()) { - const bool dark = (FramelessManager::instance()->systemTheme() == SystemTheme::Dark); - const auto isWidget = [&data]() -> bool { - const QObject *widget = data->callbacks->getWidgetHandle(); - return (widget && widget->isWidgetType()); - }(); - if (!isWidget) { - // Tell UXTheme we may need dark theme controls. - // Causes some QtWidgets paint incorrectly, so only apply to Qt Quick applications. - std::ignore = Utils::updateGlobalWin32ControlsTheme(data->windowId, dark); - } - std::ignore = Utils::refreshWin32ThemeResources(data->windowId, dark); - if (WindowsVersionHelper::isWin11OrGreater()) { - // DWM provides official API to adjust the window corner style, but only since Windows 11. - if (FramelessConfig::instance()->isSet(Option::WindowUseSquareCorners)) { - std::ignore = Utils::setCornerStyleForWindow(data->windowId, WindowCornerStyle::Square); - } - } - } - } - if (!g_internalData()->eventFilter) { - g_internalData()->eventFilter = std::make_unique(); - qApp->installNativeEventFilter(g_internalData()->eventFilter.get()); - } -} - -void FramelessHelperWin::removeWindow(const QObject *window) -{ - Q_UNUSED(window); -} - -bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result) -{ - if ((eventType != qtNativeEventType()) || !message || !result) { - return false; - } - // QPA by default stores the global mouse position in the pt field, - // but let's not reply on such Qt-specific extensions. -#if (QT_VERSION == QT_VERSION_CHECK(5, 11, 1)) - // Work-around a bug caused by typo which only exists in Qt 5.11.1 - const auto msg = *static_cast(message); -#else - const auto msg = static_cast(message); -#endif - const HWND hWnd = msg->hwnd; - if (!hWnd) { - // Why sometimes the window handle is null? Is it designed to be like this? - // Anyway, we should skip the entire processing in this case. - return false; - } - - const UINT uMsg = msg->message; - // We should skip these messages otherwise we will get crashes. - // NOTE: WM_QUIT won't be posted to the WindowProc function. - switch (uMsg) { - case WM_CLOSE: - case WM_DESTROY: - case WM_NCDESTROY: - // Undocumented messages: - case WM_UAHDESTROYWINDOW: - case WM_UNREGISTER_WINDOW_SERVICES: - return false; - default: - break; - } - - const auto windowId = reinterpret_cast(hWnd); - // Let's be extra safe. - if (!Utils::isValidWindow(windowId, false, true)) { - return false; - } - - const QObject *window = FramelessManagerPrivate::getWindow(windowId); - if (!window) { - return false; - } - const FramelessDataWinPtr data = tryGetData(window); - if (!data || !data->frameless || !data->callbacks) { - return false; - } - - QWindow *qWindow = data->callbacks->getWindowHandle(); - - const bool frameBorderVisible = Utils::isWindowFrameBorderVisible(); - - const WPARAM wParam = msg->wParam; - const LPARAM lParam = msg->lParam; - -#if (QT_VERSION < QT_VERSION_CHECK(6, 5, 1)) - const auto updateRestoreGeometry = [windowId, &data](const bool ignoreWindowState) -> void { - if (!ignoreWindowState && !Utils::isWindowNoState(windowId)) { - return; - } - const QRect rect = Utils::getWindowRestoreGeometry(windowId); - if (!Utils::isValidGeometry(rect)) { - WARNING << "The calculated restore geometry is invalid."; - return; - } - if (Utils::isValidGeometry(data->restoreGeometry) && (data->restoreGeometry == rect)) { - return; - } - data->restoreGeometry = rect; - }; -#endif // (QT_VERSION < QT_VERSION_CHECK(6, 5, 1)) - - const auto emulateClientAreaMessage = [hWnd, uMsg, wParam, lParam](const std::optional &overrideMessage = std::nullopt) -> void { - const int myMsg = overrideMessage.value_or(uMsg); - const auto wparam = [myMsg, wParam]() -> WPARAM { - if (myMsg == WM_NCMOUSELEAVE) { - // wParam is always ignored in mouse leave messages, but here we - // give them a special tag to be able to distinguish which messages - // are sent by ourselves. - return kMessageTag; - } - const quint64 keyState = Utils::getKeyState(); - if ((myMsg >= WM_NCXBUTTONDOWN) && (myMsg <= WM_NCXBUTTONDBLCLK)) { - const auto xButtonMask = GET_XBUTTON_WPARAM(wParam); - return MAKEWPARAM(keyState, xButtonMask); - } - return keyState; - }(); - const auto lparam = [myMsg, lParam, hWnd]() -> LPARAM { - if (myMsg == WM_NCMOUSELEAVE) { - // lParam is always ignored in mouse leave messages. - return 0; - } - const auto screenPos = POINT{ GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; - POINT clientPos = screenPos; - if (::ScreenToClient(hWnd, &clientPos) == FALSE) { - WARNING << Utils::getSystemErrorMessage(kScreenToClient); - return 0; - } - return MAKELPARAM(clientPos.x, clientPos.y); - }(); -#if 0 -# define SEND_MESSAGE ::SendMessageW -#else -# define SEND_MESSAGE ::PostMessageW -#endif - switch (myMsg) { - case WM_NCHITTEST: // Treat hit test messages as mouse move events. - case WM_NCMOUSEMOVE: - SEND_MESSAGE(hWnd, WM_MOUSEMOVE, wparam, lparam); - break; - case WM_NCLBUTTONDOWN: - SEND_MESSAGE(hWnd, WM_LBUTTONDOWN, wparam, lparam); - break; - case WM_NCLBUTTONUP: - SEND_MESSAGE(hWnd, WM_LBUTTONUP, wparam, lparam); - break; - case WM_NCLBUTTONDBLCLK: - SEND_MESSAGE(hWnd, WM_LBUTTONDBLCLK, wparam, lparam); - break; - case WM_NCRBUTTONDOWN: - SEND_MESSAGE(hWnd, WM_RBUTTONDOWN, wparam, lparam); - break; - case WM_NCRBUTTONUP: - SEND_MESSAGE(hWnd, WM_RBUTTONUP, wparam, lparam); - break; - case WM_NCRBUTTONDBLCLK: - SEND_MESSAGE(hWnd, WM_RBUTTONDBLCLK, wparam, lparam); - break; - case WM_NCMBUTTONDOWN: - SEND_MESSAGE(hWnd, WM_MBUTTONDOWN, wparam, lparam); - break; - case WM_NCMBUTTONUP: - SEND_MESSAGE(hWnd, WM_MBUTTONUP, wparam, lparam); - break; - case WM_NCMBUTTONDBLCLK: - SEND_MESSAGE(hWnd, WM_MBUTTONDBLCLK, wparam, lparam); - break; - case WM_NCXBUTTONDOWN: - SEND_MESSAGE(hWnd, WM_XBUTTONDOWN, wparam, lparam); - break; - case WM_NCXBUTTONUP: - SEND_MESSAGE(hWnd, WM_XBUTTONUP, wparam, lparam); - break; - case WM_NCXBUTTONDBLCLK: - SEND_MESSAGE(hWnd, WM_XBUTTONDBLCLK, wparam, lparam); - break; -#if 0 // ### TODO: How to handle touch events? - case WM_NCPOINTERUPDATE: - case WM_NCPOINTERDOWN: - case WM_NCPOINTERUP: - break; -#endif - case WM_NCMOUSEHOVER: - SEND_MESSAGE(hWnd, WM_MOUSEHOVER, wparam, lparam); - break; - case WM_NCMOUSELEAVE: - SEND_MESSAGE(hWnd, WM_MOUSELEAVE, wparam, lparam); - break; - default: - Q_UNREACHABLE(); - } - }; - - if (uMsg == WM_MOUSELEAVE) { - if (!isTaggedMessage(wParam)) { - // Qt will call TrackMouseEvent() to get the WM_MOUSELEAVE message when it receives - // WM_MOUSEMOVE messages, and since we are converting every WM_NCMOUSEMOVE message - // to WM_MOUSEMOVE message and send it back to the window to be able to hover our - // controls, we also get lots of WM_MOUSELEAVE messages at the same time because of - // the reason above, and these superfluous mouse leave events cause Qt to think the - // mouse has left the control, and thus we actually lost the hover state. - // So we filter out these superfluous mouse leave events here to avoid this issue. - const QPoint qtScenePos = Utils::fromNativeLocalPosition(qWindow, QPoint{ msg->pt.x, msg->pt.y }); - SystemButtonType dummy = SystemButtonType::Unknown; - if (data->callbacks->isInsideSystemButtons(qtScenePos, &dummy)) { - data->mouseLeaveBlocked = true; - *result = FALSE; - return true; - } - } - data->mouseLeaveBlocked = false; - } - - switch (uMsg) { -#if (QT_VERSION < QT_VERSION_CHECK(5, 9, 0)) // Qt has done this for us since 5.9.0 - case WM_NCCREATE: - // Enable automatic DPI scaling for the non-client area of the window, - // such as the caption bar, the scrollbars, and the menu bar. We need - // to do this explicitly and manually here (only inside WM_NCCREATE). - // If we are using the PMv2 DPI awareness mode, the non-client area - // of the window will be scaled by the OS automatically, so there will - // be no need to do this in that case. - std::ignore = Utils::enableNonClientAreaDpiScalingForWindow(windowId); - break; -#endif - case WM_NCCALCSIZE: { - // Windows是根据这个消息的返回值来设置窗口的客户区(窗口中真正显示的内容) - // 和非客户区(标题栏、窗口边框、菜单栏和状态栏等Windows系统自行提供的部分 - // ,不过对于Qt来说,除了标题栏和窗口边框,非客户区基本也都是自绘的)的范 - // 围的,lParam里存放的就是新客户区的几何区域,默认是整个窗口的大小,正常 - // 的程序需要修改这个参数,告知系统窗口的客户区和非客户区的范围(一般来说可 - // 以完全交给Windows,让其自行处理,使用默认的客户区和非客户区),因此如果 - // 我们不修改lParam,就可以使客户区充满整个窗口,从而去掉标题栏和窗口边框 - // (因为这些东西都被客户区给盖住了。但边框阴影也会因此而丢失,不过我们会使 - // 用其他方式将其带回,请参考其他消息的处理,此处不过多提及)。但有个情况要 - // 特别注意,那就是窗口最大化后,窗口的实际尺寸会比屏幕的尺寸大一点,从而使 - // 用户看不到窗口的边界,这样用户就不能在窗口最大化后调整窗口的大小了(虽然 - // 这个做法听起来特别奇怪,但Windows确实就是这样做的),因此如果我们要自行 - // 处理窗口的非客户区,就要在窗口最大化后,将窗口边框的宽度和高度(一般是相 - // 等的)从客户区裁剪掉,否则我们窗口所显示的内容就会超出屏幕边界,显示不全。 - // 如果用户开启了任务栏自动隐藏,在窗口最大化后,还要考虑任务栏的位置。因为 - // 如果窗口最大化后,其尺寸和屏幕尺寸相等(因为任务栏隐藏了,所以窗口最大化 - // 后其实是充满了整个屏幕,变相的全屏了),Windows会认为窗口已经进入全屏的 - // 状态,从而导致自动隐藏的任务栏无法弹出。要避免这个状况,就要使窗口的尺寸 - // 小于屏幕尺寸。我下面的做法参考了火狐、Chromium和Windows Terminal - // 如果没有开启任务栏自动隐藏,是不存在这个问题的,所以要先进行判断。 - // 一般情况下,*result设置为0(相当于DefWindowProc的返回值为0)就可以了, - // 根据MSDN的说法,返回0意为此消息已经被程序自行处理了,让Windows跳过此消 - // 息,否则Windows会添加对此消息的默认处理,对于当前这个消息而言,就意味着 - // 标题栏和窗口边框又会回来,这当然不是我们想要的结果。根据MSDN,当wParam - // 为FALSE时,只能返回0,但当其为TRUE时,可以返回0,也可以返回一个WVR_常 - // 量。根据Chromium的注释,当存在非客户区时,如果返回WVR_REDRAW会导致子 - // 窗口/子控件出现奇怪的bug(自绘控件错位),并且Lucas在Windows 10 - // 上成功复现,说明这个bug至今都没有解决。我查阅了大量资料,发现唯一的解决 - // 方案就是返回0。但如果不存在非客户区,且wParam为TRUE,最好返回 - // WVR_REDRAW,否则窗口在调整大小可能会产生严重的闪烁现象。 - // 虽然对大多数消息来说,返回0都代表让Windows忽略此消息,但实际上不同消息 - // 能接受的返回值是不一样的,请注意自行查阅MSDN。 - - // Sent when the size and position of a window's client area must be - // calculated. By processing this message, an application can - // control the content of the window's client area when the size or - // position of the window changes. If wParam is TRUE, lParam points - // to an NCCALCSIZE_PARAMS structure that contains information an - // application can use to calculate the new size and position of the - // client rectangle. If wParam is FALSE, lParam points to a RECT - // structure. On entry, the structure contains the proposed window - // rectangle for the window. On exit, the structure should contain - // the screen coordinates of the corresponding window client area. - // The client area is the window's content area, the non-client area - // is the area which is provided by the system, such as the title - // bar, the four window borders, the frame shadow, the menu bar, the - // status bar, the scroll bar, etc. But for Qt, it draws most of the - // window area (client + non-client) itself. We now know that the - // title bar and the window frame is in the non-client area and we - // can set the scope of the client area in this message, so we can - // remove the title bar and the window frame by let the non-client - // area be covered by the client area (because we can't really get - // rid of the non-client area, it will always be there, all we can - // do is to hide it) , which means we should let the client area's - // size the same with the whole window's size. So there is no room - // for the non-client area and then the user won't be able to see it - // again. But how to achieve this? Very easy, just leave lParam (the - // re-calculated client area) untouched. But of course you can - // modify lParam, then the non-client area will be seen and the - // window borders and the window frame will show up. However, things - // are quite different when you try to modify the top margin of the - // client area. DWM will always draw the whole title bar no matter - // what margin value you set for the top, unless you don't modify it - // and remove the whole top area (the title bar + the one pixel - // height window border). This can be confirmed in Windows - // Terminal's source code, you can also try yourself to verify - // it. So things will become quite complicated if you want to - // preserve the four window borders. - - // If `wParam` is `FALSE`, `lParam` points to a `RECT` that contains - // the proposed window rectangle for our window. During our - // processing of the `WM_NCCALCSIZE` message, we are expected to - // modify the `RECT` that `lParam` points to, so that its value upon - // our return is the new client area. We must return 0 if `wParam` - // is `FALSE`. - // If `wParam` is `TRUE`, `lParam` points to a `NCCALCSIZE_PARAMS` - // struct. This struct contains an array of 3 `RECT`s, the first of - // which has the exact same meaning as the `RECT` that is pointed to - // by `lParam` when `wParam` is `FALSE`. The remaining `RECT`s, in - // conjunction with our return value, can - // be used to specify portions of the source and destination window - // rectangles that are valid and should be preserved. We opt not to - // implement an elaborate client-area preservation technique, and - // simply return 0, which means "preserve the entire old client area - // and align it with the upper-left corner of our new client area". - const auto clientRect = ((wParam == FALSE) ? reinterpret_cast(lParam) : &(reinterpret_cast(lParam))->rgrc[0]); - if (frameBorderVisible) { - // Store the original top margin before the default window procedure applies the default frame. - const LONG originalTop = clientRect->top; - // Apply the default frame because we don't want to remove the whole window frame, - // we still need the standard window frame (the resizable frame border and the frame - // shadow) for the left, bottom and right edges. - // If we return 0 here directly, the whole window frame will be removed (which means - // there will be no resizable frame border and the frame shadow will also disappear), - // and that's also how most applications customize their title bars on Windows. It's - // totally OK but since we want to preserve as much original frame as possible, we - // can't use that solution. - const LRESULT hitTestResult = ::DefWindowProcW(hWnd, WM_NCCALCSIZE, wParam, lParam); - if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) { - *result = hitTestResult; - return true; - } - // Re-apply the original top from before the size of the default frame was applied, - // and the whole top frame (the title bar and the top border) is gone now. - // For the top frame, we only has 2 choices: (1) remove the top frame entirely, or - // (2) don't touch it at all. We can't preserve the top border by adjusting the top - // margin here. If we try to modify the top margin, the original title bar will - // always be painted by DWM regardless what margin we set, so here we can only remove - // the top frame entirely and use some special technique to bring the top border back. - clientRect->top = originalTop; - } - const bool max = IsMaximized(hWnd); - const bool full = Utils::isFullScreen(windowId); - // We don't need this correction when we're fullscreen. We will - // have the WS_POPUP size, so we don't have to worry about - // borders, and the default frame will be fine. - if (max && !full) { - // When a window is maximized, its size is actually a little bit more - // than the monitor's work area. The window is positioned and sized in - // such a way that the resize handles are outside of the monitor and - // then the window is clipped to the monitor so that the resize handle - // do not appear because you don't need them (because you can't resize - // a window when it's maximized unless you restore it). - const int frameSizeY = Utils::getResizeBorderThickness(windowId, false, true); - clientRect->top += frameSizeY; - if (!frameBorderVisible) { - clientRect->bottom -= frameSizeY; - const int frameSizeX = Utils::getResizeBorderThickness(windowId, true, true); - clientRect->left += frameSizeX; - clientRect->right -= frameSizeX; - } - } - // Attempt to detect if there's an autohide taskbar, and if - // there is, reduce our size a bit on the side with the taskbar, - // so the user can still mouse-over the taskbar to reveal it. - // Make sure to use MONITOR_DEFAULTTONEAREST, so that this will - // still find the right monitor even when we're restoring from - // minimized. - if (max || full) { - APPBARDATA abd; - SecureZeroMemory(&abd, sizeof(abd)); - abd.cbSize = sizeof(abd); - const UINT taskbarState = ::SHAppBarMessage(ABM_GETSTATE, &abd); - // First, check if we have an auto-hide taskbar at all: - if (taskbarState & ABS_AUTOHIDE) { - bool top = false, bottom = false, left = false, right = false; - // Due to ABM_GETAUTOHIDEBAREX was introduced in Windows 8.1, - // we have to use another way to judge this if we are running - // on Windows 7 or Windows 8. - if (WindowsVersionHelper::isWin8Point1OrGreater()) { - const std::optional monitorInfo = getMonitorForWindow(hWnd); - if (!monitorInfo.has_value()) { - WARNING << "Failed to retrieve the window's monitor."; - break; - } - const RECT monitorRect = monitorInfo.value().rcMonitor; - // This helper can be used to determine if there's a - // auto-hide taskbar on the given edge of the monitor - // we're currently on. - const auto hasAutohideTaskbar = [monitorRect](const UINT edge) -> bool { - APPBARDATA abd2; - SecureZeroMemory(&abd2, sizeof(abd2)); - abd2.cbSize = sizeof(abd2); - abd2.uEdge = edge; - abd2.rc = monitorRect; - const auto hTaskbar = reinterpret_cast(::SHAppBarMessage(ABM_GETAUTOHIDEBAREX, &abd2)); - return (hTaskbar != nullptr); - }; - top = hasAutohideTaskbar(ABE_TOP); - bottom = hasAutohideTaskbar(ABE_BOTTOM); - left = hasAutohideTaskbar(ABE_LEFT); - right = hasAutohideTaskbar(ABE_RIGHT); - } else { - int edge = -1; - APPBARDATA abd2; - SecureZeroMemory(&abd2, sizeof(abd2)); - abd2.cbSize = sizeof(abd2); - abd2.hWnd = ::FindWindowW(L"Shell_TrayWnd", nullptr); - if (abd2.hWnd) { - const HMONITOR windowMonitor = ::MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); - if (!windowMonitor) { - WARNING << Utils::getSystemErrorMessage(kMonitorFromWindow); - break; - } - const HMONITOR taskbarMonitor = ::MonitorFromWindow(abd2.hWnd, MONITOR_DEFAULTTOPRIMARY); - if (!taskbarMonitor) { - WARNING << Utils::getSystemErrorMessage(kMonitorFromWindow); - break; - } - if (taskbarMonitor == windowMonitor) { - ::SHAppBarMessage(ABM_GETTASKBARPOS, &abd2); - edge = abd2.uEdge; - } - } else { - WARNING << Utils::getSystemErrorMessage(kFindWindowW); - break; - } - top = (edge == ABE_TOP); - bottom = (edge == ABE_BOTTOM); - left = (edge == ABE_LEFT); - right = (edge == ABE_RIGHT); - } - // If there's a taskbar on any side of the monitor, reduce - // our size a little bit on that edge. - // Note to future code archeologists: - // This doesn't seem to work for fullscreen on the primary - // display. However, testing a bunch of other apps with - // fullscreen modes and an auto-hiding taskbar has - // shown that _none_ of them reveal the taskbar from - // fullscreen mode. This includes Edge, Firefox, Chrome, - // Sublime Text, PowerPoint - none seemed to support this. - // This does however work fine for maximized. - if (top) { - // Peculiarly, when we're fullscreen, - clientRect->top += kAutoHideTaskBarThickness; - } else if (bottom) { - clientRect->bottom -= kAutoHideTaskBarThickness; - } else if (left) { - clientRect->left += kAutoHideTaskBarThickness; - } else if (right) { - clientRect->right -= kAutoHideTaskBarThickness; - } - } - } - // This line improves the synchronization problem of DirectX surfaces greatly, especially on Win11. - std::ignore = Utils::updateAllDirectXSurfaces(); - std::ignore = Utils::syncWmPaintWithDwm(); // This should be executed at the very last. - // By returning WVR_REDRAW we can make the window resizing look less broken. - // But we must return 0 if wParam is FALSE, according to Microsoft Docs. - // **IMPORTANT NOTE**: - // If you are drawing something manually through D3D in your window, don't - // try to return WVR_REDRAW here, otherwise Windows exhibits bugs where - // client pixels and child windows are mispositioned by the width/height - // of the upper-left non-client area. It's confirmed that this issue exists - // from Windows 7 to Windows 10. Not tested on Windows 11 yet. Don't know - // whether it exists on Windows XP to Windows Vista or not. - static const bool needD3DWorkaround = (qEnvironmentVariableIntValue("FRAMELESSHELPER_USE_D3D_WORKAROUND") != 0); - *result = (((wParam == FALSE) || needD3DWorkaround) ? FALSE : WVR_REDRAW); - return true; - } - case WM_NCHITTEST: { - // 原生Win32窗口只有顶边是在窗口内部resize的,其余三边都是在窗口 - // 外部进行resize的,其原理是,WS_THICKFRAME这个窗口样式会在窗 - // 口的左、右和底边添加三个透明的resize区域,这三个区域在正常状态 - // 下是完全不可见的,它们由DWM负责绘制和控制。这些区域的宽度等于 - // (SM_CXSIZEFRAME + SM_CXPADDEDBORDER),高度等于 - // (SM_CYSIZEFRAME + SM_CXPADDEDBORDER),在100%缩放时,均等 - // 于8像素。它们属于窗口区域的一部分,但不属于客户区,而是属于非客 - // 户区,因此GetWindowRect获取的区域中是包含这三个resize区域的, - // 而GetClientRect获取的区域是不包含它们的。当把 - // DWMWA_EXTENDED_FRAME_BOUNDS作为参数调用 - // DwmGetWindowAttribute时,也能获取到一个窗口大小,这个大小介 - // 于前面两者之间,暂时不知道这个数据的意义及其作用。我们在 - // WM_NCCALCSIZE消息的处理中,已经把整个窗口都设置为客户区了,也 - // 就是说,我们的窗口已经没有非客户区了,因此那三个透明的resize区 - // 域,此刻也已经成为窗口客户区的一部分了,从而变得不透明了。所以 - // 现在的resize,看起来像是在窗口内部resize,是因为原本透明的地方 - // 现在变得不透明了,实际上,单纯从范围上来看,现在我们resize的地方, - // 就是普通窗口的边框外部,那三个透明区域的范围。 - // 因此,如果我们把边框完全去掉(就是我们正在做的事情),resize就 - // 会看起来是在内部进行,这个问题通过常规方法非常难以解决。我测试过 - // QQ和钉钉的窗口,它们的窗口就是在外部resize,但实际上它们是通过 - // 把窗口实际的内容,嵌入到一个完全透明的但尺寸要大一圈的窗口中实现 - // 的,虽然看起来效果还不错,但对于此项目而言,代码和窗口结构过于复 - // 杂,因此我没有采用此方案。然而,对于具体的软件项目而言,其做法也 - // 不失为一个优秀的解决方案,毕竟其在大多数条件下的表现都还可以。 - // - // 和1.x的做法不同,现在的2.x选择了保留窗口三边,去除整个窗口顶部, - // 好处是保留了系统的原生边框,外观较好,且与系统结合紧密,而且resize - // 的表现也有很大改善,缺点是需要自行绘制顶部边框线。原本以为只能像 - // Windows Terminal那样在WM_PAINT里搞黑魔法,但后来发现,其实只 - // 要颜色相近,我们自行绘制一根实线也几乎能以假乱真,而且这样也不会 - // 破坏Qt自己的绘制系统,能做到不依赖黑魔法就能实现像Windows Terminal - // 那样外观和功能都比较完美的自定义边框。 - - // A normal Win32 window can be resized outside of it. Here is the - // reason: the WS_THICKFRAME window style will cause a window has three - // transparent areas beside the window's left, right and bottom - // edge. Their width or height is eight pixels if the window is not - // scaled. In most cases, they are totally invisible. It's DWM's - // responsibility to draw and control them. They exist to let the - // user resize the window, visually outside of it. They are in the - // window area, but not the client area, so they are in the - // non-client area actually. But we have turned the whole window - // area into client area in WM_NCCALCSIZE, so the three transparent - // resize areas also become a part of the client area and thus they - // become visible. When we resize the window, it looks like we are - // resizing inside of it, however, that's because the transparent - // resize areas are visible now, we ARE resizing outside of the - // window actually. But I don't know how to make them become - // transparent again without breaking the frame shadow drawn by DWM. - // If you really want to solve it, you can try to embed your window - // into a larger transparent window and draw the frame shadow - // yourself. As what we have said in WM_NCCALCSIZE, you can only - // remove the top area of the window, this will let us be able to - // resize outside of the window and don't need much process in this - // message, it looks like a perfect plan, however, the top border is - // missing due to the whole top area is removed, and it's very hard - // to bring it back because we have to use a trick in WM_PAINT - // (learned from Windows Terminal), but no matter what we do in - // WM_PAINT, it will always break the backing store mechanism of Qt, - // so actually we can't do it. And it's very difficult to do such - // things in NativeEventFilters as well. What's worse, if we really - // do this, the four window borders will become white and they look - // horrible in dark mode. This solution only supports Windows 10 - // because the border width on Win10 is only one pixel, however it's - // eight pixels on Windows 7 so preserving the three window borders - // looks terrible on old systems. - // - // Unlike the 1.x code, we choose to preserve the three edges of the - // window in 2.x, and get rid of the whole top part of the window. - // There are quite some advantages such as the appearance looks much - // better and due to we have the original system window frame, our - // window can behave just like a normal Win32 window even if we now - // doesn't have a title bar at all. Most importantly, the flicker and - // jitter during window resizing is totally gone now. The disadvantage - // is we have to draw a top frame border ourself. Previously I thought - // we have to do the black magic in WM_PAINT just like what Windows - // Terminal does, however, later I found that if we choose a proper - // color, our homemade top border can almost have exactly the same - // appearance with the system's one. - - const auto hitTestRecorder = qScopeGuard([&data, &result](){ - data->lastHitTestResult = getHittedWindowPart(*result); - }); - - const auto nativeGlobalPos = POINT{ GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; - POINT nativeLocalPos = nativeGlobalPos; - if (::ScreenToClient(hWnd, &nativeLocalPos) == FALSE) { - WARNING << Utils::getSystemErrorMessage(kScreenToClient); - break; - } - - auto clientRect = RECT{ 0, 0, 0, 0 }; - if (::GetClientRect(hWnd, &clientRect) == FALSE) { - WARNING << Utils::getSystemErrorMessage(kGetClientRect); - break; - } - const auto clientWidth = RECT_WIDTH(clientRect); - const auto clientHeight = RECT_HEIGHT(clientRect); - - const QPoint qtScenePos = Utils::fromNativeLocalPosition(qWindow, QPoint(nativeLocalPos.x, nativeLocalPos.y)); - - const bool isFixedSize = data->callbacks->isWindowFixedSize(); - const bool isTitleBar = data->callbacks->isInsideTitleBarDraggableArea(qtScenePos); - const bool dontOverrideCursor = data->callbacks->getProperty(kDontOverrideCursorVar, false).toBool(); - const bool dontToggleMaximize = data->callbacks->getProperty(kDontToggleMaximizeVar, false).toBool(); - - if (dontToggleMaximize) { - static bool warnedOnce = false; - if (!warnedOnce) { - warnedOnce = true; - DEBUG << "To disable window maximization, you should remove the " - "WS_MAXIMIZEBOX style from the window instead. FramelessHelper " - "won't do that for you, so you'll have to do it manually yourself."; - } - } - - SystemButtonType sysButtonType = SystemButtonType::Unknown; - if (!isFixedSize && data->callbacks->isInsideSystemButtons(qtScenePos, &sysButtonType)) { - // Firstly, we set the hit test result to a default value to be able to detect whether we - // have changed it or not afterwards. - *result = HTNOWHERE; - // Even if the mouse is inside the chrome button area now, we should still allow the user - // to be able to resize the window with the top or right window border, this is also the - // normal behavior of a native Win32 window (but only when the window is not maximized/ - // fullscreened/minimized, of course). - if (Utils::isWindowNoState(windowId)) { - static constexpr const int kBorderSize = 2; - const bool isTop = (nativeLocalPos.y <= kBorderSize); - const bool isRight = (nativeLocalPos.x >= (clientWidth - kBorderSize)); - if (isTop || isRight) { - if (dontOverrideCursor) { - // The user doesn't want the window to be resized, so we tell Windows we are - // in the client area so that the controls beneath the mouse cursor can still - // be hovered or clicked. - *result = (isTitleBar ? HTCAPTION : HTCLIENT); - } else { - if (isTop && isRight) { - *result = HTTOPRIGHT; - } else if (isTop) { - *result = HTTOP; - } else { - *result = HTRIGHT; - } - } - } - } - if (*result == HTNOWHERE) { - // OK, we are now really inside one of the chrome buttons, tell Windows the exact role of our button. - // The Snap Layout feature introduced in Windows 11 won't work without this. - switch (sysButtonType) { - case SystemButtonType::WindowIcon: - *result = HTSYSMENU; - break; - case SystemButtonType::Help: - *result = HTHELP; - break; - case SystemButtonType::Minimize: - *result = HTREDUCE; - break; - case SystemButtonType::Maximize: - case SystemButtonType::Restore: - *result = HTZOOM; - break; - case SystemButtonType::Close: - *result = HTCLOSE; - break; - case SystemButtonType::Unknown: - break; - } - } - if (*result == HTNOWHERE) { - // OK, it seems we are not inside the window resize area, nor inside the chrome buttons, - // tell Windows we are in the client area to let Qt handle this event. - *result = HTCLIENT; - } - return true; - } - // OK, we are not inside of any chrome buttons, try to find out which part of the window - // are we hitting. - - const bool max = IsMaximized(hWnd); - const bool full = Utils::isFullScreen(windowId); - const int frameSizeY = Utils::getResizeBorderThickness(windowId, false, true); - const bool isTop = (nativeLocalPos.y < frameSizeY); - - if (frameBorderVisible) { - // This will handle the left, right and bottom parts of the frame - // because we didn't change them. - const LRESULT originalHitTestResult = ::DefWindowProcW(hWnd, WM_NCHITTEST, 0, lParam); - if (originalHitTestResult != HTCLIENT) { - // Even if the window is not resizable, we still can't return HTCLIENT here because - // when we enters this code path, it means the mouse cursor is outside of the window, - // that is, the three transparent window resize area. Returning HTCLIENT will confuse - // Windows and we can't put our controls there anyway. - *result = ((isFixedSize || dontOverrideCursor) ? HTBORDER : originalHitTestResult); - return true; - } - if (full) { - *result = HTCLIENT; - return true; - } - if (max) { - *result = (isTitleBar ? HTCAPTION : HTCLIENT); - return true; - } - // At this point, we know that the cursor is inside the client area - // so it has to be either the little border at the top of our custom - // title bar or the drag bar. Apparently, it must be the drag bar or - // the little border at the top which the user can use to move or - // resize the window. - if (isTop) { - // Return HTCLIENT instead of HTBORDER here, because the mouse is - // inside our homemade title bar now, return HTCLIENT to let our - // title bar can still capture mouse events. - *result = ((isFixedSize || dontOverrideCursor) ? (isTitleBar ? HTCAPTION : HTCLIENT) : HTTOP); - return true; - } - if (isTitleBar) { - *result = HTCAPTION; - return true; - } - *result = HTCLIENT; - } else { - if (full) { - *result = HTCLIENT; - return true; - } - if (max) { - *result = (isTitleBar ? HTCAPTION : HTCLIENT); - return true; - } - if (!isFixedSize) { - const bool isBottom = (nativeLocalPos.y >= (clientHeight - frameSizeY)); - // Make the border a little wider to let the user easy to resize on corners. - const auto scaleFactor = ((isTop || isBottom) ? qreal(2) : qreal(1)); - const int frameSizeX = Utils::getResizeBorderThickness(windowId, true, true); - const int scaledFrameSizeX = std::round(qreal(frameSizeX) * scaleFactor); - const bool isLeft = (nativeLocalPos.x < scaledFrameSizeX); - const bool isRight = (nativeLocalPos.x >= (clientWidth - scaledFrameSizeX)); - if (dontOverrideCursor && (isTop || isBottom || isLeft || isRight)) { - // Return HTCLIENT instead of HTBORDER here, because the mouse is - // inside the window now, return HTCLIENT to let the controls - // inside our window can still capture mouse events. - *result = (isTitleBar ? HTCAPTION : HTCLIENT); - return true; - } - if (isTop) { - if (isLeft) { - *result = HTTOPLEFT; - return true; - } - if (isRight) { - *result = HTTOPRIGHT; - return true; - } - *result = HTTOP; - return true; - } - if (isBottom) { - if (isLeft) { - *result = HTBOTTOMLEFT; - return true; - } - if (isRight) { - *result = HTBOTTOMRIGHT; - return true; - } - *result = HTBOTTOM; - return true; - } - if (isLeft) { - *result = HTLEFT; - return true; - } - if (isRight) { - *result = HTRIGHT; - return true; - } - } - if (isTitleBar) { - *result = HTCAPTION; - return true; - } - *result = HTCLIENT; - } - return true; - } - case WM_MOUSEMOVE: - if ((data->lastHitTestResult != WindowPart::ChromeButton) && data->mouseLeaveBlocked) { - data->mouseLeaveBlocked = false; - std::ignore = requestForMouseLeaveMessage(hWnd, false); - } - break; - case WM_NCMOUSEMOVE: - case WM_NCLBUTTONDOWN: - case WM_NCLBUTTONUP: - case WM_NCLBUTTONDBLCLK: - case WM_NCRBUTTONDOWN: - case WM_NCRBUTTONUP: - case WM_NCRBUTTONDBLCLK: - case WM_NCMBUTTONDOWN: - case WM_NCMBUTTONUP: - case WM_NCMBUTTONDBLCLK: - case WM_NCXBUTTONDOWN: - case WM_NCXBUTTONUP: - case WM_NCXBUTTONDBLCLK: -#if 0 // ### TODO: How to handle touch events? - case WM_NCPOINTERUPDATE: - case WM_NCPOINTERDOWN: - case WM_NCPOINTERUP: -#endif - case WM_NCMOUSEHOVER: { - const WindowPart currentWindowPart = data->lastHitTestResult; - if (uMsg == WM_NCMOUSEMOVE) { - if (currentWindowPart != WindowPart::ChromeButton) { - std::ignore = data->callbacks->resetQtGrabbedControl(); - if (data->mouseLeaveBlocked) { - emulateClientAreaMessage(WM_NCMOUSELEAVE); - } - } - - // We need to make sure we get the right hit-test result when a WM_NCMOUSELEAVE comes, - // so we reset it when we receive a WM_NCMOUSEMOVE. - - // If the mouse is entering the client area, there must be a WM_NCHITTEST setting - // it to `Client` before the WM_NCMOUSELEAVE comes; - // If the mouse is leaving the window, current window part remains as `Outside`. - data->lastHitTestResult = WindowPart::Outside; - } - - if (currentWindowPart == WindowPart::ChromeButton) { - emulateClientAreaMessage(); - if (uMsg == WM_NCMOUSEMOVE) { - // ### FIXME FIXME FIXME - // ### FIXME: Calling DefWindowProc() here is really dangerous, investigate how to avoid doing this. - // ### FIXME FIXME FIXME - *result = ::DefWindowProcW(hWnd, WM_NCMOUSEMOVE, wParam, lParam); - } else { - // According to MSDN, we should return non-zero for X button messages to indicate - // we have handled these messages (due to historical reasons), for all other messages - // we should return zero instead. - *result = (((uMsg >= WM_NCXBUTTONDOWN) && (uMsg <= WM_NCXBUTTONDBLCLK)) ? TRUE : FALSE); - } - return true; - } - } break; - case WM_NCMOUSELEAVE: { - const WindowPart currentWindowPart = data->lastHitTestResult; - if (currentWindowPart == WindowPart::ChromeButton) { - // If we press on the chrome button and move mouse, Windows will take the pressing area - // as HTCLIENT which maybe because of our former retransmission of WM_NCLBUTTONDOWN, as - // a result, a WM_NCMOUSELEAVE will come immediately and a lot of WM_MOUSEMOVE will come - // if we move the mouse, we should track the mouse in advance. - if (data->mouseLeaveBlocked) { - data->mouseLeaveBlocked = false; - std::ignore = requestForMouseLeaveMessage(hWnd, false); - } - } else { - if (data->mouseLeaveBlocked) { - // The mouse is moving from the chrome button to other non-client area, we should - // emulate a WM_MOUSELEAVE message to reset the button state. - emulateClientAreaMessage(WM_NCMOUSELEAVE); - } - - if (currentWindowPart == WindowPart::Outside) { - // Notice: we're not going to clear window part cache when the mouse leaves window - // from client area, which means we will get previous window part as HTCLIENT if - // the mouse leaves window from client area and enters window from non-client area, - // but it has no bad effect. - - std::ignore = data->callbacks->resetQtGrabbedControl(); - } - } - } break; -#if (QT_VERSION < QT_VERSION_CHECK(6, 2, 2)) // I contributed this small technique to upstream Qt since 6.2.2 - case WM_WINDOWPOSCHANGING: { - // Tell Windows to discard the entire contents of the client area, as re-using - // parts of the client area would lead to jitter during resize. - // Check the suggestedGeometry against the current one to only discard during - // resize, and not a plain move, otherwise this flag will cause many extra - // repaints during window move, which will slow down the general performance - // of the application a lot. - const auto windowPos = reinterpret_cast(lParam); - const QRect suggestedFrameGeometry{ windowPos->x, windowPos->y, windowPos->cx, windowPos->cy }; - const QMargins frameMargins = (Utils::getWindowSystemFrameMargins(windowId) + Utils::getWindowCustomFrameMargins(qWindow)); - const QRect suggestedGeometry = (suggestedFrameGeometry - frameMargins); - if (Utils::toNativePixels(qWindow, qWindow->size()) != suggestedGeometry.size()) { - windowPos->flags |= SWP_NOCOPYBITS; - } - } break; -#endif -#if (QT_VERSION <= QT_VERSION_CHECK(6, 4, 2)) - case WM_GETDPISCALEDSIZE: { - // QtBase commit 2cfca7fd1911cc82a22763152c04c65bc05bc19a introduced a bug - // which caused the custom margins is ignored during the handling of the - // WM_GETDPISCALEDSIZE message, it was shipped with Qt 6.2.1 ~ 6.4.2. - // We workaround it by overriding the wrong handling directly. - RECT clientRect = {}; - if (::GetClientRect(hWnd, &clientRect) == FALSE) { - WARNING << Utils::getSystemErrorMessage(kGetClientRect); - *result = FALSE; // Use the default linear DPI scaling provided by Windows. - return true; // Jump over Qt's wrong handling logic. - } - const auto newDpi = UINT(wParam); - const QSize oldSize = {RECT_WIDTH(clientRect), RECT_HEIGHT(clientRect)}; - const QSize newSize = Utils::rescaleSize(oldSize, data->dpi.x, newDpi); - const auto suggestedSize = reinterpret_cast(lParam); - suggestedSize->cx = newSize.width(); - suggestedSize->cy = newSize.height(); - // If the window frame is visible, we need to expand the suggested size, currently - // it's pure client size, we need to add the frame size to it. Windows expects a - // full window size, including the window frame. - // If the window frame is not visible, the window size equals to the client size, - // the suggested size doesn't need further adjustments. - if (frameBorderVisible) { - const int frameSizeX = Utils::getResizeBorderThicknessForDpi(true, newDpi); - const int frameSizeY = Utils::getResizeBorderThicknessForDpi(false, newDpi); - suggestedSize->cx += (frameSizeX * 2); // The size of the two resize borders on the left and right edge. - suggestedSize->cy += frameSizeY; // Only add the bottom resize border. We don't have anything on the top edge. - // Both the top resize border and the title bar are in the client area. - } - *result = TRUE; // We have set our preferred window size, don't use the default linear DPI scaling. - return true; // Jump over Qt's wrong handling logic. - } -#endif // (QT_VERSION <= QT_VERSION_CHECK(6, 4, 2)) - case WM_DPICHANGED: { - const Dpi oldDpi = data->dpi; - const auto newDpi = Dpi{ UINT(LOWORD(wParam)), UINT(HIWORD(wParam)) }; - DEBUG.noquote() << "New DPI for window" << hwnd2str(hWnd) - << "is" << newDpi << "(was" << oldDpi << ")."; - data->dpi = newDpi; -#if (QT_VERSION < QT_VERSION_CHECK(6, 5, 1)) - if (Utils::isValidGeometry(data->restoreGeometry)) { - // Update the window size only. The position should not be changed. - data->restoreGeometry.setSize(Utils::rescaleSize(data->restoreGeometry.size(), oldDpi.x, newDpi.x)); - } -#endif // (QT_VERSION < QT_VERSION_CHECK(6, 5, 1)) - data->callbacks->forceChildrenRepaint(); - } break; - case WM_DWMCOMPOSITIONCHANGED: - // Re-apply the custom window frame if recovered from the basic theme. - std::ignore = Utils::updateWindowFrameMargins(windowId, false); - break; -#if (QT_VERSION < QT_VERSION_CHECK(6, 5, 1)) - case WM_ENTERSIZEMOVE: // Sent to a window when the user drags the title bar or the resize border. - case WM_EXITSIZEMOVE: // Sent to a window when the user releases the mouse button (from dragging the title bar or the resize border). - updateRestoreGeometry(false); - break; - case WM_SIZE: { - if (wParam != SIZE_MAXIMIZED) { - break; - } - if (!Utils::isValidGeometry(data->restoreGeometry)) { - updateRestoreGeometry(true); - break; - } - WINDOWPLACEMENT wp; - SecureZeroMemory(&wp, sizeof(wp)); - wp.length = sizeof(wp); - if (::GetWindowPlacement(hWnd, &wp) == FALSE) { - WARNING << Utils::getSystemErrorMessage(kGetWindowPlacement); - break; - } - // The restore geometry is correct, no need to bother. - if (rect2qrect(wp.rcNormalPosition) == data->restoreGeometry) { - break; - } - // OK, the restore geometry is wrong, let's correct it then :) - wp.rcNormalPosition = qrect2rect(data->restoreGeometry); - if (::SetWindowPlacement(hWnd, &wp) == FALSE) { - WARNING << Utils::getSystemErrorMessage(kSetWindowPlacement); - } - } break; -#endif // (QT_VERSION < QT_VERSION_CHECK(6, 5, 1)) - case WM_MOVE: { - const HMONITOR currentMonitor = ::MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); - Q_ASSERT(currentMonitor); - if (!currentMonitor) { - WARNING << Utils::getSystemErrorMessage(kMonitorFromWindow); - break; - } - if (currentMonitor == data->monitor) { - break; - } - data->monitor = currentMonitor; - data->callbacks->forceChildrenRepaint(); - } break; - case WM_SYSCOMMAND: { - const WPARAM filteredWParam = (wParam & 0xFFF0); - // When the window is fullscreened, don't enter screen saver or power - // down the monitor (only a suggestion to the OS, the OS can still ignore - // our request). - if ((filteredWParam == SC_SCREENSAVE) || (filteredWParam == SC_MONITORPOWER)) { - if (Utils::isFullScreen(windowId)) { - *result = FALSE; - return true; - } - } - } break; - case WM_STYLECHANGED: { - // The window style has been changed. - if (wParam & GWL_STYLE) { - // We need a little delay here because Qt will always change the window style - // first and then change the window geometry, however we need to check the window - // geometry to see if we need to adjust the window style or not, so we need to - // wait until the window geometry has been changed. - QTimer::singleShot(0, qWindow, [windowId, hWnd](){ - // There's nothing to do when the window is fullscreened. - if (Utils::isFullScreen(windowId)) { - return; - } - // Check if the window style is "broken" when we are not fullscreened. - ::SetLastError(ERROR_SUCCESS); - auto dwStyle = static_cast(::GetWindowLongPtrW(hWnd, GWL_STYLE)); - if (dwStyle == 0) { - WARNING << Utils::getSystemErrorMessage(kGetWindowLongPtrW); - return; - } - // Avoid infinite recursions by not touching the window style if it's - // appropriate. - const bool hasPopup = (dwStyle & WS_POPUP); - const bool thickFrameMissing = !(dwStyle & WS_THICKFRAME); - if (!(hasPopup || thickFrameMissing)) { - return; - } - dwStyle &= ~WS_POPUP; - dwStyle |= WS_THICKFRAME; - ::SetLastError(ERROR_SUCCESS); - if (::SetWindowLongPtrW(hWnd, GWL_STYLE, LONG_PTR(dwStyle)) == 0) { - WARNING << Utils::getSystemErrorMessage(kSetWindowLongPtrW); - } - }); - } - // The extended window style has been changed. - if (wParam & GWL_EXSTYLE) { - } - } break; - default: - break; - } - - if (!frameBorderVisible) { - switch (uMsg) { - case WM_NCUAHDRAWCAPTION: - case WM_NCUAHDRAWFRAME: { - // These undocumented messages are sent to draw themed window - // borders. Block them to prevent drawing borders over the client - // area. - *result = FALSE; - return true; - } - case WM_NCPAINT: { - // 边框阴影处于非客户区的范围,因此如果直接阻止非客户区的绘制,会导致边框阴影丢失 - - if (!Utils::isDwmCompositionEnabled()) { - // Only block WM_NCPAINT when DWM composition is disabled. If - // it's blocked when DWM composition is enabled, the frame - // shadow won't be drawn. - *result = FALSE; - return true; - } else { - break; - } - } - case WM_NCACTIVATE: { - if (Utils::isDwmCompositionEnabled()) { - // DefWindowProc won't repaint the window border if lParam (normally a HRGN) - // is -1. See the following link's "lParam" section: - // https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-ncactivate - // Don't use "*result = 0" here, otherwise the window won't respond to the - // window activation state change. - *result = ::DefWindowProcW(hWnd, WM_NCACTIVATE, wParam, -1); - } else { - if (wParam == FALSE) { - *result = TRUE; - } else { - *result = FALSE; - } - } - return true; - } - case WM_SETICON: - case WM_SETTEXT: { - // Disable painting while these messages are handled to prevent them - // from drawing a window caption over the client area. - ::SetLastError(ERROR_SUCCESS); - const auto oldStyle = static_cast(::GetWindowLongPtrW(hWnd, GWL_STYLE)); - if (oldStyle == 0) { - WARNING << Utils::getSystemErrorMessage(kGetWindowLongPtrW); - break; - } - // Prevent Windows from drawing the default title bar by temporarily - // toggling the WS_VISIBLE style. - const DWORD newStyle = (oldStyle & ~WS_VISIBLE); - ::SetLastError(ERROR_SUCCESS); - if (::SetWindowLongPtrW(hWnd, GWL_STYLE, static_cast(newStyle)) == 0) { - WARNING << Utils::getSystemErrorMessage(kSetWindowLongPtrW); - break; - } - std::ignore = Utils::triggerFrameChange(windowId); - const LRESULT originalResult = ::DefWindowProcW(hWnd, uMsg, wParam, lParam); - ::SetLastError(ERROR_SUCCESS); - if (::SetWindowLongPtrW(hWnd, GWL_STYLE, static_cast(oldStyle)) == 0) { - WARNING << Utils::getSystemErrorMessage(kSetWindowLongPtrW); - break; - } - std::ignore = Utils::triggerFrameChange(windowId); - *result = originalResult; - return true; - } - default: - break; - } - } - -#if 0 // Conflicts with our blur mode setting. - if ((uMsg == WM_DWMCOMPOSITIONCHANGED) || (uMsg == WM_DWMCOLORIZATIONCOLORCHANGED)) { - if (Utils::isWindowAccelerated(qWindow) && Utils::isWindowTransparent(qWindow)) { - std::ignore = Utils::updateFramebufferTransparency(windowId); - } - } -#endif - - const bool wallpaperChanged = ((uMsg == WM_SETTINGCHANGE) && (wParam == SPI_SETDESKWALLPAPER)); - bool systemThemeChanged = ((uMsg == WM_THEMECHANGED) || (uMsg == WM_SYSCOLORCHANGE) - || (uMsg == WM_DWMCOLORIZATIONCOLORCHANGED)); - if (WindowsVersionHelper::isWin10RS1OrGreater()) { - if (uMsg == WM_SETTINGCHANGE) { - if ((wParam == 0) && (lParam != 0) // lParam sometimes may be NULL. - && (std::wcscmp(reinterpret_cast(lParam), kThemeSettingChangeEventName) == 0)) { - systemThemeChanged = true; - if (WindowsVersionHelper::isWin10RS5OrGreater()) { - const bool dark = (FramelessManager::instance()->systemTheme() == SystemTheme::Dark); - const auto isWidget = [&data]() -> bool { - const auto widget = data->callbacks->getWidgetHandle(); - return (widget && widget->isWidgetType()); - }(); - if (!isWidget) { - // Causes some QtWidgets paint incorrectly, so only apply to Qt Quick applications. - std::ignore = Utils::updateGlobalWin32ControlsTheme(windowId, dark); - } - std::ignore = Utils::refreshWin32ThemeResources(windowId, dark); - } - } - } - } - if (systemThemeChanged || wallpaperChanged) { - // Sometimes the FramelessManager instance may be destroyed already. - if (FramelessManager * const manager = FramelessManager::instance()) { - if (FramelessManagerPrivate * const managerPriv = FramelessManagerPrivate::get(manager)) { - if (systemThemeChanged) { - managerPriv->notifySystemThemeHasChangedOrNot(); - } - if (wallpaperChanged) { - managerPriv->notifyWallpaperHasChangedOrNot(); - } - } - } - } - - return false; -} - -FRAMELESSHELPER_END_NAMESPACE - -#endif // native_impl - -#endif // Q_OS_WINDOWS diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelper_win.h b/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelper_win.h deleted file mode 100644 index 419c1c4d..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelper_win.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Core/framelesshelper_win.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelper_windows.h b/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelper_windows.h deleted file mode 100644 index 6825491a..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelper_windows.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Core/framelesshelper_windows.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelpercore.qrc b/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelpercore.qrc deleted file mode 100644 index 0f0fa487..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelpercore.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - resources/fonts/iconfont.ttf - resources/images/noise.png - - diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelpercore_global.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelpercore_global.cpp deleted file mode 100644 index 51f539c9..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelpercore_global.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "framelesshelpercore_global.h" -#include "framelesshelpercore_global_p.h" -#include "versionnumber_p.h" -#include "utils.h" -#include -#include -#include - -#ifndef QT_NO_DEBUG_STREAM -QT_BEGIN_NAMESPACE -QDebug operator<<(QDebug d, const FRAMELESSHELPER_PREPEND_NAMESPACE(VersionNumber) &ver) -{ - const QDebugStateSaver saver(d); - d.nospace().noquote() << "VersionNumber(" - << ver.Major << ", " - << ver.Minor << ", " - << ver.Patch << ", " - << ver.Tweak << ')'; - return d; -} - -QDebug operator<<(QDebug d, const FRAMELESSHELPER_PREPEND_NAMESPACE(Global)::VersionInfo &ver) -{ - const QDebugStateSaver saver(d); - unsigned long major = 0, minor = 0, patch = 0; - FRAMELESSHELPER_EXTRACT_VERSION(ver.version.num, major, minor, patch) - const auto ver_num = FRAMELESSHELPER_PREPEND_NAMESPACE(VersionNumber){ major, minor, patch }; - d.nospace().noquote() << "VersionInfo(" - << "version number: " << ver_num << ", " - << "version string: " << ver.version.str << ", " - << "commit hash: " << ver.commit.hash << ", " - << "commit subject: " << ver.commit.subject << ", " - << "commit author: " << ver.commit.author << ", " - << "commit date time: " << ver.commit.datetime << ", " - << "commit branch: " << ver.commit.branch << ", " - << "compiler name: " << ver.compiler.name << ", " - << "compiler version: " << ver.compiler.version << ", " - << "compiler vendor: " << ver.compiler.vendor << ", " - << "cmake version: " << ver.build.cmake_version << ", " - << "cmake configure date time: " << ver.build.configure_datetime << ", " - << "cmake generator: " << ver.build.generator << ", " - << "architecture: " << ver.build.architecture << ", " - << "debug build: " << ver.build.is_debug << ", " - << "static build: " << ver.build.is_static << ')'; - return d; -} - -QDebug operator<<(QDebug d, const FRAMELESSHELPER_PREPEND_NAMESPACE(Global)::Dpi &dpi) -{ - const QDebugStateSaver saver(d); - const qreal scaleFactor = (qreal(dpi.x) / qreal(FRAMELESSHELPER_PREPEND_NAMESPACE(Utils)::defaultScreenDpi())); - d.nospace().noquote() << "Dpi(" - << "x: " << dpi.x << ", " - << "y: " << dpi.y << ", " - << "scale factor: " << scaleFactor << ')'; - return d; -} -QT_END_NAMESPACE -#endif // QT_NO_DEBUG_STREAM - -#if FRAMELESSHELPER_CONFIG(bundle_resource) -// The "Q_INIT_RESOURCE()" macro can't be used within a namespace, -// so we wrap it into a separate function outside of the namespace and -// then call it instead inside the namespace, that's also the recommended -// workaround provided by Qt's official documentation. -void FramelessHelperCoreInitResource() -{ - Q_INIT_RESOURCE(framelesshelpercore); -} -#endif // FRAMELESSHELPER_CONFIG(bundle_resource) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcCoreGlobal, "wangwenx190.framelesshelper.core.global") -# define INFO qCInfo(lcCoreGlobal) -# define DEBUG qCDebug(lcCoreGlobal) -# define WARNING qCWarning(lcCoreGlobal) -# define CRITICAL qCCritical(lcCoreGlobal) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -#ifdef Q_OS_WINDOWS -static_assert(std::size(WindowsVersions) == (static_cast(WindowsVersion::Latest) + 1)); -#endif - -FramelessCallbacks::FramelessCallbacks() = default; - -FramelessCallbacks::~FramelessCallbacks() = default; - -FramelessCallbacksPtr FramelessCallbacks::create() -{ - return std::make_shared(); -} - -FramelessExtraData::FramelessExtraData() = default; - -FramelessExtraData::~FramelessExtraData() = default; - -FramelessData::FramelessData() = default; - -FramelessData::~FramelessData() = default; - -void FramelessHelperCoreInitialize() -{ - static bool inited = false; - if (inited) { - return; - } - inited = true; - - FramelessHelperPrintLogo(); - -#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) - // Qt's Wayland experience is not good, so we force the XCB backend here. - // TODO: Remove this hack once Qt's Wayland implementation is good enough. - // We are setting the preferred QPA backend, so we have to set it early - // enough, that is, before the construction of any Q(Gui)Application - // instances. QCoreApplication won't instantiate the platform plugin. - qputenv("QT_QPA_PLATFORM", "xcb"); - // Fedora and Arch users report segfault when calling XInitThreads() and gtk_init(). - //XInitThreads(); // Users report that GTK is crashing without this. - //gtk_init(nullptr, nullptr); // Users report that GTK functionalities won't work without this. -#endif - -#if (defined(Q_OS_MACOS) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))) - qputenv("QT_MAC_WANTS_LAYER", "1"); -#endif - -#ifdef Q_OS_WINDOWS - // This is equivalent to set the "dpiAware" and "dpiAwareness" field in - // your manifest file. It works through out Windows Vista to Windows 11. - // It's highly recommended to enable the highest DPI awareness mode - // (currently it's PerMonitor Version 2, or PMv2 for short) for any GUI - // applications, to allow your user interface scale to an appropriate - // size and still stay sharp, though you will have to do the calculation - // and resize by yourself. - std::ignore = Utils::tryToEnableHighestDpiAwarenessLevel(); - // This function need to be called before any dialogs are created, so - // to be safe we call it here. - // Without this hack, our native dialogs won't be able to respond to - // DPI change messages correctly, especially the non-client area. - std::ignore = Utils::fixupDialogsDpiScaling(); -#endif - - // We need this flag to enable nested frameless windows, however, - // this flag is known to be __NOT__ compatible with QGLWidget. - QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); - -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - // Enable high DPI scaling by default, but only for Qt5 applications, - // because this has become the default setting since Qt6 and it can't - // be changed from outside anymore (except for internal testing purposes). - QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); -#endif -} - -void FramelessHelperCoreUninitialize() -{ - static bool uninited = false; - if (uninited) { - return; - } - uninited = true; -} - -VersionInfo FramelessHelperVersion() -{ - static const auto result = []() -> VersionInfo { - VersionInfo vi = {}; - vi.version.num = FRAMELESSHELPER_VERSION; - vi.version.str = FRAMELESSHELPER_VERSION_STR; - vi.commit.hash = FRAMELESSHELPER_COMMIT_HASH_STR; - vi.commit.subject = FRAMELESSHELPER_COMMIT_SUBJECT_STR; - vi.commit.author = FRAMELESSHELPER_COMMIT_AUTHOR_STR; - vi.commit.datetime = FRAMELESSHELPER_COMMIT_DATETIME_STR; - vi.commit.branch = FRAMELESSHELPER_COMMIT_BRANCH_STR; - vi.compiler.name = FRAMELESSHELPER_COMPILER_NAME_STR; - vi.compiler.version = FRAMELESSHELPER_COMPILER_VERSION_STR; - vi.compiler.vendor = FRAMELESSHELPER_COMPILER_VENDOR_STR; - vi.build.cmake_version = FRAMELESSHELPER_CMAKE_VERSION_STR; - vi.build.configure_datetime = FRAMELESSHELPER_BUILD_DATETIME_STR; - vi.build.generator = FRAMELESSHELPER_CMAKE_GENERATOR_STR; - vi.build.architecture = FRAMELESSHELPER_ARCHITECTURE_STR; - vi.build.is_debug = []() -> bool { -#ifdef _DEBUG - return true; -#else - return false; -#endif - }(); - vi.build.is_static = []() -> bool { -#if FRAMELESSHELPER_CONFIG(static_build) - return true; -#else - return false; -#endif - }(); - return vi; - }(); - return result; -} - -void FramelessHelperEnableThemeAware() -{ - static bool set = false; - if (set) { - return; - } - set = true; - -#ifdef Q_OS_WINDOWS - // This hack is needed to let AllowDarkModeForWindow() work. - std::ignore = Utils::setDarkModeAllowedForApp(true); -# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - // Qt gained the ability to detect system theme change since 5.15 but - // it's not quite useful until Qt6. - std::ignore = Utils::setQtDarkModeAwareEnabled(true); -# endif -#endif - -#if ((defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) && (QT_VERSION < QT_VERSION_CHECK(6, 4, 0))) || \ - (defined(Q_OS_MACOS) && (QT_VERSION < QT_VERSION_CHECK(5, 12, 0)))) - // Linux: Qt 6.4 gained the ability to detect system theme change. - // macOS: Qt 5.12. - std::ignore = Utils::registerThemeChangeNotification(); -#endif -} - -void FramelessHelperPrintLogo() -{ - static const bool noLogo = (qEnvironmentVariableIntValue("FRAMELESSHELPER_NO_LOGO") != 0); - if (noLogo) { - return; - } - const VersionInfo ver = FramelessHelperVersion(); - QString message = {}; - QTextStream stream(&message, QIODevice::WriteOnly); - stream << "FramelessHelper (" << (ver.build.is_static ? "static" : "shared") - << ", " << (ver.build.is_debug ? "debug" : "release") << ", " - << ver.build.architecture << ") version " << ver.version.str - << ", author wangwenx190 (Yuhang Zhao, 2546789017@qq.com)." - << " Built by " << ver.compiler.name << ver.compiler.version - << " from " << ver.commit.hash << " on " - << ver.build.configure_datetime << " (UTC)."; - INFO.nospace().noquote() << message; -} - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelpercore_global.h b/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelpercore_global.h deleted file mode 100644 index 5975bc26..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelpercore_global.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Core/framelesshelpercore_global.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelpercore_global_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelpercore_global_p.h deleted file mode 100644 index fc7697f6..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelesshelpercore_global_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Core/private/framelesshelpercore_global_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelessmanager.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelessmanager.cpp deleted file mode 100644 index 7f8681ae..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelessmanager.cpp +++ /dev/null @@ -1,534 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "framelessmanager.h" -#include "framelessmanager_p.h" -#include "framelesshelpercore_global_p.h" -#if FRAMELESSHELPER_CONFIG(native_impl) -# ifdef Q_OS_WINDOWS -# include "framelesshelper_win.h" -# elif (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) -# elif defined(Q_OS_MACOS) -# else -# endif -#else -# include "framelesshelper_qt.h" -#endif -#include "framelessconfig_p.h" -#include "utils.h" -#ifdef Q_OS_WINDOWS -# include "winverhelper_p.h" -#endif -#include -#include -#include -#include -#include -#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)) -# include -# include -#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcFramelessManager, "wangwenx190.framelesshelper.core.framelessmanager") -# define INFO qCInfo(lcFramelessManager) -# define DEBUG qCDebug(lcFramelessManager) -# define WARNING qCWarning(lcFramelessManager) -# define CRITICAL qCCritical(lcFramelessManager) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -static constexpr const int kEventDelayInterval = 1000; - -struct InternalData -{ - FramelessDataHash dataMap = {}; - QHash windowMap = {}; - - InternalData(); - ~InternalData(); - -private: - FRAMELESSHELPER_CLASS(InternalData) -}; - -InternalData::InternalData() = default; - -InternalData::~InternalData() = default; - -Q_GLOBAL_STATIC(InternalData, g_internalData) - -#if FRAMELESSHELPER_CONFIG(bundle_resource) -[[nodiscard]] static inline QString iconFontFamilyName() -{ - static const auto result = []() -> QString { -#ifdef Q_OS_WINDOWS - if (WindowsVersionHelper::isWin11OrGreater()) { - return FRAMELESSHELPER_STRING_LITERAL("Segoe Fluent Icons"); - } - if (WindowsVersionHelper::isWin10OrGreater()) { - return FRAMELESSHELPER_STRING_LITERAL("Segoe MDL2 Assets"); - } -#endif // Q_OS_WINDOWS - return FRAMELESSHELPER_STRING_LITERAL("iconfont"); - }(); - return result; -} -#endif - -InternalEventFilter::InternalEventFilter(const QObject *window, QObject *parent) : QObject(parent), m_window(window) -{ - Q_ASSERT(m_window); - Q_ASSERT(m_window->isWidgetType() || m_window->isWindowType()); -} - -InternalEventFilter::~InternalEventFilter() = default; - -bool InternalEventFilter::eventFilter(QObject *object, QEvent *event) -{ - Q_ASSERT(object); - Q_ASSERT(event); - Q_ASSERT(m_window); - if (!object || !event || !m_window || (object != m_window)) { - return false; - } - const FramelessDataPtr data = FramelessManagerPrivate::getData(m_window); - if (!data || !data->frameless || !data->callbacks) { - return false; - } - if (event->type() == QEvent::WinIdChange) { - const WId windowId = data->callbacks->getWindowId(); - Q_ASSERT(windowId); - if (windowId) { - FramelessManagerPrivate::updateWindowId(m_window, windowId); - } - } - return false; -} - -FramelessManagerPrivate::FramelessManagerPrivate(FramelessManager *q) : QObject(q) -{ - Q_ASSERT(q); - if (!q) { - return; - } - q_ptr = q; - initialize(); -} - -FramelessManagerPrivate::~FramelessManagerPrivate() = default; - -FramelessManagerPrivate *FramelessManagerPrivate::get(FramelessManager *pub) -{ - Q_ASSERT(pub); - if (!pub) { - return nullptr; - } - return pub->d_func(); -} - -const FramelessManagerPrivate *FramelessManagerPrivate::get(const FramelessManager *pub) -{ - Q_ASSERT(pub); - if (!pub) { - return nullptr; - } - return pub->d_func(); -} - -void FramelessManagerPrivate::initializeIconFont() -{ -#if FRAMELESSHELPER_CONFIG(bundle_resource) - static bool inited = false; - if (inited) { - return; - } - inited = true; - FramelessHelperCoreInitResource(); - // We always register this font because it's our only fallback. - const int id = QFontDatabase::addApplicationFont(FRAMELESSHELPER_STRING_LITERAL(":/org.wangwenx190.FramelessHelper/resources/fonts/iconfont.ttf")); - if (id < 0) { - WARNING << "Failed to load icon font."; - } else { - DEBUG << "Successfully registered icon font."; - } -#endif // FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE -} - -QFont FramelessManagerPrivate::getIconFont() -{ -#if FRAMELESSHELPER_CONFIG(bundle_resource) - static const auto font = []() -> QFont { - QFont f = {}; - f.setFamily(iconFontFamilyName()); -# ifdef Q_OS_MACOS - f.setPointSize(10); -# else // !Q_OS_MACOS - f.setPointSize(8); -# endif // Q_OS_MACOS - return f; - }(); - return font; -#else // !FRAMELESSHELPER_CONFIG(bundle_resource) - return {}; -#endif // FRAMELESSHELPER_CONFIG(bundle_resource) -} - -void FramelessManagerPrivate::notifySystemThemeHasChangedOrNot() -{ - themeTimer.start(); -} - -void FramelessManagerPrivate::notifyWallpaperHasChangedOrNot() -{ - wallpaperTimer.start(); -} - -void FramelessManagerPrivate::doNotifySystemThemeHasChangedOrNot() -{ - const SystemTheme currentSystemTheme = (Utils::shouldAppsUseDarkMode() ? SystemTheme::Dark : SystemTheme::Light); - const QColor currentAccentColor = Utils::getAccentColor(); -#ifdef Q_OS_WINDOWS - const DwmColorizationArea currentColorizationArea = Utils::getDwmColorizationArea(); -#endif - bool notify = false; - if (systemTheme != currentSystemTheme) { - systemTheme = currentSystemTheme; - notify = true; - } - if (accentColor != currentAccentColor) { - accentColor = currentAccentColor; - notify = true; - } -#ifdef Q_OS_WINDOWS - if (colorizationArea != currentColorizationArea) { - colorizationArea = currentColorizationArea; - notify = true; - } -#endif - // Don't emit the signal if the user has overrided the global theme. - if (notify && !isThemeOverrided()) { - Q_Q(FramelessManager); - Q_EMIT q->systemThemeChanged(); - DEBUG.nospace() << "System theme changed. Current theme: " << systemTheme - << ", accent color: " << accentColor.name(QColor::HexArgb).toUpper() -#ifdef Q_OS_WINDOWS - << ", colorization area: " << colorizationArea -#endif - << '.'; - } -} - -void FramelessManagerPrivate::doNotifyWallpaperHasChangedOrNot() -{ - const QString currentWallpaper = Utils::getWallpaperFilePath(); - const WallpaperAspectStyle currentWallpaperAspectStyle = Utils::getWallpaperAspectStyle(); - bool notify = false; - if (wallpaper != currentWallpaper) { - wallpaper = currentWallpaper; - notify = true; - } - if (wallpaperAspectStyle != currentWallpaperAspectStyle) { - wallpaperAspectStyle = currentWallpaperAspectStyle; - notify = true; - } - if (notify) { - Q_Q(FramelessManager); - Q_EMIT q->wallpaperChanged(); - DEBUG.nospace() << "Wallpaper changed. Current wallpaper: " << wallpaper - << ", aspect style: " << wallpaperAspectStyle << '.'; - } -} - -FramelessDataPtr FramelessManagerPrivate::getData(const QObject *window) -{ - Q_ASSERT(window); - Q_ASSERT(window->isWidgetType() || window->isWindowType()); - if (!window || !(window->isWidgetType() || window->isWindowType())) { - return nullptr; - } - return g_internalData()->dataMap.value(const_cast(window)); -} - -FramelessDataPtr FramelessManagerPrivate::createData(const QObject *window, const WId windowId) -{ - Q_ASSERT(window); - Q_ASSERT(window->isWidgetType() || window->isWindowType()); - Q_ASSERT(windowId); - if (!window || !(window->isWidgetType() || window->isWindowType()) || !windowId) { - return nullptr; - } - const auto win = const_cast(window); - auto it = g_internalData()->dataMap.find(win); - if (it == g_internalData()->dataMap.end()) { - FramelessDataPtr data = FramelessData::create(); - data->window = win; - data->windowId = windowId; - it = g_internalData()->dataMap.insert(win, data); - g_internalData()->windowMap.insert(windowId, win); - } - return it.value(); -} - -WId FramelessManagerPrivate::getWindowId(const QObject *window) -{ - Q_ASSERT(window); - Q_ASSERT(window->isWidgetType() || window->isWindowType()); - if (!window || !(window->isWidgetType() || window->isWindowType())) { - return 0; - } - if (const FramelessDataPtr data = getData(window)) { - return data->windowId; - } - return 0; -} - -QObject *FramelessManagerPrivate::getWindow(const WId windowId) -{ - Q_ASSERT(windowId); - if (!windowId) { - return nullptr; - } - return g_internalData()->windowMap.value(windowId); -} - -void FramelessManagerPrivate::updateWindowId(const QObject *window, const WId newWindowId) -{ - Q_ASSERT(window); - Q_ASSERT(window->isWidgetType() || window->isWindowType()); - Q_ASSERT(newWindowId); - if (!window || !(window->isWidgetType() || window->isWindowType()) || !newWindowId) { - return; - } - const auto win = const_cast(window); - const FramelessDataPtr data = g_internalData()->dataMap.value(win); - Q_ASSERT(data); - if (!data) { - return; - } - const WId oldWindowId = data->windowId; - data->windowId = newWindowId; - g_internalData()->windowMap.remove(oldWindowId); - g_internalData()->windowMap.insert(newWindowId, win); - data->frameless = false; - std::ignore = FramelessManager::instance()->addWindow(window, newWindowId); -} - -bool FramelessManagerPrivate::isThemeOverrided() const -{ - return (overrideTheme.value_or(SystemTheme::Unknown) != SystemTheme::Unknown); -} - -void FramelessManagerPrivate::initialize() -{ - themeTimer.setInterval(kEventDelayInterval); - themeTimer.callOnTimeout(this, [this](){ - themeTimer.stop(); - doNotifySystemThemeHasChangedOrNot(); - }); - wallpaperTimer.setInterval(kEventDelayInterval); - wallpaperTimer.callOnTimeout(this, [this](){ - wallpaperTimer.stop(); - doNotifyWallpaperHasChangedOrNot(); - }); - systemTheme = (Utils::shouldAppsUseDarkMode() ? SystemTheme::Dark : SystemTheme::Light); - accentColor = Utils::getAccentColor(); -#ifdef Q_OS_WINDOWS - colorizationArea = Utils::getDwmColorizationArea(); -#endif - wallpaper = Utils::getWallpaperFilePath(); - wallpaperAspectStyle = Utils::getWallpaperAspectStyle(); - DEBUG.nospace() << "Current system theme: " << systemTheme - << ", accent color: " << accentColor.name(QColor::HexArgb).toUpper() -#ifdef Q_OS_WINDOWS - << ", colorization area: " << colorizationArea -#endif - << ", wallpaper: " << wallpaper - << ", aspect style: " << wallpaperAspectStyle - << '.'; - // We are doing some tricks in our Windows message handling code, so - // we don't use Qt's theme notifier on Windows. But for other platforms - // we want to use as many Qt functionalities as possible. -#if ((QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)) && !FRAMELESSHELPER_CONFIG(native_impl)) - QStyleHints *styleHints = QGuiApplication::styleHints(); - Q_ASSERT(styleHints); - if (styleHints) { - connect(styleHints, &QStyleHints::colorSchemeChanged, this, [this](const Qt::ColorScheme colorScheme){ - Q_UNUSED(colorScheme); - notifySystemThemeHasChangedOrNot(); - }); - } -#endif // ((QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)) && !defined(Q_OS_WINDOWS)) - static bool flagSet = false; - if (!flagSet) { - flagSet = true; - // Set a global flag so that people can check whether FramelessHelper is being - // used without actually accessing the FramelessHelper interface. - static constexpr const char flag[] = "__FRAMELESSHELPER__"; - const auto ver = quint64(FramelessHelperVersion().version.num); - qputenv(flag, QByteArray::number(ver)); - qApp->setProperty(flag, ver); - } -} - -FramelessManager::FramelessManager(QObject *parent) : - QObject(parent), d_ptr(std::make_unique(this)) -{ -} - -FramelessManager::~FramelessManager() = default; - -FramelessManager *FramelessManager::instance() -{ - static FramelessManager manager; - return &manager; -} - -SystemTheme FramelessManager::systemTheme() const -{ - Q_D(const FramelessManager); - // The user's choice has top priority. - if (d->isThemeOverrided()) { - return d->overrideTheme.value(); - } - return d->systemTheme; -} - -QColor FramelessManager::systemAccentColor() const -{ - Q_D(const FramelessManager); - return d->accentColor; -} - -QString FramelessManager::wallpaper() const -{ - Q_D(const FramelessManager); - return d->wallpaper; -} - -WallpaperAspectStyle FramelessManager::wallpaperAspectStyle() const -{ - Q_D(const FramelessManager); - return d->wallpaperAspectStyle; -} - -void FramelessManager::setOverrideTheme(const SystemTheme theme) -{ - Q_D(FramelessManager); - if ((!d->overrideTheme.has_value() && (theme == SystemTheme::Unknown)) - || (d->overrideTheme.has_value() && (d->overrideTheme.value() == theme))) { - return; - } - if (theme == SystemTheme::Unknown) { - d->overrideTheme = std::nullopt; - } else { - d->overrideTheme = theme; - } - Q_EMIT systemThemeChanged(); -} - -bool FramelessManager::addWindow(const QObject *window, const WId windowId) -{ - Q_ASSERT(window); - Q_ASSERT(window->isWidgetType() || window->isWindowType()); - Q_ASSERT(windowId); - if (!window || !(window->isWidgetType() || window->isWindowType()) || !windowId) { - return false; - } - FramelessDataPtr data = FramelessManagerPrivate::getData(window); - if (data && data->frameless) { - return false; - } - if (!data) { - data = FramelessData::create(); - data->window = const_cast(window); - data->windowId = windowId; - g_internalData()->dataMap.insert(data->window, data); - g_internalData()->windowMap.insert(windowId, data->window); - } -#if FRAMELESSHELPER_CONFIG(native_impl) -# ifdef Q_OS_WINDOWS - std::ignore = Utils::installWindowProcHook(windowId); - FramelessHelperWin::addWindow(window); -# elif (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) -# elif defined(Q_OS_MACOS) -# else -# endif -#else - FramelessHelperQt::addWindow(window); -#endif - if (!data->internalEventHandler) { - data->internalEventHandler = new InternalEventFilter(data->window, data->window); - data->window->installEventFilter(data->internalEventHandler); - } - return true; -} - -bool FramelessManager::removeWindow(const QObject *window) -{ - Q_ASSERT(window); - if (!window) { - return false; - } - const auto it = g_internalData()->dataMap.constFind(const_cast(window)); - if (it == g_internalData()->dataMap.constEnd()) { - return false; - } - const FramelessDataPtr data = it.value(); - Q_ASSERT(data); - Q_ASSERT(data->window); - Q_ASSERT(data->windowId); - if (!data || !data->window || !data->windowId) { - return false; - } - if (data->internalEventHandler) { - data->window->removeEventFilter(data->internalEventHandler); - delete data->internalEventHandler; - data->internalEventHandler = nullptr; - } -#if FRAMELESSHELPER_CONFIG(native_impl) -# ifdef Q_OS_WINDOWS - FramelessHelperWin::removeWindow(window); - std::ignore = Utils::uninstallWindowProcHook(data->windowId); -# elif (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) -# elif defined(Q_OS_MACOS) -# else -# endif -#else - FramelessHelperQt::removeWindow(window); -#endif - g_internalData()->dataMap.erase(it); - g_internalData()->windowMap.remove(data->windowId); - return true; -} - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelessmanager.h b/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelessmanager.h deleted file mode 100644 index 21448340..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelessmanager.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Core/framelessmanager.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelessmanager_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelessmanager_p.h deleted file mode 100644 index d1f24624..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/framelessmanager_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Core/private/framelessmanager_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/micamaterial.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/core/micamaterial.cpp deleted file mode 100644 index eafe5abc..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/micamaterial.cpp +++ /dev/null @@ -1,999 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "micamaterial.h" -#include "micamaterial_p.h" - -#if FRAMELESSHELPER_CONFIG(mica_material) - -#include "framelessmanager.h" -#include "utils.h" -#include "framelessconfig_p.h" -#include "framelesshelpercore_global_p.h" -#include -#include -#include -#include -#if FRAMELESSHELPER_HAS_THREAD -# include -#endif -#include -#include -#include -#include -#include -#include -#if FRAMELESSHELPER_CONFIG(private_qt) -# include -#endif - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcMicaMaterial, "wangwenx190.framelesshelper.core.micamaterial") -# define INFO qCInfo(lcMicaMaterial) -# define DEBUG qCDebug(lcMicaMaterial) -# define WARNING qCWarning(lcMicaMaterial) -# define CRITICAL qCCritical(lcMicaMaterial) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -[[maybe_unused]] static constexpr const QSize kMaximumPictureSize = { 1920, 1080 }; -[[maybe_unused]] static constexpr const QImage::Format kDefaultImageFormat = QImage::Format_ARGB32_Premultiplied; - -[[maybe_unused]] static constexpr const qreal kDefaultTintOpacity = 0.7; -[[maybe_unused]] static constexpr const qreal kDefaultNoiseOpacity = 0.04; -[[maybe_unused]] static constexpr const qreal kDefaultBlurRadius = 128.0; - -[[maybe_unused]] static Q_COLOR_CONSTEXPR const QColor kDefaultSystemLightColor2 = {243, 243, 243}; // #F3F3F3 - -[[maybe_unused]] static Q_COLOR_CONSTEXPR const QColor kDefaultFallbackColorDark = {44, 44, 44}; // #2C2C2C -[[maybe_unused]] static Q_COLOR_CONSTEXPR const QColor kDefaultFallbackColorLight = {249, 249, 249}; // #F9F9F9 - -struct ImageData -{ - QPixmap blurredWallpaper = {}; - bool graphicsResourcesReady = false; -#if FRAMELESSHELPER_HAS_THREAD - QMutex mutex{}; -#endif -}; - -Q_GLOBAL_STATIC(ImageData, g_imageData) - -#if FRAMELESSHELPER_CONFIG(private_qt) -template -[[nodiscard]] static inline constexpr int qt_static_shift(const int value) -{ - if constexpr (shift == 0) { - return value; - } else if constexpr (shift > 0) { - return (value << (quint32(shift) & 0x1f)); - } else { - return (value >> (quint32(-shift) & 0x1f)); - } -} - -template -static inline void qt_blurinner(uchar *bptr, int &zR, int &zG, int &zB, int &zA, const int alpha) -{ - const auto pixel = reinterpret_cast(bptr); - -#define Z_MASK (0xff << zprec) - const int A_zprec = (qt_static_shift(*pixel) & Z_MASK); - const int R_zprec = (qt_static_shift(*pixel) & Z_MASK); - const int G_zprec = (qt_static_shift(*pixel) & Z_MASK); - const int B_zprec = (qt_static_shift(*pixel) & Z_MASK); -#undef Z_MASK - - const int zR_zprec = (zR >> aprec); - const int zG_zprec = (zG >> aprec); - const int zB_zprec = (zB >> aprec); - const int zA_zprec = (zA >> aprec); - - zR += (alpha * (R_zprec - zR_zprec)); - zG += (alpha * (G_zprec - zG_zprec)); - zB += (alpha * (B_zprec - zB_zprec)); - zA += (alpha * (A_zprec - zA_zprec)); - -#define ZA_MASK (0xff << (zprec + aprec)) - *pixel = (qt_static_shift<24 - zprec - aprec>(zA & ZA_MASK) - | qt_static_shift<16 - zprec - aprec>(zR & ZA_MASK) - | qt_static_shift<8 - zprec - aprec>(zG & ZA_MASK) - | qt_static_shift<-zprec - aprec>(zB & ZA_MASK)); -#undef ZA_MASK -} - -static constexpr const int alphaIndex = ((QSysInfo::ByteOrder == QSysInfo::BigEndian) ? 0 : 3); - -template -static inline void qt_blurinner_alphaOnly(uchar *bptr, int &z, const int alpha) -{ - const int A_zprec = (int(*(bptr)) << zprec); - const int z_zprec = (z >> aprec); - z += (alpha * (A_zprec - z_zprec)); - *(bptr) = (z >> (zprec + aprec)); -} - -template -static inline void qt_blurrow(QImage &im, const int line, const int alpha) -{ - uchar *bptr = im.scanLine(line); - - int zR = 0, zG = 0, zB = 0, zA = 0; - - QT_WARNING_PUSH - QT_WARNING_DISABLE_MSVC(4127) // false alarm. - if (alphaOnly && (im.format() != QImage::Format_Indexed8)) { - bptr += alphaIndex; - } - QT_WARNING_POP - - const int stride = (im.depth() >> 3); - const int im_width = im.width(); - for (int index = 0; index != im_width; ++index) { - if (alphaOnly) { - qt_blurinner_alphaOnly(bptr, zA, alpha); - } else { - qt_blurinner(bptr, zR, zG, zB, zA, alpha); - } - bptr += stride; - } - - bptr -= stride; - - for (int index = (im_width - 2); index >= 0; --index) { - bptr -= stride; - if (alphaOnly) { - qt_blurinner_alphaOnly(bptr, zA, alpha); - } else { - qt_blurinner(bptr, zR, zG, zB, zA, alpha); - } - } -} - -/* -* expblur(QImage &img, int radius) -* -* Based on exponential blur algorithm by Jani Huhtanen -* -* In-place blur of image 'img' with kernel -* of approximate radius 'radius'. -* -* Blurs with two sided exponential impulse -* response. -* -* aprec = precision of alpha parameter -* in fixed-point format 0.aprec -* -* zprec = precision of state parameters -* zR,zG,zB and zA in fp format 8.zprec -*/ -template -static inline void expblur(QImage &img, qreal radius, const bool improvedQuality = false, const int transposed = 0) -{ - Q_ASSERT((img.format() == kDefaultImageFormat) - || (img.format() == QImage::Format_RGB32) - || (img.format() == QImage::Format_Indexed8) - || (img.format() == QImage::Format_Grayscale8)); - if ((img.format() != kDefaultImageFormat) - && (img.format() != QImage::Format_RGB32) - && (img.format() != QImage::Format_Indexed8) - && (img.format() != QImage::Format_Grayscale8)) { - return; - } - - // halve the radius if we're using two passes - if (improvedQuality) { - radius *= 0.5; - } - - // choose the alpha such that pixels at radius distance from a fully - // saturated pixel will have an alpha component of no greater than - // the cutOffIntensity - static constexpr const qreal cutOffIntensity = 2.0; - const int alpha = ((radius <= qreal(1e-5)) ? ((1 << aprec) - 1) : - std::round((1 << aprec) * (1 - qPow(cutOffIntensity / qreal(255), qreal(1) / radius)))); - - int img_height = img.height(); - for (int row = 0; row != img_height; ++row) { - for (int i = 0; i <= int(improvedQuality); ++i) { - qt_blurrow(img, row, alpha); - } - } - - QImage temp(img.height(), img.width(), img.format()); - temp.setDevicePixelRatio(img.devicePixelRatio()); - - if (transposed >= 0) { - if (img.depth() == 8) { - qt_memrotate270(reinterpret_cast(img.bits()), - img.width(), img.height(), img.bytesPerLine(), - reinterpret_cast(temp.bits()), - temp.bytesPerLine()); - } else { - qt_memrotate270(reinterpret_cast(img.bits()), - img.width(), img.height(), img.bytesPerLine(), - reinterpret_cast(temp.bits()), - temp.bytesPerLine()); - } - } else { - if (img.depth() == 8) { - qt_memrotate90(reinterpret_cast(img.bits()), - img.width(), img.height(), img.bytesPerLine(), - reinterpret_cast(temp.bits()), - temp.bytesPerLine()); - } else { - qt_memrotate90(reinterpret_cast(img.bits()), - img.width(), img.height(), img.bytesPerLine(), - reinterpret_cast(temp.bits()), - temp.bytesPerLine()); - } - } - - img_height = temp.height(); - for (int row = 0; row != img_height; ++row) { - for (int i = 0; i <= int(improvedQuality); ++i) { - qt_blurrow(temp, row, alpha); - } - } - - if (transposed == 0) { - if (img.depth() == 8) { - qt_memrotate90(reinterpret_cast(temp.bits()), - temp.width(), temp.height(), temp.bytesPerLine(), - reinterpret_cast(img.bits()), - img.bytesPerLine()); - } else { - qt_memrotate90(reinterpret_cast(temp.bits()), - temp.width(), temp.height(), temp.bytesPerLine(), - reinterpret_cast(img.bits()), - img.bytesPerLine()); - } - } else { - img = temp; - } -} - -#define AVG(a,b) ( ((((a)^(b)) & 0xfefefefeUL) >> 1) + ((a)&(b)) ) -#define AVG16(a,b) ( ((((a)^(b)) & 0xf7deUL) >> 1) + ((a)&(b)) ) - -[[nodiscard]] static inline QImage qt_halfScaled(const QImage &source) -{ - if ((source.width() < 2) || (source.height() < 2)) { - return {}; - } - - QImage srcImage = source; - - if ((source.format() == QImage::Format_Indexed8) - || (source.format() == QImage::Format_Grayscale8)) { - // assumes grayscale - QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); - dest.setDevicePixelRatio(source.devicePixelRatio()); - - auto src = reinterpret_cast(const_cast(srcImage).bits()); - const qsizetype sx = srcImage.bytesPerLine(); - const qsizetype sx2 = (sx << 1); - - auto dst = reinterpret_cast(dest.bits()); - const qsizetype dx = dest.bytesPerLine(); - const int ww = dest.width(); - const int hh = dest.height(); - - for (int y = hh; y; --y, dst += dx, src += sx2) { - const uchar *p1 = src; - const uchar *p2 = (src + sx); - uchar *q = dst; - for (int x = ww; x; --x, ++q, p1 += 2, p2 += 2) { - *q = (((int(p1[0]) + int(p1[1]) + int(p2[0]) + int(p2[1])) + 2) >> 2); - } - } - - return dest; - } - if (source.format() == QImage::Format_ARGB8565_Premultiplied) { - QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); - dest.setDevicePixelRatio(source.devicePixelRatio()); - - auto src = reinterpret_cast(const_cast(srcImage).bits()); - const qsizetype sx = srcImage.bytesPerLine(); - const qsizetype sx2 = (sx << 1); - - auto dst = reinterpret_cast(dest.bits()); - const qsizetype dx = dest.bytesPerLine(); - const int ww = dest.width(); - const int hh = dest.height(); - - for (int y = hh; y; --y, dst += dx, src += sx2) { - const uchar *p1 = src; - const uchar *p2 = (src + sx); - uchar *q = dst; - for (int x = ww; x; --x, q += 3, p1 += 6, p2 += 6) { - // alpha - q[0] = AVG(AVG(p1[0], p1[3]), AVG(p2[0], p2[3])); - // rgb - const quint16 p16_1 = ((p1[2] << 8) | p1[1]); - const quint16 p16_2 = ((p1[5] << 8) | p1[4]); - const quint16 p16_3 = ((p2[2] << 8) | p2[1]); - const quint16 p16_4 = ((p2[5] << 8) | p2[4]); - const quint16 result = AVG16(AVG16(p16_1, p16_2), AVG16(p16_3, p16_4)); - q[1] = (result & 0xff); - q[2] = (result >> 8); - } - } - - return dest; - } - if ((source.format() != kDefaultImageFormat) - && (source.format() != QImage::Format_RGB32)) { - srcImage = source.convertToFormat(kDefaultImageFormat); - } - - QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); - dest.setDevicePixelRatio(source.devicePixelRatio()); - - auto src = reinterpret_cast(const_cast(srcImage).bits()); - const qsizetype sx = (srcImage.bytesPerLine() >> 2); - const qsizetype sx2 = (sx << 1); - - auto dst = reinterpret_cast(dest.bits()); - const qsizetype dx = (dest.bytesPerLine() >> 2); - const int ww = dest.width(); - const int hh = dest.height(); - - for (int y = hh; y; --y, dst += dx, src += sx2) { - const quint32 *p1 = src; - const quint32 *p2 = (src + sx); - quint32 *q = dst; - for (int x = ww; x; --x, q++, p1 += 2, p2 += 2) { - *q = AVG(AVG(p1[0], p1[1]), AVG(p2[0], p2[1])); - } - } - - return dest; -} - -[[maybe_unused]] static inline void qt_blurImage(QPainter *p, QImage &blurImage, - qreal radius, const bool quality, const bool alphaOnly, const int transposed = 0) -{ - if ((blurImage.format() != kDefaultImageFormat) - && (blurImage.format() != QImage::Format_RGB32)) { - blurImage = blurImage.convertToFormat(kDefaultImageFormat); - } - - qreal scale = 1.0; - if ((radius >= 4) && (blurImage.width() >= 2) && (blurImage.height() >= 2)) { - blurImage = qt_halfScaled(blurImage); - scale = 2.0; - radius *= 0.5; - } - - if (alphaOnly) { - expblur<12, 10, true>(blurImage, radius, quality, transposed); - } else { - expblur<12, 10, false>(blurImage, radius, quality, transposed); - } - - if (p) { - p->save(); - // We need a blurry image anyway, we don't need high quality image processing. - p->setRenderHint(QPainter::Antialiasing, false); - p->setRenderHint(QPainter::TextAntialiasing, false); - p->setRenderHint(QPainter::SmoothPixmapTransform, false); - p->scale(scale, scale); -#if (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)) - const QSize imageSize = blurImage.deviceIndependentSize().toSize(); -#else - const QSize imageSize = QSizeF(QSizeF(blurImage.size()) / blurImage.devicePixelRatio()).toSize(); -#endif - p->drawImage(QRect(QPoint(0, 0), imageSize), blurImage); - p->restore(); - } -} - -[[maybe_unused]] static inline void qt_blurImage(QImage &blurImage, - const qreal radius, const bool quality, const int transposed = 0) -{ - if ((blurImage.format() == QImage::Format_Indexed8) - || (blurImage.format() == QImage::Format_Grayscale8)) { - expblur<12, 10, true>(blurImage, radius, quality, transposed); - } else { - expblur<12, 10, false>(blurImage, radius, quality, transposed); - } -} -#endif - -/*! - Transforms an \a alignment of Qt::AlignLeft or Qt::AlignRight - without Qt::AlignAbsolute into Qt::AlignLeft or Qt::AlignRight with - Qt::AlignAbsolute according to the layout \a direction. The other - alignment flags are left untouched. - - If no horizontal alignment was specified, the function returns the - default alignment for the given layout \a direction. - - \sa QWidget::layoutDirection -*/ -[[nodiscard]] static inline Qt::Alignment visualAlignment - (const Qt::LayoutDirection direction, Qt::Alignment alignment) -{ - if (!(alignment & Qt::AlignHorizontal_Mask)) { - alignment |= Qt::AlignLeft; - } - if (!(alignment & Qt::AlignAbsolute) && (alignment & (Qt::AlignLeft | Qt::AlignRight))) { - if (direction == Qt::RightToLeft) { - alignment ^= (Qt::AlignLeft | Qt::AlignRight); - } - alignment |= Qt::AlignAbsolute; - } - return alignment; -} - -/*! - Returns a new rectangle of the specified \a size that is aligned to the given - \a rectangle according to the specified \a alignment and \a direction. - */ -[[nodiscard]] static inline QRect alignedRect(const Qt::LayoutDirection direction, - Qt::Alignment alignment, const QSize &size, const QRect &rectangle) -{ - alignment = visualAlignment(direction, alignment); - int x = rectangle.x(); - int y = rectangle.y(); - int w = size.width(); - int h = size.height(); - if ((alignment & Qt::AlignVCenter) == Qt::AlignVCenter) { - y += ((rectangle.size().height() / 2) - (h / 2)); - } else if ((alignment & Qt::AlignBottom) == Qt::AlignBottom) { - y += (rectangle.size().height() - h); - } - if ((alignment & Qt::AlignRight) == Qt::AlignRight) { - x += (rectangle.size().width() - w); - } else if ((alignment & Qt::AlignHCenter) == Qt::AlignHCenter) { - x += ((rectangle.size().width() / 2) - (w / 2)); - } - return {x, y, w, h}; -} - -WallpaperThread::WallpaperThread(QObject *parent) : FramelessHelperThreadClass(parent) -{ -} - -WallpaperThread::~WallpaperThread() = default; - -#if FRAMELESSHELPER_HAS_THREAD -void WallpaperThread::run() -#else -void WallpaperThread::start() -#endif -{ - const QString wallpaperFilePath = Utils::getWallpaperFilePath(); - if (wallpaperFilePath.isEmpty()) { - WARNING << "Failed to retrieve the wallpaper file path."; - return; - } - // QImageReader allows us read the image size before we actually loading it, this behavior - // can help us avoid consume too much memory if the image resolution is very large, eg, 4K. - QImageReader reader(wallpaperFilePath); - if (!reader.canRead()) { - WARNING << "Qt can't read the wallpaper file:" << reader.errorString(); - return; - } - const QSize actualSize = reader.size(); - if (actualSize.isEmpty()) { - WARNING << "The wallpaper picture size is invalid."; - return; - } - const QSize correctedSize = (actualSize > kMaximumPictureSize ? kMaximumPictureSize : actualSize); - if (correctedSize != actualSize) { - DEBUG << "The wallpaper picture size is greater than 1920x1080, it will be shrinked to reduce memory consumption."; - reader.setScaledSize(correctedSize); - } - QImage image(correctedSize, kDefaultImageFormat); - if (!reader.read(&image)) { - WARNING << "Failed to read the wallpaper image:" << reader.errorString(); - return; - } - if (image.isNull()) { - WARNING << "The obtained image data is null."; - return; - } - WallpaperAspectStyle aspectStyle = Utils::getWallpaperAspectStyle(); - const QSize wallpaperSize = QGuiApplication::primaryScreen()->size(); - QImage buffer(wallpaperSize, kDefaultImageFormat); -#ifdef Q_OS_WINDOWS - if (aspectStyle == WallpaperAspectStyle::Center) { - buffer.fill(kDefaultBlackColor); - } -#endif - if ((aspectStyle == WallpaperAspectStyle::Stretch) - || (aspectStyle == WallpaperAspectStyle::Fit) - || (aspectStyle == WallpaperAspectStyle::Fill)) { - Qt::AspectRatioMode mode = Qt::KeepAspectRatioByExpanding; - if (aspectStyle == WallpaperAspectStyle::Stretch) { - mode = Qt::IgnoreAspectRatio; - } else if (aspectStyle == WallpaperAspectStyle::Fit) { - mode = Qt::KeepAspectRatio; - } - QSize newSize = image.size(); - newSize.scale(wallpaperSize, mode); - image = image.scaled(newSize); - } - static constexpr const QPoint desktopOriginPoint = {0, 0}; - const QRect desktopRect = {desktopOriginPoint, wallpaperSize}; - if (aspectStyle == WallpaperAspectStyle::Tile) { - QPainter bufferPainter(&buffer); - // Same as above, we prefer speed than quality here. - bufferPainter.setRenderHint(QPainter::Antialiasing, false); - bufferPainter.setRenderHint(QPainter::TextAntialiasing, false); - bufferPainter.setRenderHint(QPainter::SmoothPixmapTransform, false); - bufferPainter.fillRect(desktopRect, QBrush(image)); - } else { - QPainter bufferPainter(&buffer); - // Same here. - bufferPainter.setRenderHint(QPainter::Antialiasing, false); - bufferPainter.setRenderHint(QPainter::TextAntialiasing, false); - bufferPainter.setRenderHint(QPainter::SmoothPixmapTransform, false); - const QRect rect = alignedRect(Qt::LeftToRight, Qt::AlignCenter, image.size(), desktopRect); - bufferPainter.drawImage(rect.topLeft(), image); - } - { -#if FRAMELESSHELPER_HAS_THREAD - const QMutexLocker locker(&g_imageData()->mutex); -#endif - g_imageData()->blurredWallpaper = QPixmap(wallpaperSize); - g_imageData()->blurredWallpaper.fill(kDefaultTransparentColor); - QPainter painter(&g_imageData()->blurredWallpaper); - // Same here. - painter.setRenderHint(QPainter::Antialiasing, false); - painter.setRenderHint(QPainter::TextAntialiasing, false); - painter.setRenderHint(QPainter::SmoothPixmapTransform, false); -#if FRAMELESSHELPER_CONFIG(private_qt) - qt_blurImage(&painter, buffer, kDefaultBlurRadius, false, false); -#else // !FRAMELESSHELPER_CONFIG(private_qt) - painter.drawImage(desktopOriginPoint, buffer); -#endif // FRAMELESSHELPER_CONFIG(private_qt) - } - Q_EMIT imageUpdated(); -} - -struct ThreadData -{ - std::unique_ptr thread = nullptr; -#if FRAMELESSHELPER_HAS_THREAD - QMutex mutex{}; -#endif -}; -Q_GLOBAL_STATIC(ThreadData, g_threadData) - -#if FRAMELESSHELPER_HAS_THREAD -static inline void threadCleaner() -{ - const QMutexLocker locker(&g_threadData()->mutex); - if (g_threadData()->thread && g_threadData()->thread->isRunning()) { - g_threadData()->thread->requestInterruption(); - g_threadData()->thread->quit(); - g_threadData()->thread->wait(); - } -} -#endif - -MicaMaterialPrivate::MicaMaterialPrivate(MicaMaterial *q) : QObject(q) -{ - Q_ASSERT(q); - if (!q) { - return; - } - q_ptr = q; - initialize(); -} - -MicaMaterialPrivate::~MicaMaterialPrivate() = default; - -MicaMaterialPrivate *MicaMaterialPrivate::get(MicaMaterial *q) -{ - Q_ASSERT(q); - if (!q) { - return nullptr; - } - return q->d_func(); -} - -const MicaMaterialPrivate *MicaMaterialPrivate::get(const MicaMaterial *q) -{ - Q_ASSERT(q); - if (!q) { - return nullptr; - } - return q->d_func(); -} - -void MicaMaterialPrivate::maybeGenerateBlurredWallpaper(const bool force) -{ -#if FRAMELESSHELPER_HAS_THREAD - g_imageData()->mutex.lock(); -#endif - if (!g_imageData()->blurredWallpaper.isNull() && !force) { -#if FRAMELESSHELPER_HAS_THREAD - g_imageData()->mutex.unlock(); -#endif - return; - } -#if FRAMELESSHELPER_HAS_THREAD - g_imageData()->mutex.unlock(); - const QMutexLocker locker(&g_threadData()->mutex); - if (g_threadData()->thread->isRunning()) { - g_threadData()->thread->requestInterruption(); - g_threadData()->thread->quit(); - g_threadData()->thread->wait(); - } - g_threadData()->thread->start(QThread::LowPriority); -#else - g_threadData()->thread->start(); -#endif -} - -void MicaMaterialPrivate::updateMaterialBrush() -{ -#if FRAMELESSHELPER_CONFIG(bundle_resource) - FramelessHelperCoreInitResource(); - static const QImage noiseTexture = QImage(FRAMELESSHELPER_STRING_LITERAL(":/org.wangwenx190.FramelessHelper/resources/images/noise.png")); -#endif // FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE - QImage micaTexture = QImage(QSize(64, 64), kDefaultImageFormat); - QColor fillColor = ((FramelessManager::instance()->systemTheme() == SystemTheme::Dark) ? kDefaultSystemDarkColor : kDefaultSystemLightColor2); - fillColor.setAlphaF(0.9f); - micaTexture.fill(fillColor); - QPainter painter(&micaTexture); - // Same as above. We need speed, not quality. - painter.setRenderHint(QPainter::Antialiasing, false); - painter.setRenderHint(QPainter::TextAntialiasing, false); - painter.setRenderHint(QPainter::SmoothPixmapTransform, false); - painter.setOpacity(tintOpacity); - const QRect rect = {QPoint(0, 0), micaTexture.size()}; - painter.fillRect(rect, tintColor); - painter.setOpacity(noiseOpacity); -#if FRAMELESSHELPER_CONFIG(bundle_resource) - painter.fillRect(rect, QBrush(noiseTexture)); -#endif // FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE - micaBrush = QBrush(micaTexture); - if (initialized) { - Q_Q(MicaMaterial); - Q_EMIT q->shouldRedraw(); - } -} - -void MicaMaterialPrivate::forceRebuildWallpaper() -{ - wallpaperSize = QGuiApplication::primaryScreen()->size(); - maybeGenerateBlurredWallpaper(true); -} - -void MicaMaterialPrivate::initialize() -{ -#if FRAMELESSHELPER_HAS_THREAD - g_threadData()->mutex.lock(); -#endif - if (!g_threadData()->thread) { - g_threadData()->thread = std::make_unique(); -#if FRAMELESSHELPER_HAS_THREAD - qAddPostRoutine(threadCleaner); -#endif - } - connect(g_threadData()->thread.get(), &WallpaperThread::imageUpdated, this, [this](){ - if (initialized) { - Q_Q(MicaMaterial); - Q_EMIT q->shouldRedraw(); - } - }); -#if FRAMELESSHELPER_HAS_THREAD - g_threadData()->mutex.unlock(); -#endif - - wallpaperSize = QGuiApplication::primaryScreen()->size(); - - tintColor = kDefaultTransparentColor; - tintOpacity = kDefaultTintOpacity; - // Leave fallbackColor invalid, we need to use this state to judge - // whether we should use the system color instead. - noiseOpacity = kDefaultNoiseOpacity; - - updateMaterialBrush(); - - connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged, - this, &MicaMaterialPrivate::updateMaterialBrush); - connect(FramelessManager::instance(), &FramelessManager::wallpaperChanged, - this, &MicaMaterialPrivate::forceRebuildWallpaper); - connect(qGuiApp, &QGuiApplication::primaryScreenChanged, - this, &MicaMaterialPrivate::forceRebuildWallpaper); - - if (FramelessConfig::instance()->isSet(Option::DisableLazyInitializationForMicaMaterial)) { - prepareGraphicsResources(); - } - - initialized = true; -} - -void MicaMaterialPrivate::prepareGraphicsResources() -{ -#if FRAMELESSHELPER_HAS_THREAD - g_imageData()->mutex.lock(); -#endif - if (g_imageData()->graphicsResourcesReady) { -#if FRAMELESSHELPER_HAS_THREAD - g_imageData()->mutex.unlock(); -#endif - return; - } - g_imageData()->graphicsResourcesReady = true; -#if FRAMELESSHELPER_HAS_THREAD - g_imageData()->mutex.unlock(); -#endif - maybeGenerateBlurredWallpaper(); -} - -QColor MicaMaterialPrivate::systemFallbackColor() -{ - return ((FramelessManager::instance()->systemTheme() == SystemTheme::Dark) ? kDefaultFallbackColorDark : kDefaultFallbackColorLight); -} - -QPoint MicaMaterialPrivate::mapToWallpaper(const QPoint &pos) const -{ - if (pos.isNull()) { - return {}; - } - QPointF result = pos; - // Make sure the position is always inside the wallpaper rectangle. - while (result.x() < qreal(0)) { - result.setX(result.x() + wallpaperSize.width()); - } - while ((result.x() > wallpaperSize.width()) || qFuzzyCompare(result.x(), wallpaperSize.width())) { - result.setX(result.x() - wallpaperSize.width()); - } - while (result.y() < qreal(0)) { - result.setY(result.y() + wallpaperSize.height()); - } - while ((result.y() > wallpaperSize.height()) || qFuzzyCompare(result.y(), wallpaperSize.height())) { - result.setY(result.y() - wallpaperSize.height()); - } - return result.toPoint(); -} - -QSize MicaMaterialPrivate::mapToWallpaper(const QSize &size) const -{ - if (size.isEmpty()) { - return {}; - } - QSizeF result = size; - // Make sure we don't get a size larger than the wallpaper's size. - if (result.width() > wallpaperSize.width()) { - result.setWidth(wallpaperSize.width()); - } - if (result.height() > wallpaperSize.height()) { - result.setHeight(wallpaperSize.height()); - } - return result.toSize(); -} - -QRect MicaMaterialPrivate::mapToWallpaper(const QRect &rect) const -{ - const auto wallpaperRect = QRectF{ QPointF{ 0, 0 }, wallpaperSize }; - const auto mappedRect = QRectF{ mapToWallpaper(rect.topLeft()), mapToWallpaper(rect.size()) }; - if (!Utils::isValidGeometry(mappedRect)) { - WARNING << "The calculated mapped rectangle is not valid."; - return wallpaperRect.toRect(); - } - return mappedRect.toRect(); -} - -MicaMaterial::MicaMaterial(QObject *parent) - : QObject(parent), d_ptr(std::make_unique(this)) -{ -} - -MicaMaterial::~MicaMaterial() = default; - -QColor MicaMaterial::tintColor() const -{ - Q_D(const MicaMaterial); - return d->tintColor; -} - -void MicaMaterial::setTintColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - Q_D(MicaMaterial); - if (d->tintColor == value) { - return; - } - d->prepareGraphicsResources(); - d->tintColor = value; - d->updateMaterialBrush(); - Q_EMIT tintColorChanged(); -} - -qreal MicaMaterial::tintOpacity() const -{ - Q_D(const MicaMaterial); - return d->tintOpacity; -} - -void MicaMaterial::setTintOpacity(const qreal value) -{ - Q_D(MicaMaterial); - if (qFuzzyCompare(d->tintOpacity, value)) { - return; - } - d->prepareGraphicsResources(); - d->tintOpacity = value; - d->updateMaterialBrush(); - Q_EMIT tintOpacityChanged(); -} - -QColor MicaMaterial::fallbackColor() const -{ - Q_D(const MicaMaterial); - return d->fallbackColor; -} - -void MicaMaterial::setFallbackColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - Q_D(MicaMaterial); - if (d->fallbackColor == value) { - return; - } - d->prepareGraphicsResources(); - d->fallbackColor = value; - d->updateMaterialBrush(); - Q_EMIT fallbackColorChanged(); -} - -qreal MicaMaterial::noiseOpacity() const -{ - Q_D(const MicaMaterial); - return d->noiseOpacity; -} - -void MicaMaterial::setNoiseOpacity(const qreal value) -{ - Q_D(MicaMaterial); - if (qFuzzyCompare(d->noiseOpacity, value)) { - return; - } - d->prepareGraphicsResources(); - d->noiseOpacity = value; - d->updateMaterialBrush(); - Q_EMIT noiseOpacityChanged(); -} - -bool MicaMaterial::isFallbackEnabled() const -{ - Q_D(const MicaMaterial); - return d->fallbackEnabled; -} - -void MicaMaterial::setFallbackEnabled(const bool value) -{ - Q_D(MicaMaterial); - if (d->fallbackEnabled == value) { - return; - } - d->prepareGraphicsResources(); - d->fallbackEnabled = value; - d->updateMaterialBrush(); - Q_EMIT fallbackEnabledChanged(); -} - -void MicaMaterial::paint(QPainter *painter, const QRect &rect, const bool active) -{ - Q_ASSERT(painter); - if (!painter) { - return; - } - Q_D(MicaMaterial); - d->prepareGraphicsResources(); - static constexpr const auto originPoint = QPoint{ 0, 0 }; - const QRect wallpaperRect = { originPoint, d->wallpaperSize }; - const QRect mappedRect = d->mapToWallpaper(rect); - painter->save(); - // Same as above. Speed is more important here. - painter->setRenderHint(QPainter::Antialiasing, false); - painter->setRenderHint(QPainter::TextAntialiasing, false); - painter->setRenderHint(QPainter::SmoothPixmapTransform, false); - if (active) { - const QRect intersectedRect = wallpaperRect.intersected(mappedRect); -#if FRAMELESSHELPER_HAS_THREAD - g_imageData()->mutex.lock(); -#endif - painter->drawPixmap(originPoint, g_imageData()->blurredWallpaper, intersectedRect); -#if FRAMELESSHELPER_HAS_THREAD - g_imageData()->mutex.unlock(); -#endif - if (intersectedRect != mappedRect) { - static constexpr const auto xOffset = QPoint{ 1, 0 }; - if (mappedRect.y() + mappedRect.height() <= wallpaperRect.height()) { - const QRect outerRect = { intersectedRect.topRight() + xOffset, QSize{ mappedRect.width() - intersectedRect.width(), intersectedRect.height() } }; - const QPoint outerRectOriginPoint = originPoint + QPoint{ intersectedRect.width(), 0 } + xOffset; - const QRect mappedOuterRect = d->mapToWallpaper(outerRect); -#if FRAMELESSHELPER_HAS_THREAD - const QMutexLocker locker(&g_imageData()->mutex); -#endif - painter->drawPixmap(outerRectOriginPoint, g_imageData()->blurredWallpaper, mappedOuterRect); - } else { - static constexpr const auto yOffset = QPoint{ 0, 1 }; - const QRect outerRectBottom = { intersectedRect.bottomLeft() + yOffset, QSize{ intersectedRect.width(), mappedRect.height() - intersectedRect.height() } }; - const QPoint outerRectBottomOriginPoint = originPoint + QPoint{ 0, intersectedRect.height() } + yOffset; - const QRect mappedOuterRectBottom = d->mapToWallpaper(outerRectBottom); -#if FRAMELESSHELPER_HAS_THREAD - g_imageData()->mutex.lock(); -#endif - painter->drawPixmap(outerRectBottomOriginPoint, g_imageData()->blurredWallpaper, mappedOuterRectBottom); -#if FRAMELESSHELPER_HAS_THREAD - g_imageData()->mutex.unlock(); -#endif - if (mappedRect.x() + mappedRect.width() > wallpaperRect.width()) { - const QRect outerRectRight = { intersectedRect.topRight() + xOffset, QSize{ mappedRect.width() - intersectedRect.width(), intersectedRect.height() } }; - const QPoint outerRectRightOriginPoint = originPoint + QPoint{ intersectedRect.width(), 0 } + xOffset; - const QRect mappedOuterRectRight = d->mapToWallpaper(outerRectRight); - const QRect outerRectCorner = { intersectedRect.bottomRight() + xOffset + yOffset, QSize{ outerRectRight.width(), outerRectBottom.height() } }; - const QPoint outerRectCornerOriginPoint = originPoint + QPoint{ intersectedRect.width(), intersectedRect.height() } + xOffset + yOffset; - const QRect mappedOuterRectCorner = d->mapToWallpaper(outerRectCorner); -#if FRAMELESSHELPER_HAS_THREAD - const QMutexLocker locker(&g_imageData()->mutex); -#endif - painter->drawPixmap(outerRectRightOriginPoint, g_imageData()->blurredWallpaper, mappedOuterRectRight); - painter->drawPixmap(outerRectCornerOriginPoint, g_imageData()->blurredWallpaper, mappedOuterRectCorner); - } - } - } - } - painter->setCompositionMode(QPainter::CompositionMode_SourceOver); - painter->setOpacity(qreal(1)); - painter->fillRect(QRect{originPoint, mappedRect.size()}, [d, active]() -> QBrush { - if (!d->fallbackEnabled || active) { - return d->micaBrush; - } - if (d->fallbackColor.isValid()) { - return d->fallbackColor; - } - return d->systemFallbackColor(); - }()); - painter->restore(); -} - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/micamaterial.h b/src/SARibbonBar/3rdparty/framelesshelper/src/core/micamaterial.h deleted file mode 100644 index 1f0b6dca..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/micamaterial.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Core/micamaterial.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/micamaterial_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/core/micamaterial_p.h deleted file mode 100644 index 08da739e..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/micamaterial_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Core/private/micamaterial_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/platformsupport_linux.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/core/platformsupport_linux.cpp deleted file mode 100644 index 300edbc2..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/platformsupport_linux.cpp +++ /dev/null @@ -1,515 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifdef __linux__ - -#include "framelesshelper_linux.h" -#include "sysapiloader_p.h" - -////////////////////////////////////////////// -// Xlib - -#if 0 // Causes segfault -#ifndef FRAMELESSHELPER_HAS_XLIB - -FRAMELESSHELPER_STRING_CONSTANT(libX11) - -FRAMELESSHELPER_STRING_CONSTANT(XInitThreads) - -extern "C" int -XInitThreads( - void -) -{ - if (!API_XLIB_AVAILABLE(XInitThreads)) { - return 0; - } - return API_CALL_FUNCTION(libX11, XInitThreads); -} - -#endif // FRAMELESSHELPER_HAS_XLIB -#endif - -////////////////////////////////////////////// -// XCB - -#ifndef FRAMELESSHELPER_HAS_XCB - -FRAMELESSHELPER_STRING_CONSTANT(libxcb) - -FRAMELESSHELPER_STRING_CONSTANT(xcb_send_event) -FRAMELESSHELPER_STRING_CONSTANT(xcb_flush) -FRAMELESSHELPER_STRING_CONSTANT(xcb_intern_atom) -FRAMELESSHELPER_STRING_CONSTANT(xcb_intern_atom_reply) -FRAMELESSHELPER_STRING_CONSTANT(xcb_ungrab_pointer) -FRAMELESSHELPER_STRING_CONSTANT(xcb_change_property) -FRAMELESSHELPER_STRING_CONSTANT(xcb_delete_property_checked) -FRAMELESSHELPER_STRING_CONSTANT(xcb_get_property) -FRAMELESSHELPER_STRING_CONSTANT(xcb_get_property_reply) -FRAMELESSHELPER_STRING_CONSTANT(xcb_get_property_value) -FRAMELESSHELPER_STRING_CONSTANT(xcb_get_property_value_length) -FRAMELESSHELPER_STRING_CONSTANT(xcb_list_properties) -FRAMELESSHELPER_STRING_CONSTANT(xcb_list_properties_reply) -FRAMELESSHELPER_STRING_CONSTANT(xcb_list_properties_atoms_length) -FRAMELESSHELPER_STRING_CONSTANT(xcb_list_properties_atoms) -FRAMELESSHELPER_STRING_CONSTANT(xcb_get_property_unchecked) - -extern "C" xcb_void_cookie_t -xcb_send_event( - xcb_connection_t *connection, - uint8_t propagate, - xcb_window_t destination, - uint32_t event_mask, - const char *event -) -{ - if (!API_XCB_AVAILABLE(xcb_send_event)) { - return {}; - } - return API_CALL_FUNCTION(libxcb, xcb_send_event, connection, propagate, destination, event_mask, event); -} - -extern "C" int -xcb_flush( - xcb_connection_t *connection -) -{ - if (!API_XCB_AVAILABLE(xcb_flush)) { - return 0; - } - return API_CALL_FUNCTION(libxcb, xcb_flush, connection); -} - -extern "C" xcb_intern_atom_cookie_t -xcb_intern_atom( - xcb_connection_t *connection, - uint8_t only_if_exists, - uint16_t name_len, - const char *name -) -{ - if (!API_XCB_AVAILABLE(xcb_intern_atom)) { - return {}; - } - return API_CALL_FUNCTION(libxcb, xcb_intern_atom, connection, only_if_exists, name_len, name); -} - -extern "C" xcb_intern_atom_reply_t * -xcb_intern_atom_reply( - xcb_connection_t *connection, - xcb_intern_atom_cookie_t cookie, - xcb_generic_error_t **error -) -{ - if (!API_XCB_AVAILABLE(xcb_intern_atom_reply)) { - return nullptr; - } - return API_CALL_FUNCTION(libxcb, xcb_intern_atom_reply, connection, cookie, error); -} - -extern "C" xcb_void_cookie_t -xcb_ungrab_pointer( - xcb_connection_t *connection, - xcb_timestamp_t time -) -{ - if (!API_XCB_AVAILABLE(xcb_ungrab_pointer)) { - return {}; - } - return API_CALL_FUNCTION(libxcb, xcb_ungrab_pointer, connection, time); -} - -extern "C" xcb_void_cookie_t -xcb_change_property( - xcb_connection_t *connection, - uint8_t mode, - xcb_window_t window, - xcb_atom_t property, - xcb_atom_t type, - uint8_t format, - uint32_t data_len, - const void *data -) -{ - if (!API_XCB_AVAILABLE(xcb_change_property)) { - return {}; - } - return API_CALL_FUNCTION(libxcb, xcb_change_property, connection, - mode, window, property, type, format, data_len, data); -} - -extern "C" xcb_void_cookie_t -xcb_delete_property_checked( - xcb_connection_t *connection, - xcb_window_t window, - xcb_atom_t property -) -{ - if (!API_XCB_AVAILABLE(xcb_delete_property_checked)) { - return {}; - } - return API_CALL_FUNCTION(libxcb, xcb_delete_property_checked, connection, window, property); -} - -extern "C" xcb_get_property_cookie_t -xcb_get_property( - xcb_connection_t *connection, - uint8_t _delete, - xcb_window_t window, - xcb_atom_t property, - xcb_atom_t type, - uint32_t long_offset, - uint32_t long_length -) -{ - if (!API_XCB_AVAILABLE(xcb_get_property)) { - return {}; - } - return API_CALL_FUNCTION(libxcb, xcb_get_property, connection, - _delete, window, property, type, long_offset, long_length); -} - -extern "C" xcb_get_property_reply_t * -xcb_get_property_reply( - xcb_connection_t *connection, - xcb_get_property_cookie_t cookie, - xcb_generic_error_t **error -) -{ - if (!API_XCB_AVAILABLE(xcb_get_property_reply)) { - return nullptr; - } - return API_CALL_FUNCTION(libxcb, xcb_get_property_reply, connection, cookie, error); -} - -extern "C" void * -xcb_get_property_value( - const xcb_get_property_reply_t *reply -) -{ - if (!API_XCB_AVAILABLE(xcb_get_property_value)) { - return nullptr; - } - return API_CALL_FUNCTION(libxcb, xcb_get_property_value, reply); -} - -extern "C" int -xcb_get_property_value_length( - const xcb_get_property_reply_t *reply -) -{ - if (!API_XCB_AVAILABLE(xcb_get_property_value_length)) { - return 0; - } - return API_CALL_FUNCTION(libxcb, xcb_get_property_value_length, reply); -} - -extern "C" xcb_list_properties_cookie_t -xcb_list_properties( - xcb_connection_t *connection, - xcb_window_t window -) -{ - if (!API_XCB_AVAILABLE(xcb_list_properties)) { - return {}; - } - return API_CALL_FUNCTION(libxcb, xcb_list_properties, connection, window); -} - -extern "C" xcb_list_properties_reply_t * -xcb_list_properties_reply( - xcb_connection_t *connection, - xcb_list_properties_cookie_t cookie, - xcb_generic_error_t **error -) -{ - if (!API_XCB_AVAILABLE(xcb_list_properties_reply)) { - return nullptr; - } - return API_CALL_FUNCTION(libxcb, xcb_list_properties_reply, connection, cookie, error); -} - -extern "C" int -xcb_list_properties_atoms_length( - const xcb_list_properties_reply_t *atom -) -{ - if (!API_XCB_AVAILABLE(xcb_list_properties_atoms_length)) { - return 0; - } - return API_CALL_FUNCTION(libxcb, xcb_list_properties_atoms_length, atom); -} - -extern "C" xcb_atom_t * -xcb_list_properties_atoms( - const xcb_list_properties_reply_t *atom -) -{ - if (!API_XCB_AVAILABLE(xcb_list_properties_atoms)) { - return nullptr; - } - return API_CALL_FUNCTION(libxcb, xcb_list_properties_atoms, atom); -} - -extern "C" xcb_get_property_cookie_t -xcb_get_property_unchecked( - xcb_connection_t *connection, - uint8_t _delete, - xcb_window_t window, - xcb_atom_t property, - xcb_atom_t type, - uint32_t long_offset, - uint32_t long_length -) -{ - if (!API_XCB_AVAILABLE(xcb_get_property_unchecked)) { - return {}; - } - return API_CALL_FUNCTION(libxcb, xcb_get_property_unchecked, connection, - _delete, window, property, type, long_offset, long_length); -} - -#endif // FRAMELESSHELPER_HAS_XCB - -/////////////////////////////////////////////////// -// GTK - -#ifndef FRAMELESSHELPER_HAS_GTK - -#define GTKSETTINGS_IMPL(Type, ...) \ - Type gtkSettings(const gchar *property) \ - { \ - Q_ASSERT(property); \ - Q_ASSERT(*property != '\0'); \ - if (!property || (*property == '\0')) { \ - return Type{}; \ - } \ - static GtkSettings * const settings = gtk_settings_get_default(); \ - Q_ASSERT(settings); \ - if (!settings) { \ - return Type{}; \ - } \ - GValue value = G_VALUE_INIT; \ - g_object_get_property(reinterpret_cast(settings), property, &value); \ - __VA_ARGS__ \ - g_value_unset(&value); \ - return result; \ - } - -FRAMELESSHELPER_STRING_CONSTANT2(libgtk, "libgtk-3") - -FRAMELESSHELPER_STRING_CONSTANT(gtk_init) -FRAMELESSHELPER_STRING_CONSTANT(g_value_init) -FRAMELESSHELPER_STRING_CONSTANT(g_value_reset) -FRAMELESSHELPER_STRING_CONSTANT(g_value_unset) -FRAMELESSHELPER_STRING_CONSTANT(g_value_get_boolean) -FRAMELESSHELPER_STRING_CONSTANT(g_value_get_string) -FRAMELESSHELPER_STRING_CONSTANT(gtk_settings_get_default) -FRAMELESSHELPER_STRING_CONSTANT(g_object_get_property) -FRAMELESSHELPER_STRING_CONSTANT(g_signal_connect_data) -FRAMELESSHELPER_STRING_CONSTANT(g_free) -FRAMELESSHELPER_STRING_CONSTANT(g_object_unref) -FRAMELESSHELPER_STRING_CONSTANT(g_clear_object) - -extern "C" void -gtk_init( - int *argc, - char ***argv -) -{ - if (!API_GTK_AVAILABLE(gtk_init)) { - return; - } - API_CALL_FUNCTION(libgtk, gtk_init, argc, argv); -} - -extern "C" GValue * -g_value_init( - GValue *value, - GType g_type -) -{ - if (!API_GTK_AVAILABLE(g_value_init)) { - return nullptr; - } - return API_CALL_FUNCTION(libgtk, g_value_init, value, g_type); -} - -extern "C" GValue * -g_value_reset( - GValue *value -) -{ - if (!API_GTK_AVAILABLE(g_value_reset)) { - return nullptr; - } - return API_CALL_FUNCTION(libgtk, g_value_reset, value); -} - -extern "C" void -g_value_unset( - GValue *value -) -{ - if (!API_GTK_AVAILABLE(g_value_unset)) { - return; - } - API_CALL_FUNCTION(libgtk, g_value_unset, value); -} - -extern "C" gboolean -g_value_get_boolean( - const GValue *value -) -{ - if (!API_GTK_AVAILABLE(g_value_get_boolean)) { - return false; - } - return API_CALL_FUNCTION(libgtk, g_value_get_boolean, value); -} - -extern "C" const gchar * -g_value_get_string( - const GValue *value -) -{ - if (!API_GTK_AVAILABLE(g_value_get_string)) { - return nullptr; - } - return API_CALL_FUNCTION(libgtk, g_value_get_string, value); -} - -extern "C" GtkSettings * -gtk_settings_get_default( - void -) -{ - if (!API_GTK_AVAILABLE(gtk_settings_get_default)) { - return nullptr; - } - return API_CALL_FUNCTION(libgtk, gtk_settings_get_default); -} - -extern "C" void -g_object_get_property( - GObject *object, - const gchar *property_name, - GValue *value -) -{ - if (!API_GTK_AVAILABLE(g_object_get_property)) { - return; - } - API_CALL_FUNCTION(libgtk, g_object_get_property, object, property_name, value); -} - -extern "C" gulong -g_signal_connect_data( - gpointer instance, - const gchar *detailed_signal, - GCallback c_handler, - gpointer data, - GClosureNotify destroy_data, - GConnectFlags connect_flags -) -{ - if (!API_GTK_AVAILABLE(g_signal_connect_data)) { - return 0; - } - return API_CALL_FUNCTION(libgtk, g_signal_connect_data, instance, detailed_signal, c_handler, data, destroy_data, connect_flags); -} - -extern "C" void -g_free( - gpointer mem -) -{ - if (!API_GTK_AVAILABLE(g_free)) { - return; - } - API_CALL_FUNCTION(libgtk, g_free, mem); -} - -extern "C" void -g_object_unref( - GObject *object -) -{ - if (!API_GTK_AVAILABLE(g_object_unref)) { - return; - } - API_CALL_FUNCTION(libgtk, g_object_unref, object); -} - -extern "C" void -g_clear_object( - GObject **object_ptr -) -{ - if (!API_GTK_AVAILABLE(g_clear_object)) { - return; - } - API_CALL_FUNCTION(libgtk, g_clear_object, object_ptr); -} - -GTKSETTINGS_IMPL(bool, const bool result = g_value_get_boolean(&value);) -GTKSETTINGS_IMPL(QString, const QString result = QUtf8String(g_value_get_string(&value));) - -#endif // FRAMELESSHELPER_HAS_GTK - -FRAMELESSHELPER_BEGIN_NAMESPACE -template -T gtkSettings(const gchar *property) -{ - Q_ASSERT(property); - Q_ASSERT(*property != '\0'); - if (!property || (*property == '\0')) { - return T{}; - } - static GtkSettings * const settings = gtk_settings_get_default(); - if (!settings) { - return T{}; - } - T result = {}; - g_object_get(settings, property, &result, nullptr); - return result; -} - -template bool gtkSettings(const gchar *); - -QString gtkSettings(const gchar *property) -{ - Q_ASSERT(property); - Q_ASSERT(*property != '\0'); - if (!property || (*property == '\0')) { - return {}; - } - const auto raw = gtkSettings(property); - const QString result = QUtf8String(raw); - g_free(raw); - return result; -} -FRAMELESSHELPER_END_NAMESPACE - -#endif // __linux__ diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/platformsupport_win.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/core/platformsupport_win.cpp deleted file mode 100644 index a710dd1c..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/platformsupport_win.cpp +++ /dev/null @@ -1,505 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#if (defined(WIN32) || defined(_WIN32)) - -#include "sysapiloader_p.h" -#include "winverhelper_p.h" -#include "framelesshelper_windows.h" - -FRAMELESSHELPER_STRING_CONSTANT(user32) -FRAMELESSHELPER_STRING_CONSTANT(uxtheme) -FRAMELESSHELPER_STRING_CONSTANT(win32u) - -FRAMELESSHELPER_STRING_CONSTANT(GetWindowCompositionAttribute) -FRAMELESSHELPER_STRING_CONSTANT(SetWindowCompositionAttribute) -FRAMELESSHELPER_STRING_CONSTANT(SetWindowThemeAttribute) -FRAMELESSHELPER_STRING_CONSTANT(NtUserEnableChildWindowDpiMessage) -FRAMELESSHELPER_STRING_CONSTANT(EnableChildWindowDpiMessage) -FRAMELESSHELPER_STRING_CONSTANT(EnablePerMonitorDialogScaling) -FRAMELESSHELPER_STRING_CONSTANT(GetDpiForWindow) -FRAMELESSHELPER_STRING_CONSTANT(GetWindowDPI) -FRAMELESSHELPER_STRING_CONSTANT(GetSystemMetricsForDpi) -FRAMELESSHELPER_STRING_CONSTANT(GetDpiMetrics) -FRAMELESSHELPER_STRING_CONSTANT(AdjustWindowRectExForDpi) - -EXTERN_C BOOL WINAPI -_GetWindowCompositionAttribute(const HWND hWnd, PWINDOWCOMPOSITIONATTRIBDATA pvData) -{ - Q_ASSERT(hWnd); - Q_ASSERT(pvData); - if (!hWnd || !pvData) { - ::SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - if (!API_USER_AVAILABLE(GetWindowCompositionAttribute)) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - return API_CALL_FUNCTION4(user32, GetWindowCompositionAttribute, hWnd, pvData); -} - -EXTERN_C BOOL WINAPI -_SetWindowCompositionAttribute(const HWND hWnd, PWINDOWCOMPOSITIONATTRIBDATA pvData) -{ - Q_ASSERT(hWnd); - Q_ASSERT(pvData); - if (!hWnd || !pvData) { - ::SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - if (!API_USER_AVAILABLE(SetWindowCompositionAttribute)) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - return API_CALL_FUNCTION4(user32, SetWindowCompositionAttribute, hWnd, pvData); -} - -EXTERN_C HRESULT WINAPI -_SetWindowThemeAttribute(const HWND hWnd, const _WINDOWTHEMEATTRIBUTETYPE attrib, - PVOID pvData, const DWORD cbData -) -{ - Q_ASSERT(hWnd); - Q_ASSERT(pvData); - Q_ASSERT(cbData != 0); - if (!hWnd || !pvData || (cbData == 0)) { - return E_INVALIDARG; - } - if (!API_THEME_AVAILABLE(SetWindowThemeAttribute)) { - return E_NOTIMPL; - } - return API_CALL_FUNCTION4(uxtheme, SetWindowThemeAttribute, hWnd, attrib, pvData, cbData); -} - -EXTERN_C HRESULT WINAPI -_SetWindowThemeNonClientAttributes(const HWND hWnd, const DWORD dwMask, const DWORD dwAttributes) -{ - Q_ASSERT(hWnd); - if (!hWnd) { - return E_INVALIDARG; - } - WTA_OPTIONS2 options = {}; - options.dwFlags = dwAttributes; - options.dwMask = dwMask; - return _SetWindowThemeAttribute(hWnd, _WTA_NONCLIENT, &options, sizeof(options)); -} - -EXTERN_C BOOL WINAPI -_ShouldAppsUseDarkMode(VOID) -{ - FRAMELESSHELPER_USE_NAMESPACE - if (!WindowsVersionHelper::isWin10OrGreater()) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - static const auto pShouldAppsUseDarkMode - = reinterpret_cast( - SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(132))); - if (!pShouldAppsUseDarkMode) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - return pShouldAppsUseDarkMode(); -} - -EXTERN_C BOOL WINAPI -_AllowDarkModeForWindow(const HWND hWnd, const BOOL bAllow) -{ - Q_ASSERT(hWnd); - if (!hWnd) { - ::SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - FRAMELESSHELPER_USE_NAMESPACE - if (!WindowsVersionHelper::isWin10OrGreater()) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - static const auto pAllowDarkModeForWindow - = reinterpret_cast( - SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(133))); - if (!pAllowDarkModeForWindow) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - return pAllowDarkModeForWindow(hWnd, bAllow); -} - -EXTERN_C BOOL WINAPI -_AllowDarkModeForApp(const BOOL bAllow) -{ - FRAMELESSHELPER_USE_NAMESPACE - if (!WindowsVersionHelper::isWin10OrGreater()) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - static const auto pAllowDarkModeForApp - = reinterpret_cast( - SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(135))); - if (!pAllowDarkModeForApp) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - return pAllowDarkModeForApp(bAllow); -} - -EXTERN_C VOID WINAPI -_FlushMenuThemes(VOID) -{ - FRAMELESSHELPER_USE_NAMESPACE - if (!WindowsVersionHelper::isWin10OrGreater()) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return; - } - static const auto pFlushMenuThemes - = reinterpret_cast( - SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(136))); - if (!pFlushMenuThemes) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return; - } - pFlushMenuThemes(); -} - -EXTERN_C VOID WINAPI -_RefreshImmersiveColorPolicyState(VOID) -{ - FRAMELESSHELPER_USE_NAMESPACE - if (!WindowsVersionHelper::isWin10OrGreater()) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return; - } - static const auto pRefreshImmersiveColorPolicyState - = reinterpret_cast( - SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(104))); - if (!pRefreshImmersiveColorPolicyState) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return; - } - pRefreshImmersiveColorPolicyState(); -} - -EXTERN_C BOOL WINAPI -_IsDarkModeAllowedForWindow(const HWND hWnd) -{ - Q_ASSERT(hWnd); - if (!hWnd) { - ::SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - FRAMELESSHELPER_USE_NAMESPACE - if (!WindowsVersionHelper::isWin10OrGreater()) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - static const auto pIsDarkModeAllowedForWindow - = reinterpret_cast( - SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(137))); - if (!pIsDarkModeAllowedForWindow) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - return pIsDarkModeAllowedForWindow(hWnd); -} - -EXTERN_C BOOL WINAPI -_GetIsImmersiveColorUsingHighContrast(const IMMERSIVE_HC_CACHE_MODE mode) -{ - FRAMELESSHELPER_USE_NAMESPACE - if (!WindowsVersionHelper::isWin10OrGreater()) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - static const auto pGetIsImmersiveColorUsingHighContrast - = reinterpret_cast( - SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(106))); - if (!pGetIsImmersiveColorUsingHighContrast) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - return pGetIsImmersiveColorUsingHighContrast(mode); -} - -EXTERN_C HTHEME WINAPI -_OpenNcThemeData(const HWND hWnd, LPCWSTR pszClassList) -{ - Q_ASSERT(hWnd); - Q_ASSERT(pszClassList); - if (!hWnd || !pszClassList) { - ::SetLastError(ERROR_INVALID_PARAMETER); - return nullptr; - } - FRAMELESSHELPER_USE_NAMESPACE - if (!WindowsVersionHelper::isWin10OrGreater()) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return nullptr; - } - static const auto pOpenNcThemeData - = reinterpret_cast( - SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(49))); - if (!pOpenNcThemeData) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return nullptr; - } - return pOpenNcThemeData(hWnd, pszClassList); -} - -EXTERN_C BOOL WINAPI -_ShouldSystemUseDarkMode(VOID) -{ - FRAMELESSHELPER_USE_NAMESPACE - if (!WindowsVersionHelper::isWin10OrGreater()) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - static const auto pShouldSystemUseDarkMode - = reinterpret_cast( - SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(138))); - if (!pShouldSystemUseDarkMode) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - return pShouldSystemUseDarkMode(); -} - -EXTERN_C PREFERRED_APP_MODE WINAPI -_SetPreferredAppMode(const PREFERRED_APP_MODE mode) -{ - FRAMELESSHELPER_USE_NAMESPACE - if (!WindowsVersionHelper::isWin10OrGreater()) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return PAM_MAX; - } - static const auto pSetPreferredAppMode - = reinterpret_cast( - SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(135))); - if (!pSetPreferredAppMode) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return PAM_MAX; - } - return pSetPreferredAppMode(mode); -} - -EXTERN_C BOOL WINAPI -_IsDarkModeAllowedForApp(VOID) -{ - FRAMELESSHELPER_USE_NAMESPACE - if (!WindowsVersionHelper::isWin10OrGreater()) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - static const auto pIsDarkModeAllowedForApp - = reinterpret_cast( - SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(139))); - if (!pIsDarkModeAllowedForApp) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - return pIsDarkModeAllowedForApp(); -} - -EXTERN_C BOOL WINAPI -_EnableChildWindowDpiMessage2(const HWND hWnd, const BOOL fEnable) -{ - Q_ASSERT(hWnd); - if (!hWnd) { - ::SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - FRAMELESSHELPER_USE_NAMESPACE - if (!WindowsVersionHelper::isWin10OrGreater()) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - using EnableChildWindowDpiMessagePtr = decltype(&::_EnableChildWindowDpiMessage); - static const auto pEnableChildWindowDpiMessage = []() -> EnableChildWindowDpiMessagePtr { - // EnableChildWindowDpiMessage() was moved to "win32u.dll" and renamed to - // "NtUserEnableChildWindowDpiMessage" since Win10 1607. - if (const auto pFunc = reinterpret_cast( - SysApiLoader::resolve(kwin32u, kNtUserEnableChildWindowDpiMessage))) { - return pFunc; - } - // EnableChildWindowDpiMessage() was once a public API, so we can load it by name, - // but it got removed in Win10 1607, so we can't link to it directly. - if (const auto pFunc = reinterpret_cast( - SysApiLoader::resolve(kuser32, kEnableChildWindowDpiMessage))) { - return pFunc; - } - // EnableChildWindowDpiMessage() was made private since Win10 1607. - if (const auto pFunc = reinterpret_cast( - SysApiLoader::resolve(kuser32, MAKEINTRESOURCEA(2704)))) { - return pFunc; - } - return nullptr; - }(); - if (!pEnableChildWindowDpiMessage) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - return pEnableChildWindowDpiMessage(hWnd, fEnable); -} - -EXTERN_C BOOL WINAPI -_EnablePerMonitorDialogScaling2(VOID) -{ - FRAMELESSHELPER_USE_NAMESPACE - if (!WindowsVersionHelper::isWin10OrGreater()) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - using EnablePerMonitorDialogScalingPtr = decltype(&::_EnablePerMonitorDialogScaling); - static const auto pEnablePerMonitorDialogScaling = []() -> EnablePerMonitorDialogScalingPtr { - // EnablePerMonitorDialogScaling() was once a public API, so we can load it by name, - // but it got removed in Win10 1607, so we can't link to it directly. - if (const auto pFunc = reinterpret_cast( - SysApiLoader::resolve(kuser32, kEnablePerMonitorDialogScaling))) { - return pFunc; - } - // EnablePerMonitorDialogScaling() was made private since Win10 1607. - if (const auto pFunc = reinterpret_cast( - SysApiLoader::resolve(kuser32, MAKEINTRESOURCEA(2577)))) { - return pFunc; - } - return nullptr; - }(); - if (!pEnablePerMonitorDialogScaling) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - return pEnablePerMonitorDialogScaling(); -} - -EXTERN_C UINT WINAPI -_GetDpiForWindow2(const HWND hWnd) -{ - Q_ASSERT(hWnd); - if (!hWnd) { - ::SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - FRAMELESSHELPER_USE_NAMESPACE - if (!WindowsVersionHelper::isWin10OrGreater()) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; - } - using GetDpiForWindowPtr = decltype(&::_GetDpiForWindow); - static const auto pGetDpiForWindow = []() -> GetDpiForWindowPtr { - // GetDpiForWindow() was made public since Win10 1607. - if (const auto pFunc = reinterpret_cast( - SysApiLoader::resolve(kuser32, kGetDpiForWindow))) { - return pFunc; - } - // GetDpiForWindow() was named "GetWindowDPI" before made public. - if (const auto pFunc = reinterpret_cast( - SysApiLoader::resolve(kuser32, kGetWindowDPI))) { - return pFunc; - } - // GetWindowDPI() was made private since Win10 1607. - if (const auto pFunc = reinterpret_cast( - SysApiLoader::resolve(kuser32, MAKEINTRESOURCEA(2707)))) { - return pFunc; - } - return nullptr; - }(); - if (!pGetDpiForWindow) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; - } - return pGetDpiForWindow(hWnd); -} - -EXTERN_C int WINAPI -_GetSystemMetricsForDpi2(const int nIndex, const UINT dpi) -{ - Q_ASSERT(nIndex >= 0); - Q_ASSERT(dpi != 0); - if ((nIndex < 0) || (dpi == 0)) { - ::SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - FRAMELESSHELPER_USE_NAMESPACE - if (!WindowsVersionHelper::isWin10OrGreater()) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; - } - using GetSystemMetricsForDpiPtr = decltype(&::_GetSystemMetricsForDpi); - static const auto pGetSystemMetricsForDpi = []() -> GetSystemMetricsForDpiPtr { - // GetSystemMetricsForDpi() was made public since Win10 1607. - if (const auto pFunc = reinterpret_cast( - SysApiLoader::resolve(kuser32, kGetSystemMetricsForDpi))) { - return pFunc; - } - // GetSystemMetricsForDpi() was named "GetDpiMetrics" before made public, - // that is, when in Win10 1507 & 1511. - if (const auto pFunc = reinterpret_cast( - SysApiLoader::resolve(kuser32, kGetDpiMetrics))) { - return pFunc; - } - return nullptr; - }(); - if (!pGetSystemMetricsForDpi) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; - } - return pGetSystemMetricsForDpi(nIndex, dpi); -} - -EXTERN_C BOOL WINAPI -_AdjustWindowRectExForDpi2(LPRECT lpRect, const DWORD dwStyle, - const BOOL bMenu, const DWORD dwExStyle, const UINT dpi) -{ - Q_ASSERT(lpRect); - Q_ASSERT(dpi != 0); - if (!lpRect || (dpi == 0)) { - ::SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - FRAMELESSHELPER_USE_NAMESPACE - if (!WindowsVersionHelper::isWin10OrGreater()) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - using AdjustWindowRectExForDpiPtr = decltype(&::_AdjustWindowRectExForDpi); - static const auto pAdjustWindowRectExForDpi = []() -> AdjustWindowRectExForDpiPtr { - // AdjustWindowRectExForDpi() was made public since Win10 1607. - if (const auto pFunc = reinterpret_cast( - SysApiLoader::resolve(kuser32, kAdjustWindowRectExForDpi))) { - return pFunc; - } - // AdjustWindowRectExForDpi() was made private in Win10 1507 & 1511. - if (const auto pFunc = reinterpret_cast( - SysApiLoader::resolve(kuser32, MAKEINTRESOURCEA(2580)))) { - return pFunc; - } - return nullptr; - }(); - if (!pAdjustWindowRectExForDpi) { - ::SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - return pAdjustWindowRectExForDpi(lpRect, dwStyle, bMenu, dwExStyle, dpi); -} - -#endif // Q_OS_WINDOWS diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/registrykey.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/core/registrykey.cpp deleted file mode 100644 index 1dd283eb..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/registrykey.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "registrykey_p.h" - -#ifdef Q_OS_WINDOWS - -#include "framelesshelper_windows.h" -#include -#include -#if REGISTRYKEY_QWINREGISTRYKEY -# include -#else -# include -#endif - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcCoreRegistryKey, "wangwenx190.framelesshelper.core.registrykey") -# define INFO qCInfo(lcCoreRegistryKey) -# define DEBUG qCDebug(lcCoreRegistryKey) -# define WARNING qCWarning(lcCoreRegistryKey) -# define CRITICAL qCCritical(lcCoreRegistryKey) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -static constexpr const std::array g_registryKeyMap = -{ - 0x80000000, // HKEY_CLASSES_ROOT - 0x80000001, // HKEY_CURRENT_USER - 0x80000002, // HKEY_LOCAL_MACHINE - 0x80000003, // HKEY_USERS - 0x80000004, // HKEY_PERFORMANCE_DATA - 0x80000005, // HKEY_CURRENT_CONFIG - 0x80000006, // HKEY_DYN_DATA - 0x80000007, // HKEY_CURRENT_USER_LOCAL_SETTINGS - 0x80000050, // HKEY_PERFORMANCE_TEXT - 0x80000060 // HKEY_PERFORMANCE_NLSTEXT -}; -static constexpr const auto registryKeyCount = std::size(g_registryKeyMap); -static_assert(registryKeyCount == (static_cast(RegistryRootKey::PerformanceNlsText) + 1)); - -[[maybe_unused]] static Q_STRING_CONSTEXPR const std::array g_registryStrMap = -{ - FRAMELESSHELPER_STRING("HKEY_CLASSES_ROOT"), - FRAMELESSHELPER_STRING("HKEY_CURRENT_USER"), - FRAMELESSHELPER_STRING("HKEY_LOCAL_MACHINE"), - FRAMELESSHELPER_STRING("HKEY_USERS"), - FRAMELESSHELPER_STRING("HKEY_PERFORMANCE_DATA"), - FRAMELESSHELPER_STRING("HKEY_CURRENT_CONFIG"), - FRAMELESSHELPER_STRING("HKEY_DYN_DATA"), - FRAMELESSHELPER_STRING("HKEY_CURRENT_USER_LOCAL_SETTINGS"), - FRAMELESSHELPER_STRING("HKEY_PERFORMANCE_TEXT"), - FRAMELESSHELPER_STRING("HKEY_PERFORMANCE_NLSTEXT") -}; - -RegistryKey::RegistryKey(const RegistryRootKey root, const QString &key, QObject *parent) : QObject(parent) -{ - Q_ASSERT(!key.isEmpty()); - if (key.isEmpty()) { - return; - } - m_rootKey = root; - m_subKey = key; -#if REGISTRYKEY_QWINREGISTRYKEY - m_registryKey = std::make_unique(reinterpret_cast(g_registryKeyMap.at(static_cast(m_rootKey))), m_subKey); - if (!m_registryKey->isValid()) { - m_registryKey.reset(); - } -#else - const QString rootKey = g_registryStrMap.at(static_cast(m_rootKey)); - const auto lastSlashPos = m_subKey.lastIndexOf(u'\\'); - m_settings = std::make_unique(rootKey + u'\\' + m_subKey.left(lastSlashPos), QSettings::NativeFormat); - if (m_settings->childGroups().contains(m_subKey.mid(lastSlashPos + 1))) { - m_settings.reset(new QSettings(rootKey + u'\\' + m_subKey, QSettings::NativeFormat)); - } else { - m_settings.reset(); - } -#endif -} - -RegistryKey::~RegistryKey() = default; - -RegistryRootKey RegistryKey::rootKey() const -{ - return m_rootKey; -} - -QString RegistryKey::subKey() const -{ - return m_subKey; -} - -bool RegistryKey::isValid() const -{ -#if REGISTRYKEY_QWINREGISTRYKEY - return (m_registryKey && m_registryKey->isValid()); -#else - return m_settings; -#endif -} - -QVariant RegistryKey::value(const QString &name) const -{ - Q_ASSERT(!name.isEmpty()); - Q_ASSERT(isValid()); - if (name.isEmpty() || !isValid()) { - return {}; - } -#if REGISTRYKEY_QWINREGISTRYKEY -# if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)) - return m_registryKey->value(name); -# else // (QT_VERSION < QT_VERSION_CHECK(6, 5, 0)) - const QPair dwVal = m_registryKey->dwordValue(name); - if (dwVal.second) { - return qulonglong(dwVal.first); - } - const QString strVal = m_registryKey->stringValue(name); - if (!strVal.isEmpty()) { - return strVal; - } - return {}; -# endif // (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)) -#else // !REGISTRYKEY_QWINREGISTRYKEY - return m_settings->value(name); -#endif // REGISTRYKEY_QWINREGISTRYKEY -} - -FRAMELESSHELPER_END_NAMESPACE - -#endif // Q_OS_WINDOWS diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/registrykey_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/core/registrykey_p.h deleted file mode 100644 index 066f098a..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/registrykey_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Core/private/registrykey_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/resources/fonts/iconfont.ttf b/src/SARibbonBar/3rdparty/framelesshelper/src/core/resources/fonts/iconfont.ttf deleted file mode 100644 index 26a3b013..00000000 Binary files a/src/SARibbonBar/3rdparty/framelesshelper/src/core/resources/fonts/iconfont.ttf and /dev/null differ diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/resources/images/noise.png b/src/SARibbonBar/3rdparty/framelesshelper/src/core/resources/images/noise.png deleted file mode 100644 index a78e8296..00000000 Binary files a/src/SARibbonBar/3rdparty/framelesshelper/src/core/resources/images/noise.png and /dev/null differ diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/scopeguard_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/core/scopeguard_p.h deleted file mode 100644 index 13bd8a3b..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/scopeguard_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Core/private/scopeguard_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/sysapiloader.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/core/sysapiloader.cpp deleted file mode 100644 index c58dc640..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/sysapiloader.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "sysapiloader_p.h" - -#ifndef SYSAPILOADER_FORCE_QLIBRARY -# define SYSAPILOADER_FORCE_QLIBRARY (0) -#endif // SYSAPILOADER_FORCE_QLIBRARY - -#ifndef SYSAPILOADER_IMPL -# if (defined(Q_OS_WINDOWS) && !defined(FRAMELESSHELPER_CORE_NO_PRIVATE)) -# define SYSAPILOADER_IMPL (1) -# else // (!Q_OS_WINDOWS || FRAMELESSHELPER_CORE_NO_PRIVATE) -# define SYSAPILOADER_IMPL (2) -# endif // (defined(Q_OS_WINDOWS) && !defined(FRAMELESSHELPER_CORE_NO_PRIVATE)) -#endif // SYSAPILOADER_IMPL - -#ifndef SYSAPILOADER_QSYSTEMLIBRARY -# define SYSAPILOADER_QSYSTEMLIBRARY ((SYSAPILOADER_IMPL) == 1) -#endif // SYSAPILOADER_QSYSTEMLIBRARY - -#ifndef SYSAPILOADER_QLIBRARY -# define SYSAPILOADER_QLIBRARY ((SYSAPILOADER_IMPL) == 2) -#endif // SYSAPILOADER_QLIBRARY - -#include -#include -#include -#include -#if SYSAPILOADER_QSYSTEMLIBRARY -# include -#endif // SYSAPILOADER_QSYSTEMLIBRARY -#if SYSAPILOADER_QLIBRARY -# include -#endif // SYSAPILOADER_QLIBRARY - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcSysApiLoader, "wangwenx190.framelesshelper.core.sysapiloader") -# define INFO qCInfo(lcSysApiLoader) -# define DEBUG qCDebug(lcSysApiLoader) -# define WARNING qCWarning(lcSysApiLoader) -# define CRITICAL qCCritical(lcSysApiLoader) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using SysApiLoaderData = QHash; - -Q_GLOBAL_STATIC(SysApiLoaderData, g_sysApiLoaderData) - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[nodiscard]] static inline bool isDebug() -{ - static const bool flag = (qEnvironmentVariableIntValue("FRAMELESSHELPER_SYSAPILOADER_DEBUG") != 0); - return flag; -} -#endif - -SysApiLoader::SysApiLoader(QObject *parent) : QObject(parent) -{ -} - -SysApiLoader::~SysApiLoader() = default; - -SysApiLoader *SysApiLoader::instance() -{ - static SysApiLoader loader; - return &loader; -} - -QString SysApiLoader::platformSharedLibrarySuffixName() -{ - static const auto result = []() -> QString { -#ifdef Q_OS_WINDOWS - return FRAMELESSHELPER_STRING_LITERAL(".dll"); -#elif (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) - return FRAMELESSHELPER_STRING_LITERAL(".so"); -#elif defined(Q_OS_MACOS) - return FRAMELESSHELPER_STRING_LITERAL(".dylib"); -#else -# error "Unsupported platform!" -#endif - }(); - return result; -} - -QString SysApiLoader::platformSystemLibraryDirectory() -{ - static const auto result = []() -> QString { -#ifdef Q_OS_WINDOWS - QVarLengthArray buf = {}; - const UINT len = ::GetSystemDirectoryW(buf.data(), MAX_PATH); - if (len > MAX_PATH) { - // No need to +1 here, GetSystemDirectoryW() will always give us a null terminator. - buf.resize(len); - ::GetSystemDirectoryW(buf.data(), len); - } - return QString::fromWCharArray(buf.constData(), len); -#else - return FRAMELESSHELPER_STRING_LITERAL("/usr/lib"); -#endif - }(); - return result; -} - -QString SysApiLoader::generateUniqueKey(const QString &library, const QString &function) -{ - Q_ASSERT(!library.isEmpty()); - Q_ASSERT(!function.isEmpty()); - if (library.isEmpty() || function.isEmpty()) { - return {}; - } - QString key = QDir::toNativeSeparators(library); - // Remove path, only keep the file name. - if (const qsizetype lastSeparatorPos = key.lastIndexOf(QDir::separator()); lastSeparatorPos >= 0) { - key.remove(0, lastSeparatorPos); - } -#ifdef Q_OS_WINDOWS - key = key.toLower(); -#endif // Q_OS_WINDOWS - static const QString suffix = platformSharedLibrarySuffixName(); - if (!key.endsWith(suffix)) { - key.append(suffix); - } - key.append(u'@'); - key.append(function); - return key; -} - -QFunctionPointer SysApiLoader::resolve(const QString &library, const char *function) -{ - Q_ASSERT(!library.isEmpty()); - Q_ASSERT(function); - if (library.isEmpty() || !function) { - return nullptr; - } -#if SYSAPILOADER_QSYSTEMLIBRARY - return QSystemLibrary::resolve(library, function); -#endif // SYSAPILOADER_QSYSTEMLIBRARY -#if SYSAPILOADER_QLIBRARY - return QLibrary::resolve(library, function); -#endif // SYSAPILOADER_QLIBRARY -} - -QFunctionPointer SysApiLoader::resolve(const QString &library, const QString &function) -{ - Q_ASSERT(!library.isEmpty()); - Q_ASSERT(!function.isEmpty()); - if (library.isEmpty() || function.isEmpty()) { - return nullptr; - } - return SysApiLoader::resolve(library, function.toUtf8().constData()); -} - -bool SysApiLoader::isAvailable(const QString &library, const QString &function) -{ - Q_ASSERT(!library.isEmpty()); - Q_ASSERT(!function.isEmpty()); - if (library.isEmpty() || function.isEmpty()) { - return false; - } - const QString key = generateUniqueKey(library, function); - const auto it = g_sysApiLoaderData()->constFind(key); - if (it != g_sysApiLoaderData()->constEnd()) { -#if FRAMELESSHELPER_CONFIG(debug_output) - if (isDebug()) { - DEBUG << Q_FUNC_INFO << "Function cache found:" << key; - } -#endif - return (it.value() != nullptr); - } else { - const QFunctionPointer symbol = SysApiLoader::resolve(library, function); - g_sysApiLoaderData()->insert(key, symbol); -#if FRAMELESSHELPER_CONFIG(debug_output) - if (isDebug()) { - DEBUG << Q_FUNC_INFO << "New function cache:" << key << (symbol ? "[VALID]" : "[NULL]"); - } -#endif - if (symbol) { - DEBUG << "Successfully loaded" << function << "from" << library; - return true; - } else { - WARNING << "Failed to load" << function << "from" << library; - return false; - } - } -} - -QFunctionPointer SysApiLoader::get(const QString &library, const QString &function) -{ - Q_ASSERT(!library.isEmpty()); - Q_ASSERT(!function.isEmpty()); - if (library.isEmpty() || function.isEmpty()) { - return nullptr; - } - const QString key = generateUniqueKey(library, function); - const auto it = g_sysApiLoaderData()->constFind(key); - if (it != g_sysApiLoaderData()->constEnd()) { -#if FRAMELESSHELPER_CONFIG(debug_output) - if (isDebug()) { - DEBUG << Q_FUNC_INFO << "Function cache found:" << key; - } -#endif - return it.value(); - } else { -#if FRAMELESSHELPER_CONFIG(debug_output) - if (isDebug()) { - DEBUG << Q_FUNC_INFO << "Function cache not found:" << key; - } -#endif - return nullptr; - } -} - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/sysapiloader_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/core/sysapiloader_p.h deleted file mode 100644 index 331965ab..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/sysapiloader_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Core/private/sysapiloader_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/utils.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/core/utils.cpp deleted file mode 100644 index 25c31e1a..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/utils.cpp +++ /dev/null @@ -1,668 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "utils.h" -#include "framelesshelpercore_global_p.h" -#include "framelessmanager_p.h" -#include "framelessmanager.h" -#ifdef Q_OS_WINDOWS -# include "winverhelper_p.h" -#endif // Q_OS_WINDOWS -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if FRAMELESSHELPER_CONFIG(private_qt) -# include -# include -#endif // FRAMELESSHELPER_CONFIG(private_qt) -#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)) -# include -#elif ((QT_VERSION >= QT_VERSION_CHECK(6, 2, 1)) && FRAMELESSHELPER_CONFIG(private_qt)) -# include -# include -#endif // ((QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)) && FRAMELESSHELPER_CONFIG(private_qt)) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcUtilsCommon, "wangwenx190.framelesshelper.core.utils.common") -# define INFO qCInfo(lcUtilsCommon) -# define DEBUG qCDebug(lcUtilsCommon) -# define WARNING qCWarning(lcUtilsCommon) -# define CRITICAL qCCritical(lcUtilsCommon) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -#if FRAMELESSHELPER_CONFIG(bundle_resource) -struct FONT_ICON -{ - quint32 SegoeUI = 0; - quint32 Fallback = 0; -}; - -static constexpr const std::array(SystemButtonType::Last) + 1> g_fontIconsTable = -{ - FONT_ICON{ 0x0000, 0x0000 }, - FONT_ICON{ 0xE756, 0x0000 }, - FONT_ICON{ 0xE897, 0x0000 }, - FONT_ICON{ 0xE921, 0xE93E }, - FONT_ICON{ 0xE922, 0xE93C }, - FONT_ICON{ 0xE923, 0xE93D }, - FONT_ICON{ 0xE8BB, 0xE93B } -}; -#endif // FRAMELESSHELPER_CONFIG(bundle_resource) - -#if !FRAMELESSHELPER_CONFIG(private_qt) -[[nodiscard]] static inline QPoint getScaleOrigin(const QWindow *window) -{ - Q_ASSERT(window); - if (!window) { - return {}; - } - QScreen *screen = window->screen(); - if (!screen) { - screen = QGuiApplication::primaryScreen(); - } - if (!screen) { - return {}; - } - return screen->geometry().topLeft(); -} -#endif // !FRAMELESSHELPER_CONFIG(private_qt) - -Qt::CursorShape Utils::calculateCursorShape(const QWindow *window, const QPoint &pos) -{ -#ifdef Q_OS_MACOS - Q_UNUSED(window); - Q_UNUSED(pos); - return Qt::ArrowCursor; -#else - Q_ASSERT(window); - if (!window) { - return Qt::ArrowCursor; - } - if (window->visibility() != QWindow::Windowed) { - return Qt::ArrowCursor; - } - const int x = pos.x(); - const int y = pos.y(); - const int w = window->width(); - const int h = window->height(); - if (((x < kDefaultResizeBorderThickness) && (y < kDefaultResizeBorderThickness)) - || ((x >= (w - kDefaultResizeBorderThickness)) && (y >= (h - kDefaultResizeBorderThickness)))) { - return Qt::SizeFDiagCursor; - } - if (((x >= (w - kDefaultResizeBorderThickness)) && (y < kDefaultResizeBorderThickness)) - || ((x < kDefaultResizeBorderThickness) && (y >= (h - kDefaultResizeBorderThickness)))) { - return Qt::SizeBDiagCursor; - } - if ((x < kDefaultResizeBorderThickness) || (x >= (w - kDefaultResizeBorderThickness))) { - return Qt::SizeHorCursor; - } - if ((y < kDefaultResizeBorderThickness) || (y >= (h - kDefaultResizeBorderThickness))) { - return Qt::SizeVerCursor; - } - return Qt::ArrowCursor; -#endif -} - -Qt::Edges Utils::calculateWindowEdges(const QWindow *window, const QPoint &pos) -{ -#ifdef Q_OS_MACOS - Q_UNUSED(window); - Q_UNUSED(pos); - return {}; -#else - Q_ASSERT(window); - if (!window) { - return {}; - } - if (window->visibility() != QWindow::Windowed) { - return {}; - } - Qt::Edges edges = {}; - const int x = pos.x(); - const int y = pos.y(); - if (x < kDefaultResizeBorderThickness) { - edges |= Qt::LeftEdge; - } - if (x >= (window->width() - kDefaultResizeBorderThickness)) { - edges |= Qt::RightEdge; - } - if (y < kDefaultResizeBorderThickness) { - edges |= Qt::TopEdge; - } - if (y >= (window->height() - kDefaultResizeBorderThickness)) { - edges |= Qt::BottomEdge; - } - return edges; -#endif -} - -QString Utils::getSystemButtonGlyph(const SystemButtonType button) -{ -#if FRAMELESSHELPER_CONFIG(bundle_resource) - const FONT_ICON &icon = g_fontIconsTable.at(static_cast(button)); -# ifdef Q_OS_WINDOWS - // Windows 11: Segoe Fluent Icons (https://docs.microsoft.com/en-us/windows/apps/design/style/segoe-fluent-icons-font) - // Windows 10: Segoe MDL2 Assets (https://docs.microsoft.com/en-us/windows/apps/design/style/segoe-ui-symbol-font) - // Windows 7~8.1: Our own custom icon - if (WindowsVersionHelper::isWin10OrGreater()) { - return QChar(icon.SegoeUI); - } -# endif // Q_OS_WINDOWS - // We always use our own icons on UNIX platforms because Microsoft doesn't allow distributing - // the Segoe icon font to other platforms than Windows. - return QChar(icon.Fallback); -#else // !FRAMELESSHELPER_CONFIG(bundle_resource) - return {}; -#endif // FRAMELESSHELPER_CONFIG(bundle_resource) -} - -QWindow *Utils::findWindow(const WId windowId) -{ - Q_ASSERT(windowId); - if (!windowId) { - return nullptr; - } - const QWindowList windows = QGuiApplication::topLevelWindows(); - if (windows.isEmpty()) { - return nullptr; - } - for (auto &&window : std::as_const(windows)) { - if (window && window->handle()) { - if (window->winId() == windowId) { - return window; - } - } - } - return nullptr; -} - -bool Utils::moveWindowToDesktopCenter(const WId windowId, const bool considerTaskBar) -{ - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - const QObject *window = FramelessManagerPrivate::getWindow(windowId); - if (!window) { - return false; - } - const FramelessDataPtr data = FramelessManagerPrivate::getData(window); - if (!data || !data->callbacks) { - return false; - } - const QSize windowSize = data->callbacks->getWindowSize(); - if (windowSize.isEmpty() || (windowSize <= kDefaultWindowSize)) { - return false; - } - const QScreen *screen = data->callbacks->getWindowScreen(); - if (!screen) { - screen = QGuiApplication::primaryScreen(); - } - Q_ASSERT(screen); - if (!screen) { - return false; - } - const QSize screenSize = (considerTaskBar ? screen->availableSize() : screen->size()); - const QPoint offset = (considerTaskBar ? screen->availableGeometry().topLeft() : QPoint(0, 0)); - const int newX = std::round(qreal(screenSize.width() - windowSize.width()) / qreal(2)); - const int newY = std::round(qreal(screenSize.height() - windowSize.height()) / qreal(2)); - data->callbacks->setWindowPosition(QPoint(newX + offset.x(), newY + offset.y())); - return true; -} - -Qt::WindowState Utils::windowStatesToWindowState(const Qt::WindowStates states) -{ - if (states & Qt::WindowFullScreen) { - return Qt::WindowFullScreen; - } - if (states & Qt::WindowMaximized) { - return Qt::WindowMaximized; - } - if (states & Qt::WindowMinimized) { - return Qt::WindowMinimized; - } - return Qt::WindowNoState; -} - -bool Utils::isThemeChangeEvent(const QEvent * const event) -{ - Q_ASSERT(event); - if (!event) { - return false; - } - // QGuiApplication will only deliver theme change events to top level Q(Quick)Windows, - // QWidgets won't get such notifications, no matter whether it's top level widget or not. - // QEvent::ThemeChange: Send by the Windows QPA. - // QEvent::ApplicationPaletteChange: All other platforms (Linux & macOS). - const QEvent::Type type = event->type(); - return ((type == QEvent::ThemeChange) || (type == QEvent::ApplicationPaletteChange)); -} - -QColor Utils::calculateSystemButtonBackgroundColor(const SystemButtonType button, const ButtonState state) -{ - if (state == ButtonState::Normal) { - return kDefaultTransparentColor; - } - const bool isDark = (FramelessManager::instance()->systemTheme() == SystemTheme::Dark); - const bool isClose = (button == SystemButtonType::Close); - const bool isTitleColor = isTitleBarColorized(); - const bool isHovered = (state == ButtonState::Hovered); - auto result = [isDark, isClose, isTitleColor]() -> QColor { - if (isClose) { - return kDefaultSystemCloseButtonBackgroundColor; - } - if (isTitleColor) { - return calculateForegroundColor(getAccentColor()); - } - return (isDark ? kDefaultWhiteColor : kDefaultBlackColor); - }(); - if (isClose) { - return (isHovered ? result.lighter(110) : result.lighter(140)); - } - if (isHovered) { - result.setAlpha(12); - } else { - result.setAlpha(6); - } - return result; -} - -bool Utils::shouldAppsUseDarkMode() -{ -#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)) - return (QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark); -#elif ((QT_VERSION >= QT_VERSION_CHECK(6, 2, 1)) && FRAMELESSHELPER_CONFIG(private_qt)) - if (const QPlatformTheme * const theme = QGuiApplicationPrivate::platformTheme()) { - return (theme->appearance() == QPlatformTheme::Appearance::Dark); - } - return false; -#else // ((QT_VERSION < QT_VERSION_CHECK(6, 2, 1)) || !FRAMELESSHELPER_CONFIG(private_qt)) -# ifdef Q_OS_WINDOWS - return shouldAppsUseDarkMode_windows(); -# elif (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) - return shouldAppsUseDarkMode_linux(); -# elif defined(Q_OS_MACOS) - return shouldAppsUseDarkMode_macos(); -# else - return false; -# endif -#endif -} - -qreal Utils::roundScaleFactor(const qreal factor) -{ - // Qt can't handle scale factors less than 1.0 (according to the comments in qhighdpiscaling.cpp). - Q_ASSERT((factor > qreal(1)) || qFuzzyCompare(factor, qreal(1))); - if (factor < qreal(1)) { - return qreal(1); - } -#if (!FRAMELESSHELPER_CONFIG(private_qt) || (QT_VERSION < QT_VERSION_CHECK(6, 2, 1))) -# if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) - static const auto policy = QGuiApplication::highDpiScaleFactorRoundingPolicy(); - switch (policy) { - case Qt::HighDpiScaleFactorRoundingPolicy::Round: - return std::round(factor); - case Qt::HighDpiScaleFactorRoundingPolicy::Ceil: - return std::ceil(factor); - case Qt::HighDpiScaleFactorRoundingPolicy::Floor: - return std::floor(factor); - case Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor: - { - static constexpr const auto flag = qreal(0.75); - const qreal gap = (factor - qreal(int(factor))); - return (((gap > flag) || qFuzzyCompare(gap, flag)) ? std::round(factor) : std::floor(factor)); - } - case Qt::HighDpiScaleFactorRoundingPolicy::PassThrough: - case Qt::HighDpiScaleFactorRoundingPolicy::Unset: // According to Qt source code, this enum value is the same with PassThrough. - return factor; - } - return 1; -# else // (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - return std::round(factor); -# endif // (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) -#else // (FRAMELESSHELPER_CONFIG(private_qt) && (QT_VERSION >= QT_VERSION_CHECK(6, 2, 1))) - return QHighDpiScaling::roundScaleFactor(factor); -#endif -} - -int Utils::toNativePixels(const QWindow *window, const int value) -{ - Q_ASSERT(window); - if (!window) { - return 0; - } -#if FRAMELESSHELPER_CONFIG(private_qt) - return QHighDpi::toNativePixels(value, window); -#else - return std::round(qreal(value) * window->devicePixelRatio()); -#endif -} - -QPoint Utils::toNativePixels(const QWindow *window, const QPoint &point) -{ - Q_ASSERT(window); - if (!window) { - return {}; - } -#if FRAMELESSHELPER_CONFIG(private_qt) - return QHighDpi::toNativePixels(point, window); -#else - const QPoint origin = getScaleOrigin(window); - return QPointF(QPointF(point - origin) * window->devicePixelRatio()).toPoint() + origin; -#endif -} - -QSize Utils::toNativePixels(const QWindow *window, const QSize &size) -{ - Q_ASSERT(window); - if (!window) { - return {}; - } -#if FRAMELESSHELPER_CONFIG(private_qt) - return QHighDpi::toNativePixels(size, window); -#else - return QSizeF(QSizeF(size) * window->devicePixelRatio()).toSize(); -#endif -} - -QRect Utils::toNativePixels(const QWindow *window, const QRect &rect) -{ - Q_ASSERT(window); - if (!window) { - return {}; - } -#if FRAMELESSHELPER_CONFIG(private_qt) - return QHighDpi::toNativePixels(rect, window); -#else - return QRect(toNativePixels(window, rect.topLeft()), toNativePixels(window, rect.size())); -#endif -} - -int Utils::fromNativePixels(const QWindow *window, const int value) -{ - Q_ASSERT(window); - if (!window) { - return 0; - } -#if FRAMELESSHELPER_CONFIG(private_qt) - return QHighDpi::fromNativePixels(value, window); -#else - return std::round(qreal(value) / window->devicePixelRatio()); -#endif -} - -QPoint Utils::fromNativePixels(const QWindow *window, const QPoint &point) -{ - Q_ASSERT(window); - if (!window) { - return {}; - } -#if FRAMELESSHELPER_CONFIG(private_qt) - return QHighDpi::fromNativePixels(point, window); -#else - const QPoint origin = getScaleOrigin(window); - return QPointF(QPointF(point - origin) / window->devicePixelRatio()).toPoint() + origin; -#endif -} - -QSize Utils::fromNativePixels(const QWindow *window, const QSize &size) -{ - Q_ASSERT(window); - if (!window) { - return {}; - } -#if FRAMELESSHELPER_CONFIG(private_qt) - return QHighDpi::fromNativePixels(size, window); -#else - return QSizeF(QSizeF(size) / window->devicePixelRatio()).toSize(); -#endif -} - -QRect Utils::fromNativePixels(const QWindow *window, const QRect &rect) -{ - Q_ASSERT(window); - if (!window) { - return {}; - } -#if FRAMELESSHELPER_CONFIG(private_qt) - return QHighDpi::fromNativePixels(rect, window); -#else - return QRect(fromNativePixels(window, rect.topLeft()), fromNativePixels(window, rect.size())); -#endif -} - -QPoint Utils::toNativeLocalPosition(const QWindow *window, const QPoint &point) -{ - Q_ASSERT(window); - if (!window) { - return {}; - } -#if FRAMELESSHELPER_CONFIG(private_qt) - return QHighDpi::toNativeLocalPosition(point, window); -#else - return QPointF(QPointF(point) * window->devicePixelRatio()).toPoint(); -#endif -} - -QPoint Utils::toNativeGlobalPosition(const QWindow *window, const QPoint &point) -{ - Q_ASSERT(window); - if (!window) { - return {}; - } -#if (!FRAMELESSHELPER_CONFIG(private_qt) || (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))) - return toNativePixels(window, point); -#else - return QHighDpi::toNativeGlobalPosition(point, window); -#endif -} - -QPoint Utils::fromNativeLocalPosition(const QWindow *window, const QPoint &point) -{ - Q_ASSERT(window); - if (!window) { - return {}; - } -#if FRAMELESSHELPER_CONFIG(private_qt) - return QHighDpi::fromNativeLocalPosition(point, window); -#else - return QPointF(QPointF(point) / window->devicePixelRatio()).toPoint(); -#endif -} - -QPoint Utils::fromNativeGlobalPosition(const QWindow *window, const QPoint &point) -{ - Q_ASSERT(window); - if (!window) { - return {}; - } -#if (!FRAMELESSHELPER_CONFIG(private_qt) || (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))) - return fromNativePixels(window, point); -#else - return QHighDpi::fromNativeGlobalPosition(point, window); -#endif -} - -int Utils::horizontalAdvance(const QFontMetrics &fm, const QString &str) -{ -#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)) - return fm.horizontalAdvance(str); -#else // (QT_VERSION < QT_VERSION_CHECK(5, 11, 0)) - return fm.width(); -#endif // (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)) -} - -qreal Utils::getRelativeScaleFactor(const quint32 oldDpi, const quint32 newDpi) -{ - if (newDpi == oldDpi) { - return qreal(1); - } - static const quint32 defaultDpi = defaultScreenDpi(); - if ((oldDpi < defaultDpi) || (newDpi < defaultDpi)) { - return qreal(1); - } - // We need to round the scale factor according to Qt's rounding policy. - const qreal oldDpr = roundScaleFactor(qreal(oldDpi) / qreal(defaultDpi)); - const qreal newDpr = roundScaleFactor(qreal(newDpi) / qreal(defaultDpi)); - return qreal(newDpr / oldDpr); -} - -QSizeF Utils::rescaleSize(const QSizeF &oldSize, const quint32 oldDpi, const quint32 newDpi) -{ - if (oldSize.isEmpty()) { - return {}; - } - if (newDpi == oldDpi) { - return oldSize; - } - const qreal scaleFactor = getRelativeScaleFactor(oldDpi, newDpi); - if (qFuzzyIsNull(scaleFactor)) { - return {}; - } - if (qFuzzyCompare(scaleFactor, qreal(1))) { - return oldSize; - } - return QSizeF(oldSize * scaleFactor); -} - -QSize Utils::rescaleSize(const QSize &oldSize, const quint32 oldDpi, const quint32 newDpi) -{ - return rescaleSize(QSizeF(oldSize), oldDpi, newDpi).toSize(); -} - -bool Utils::isValidGeometry(const QRectF &rect) -{ - // The position of the rectangle is not relevant. - return ((rect.right() > rect.left()) && (rect.bottom() > rect.top())); -} - -bool Utils::isValidGeometry(const QRect &rect) -{ - return isValidGeometry(QRectF(rect)); -} - -quint32 Utils::defaultScreenDpi() -{ -#ifdef Q_OS_MACOS - return 72; -#else // !Q_OS_MACOS - return 96; -#endif // Q_OS_MACOS -} - -QColor Utils::getAccentColor() -{ -#if (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)) - return QGuiApplication::palette().color(QPalette::Accent); -#else // (QT_VERSION < QT_VERSION_CHECK(6, 6, 0)) -# ifdef Q_OS_WINDOWS - return getAccentColor_windows(); -# elif (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) - return getAccentColor_linux(); -# elif defined(Q_OS_MACOS) - return getAccentColor_macos(); -# else - return QGuiApplication::palette().color(QPalette::Highlight); -# endif -#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)) -} - -bool Utils::isWindowAccelerated(const QWindow *window) -{ - Q_ASSERT(window); - if (!window) { - return false; - } - switch (window->surfaceType()) { - case QSurface::RasterGLSurface: -#if FRAMELESSHELPER_CONFIG(private_qt) - return qt_window_private(const_cast(window))->compositing; -#else - return true; -#endif - case QSurface::OpenGLSurface: - case QSurface::VulkanSurface: - case QSurface::MetalSurface: -#if (QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)) - case QSurface::Direct3DSurface: -#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)) - return true; - default: - break; - } - return false; -} - -bool Utils::isWindowTransparent(const QWindow *window) -{ - Q_ASSERT(window); - if (!window) { - return false; - } - // On most platforms, QWindow::format() will just return the - // user set format if there is one, otherwise it will return - // an invalid surface format. That means, most of the time - // the following check will not be useful. But since this is - // what the QPA code does, we just mirror it here. - return window->format().hasAlpha(); -} - -QColor Utils::calculateForegroundColor(const QColor &backgroundColor) -{ - Q_ASSERT(backgroundColor.isValid()); - if (!backgroundColor.isValid()) { - return kDefaultBlackColor; - } - static constexpr const auto kFlag = qreal(0.5); - if (backgroundColor.alphaF() < kFlag) { - return kDefaultBlackColor; - } - // Calculate the most appropriate foreground color, based on the - // current background color. - const qreal grayF = ( - (qreal(0.299) * backgroundColor.redF()) + - (qreal(0.587) * backgroundColor.greenF()) + - (qreal(0.114) * backgroundColor.blueF())); - if ((grayF < kFlag) || qFuzzyCompare(grayF, kFlag)) { - return kDefaultWhiteColor; - } - return kDefaultBlackColor; -} - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/utils.h b/src/SARibbonBar/3rdparty/framelesshelper/src/core/utils.h deleted file mode 100644 index 072a20e4..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/utils.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Core/utils.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/utils_linux.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/core/utils_linux.cpp deleted file mode 100644 index c7c941eb..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/utils_linux.cpp +++ /dev/null @@ -1,999 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "utils.h" - -#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) - -#include "framelessconfig_p.h" -#include "framelessmanager.h" -#include "framelessmanager_p.h" -#include // for std::memcpy -#include -#include -#include -#include -#include -#include -#if FRAMELESSHELPER_CONFIG(private_qt) -# include -# include -# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) -# include -# include -# else // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) -# include -# endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) -# if (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)) -# include -# define FRAMELESSHELPER_HAS_X11EXTRAS -# endif // (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)) -#else // !FRAMELESSHELPER_CONFIG(private_qt) -# if __has_include() -# include -# define FRAMELESSHELPER_HAS_X11EXTRAS -# endif // __has_include() -#endif // FRAMELESSHELPER_CONFIG(private_qt) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcUtilsLinux, "wangwenx190.framelesshelper.core.utils.linux") -# define INFO qCInfo(lcUtilsLinux) -# define DEBUG qCDebug(lcUtilsLinux) -# define WARNING qCWarning(lcUtilsLinux) -# define CRITICAL qCCritical(lcUtilsLinux) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -FRAMELESSHELPER_STRING_CONSTANT(dark) - -FRAMELESSHELPER_BYTEARRAY_CONSTANT(rootwindow) -FRAMELESSHELPER_BYTEARRAY_CONSTANT(x11screen) -FRAMELESSHELPER_BYTEARRAY_CONSTANT(apptime) -FRAMELESSHELPER_BYTEARRAY_CONSTANT(appusertime) -FRAMELESSHELPER_BYTEARRAY_CONSTANT(gettimestamp) -FRAMELESSHELPER_BYTEARRAY_CONSTANT(startupid) -FRAMELESSHELPER_BYTEARRAY_CONSTANT(display) -FRAMELESSHELPER_BYTEARRAY_CONSTANT(connection) - -static constexpr const auto _XCB_SEND_EVENT_MASK = - (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY); - -extern template bool gtkSettings(const gchar *); -extern QString gtkSettings(const gchar *); - -[[maybe_unused]] [[nodiscard]] static inline int - qtEdgesToWmMoveOrResizeOperation(const Qt::Edges edges) -{ - if (edges == Qt::Edges{}) { - return _NET_WM_MOVERESIZE_CANCEL; - } - if (edges & Qt::TopEdge) { - if (edges & Qt::LeftEdge) { - return _NET_WM_MOVERESIZE_SIZE_TOPLEFT; - } - if (edges & Qt::RightEdge) { - return _NET_WM_MOVERESIZE_SIZE_TOPRIGHT; - } - return _NET_WM_MOVERESIZE_SIZE_TOP; - } - if (edges & Qt::BottomEdge) { - if (edges & Qt::LeftEdge) { - return _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT; - } - if (edges & Qt::RightEdge) { - return _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT; - } - return _NET_WM_MOVERESIZE_SIZE_BOTTOM; - } - if (edges & Qt::LeftEdge) { - return _NET_WM_MOVERESIZE_SIZE_LEFT; - } - if (edges & Qt::RightEdge) { - return _NET_WM_MOVERESIZE_SIZE_RIGHT; - } - return _NET_WM_MOVERESIZE_CANCEL; -} - -[[maybe_unused]] static inline void generateMouseReleaseEvent(QWindow *window, const QPoint &globalPos) -{ - Q_ASSERT(window); - if (!window) { - return; - } - // https://bugreports.qt.io/browse/QTBUG-102488 - const QPoint localPos = window->mapFromGlobal(globalPos); - const QPoint scenePos = localPos; // windowPos in Qt5. - const auto event = new QMouseEvent( - QEvent::MouseButtonRelease, - localPos, - scenePos, - globalPos, - Qt::LeftButton, - QGuiApplication::mouseButtons() ^ Qt::LeftButton, - QGuiApplication::keyboardModifiers()); - QGuiApplication::postEvent(window, event); -} - -QScreen *Utils::x11_findScreenForVirtualDesktop(const int virtualDesktopNumber) -{ -#if FRAMELESSHELPER_CONFIG(private_qt) - if (virtualDesktopNumber == -1) { - return QGuiApplication::primaryScreen(); - } - const QList screens = QGuiApplication::screens(); - if (screens.isEmpty()) { - return nullptr; - } - for (auto &&screen : std::as_const(screens)) { -# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - const auto qxcbScreen = dynamic_cast(screen->handle()); - if (qxcbScreen && (qxcbScreen->virtualDesktopNumber() == virtualDesktopNumber)) { - return screen; - } -# else // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - if (QXcbScreenFunctions::virtualDesktopNumber(screen) == virtualDesktopNumber) { - return screen; - } -# endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - } - return nullptr; -#else // !FRAMELESSHELPER_CONFIG(private_qt) - Q_UNUSED(virtualDesktopNumber); - return QGuiApplication::primaryScreen(); -#endif // FRAMELESSHELPER_CONFIG(private_qt) -} - -x11_return_type Utils::x11_appRootWindow(const int screen) -{ -#ifdef FRAMELESSHELPER_HAS_X11EXTRAS - return QX11Info::appRootWindow(screen); -#else // !FRAMELESSHELPER_HAS_X11EXTRAS -# if FRAMELESSHELPER_CONFIG(private_qt) - if (!qApp) { - return 0; - } - QPlatformNativeInterface *native = qApp->platformNativeInterface(); - if (!native) { - return 0; - } - QScreen *scr = ((screen == -1) ? QGuiApplication::primaryScreen() : x11_findScreenForVirtualDesktop(screen)); - if (!scr) { - return 0; - } - return static_cast(reinterpret_cast(native->nativeResourceForScreen(krootwindow, scr))); -# else // !FRAMELESSHELPER_CONFIG(private_qt) - Q_UNUSED(screen); - return 0; -# endif // FRAMELESSHELPER_CONFIG(private_qt) -#endif // FRAMELESSHELPER_HAS_X11EXTRAS -} - -int Utils::x11_appScreen() -{ -#ifdef FRAMELESSHELPER_HAS_X11EXTRAS - return QX11Info::appScreen(); -#else // !FRAMELESSHELPER_HAS_X11EXTRAS -# if FRAMELESSHELPER_CONFIG(private_qt) - if (!qApp) { - return 0; - } - QPlatformNativeInterface *native = qApp->platformNativeInterface(); - if (!native) { - return 0; - } - return reinterpret_cast(native->nativeResourceForIntegration(kx11screen)); -# else // !FRAMELESSHELPER_CONFIG(private_qt) - return 0; -# endif // FRAMELESSHELPER_CONFIG(private_qt) -#endif // FRAMELESSHELPER_HAS_X11EXTRAS -} - -x11_return_type Utils::x11_appTime() -{ -#ifdef FRAMELESSHELPER_HAS_X11EXTRAS - return QX11Info::appTime(); -#else // !FRAMELESSHELPER_HAS_X11EXTRAS -# if FRAMELESSHELPER_CONFIG(private_qt) - if (!qApp) { - return 0; - } - QPlatformNativeInterface *native = qApp->platformNativeInterface(); - if (!native) { - return 0; - } - QScreen *screen = QGuiApplication::primaryScreen(); - if (!screen) { - return 0; - } - return static_cast(reinterpret_cast(native->nativeResourceForScreen(kapptime, screen))); -# else // !FRAMELESSHELPER_CONFIG(private_qt) - return 0; -# endif // FRAMELESSHELPER_CONFIG(private_qt) -#endif // FRAMELESSHELPER_HAS_X11EXTRAS -} - -x11_return_type Utils::x11_appUserTime() -{ -#ifdef FRAMELESSHELPER_HAS_X11EXTRAS - return QX11Info::appUserTime(); -#else // !FRAMELESSHELPER_HAS_X11EXTRAS -# if FRAMELESSHELPER_CONFIG(private_qt) - if (!qApp) { - return 0; - } - QPlatformNativeInterface *native = qApp->platformNativeInterface(); - if (!native) { - return 0; - } - QScreen *screen = QGuiApplication::primaryScreen(); - if (!screen) { - return 0; - } - return static_cast(reinterpret_cast(native->nativeResourceForScreen(kappusertime, screen))); -# else // !FRAMELESSHELPER_CONFIG(private_qt) - return 0; -# endif // FRAMELESSHELPER_CONFIG(private_qt) -#endif // FRAMELESSHELPER_HAS_X11EXTRAS -} - -x11_return_type Utils::x11_getTimestamp() -{ -#ifdef FRAMELESSHELPER_HAS_X11EXTRAS - return QX11Info::getTimestamp(); -#else // !FRAMELESSHELPER_HAS_X11EXTRAS -# if FRAMELESSHELPER_CONFIG(private_qt) - if (!qApp) { - return 0; - } - QPlatformNativeInterface *native = qApp->platformNativeInterface(); - if (!native) { - return 0; - } - QScreen *screen = QGuiApplication::primaryScreen(); - if (!screen) { - return 0; - } - return static_cast(reinterpret_cast(native->nativeResourceForScreen(kgettimestamp, screen))); -# else // !FRAMELESSHELPER_CONFIG(private_qt) - return 0; -# endif // FRAMELESSHELPER_CONFIG(private_qt) -#endif // FRAMELESSHELPER_HAS_X11EXTRAS -} - -QByteArray Utils::x11_nextStartupId() -{ -#ifdef FRAMELESSHELPER_HAS_X11EXTRAS - return QX11Info::nextStartupId(); -#else // !FRAMELESSHELPER_HAS_X11EXTRAS -# if FRAMELESSHELPER_CONFIG(private_qt) - if (!qApp) { - return {}; - } - QPlatformNativeInterface *native = qApp->platformNativeInterface(); - if (!native) { - return {}; - } - return static_cast(native->nativeResourceForIntegration(kstartupid)); -# else // !FRAMELESSHELPER_CONFIG(private_qt) - return {}; -# endif // FRAMELESSHELPER_CONFIG(private_qt) -#endif // FRAMELESSHELPER_HAS_X11EXTRAS -} - -Display *Utils::x11_display() -{ -#ifdef FRAMELESSHELPER_HAS_X11EXTRAS - return QX11Info::display(); -#else // !FRAMELESSHELPER_HAS_X11EXTRAS -# if FRAMELESSHELPER_CONFIG(private_qt) - if (!qApp) { - return nullptr; - } -# if (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)) - using App = QNativeInterface::QX11Application; - const auto native = qApp->nativeInterface(); -# else // (QT_VERSION < QT_VERSION_CHECK(6, 2, 0)) - const auto native = qApp->platformNativeInterface(); -# endif // (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)) - if (!native) { - return nullptr; - } -# if (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)) - return native->display(); -# else // (QT_VERSION < QT_VERSION_CHECK(6, 2, 0)) - return reinterpret_cast(native->nativeResourceForIntegration(kdisplay)); -# endif // (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)) -# else // !FRAMELESSHELPER_CONFIG(private_qt) - return nullptr; -# endif // FRAMELESSHELPER_CONFIG(private_qt) -#endif // FRAMELESSHELPER_HAS_X11EXTRAS -} - -xcb_connection_t *Utils::x11_connection() -{ -#ifdef FRAMELESSHELPER_HAS_X11EXTRAS - return QX11Info::connection(); -#else // !FRAMELESSHELPER_HAS_X11EXTRAS -# if FRAMELESSHELPER_CONFIG(private_qt) - if (!qApp) { - return nullptr; - } -# if (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)) - using App = QNativeInterface::QX11Application; - const auto native = qApp->nativeInterface(); -# else // (QT_VERSION < QT_VERSION_CHECK(6, 2, 0)) - const auto native = qApp->platformNativeInterface(); -# endif // (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)) - if (!native) { - return nullptr; - } -# if (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)) - return native->connection(); -# else // (QT_VERSION < QT_VERSION_CHECK(6, 2, 0)) - return reinterpret_cast(native->nativeResourceForIntegration(kconnection)); -# endif // (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)) -# else // !FRAMELESSHELPER_CONFIG(private_qt) - return nullptr; -# endif // FRAMELESSHELPER_CONFIG(private_qt) -#endif // FRAMELESSHELPER_HAS_X11EXTRAS -} - -bool Utils::startSystemMove(QWindow *window, const QPoint &globalPos) -{ - Q_ASSERT(window); - if (!window) { - return false; - } -#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) - window->startSystemMove(); - generateMouseReleaseEvent(window, globalPos); - return true; -#else // (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) - const QPoint nativeGlobalPos = Utils::toNativeGlobalPosition(window, globalPos); - sendMoveResizeMessage(window->winId(), _NET_WM_MOVERESIZE_MOVE, nativeGlobalPos); - return true; -#endif // (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) -} - -bool Utils::startSystemResize(QWindow *window, const Qt::Edges edges, const QPoint &globalPos) -{ - Q_ASSERT(window); - if (!window) { - return false; - } - if (edges == Qt::Edges{}) { - return false; - } -#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) - window->startSystemResize(edges); - generateMouseReleaseEvent(window, globalPos); - return true; -#else // (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) - const QPoint nativeGlobalPos = Utils::toNativeGlobalPosition(window, globalPos); - const int netWmOperation = qtEdgesToWmMoveOrResizeOperation(edges); - sendMoveResizeMessage(window->winId(), netWmOperation, nativeGlobalPos); - return true; -#endif // (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) -} - -bool Utils::isTitleBarColorized() -{ - // ### TODO - return false; -} - -QColor Utils::getAccentColor_linux() -{ - // ### TODO - return QGuiApplication::palette().color(QPalette::Highlight); -} - -bool Utils::shouldAppsUseDarkMode_linux() -{ - /* - https://docs.gtk.org/gtk3/running.html - - It's possible to set a theme variant after the theme name when using GTK_THEME: - - GTK_THEME=Adwaita:dark - - Some themes also have "-dark" as part of their name. - - We test this environment variable first because the documentation says - it's mainly used for easy debugging, so it should be possible to use it - to override any other settings. - */ - const QString envThemeName = qEnvironmentVariable(GTK_THEME_NAME_ENV_VAR); - if (!envThemeName.isEmpty()) { - return envThemeName.contains(kdark, Qt::CaseInsensitive); - } - - /* - https://docs.gtk.org/gtk3/property.Settings.gtk-application-prefer-dark-theme.html - - This setting controls which theme is used when the theme specified by - gtk-theme-name provides both light and dark variants. We can save a - regex check by testing this property first. - */ - const auto preferDark = gtkSettings(GTK_THEME_PREFER_DARK_PROP); - if (preferDark) { - return true; - } - - /* - https://docs.gtk.org/gtk3/property.Settings.gtk-theme-name.html - */ - const auto curThemeName = gtkSettings(GTK_THEME_NAME_PROP); - if (!curThemeName.isEmpty()) { - return curThemeName.contains(kdark, Qt::CaseInsensitive); - } - - return false; -} - -bool Utils::setBlurBehindWindowEnabled(const WId windowId, const BlurMode mode, const QColor &color) -{ - Q_UNUSED(color); - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - static const xcb_atom_t atom = internAtom(ATOM_KDE_NET_WM_BLUR_BEHIND_REGION); - if ((atom == XCB_NONE) || !isSupportedByRootWindow(atom)) { - WARNING << "Current window manager doesn't support blur behind window."; - return false; - } - static const xcb_atom_t deepinAtom = internAtom(ATOM_NET_WM_DEEPIN_BLUR_REGION_MASK); - if ((deepinAtom != XCB_NONE) && isSupportedByWindowManager(deepinAtom)) { - clearWindowProperty(windowId, deepinAtom); - } - const auto blurMode = [mode]() -> BlurMode { - if ((mode == BlurMode::Disable) || (mode == BlurMode::Default)) { - return mode; - } - WARNING << "The BlurMode::Windows_* enum values are not supported on Linux."; - return BlurMode::Default; - }(); - if (blurMode == BlurMode::Disable) { - clearWindowProperty(windowId, atom); - } else { - const quint32 value = true; - setWindowProperty(windowId, atom, XCB_ATOM_CARDINAL, &value, 1, sizeof(quint32) * 8); - } - return true; -} - -QString Utils::getWallpaperFilePath() -{ -#if 0 - GConfClient * const client = gconf_client_get_default(); - Q_ASSERT(client); - if (!client) { - return {}; - } - const gchararray rawPath = gconf_client_get_string(client, "/desktop/gnome/background/picture_filename", nullptr); - if (!rawPath || (*rawPath == '\0')) { - WARNING << "Failed to retrieve the wallpaper file path."; - return {}; - } - return QUtf8String(rawPath); -#else - // ### TODO - return {}; -#endif -} - -WallpaperAspectStyle Utils::getWallpaperAspectStyle() -{ -#if 0 - static constexpr const auto defaultAspectStyle = WallpaperAspectStyle::Fill; - GConfClient * const client = gconf_client_get_default(); - Q_ASSERT(client); - if (!client) { - return defaultAspectStyle; - } - const gchararray rawOptions = gconf_client_get_string(client, "/desktop/gnome/background/picture_options", nullptr); - if (!rawOptions || (*rawOptions == '\0')) { - WARNING << "Failed to retrieve the wallpaper tile options."; - return defaultAspectStyle; - } - const QString options = QUtf8String(rawOptions); - if (options.isEmpty()) { - return defaultAspectStyle; - } else { - if ((options == "wallpaper"_L1) || (options == "tiled"_L1)) { - return WallpaperAspectStyle::Tile; - } else if (options == "centered"_L1) { - return WallpaperAspectStyle::Center; - } else if (options == "stretched"_L1) { - return WallpaperAspectStyle::Stretch; - } else if (options == "scaled"_L1) { - return WallpaperAspectStyle::Fit; - } else { - return defaultAspectStyle; - } - } -#else - // ### TODO - return WallpaperAspectStyle::Fill; -#endif -} - -bool Utils::isBlurBehindWindowSupported() -{ - static const auto result = []() -> bool { - if (FramelessConfig::instance()->isSet(Option::ForceNativeBackgroundBlur)) { - return true; - } - if (FramelessConfig::instance()->isSet(Option::ForceNonNativeBackgroundBlur)) { - return false; - } -#if 0 // FIXME: The window will become totally black if we enable blur behind window on KWin. - static const QString windowManager = getWindowManagerName(); - static const bool isDeepinV15 = (windowManager == FRAMELESSHELPER_STRING_LITERAL("Mutter(DeepinGala)")); - if (isDeepinV15) { - static const xcb_atom_t atom = internAtom(ATOM_NET_WM_DEEPIN_BLUR_REGION_ROUNDED); - return ((atom != XCB_NONE) && isSupportedByWindowManager(atom)); - } - static const bool isKWin = (windowManager == FRAMELESSHELPER_STRING_LITERAL("KWin")); - if (isKWin) { - static const xcb_atom_t atom = internAtom(ATOM_KDE_NET_WM_BLUR_BEHIND_REGION); - return ((atom != XCB_NONE) && isSupportedByRootWindow(atom)); - } -#endif - return false; - }(); - return result; -} - -static inline void themeChangeNotificationCallback() -{ - // Sometimes the FramelessManager instance may be destroyed already. - if (FramelessManager * const manager = FramelessManager::instance()) { - if (FramelessManagerPrivate * const managerPriv = FramelessManagerPrivate::get(manager)) { - managerPriv->notifySystemThemeHasChangedOrNot(); - } - } -} - -bool Utils::registerThemeChangeNotification() -{ - GtkSettings * const settings = gtk_settings_get_default(); - Q_ASSERT(settings); - if (!settings) { - return false; - } - g_signal_connect(settings, "notify::gtk-application-prefer-dark-theme", themeChangeNotificationCallback, nullptr); - g_signal_connect(settings, "notify::gtk-theme-name", themeChangeNotificationCallback, nullptr); - return true; -} - -QColor Utils::getFrameBorderColor(const bool active) -{ - return (active ? getAccentColor() : kDefaultDarkGrayColor); -} - -xcb_atom_t Utils::internAtom(const char *name) -{ - Q_ASSERT(name); - Q_ASSERT(*name != '\0'); - if (!name || (*name == '\0')) { - return XCB_NONE; - } - xcb_connection_t * const connection = x11_connection(); - Q_ASSERT(connection); - if (!connection) { - return XCB_NONE; - } - const xcb_intern_atom_cookie_t cookie = xcb_intern_atom(connection, false, qstrlen(name), name); - xcb_intern_atom_reply_t * const reply = xcb_intern_atom_reply(connection, cookie, nullptr); - if (!reply) { - return XCB_NONE; - } - const xcb_atom_t atom = reply->atom; - std::free(reply); - return atom; -} - -QString Utils::getWindowManagerName() -{ - static const auto result = []() -> QString { - xcb_connection_t * const connection = x11_connection(); - Q_ASSERT(connection); - if (!connection) { - return {}; - } - const quint32 rootWindow = x11_appRootWindow(x11_appScreen()); - Q_ASSERT(rootWindow); - if (!rootWindow) { - return {}; - } - static const xcb_atom_t wmCheckAtom = internAtom(ATOM_NET_SUPPORTING_WM_CHECK); - if (wmCheckAtom == XCB_NONE) { - WARNING << "Failed to retrieve the atom of _NET_SUPPORTING_WM_CHECK."; - return {}; - } - const xcb_get_property_cookie_t cookie = xcb_get_property_unchecked(connection, false, rootWindow, wmCheckAtom, XCB_ATOM_WINDOW, 0, 1024); - xcb_get_property_reply_t * const reply = xcb_get_property_reply(connection, cookie, nullptr); - if (!reply) { - return {}; - } - if (!((reply->format == 32) && (reply->type == XCB_ATOM_WINDOW))) { - std::free(reply); - return {}; - } - const auto windowManager = *static_cast(xcb_get_property_value(reply)); - if (windowManager == XCB_WINDOW_NONE) { - std::free(reply); - return {}; - } - static const xcb_atom_t wmNameAtom = internAtom(ATOM_NET_WM_NAME); - if (wmNameAtom == XCB_NONE) { - WARNING << "Failed to retrieve the atom of _NET_WM_NAME."; - return {}; - } - static const xcb_atom_t strAtom = internAtom(ATOM_UTF8_STRING); - if (strAtom == XCB_NONE) { - WARNING << "Failed to retrieve the atom of UTF8_STRING."; - return {}; - } - const xcb_get_property_cookie_t wmCookie = xcb_get_property_unchecked(connection, false, windowManager, wmNameAtom, strAtom, 0, 1024); - xcb_get_property_reply_t * const wmReply = xcb_get_property_reply(connection, wmCookie, nullptr); - if (!wmReply) { - std::free(reply); - return {}; - } - if (!((wmReply->format == 8) && (wmReply->type == strAtom))) { - std::free(wmReply); - std::free(reply); - return {}; - } - const auto data = static_cast(xcb_get_property_value(wmReply)); - const int len = xcb_get_property_value_length(wmReply); - const QString wmName = QString::fromUtf8(data, len); - std::free(wmReply); - std::free(reply); - return wmName; - }(); - return result; -} - -void Utils::openSystemMenu(const WId windowId, const QPoint &globalPos) -{ - Q_ASSERT(windowId); - if (!windowId) { - return; - } - - xcb_connection_t * const connection = x11_connection(); - Q_ASSERT(connection); - if (!connection) { - return; - } - - const quint32 rootWindow = x11_appRootWindow(x11_appScreen()); - Q_ASSERT(rootWindow); - if (!rootWindow) { - return; - } - - static const xcb_atom_t atom = internAtom(ATOM_GTK_SHOW_WINDOW_MENU); - if ((atom == XCB_NONE) || !isSupportedByWindowManager(atom)) { - WARNING << "Current window manager doesn't support showing window menu."; - return; - } - - xcb_client_message_event_t xev; - memset(&xev, 0, sizeof(xev)); - xev.response_type = XCB_CLIENT_MESSAGE; - xev.type = atom; - xev.window = windowId; - xev.format = 32; - xev.data.data32[1] = globalPos.x(); - xev.data.data32[2] = globalPos.y(); - - xcb_ungrab_pointer(connection, XCB_CURRENT_TIME); - xcb_send_event(connection, false, rootWindow, _XCB_SEND_EVENT_MASK, reinterpret_cast(&xev)); - xcb_flush(connection); -} - -QByteArray Utils::getWindowProperty(const WId windowId, const xcb_atom_t prop, const xcb_atom_t type, const quint32 data_len) -{ - Q_ASSERT(windowId); - Q_ASSERT(prop != XCB_NONE); - Q_ASSERT(type != XCB_NONE); - if (!windowId || (prop == XCB_NONE) || (type == XCB_NONE)) { - return {}; - } - xcb_connection_t * const connection = x11_connection(); - Q_ASSERT(connection); - if (!connection) { - return {}; - } - const xcb_get_property_cookie_t cookie = xcb_get_property(connection, false, windowId, prop, type, 0, data_len); - xcb_get_property_reply_t * const reply = xcb_get_property_reply(connection, cookie, nullptr); - if (!reply) { - return {}; - } - QByteArray data = {}; - const int len = xcb_get_property_value_length(reply); - const auto buf = static_cast(xcb_get_property_value(reply)); - data.append(buf, len); - std::free(reply); - return data; -} - -void Utils::setWindowProperty(const WId windowId, const xcb_atom_t prop, const xcb_atom_t type, const void *data, const quint32 data_len, const uint8_t format) -{ - Q_ASSERT(windowId); - Q_ASSERT(prop != XCB_NONE); - Q_ASSERT(type != XCB_NONE); - if (!windowId || (prop == XCB_NONE) || (type == XCB_NONE)) { - return; - } - xcb_connection_t * const connection = x11_connection(); - Q_ASSERT(connection); - if (!connection) { - return; - } - xcb_change_property(connection, XCB_PROP_MODE_REPLACE, windowId, prop, type, format, data_len, data); - xcb_flush(connection); -} - -void Utils::clearWindowProperty(const WId windowId, const xcb_atom_t prop) -{ - Q_ASSERT(windowId); - Q_ASSERT(prop != XCB_NONE); - if (!windowId || (prop == XCB_NONE)) { - return; - } - xcb_connection_t * const connection = x11_connection(); - Q_ASSERT(connection); - if (!connection) { - return; - } - xcb_delete_property_checked(connection, windowId, prop); -} - -bool Utils::isSupportedByWindowManager(const xcb_atom_t atom) -{ - Q_ASSERT(atom != XCB_NONE); - if (atom == XCB_NONE) { - return false; - } -#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - using result_type = QList; -#else // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - using result_type = QVector; -#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - static const auto netWmAtoms = []() -> result_type { - xcb_connection_t * const connection = x11_connection(); - Q_ASSERT(connection); - if (!connection) { - return {}; - } - const quint32 rootWindow = x11_appRootWindow(x11_appScreen()); - Q_ASSERT(rootWindow); - if (!rootWindow) { - return {}; - } - static const xcb_atom_t netSupportedAtom = internAtom(ATOM_NET_SUPPORTED); - if (netSupportedAtom == XCB_NONE) { - WARNING << "Failed to retrieve the atom of _NET_SUPPORTED."; - return {}; - } - result_type result = {}; - int offset = 0; - int remaining = 0; - do { - const xcb_get_property_cookie_t cookie = xcb_get_property(connection, false, rootWindow, netSupportedAtom, XCB_ATOM_ATOM, offset, 1024); - xcb_get_property_reply_t * const reply = xcb_get_property_reply(connection, cookie, nullptr); - if (!reply) { - break; - } - remaining = 0; - if ((reply->type == XCB_ATOM_ATOM) && (reply->format == 32)) { - const int len = (xcb_get_property_value_length(reply) / sizeof(xcb_atom_t)); - const auto atoms = static_cast(xcb_get_property_value(reply)); - const int size = result.size(); - result.resize(size + len); - std::memcpy(result.data() + size, atoms, len * sizeof(xcb_atom_t)); - remaining = reply->bytes_after; - offset += len; - } - std::free(reply); - } while (remaining > 0); - return result; - }(); - return netWmAtoms.contains(atom); -} - -bool Utils::isSupportedByRootWindow(const xcb_atom_t atom) -{ - Q_ASSERT(atom != XCB_NONE); - if (atom == XCB_NONE) { - return false; - } -#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - using result_type = QList; -#else // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - using result_type = QVector; -#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - static const auto rootWindowProperties = []() -> result_type { - xcb_connection_t * const connection = x11_connection(); - Q_ASSERT(connection); - if (!connection) { - return {}; - } - const quint32 rootWindow = x11_appRootWindow(x11_appScreen()); - Q_ASSERT(rootWindow); - if (!rootWindow) { - return {}; - } - result_type result = {}; - const xcb_list_properties_cookie_t cookie = xcb_list_properties(connection, rootWindow); - xcb_list_properties_reply_t * const reply = xcb_list_properties_reply(connection, cookie, nullptr); - if (!reply) { - return {}; - } - const int len = xcb_list_properties_atoms_length(reply); - const auto atoms = static_cast(xcb_list_properties_atoms(reply)); - result.resize(len); - std::memcpy(result.data(), atoms, len * sizeof(xcb_atom_t)); - std::free(reply); - return result; - }(); - return rootWindowProperties.contains(atom); -} - -bool Utils::tryHideSystemTitleBar(const WId windowId, const bool hide) -{ - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - static const xcb_atom_t deepinNoTitleBarAtom = internAtom(ATOM_DEEPIN_NO_TITLEBAR); - if ((deepinNoTitleBarAtom == XCB_NONE) || !isSupportedByWindowManager(deepinNoTitleBarAtom)) { - WARNING << "Current window manager doesn't support hiding title bar natively."; - return false; - } - const quint32 value = hide; - setWindowProperty(windowId, deepinNoTitleBarAtom, XCB_ATOM_CARDINAL, &value, 1, sizeof(quint32) * 8); - static const xcb_atom_t deepinForceDecorateAtom = internAtom(ATOM_DEEPIN_FORCE_DECORATE); - if ((deepinForceDecorateAtom == XCB_NONE) || !isSupportedByWindowManager(deepinForceDecorateAtom)) { - return true; - } - if (hide) { - setWindowProperty(windowId, deepinForceDecorateAtom, XCB_ATOM_CARDINAL, &value, 1, sizeof(quint32) * 8); - } else { - clearWindowProperty(windowId, deepinForceDecorateAtom); - } - return true; -} - -void Utils::sendMoveResizeMessage(const WId windowId, const uint32_t action, const QPoint &globalPos, const Qt::MouseButton button) -{ - Q_ASSERT(windowId); - if (!windowId) { - return; - } - - xcb_connection_t * const connection = x11_connection(); - Q_ASSERT(connection); - if (!connection) { - return; - } - const quint32 rootWindow = x11_appRootWindow(x11_appScreen()); - Q_ASSERT(rootWindow); - if (!rootWindow) { - return; - } - - static const xcb_atom_t atom = internAtom(ATOM_NET_WM_MOVERESIZE); - if ((atom == XCB_NONE) || !isSupportedByWindowManager(atom)) { - WARNING << "Current window manager doesn't support move resize operation."; - return; - } - - xcb_client_message_event_t xev; - memset(&xev, 0, sizeof(xev)); - xev.response_type = XCB_CLIENT_MESSAGE; - xev.type = atom; - xev.window = windowId; - xev.format = 32; - xev.data.data32[0] = globalPos.x(); - xev.data.data32[1] = globalPos.y(); - xev.data.data32[2] = action; - xev.data.data32[3] = [button]() -> int { - if (button == Qt::LeftButton) { - return XCB_BUTTON_INDEX_1; - } - if (button == Qt::RightButton) { - return XCB_BUTTON_INDEX_3; - } - return XCB_BUTTON_INDEX_ANY; - }(); - xev.data.data32[4] = 0; - - if (action != _NET_WM_MOVERESIZE_CANCEL) { - xcb_ungrab_pointer(connection, XCB_CURRENT_TIME); - } - xcb_send_event(connection, false, rootWindow, _XCB_SEND_EVENT_MASK, reinterpret_cast(&xev)); - xcb_flush(connection); -} - -bool Utils::isCustomDecorationSupported() -{ - static const xcb_atom_t atom = internAtom(ATOM_DEEPIN_NO_TITLEBAR); - return ((atom != XCB_NONE) && isSupportedByWindowManager(atom)); -} - -bool Utils::setPlatformPropertiesForWindow(QWindow *window, const QVariantHash &props) -{ - Q_ASSERT(window); - Q_ASSERT(!props.isEmpty()); - if (!window || props.isEmpty()) { - return false; - } - static const auto object = [window]() -> QObject * { - if (!qGuiApp) { - return nullptr; - } - using buildNativeSettingsPtr = bool(*)(QObject *, WId); - static const auto pbuildNativeSettings - = reinterpret_cast( - QGuiApplication::platformFunction( - FRAMELESSHELPER_BYTEARRAY_LITERAL("_d_buildNativeSettings"))); - if (!pbuildNativeSettings) { - return nullptr; - } - const auto obj = new QObject(window); - if (!pbuildNativeSettings(obj, window->winId())) { - delete obj; - return nullptr; - } - return obj; - }(); - if (!object) { - return false; - } - auto it = props.constBegin(); - while (it != props.constEnd()) { - object->setProperty(qUtf8Printable(it.key()), it.value()); - ++it; - } - return true; -} - -FRAMELESSHELPER_END_NAMESPACE - -#endif // Q_OS_LINUX diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/utils_mac.mm b/src/SARibbonBar/3rdparty/framelesshelper/src/core/utils_mac.mm deleted file mode 100644 index 80dd2e39..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/utils_mac.mm +++ /dev/null @@ -1,762 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "utils.h" - -#ifdef Q_OS_MACOS - -#include "framelessmanager.h" -#include "framelessmanager_p.h" -#include "framelessconfig_p.h" -#include "framelesshelpercore_global_p.h" -#include -#include -#include -#include -#include -#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) -# include -#else -# include -#endif -#include -#include -#include - -QT_BEGIN_NAMESPACE -[[nodiscard]] extern Q_CORE_EXPORT bool qt_mac_applicationIsInDarkMode(); // Since 5.12 -[[nodiscard]] extern Q_GUI_EXPORT QColor qt_mac_toQColor(const NSColor *color); // Since 5.8 -QT_END_NAMESPACE - -FRAMELESSHELPER_BEGIN_NAMESPACE -using Callback = std::function; -FRAMELESSHELPER_END_NAMESPACE - -@interface MyKeyValueObserver : NSObject -@end - -@implementation MyKeyValueObserver -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object - change:(NSDictionary *)change context:(void *)context -{ - Q_UNUSED(keyPath); - Q_UNUSED(object); - Q_UNUSED(change); - - (*reinterpret_cast(context))(); -} -@end - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcUtilsMac, "wangwenx190.framelesshelper.core.utils.mac") -# define INFO qCInfo(lcUtilsMac) -# define DEBUG qCDebug(lcUtilsMac) -# define WARNING qCWarning(lcUtilsMac) -# define CRITICAL qCCritical(lcUtilsMac) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -class MacOSNotificationObserver -{ - FRAMELESSHELPER_CLASS(MacOSNotificationObserver) - -public: - explicit MacOSNotificationObserver(NSObject *object, NSNotificationName name, const Callback &callback) { - Q_ASSERT(name); - Q_ASSERT(callback); - if (!name || !callback) { - return; - } - observer = [[NSNotificationCenter defaultCenter] addObserverForName:name - object:object queue:nil usingBlock:^(NSNotification *) { - callback(); - } - ]; - } - - explicit MacOSNotificationObserver() = default; - - ~MacOSNotificationObserver() - { - remove(); - } - - void remove() - { - if (!observer) { - return; - } - [[NSNotificationCenter defaultCenter] removeObserver:observer]; - observer = nil; - } - -private: - NSObject *observer = nil; -}; - -class MacOSKeyValueObserver -{ - FRAMELESSHELPER_CLASS(MacOSKeyValueObserver) - -public: - // Note: MacOSKeyValueObserver must not outlive the object observed! - explicit MacOSKeyValueObserver(NSObject *obj, NSString *key, const Callback &cb, - const NSKeyValueObservingOptions options = NSKeyValueObservingOptionNew) - { - Q_ASSERT(obj); - Q_ASSERT(key); - Q_ASSERT(cb); - if (!obj || !key || !cb) { - return; - } - object = obj; - keyPath = key; - callback = std::make_unique(cb); - addObserver(options); - } - - explicit MacOSKeyValueObserver() = default; - - ~MacOSKeyValueObserver() - { - removeObserver(); - } - - void removeObserver() - { - if (!object) { - return; - } - [object removeObserver:observer forKeyPath:keyPath context:callback.get()]; - object = nil; - } - -private: - void addObserver(const NSKeyValueObservingOptions options) - { - [object addObserver:observer forKeyPath:keyPath options:options context:callback.get()]; - } - -private: - NSObject *object = nil; - NSString *keyPath = nil; - std::unique_ptr callback = nil; - - static inline MyKeyValueObserver *observer = [[MyKeyValueObserver alloc] init]; -}; - -class MacOSThemeObserver -{ - FRAMELESSHELPER_CLASS(MacOSThemeObserver) - -public: - explicit MacOSThemeObserver() - { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 2)) - static const bool isMojave = (QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSMojave); -#elif (QT_VERSION >= QT_VERSION_CHECK(5, 9, 1)) - static const bool isMojave = (QOperatingSystemVersion::current() > QOperatingSystemVersion::MacOSHighSierra); -#elif (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) - static const bool isMojave = (QOperatingSystemVersion::current() > QOperatingSystemVersion::MacOSSierra); -#else - static const bool isMojave = (QSysInfo::macVersion() > QSysInfo::MV_SIERRA); -#endif - if (isMojave) { - m_appearanceObserver = std::make_unique(NSApp, @"effectiveAppearance", [](){ - QT_WARNING_PUSH - QT_WARNING_DISABLE_DEPRECATED - NSAppearance.currentAppearance = NSApp.effectiveAppearance; // FIXME: use latest API. - QT_WARNING_POP - MacOSThemeObserver::notifySystemThemeChange(); - }); - } - m_systemColorObserver = std::make_unique(nil, NSSystemColorsDidChangeNotification, - [](){ MacOSThemeObserver::notifySystemThemeChange(); }); - } - - ~MacOSThemeObserver() = default; - - static void notifySystemThemeChange() - { - // Sometimes the FramelessManager instance may be destroyed already. - if (FramelessManager * const manager = FramelessManager::instance()) { - if (FramelessManagerPrivate * const managerPriv = FramelessManagerPrivate::get(manager)) { - managerPriv->notifySystemThemeHasChangedOrNot(); - } - } - } - -private: - std::unique_ptr m_systemColorObserver = nil; - std::unique_ptr m_appearanceObserver = nil; -}; - -class NSWindowProxy : public QObject -{ - Q_OBJECT - FRAMELESSHELPER_QT_CLASS(NSWindowProxy) - -public: - explicit NSWindowProxy(QWindow *qtWindow, NSWindow *macWindow, QObject *parent = nil) : QObject(parent) - { - Q_ASSERT(qtWindow); - Q_ASSERT(macWindow); - Q_ASSERT(!instances.contains(macWindow)); - if (!qtWindow || !macWindow || instances.contains(macWindow)) { - return; - } - qwindow = qtWindow; - nswindow = macWindow; - instances.insert(macWindow, this); - if (!windowClass) { - windowClass = [nswindow class]; - Q_ASSERT(windowClass); - replaceImplementations(); - } - } - - ~NSWindowProxy() override - { - instances.remove(nswindow); - if (instances.count() <= 0) { - windowClass = nil; - } - nswindow = nil; - } - -public Q_SLOTS: - void replaceImplementations() - { - Method method = class_getInstanceMethod(windowClass, @selector(setStyleMask:)); - Q_ASSERT(method); - oldSetStyleMask = reinterpret_cast(method_setImplementation(method, reinterpret_cast(setStyleMask))); - Q_ASSERT(oldSetStyleMask); - - method = class_getInstanceMethod(windowClass, @selector(setTitlebarAppearsTransparent:)); - Q_ASSERT(method); - oldSetTitlebarAppearsTransparent = reinterpret_cast(method_setImplementation(method, reinterpret_cast(setTitlebarAppearsTransparent))); - Q_ASSERT(oldSetTitlebarAppearsTransparent); - -#if 0 - method = class_getInstanceMethod(windowClass, @selector(canBecomeKeyWindow)); - Q_ASSERT(method); - oldCanBecomeKeyWindow = reinterpret_cast(method_setImplementation(method, reinterpret_cast(canBecomeKeyWindow))); - Q_ASSERT(oldCanBecomeKeyWindow); - - method = class_getInstanceMethod(windowClass, @selector(canBecomeMainWindow)); - Q_ASSERT(method); - oldCanBecomeMainWindow = reinterpret_cast(method_setImplementation(method, reinterpret_cast(canBecomeMainWindow))); - Q_ASSERT(oldCanBecomeMainWindow); -#endif - - method = class_getInstanceMethod(windowClass, @selector(sendEvent:)); - Q_ASSERT(method); - oldSendEvent = reinterpret_cast(method_setImplementation(method, reinterpret_cast(sendEvent))); - Q_ASSERT(oldSendEvent); - } - - void restoreImplementations() - { - Method method = class_getInstanceMethod(windowClass, @selector(setStyleMask:)); - Q_ASSERT(method); - method_setImplementation(method, reinterpret_cast(oldSetStyleMask)); - oldSetStyleMask = nil; - - method = class_getInstanceMethod(windowClass, @selector(setTitlebarAppearsTransparent:)); - Q_ASSERT(method); - method_setImplementation(method, reinterpret_cast(oldSetTitlebarAppearsTransparent)); - oldSetTitlebarAppearsTransparent = nil; - -#if 0 - method = class_getInstanceMethod(windowClass, @selector(canBecomeKeyWindow)); - Q_ASSERT(method); - method_setImplementation(method, reinterpret_cast(oldCanBecomeKeyWindow)); - oldCanBecomeKeyWindow = nil; - - method = class_getInstanceMethod(windowClass, @selector(canBecomeMainWindow)); - Q_ASSERT(method); - method_setImplementation(method, reinterpret_cast(oldCanBecomeMainWindow)); - oldCanBecomeMainWindow = nil; -#endif - - method = class_getInstanceMethod(windowClass, @selector(sendEvent:)); - Q_ASSERT(method); - method_setImplementation(method, reinterpret_cast(oldSendEvent)); - oldSendEvent = nil; - } - - void setSystemTitleBarVisible(const bool visible) - { - NSView * const nsview = [nswindow contentView]; - Q_ASSERT(nsview); - if (!nsview) { - return; - } - nsview.wantsLayer = YES; - nswindow.styleMask |= NSWindowStyleMaskResizable; - if (visible) { - nswindow.styleMask &= ~NSWindowStyleMaskFullSizeContentView; - } else { - nswindow.styleMask |= NSWindowStyleMaskFullSizeContentView; - } - nswindow.titlebarAppearsTransparent = (visible ? NO : YES); - nswindow.titleVisibility = (visible ? NSWindowTitleVisible : NSWindowTitleHidden); - nswindow.hasShadow = YES; - nswindow.showsToolbarButton = NO; - nswindow.movableByWindowBackground = NO; - nswindow.movable = NO; - // For some unknown reason, we don't need the following hack in Qt versions below or equal to 6.2.4. -#if (QT_VERSION > QT_VERSION_CHECK(6, 2, 4)) - [nswindow standardWindowButton:NSWindowCloseButton].hidden = (visible ? NO : YES); - [nswindow standardWindowButton:NSWindowMiniaturizeButton].hidden = (visible ? NO : YES); - [nswindow standardWindowButton:NSWindowZoomButton].hidden = (visible ? NO : YES); -#endif - } - - void setBlurBehindWindowEnabled(const bool enable) - { - if (enable) { - if (blurEffect) { - return; - } - NSView * const view = [nswindow contentView]; -#if 1 - const Class visualEffectViewClass = NSClassFromString(@"NSVisualEffectView"); - if (!visualEffectViewClass) { - return; - } - NSVisualEffectView * const blurView = [[visualEffectViewClass alloc] initWithFrame:view.bounds]; -#else - NSVisualEffectView * const blurView = [[NSVisualEffectView alloc] initWithFrame:view.bounds]; -#endif - blurView.material = NSVisualEffectMaterialUnderWindowBackground; - blurView.blendingMode = NSVisualEffectBlendingModeBehindWindow; - blurView.state = NSVisualEffectStateFollowsWindowActiveState; - const NSView * const parent = [view superview]; - [parent addSubview:blurView positioned:NSWindowBelow relativeTo:view]; - blurEffect = blurView; - updateBlurTheme(); - updateBlurSize(); - connect(FramelessManager::instance(), - &FramelessManager::systemThemeChanged, this, &NSWindowProxy::updateBlurTheme); - connect(qwindow, &QWindow::widthChanged, this, &NSWindowProxy::updateBlurSize); - connect(qwindow, &QWindow::heightChanged, this, &NSWindowProxy::updateBlurSize); - } else { - if (!blurEffect) { - return; - } - if (widthChangeConnection) { - disconnect(widthChangeConnection); - widthChangeConnection = {}; - } - if (heightChangeConnection) { - disconnect(heightChangeConnection); - heightChangeConnection = {}; - } - if (themeChangeConnection) { - disconnect(themeChangeConnection); - themeChangeConnection = {}; - } - [blurEffect removeFromSuperview]; - blurEffect = nil; - } - } - - void updateBlurSize() - { - if (!blurEffect) { - return; - } - const NSView * const view = [nswindow contentView]; - blurEffect.frame = view.frame; - } - - void updateBlurTheme() - { - if (!blurEffect) { - return; - } - const auto view = static_cast(blurEffect); - if (FramelessManager::instance()->systemTheme() == SystemTheme::Dark) { - view.appearance = [NSAppearance appearanceNamed:@"NSAppearanceNameVibrantDark"]; - } else { - view.appearance = [NSAppearance appearanceNamed:@"NSAppearanceNameVibrantLight"]; - } - } - -private: - static BOOL canBecomeKeyWindow(id obj, SEL sel) - { - if (instances.contains(reinterpret_cast(obj))) { - return YES; - } - - if (oldCanBecomeKeyWindow) { - return oldCanBecomeKeyWindow(obj, sel); - } - - return YES; - } - - static BOOL canBecomeMainWindow(id obj, SEL sel) - { - if (instances.contains(reinterpret_cast(obj))) { - return YES; - } - - if (oldCanBecomeMainWindow) { - return oldCanBecomeMainWindow(obj, sel); - } - - return YES; - } - - static void setStyleMask(id obj, SEL sel, NSWindowStyleMask styleMask) - { - if (instances.contains(reinterpret_cast(obj))) { - styleMask |= NSWindowStyleMaskFullSizeContentView; - } - - if (oldSetStyleMask) { - oldSetStyleMask(obj, sel, styleMask); - } - } - - static void setTitlebarAppearsTransparent(id obj, SEL sel, BOOL transparent) - { - if (instances.contains(reinterpret_cast(obj))) { - transparent = YES; - } - - if (oldSetTitlebarAppearsTransparent) { - oldSetTitlebarAppearsTransparent(obj, sel, transparent); - } - } - - static void sendEvent(id obj, SEL sel, NSEvent *event) - { - if (oldSendEvent) { - oldSendEvent(obj, sel, event); - } - -#if 0 - const auto nswindow = reinterpret_cast(obj); - const auto it = instances.find(nswindow); - if (it == instances.end()) { - return; - } - - NSWindowProxy * const proxy = it.value(); - if (event.type == NSEventTypeLeftMouseDown) { - proxy->lastMouseDownEvent = event; - QCoreApplication::processEvents(); - proxy->lastMouseDownEvent = nil; - } -#endif - } - -private: - QWindow *qwindow = nil; - NSWindow *nswindow = nil; - //NSEvent *lastMouseDownEvent = nil; - NSView *blurEffect = nil; - - QMetaObject::Connection widthChangeConnection = {}; - QMetaObject::Connection heightChangeConnection = {}; - QMetaObject::Connection themeChangeConnection = {}; - - static inline QHash instances = {}; - - static inline Class windowClass = nil; - - using setStyleMaskPtr = void(*)(id, SEL, NSWindowStyleMask); - static inline setStyleMaskPtr oldSetStyleMask = nil; - - using setTitlebarAppearsTransparentPtr = void(*)(id, SEL, BOOL); - static inline setTitlebarAppearsTransparentPtr oldSetTitlebarAppearsTransparent = nil; - - using canBecomeKeyWindowPtr = BOOL(*)(id, SEL); - static inline canBecomeKeyWindowPtr oldCanBecomeKeyWindow = nil; - - using canBecomeMainWindowPtr = BOOL(*)(id, SEL); - static inline canBecomeMainWindowPtr oldCanBecomeMainWindow = nil; - - using sendEventPtr = void(*)(id, SEL, NSEvent *); - static inline sendEventPtr oldSendEvent = nil; -}; - -using MacUtilsData = QHash; -Q_GLOBAL_STATIC(MacUtilsData, g_macUtilsData); - -[[nodiscard]] static inline NSWindow *mac_getNSWindow(const WId windowId) -{ - Q_ASSERT(windowId); - if (!windowId) { - return nil; - } - const auto nsview = reinterpret_cast(windowId); - Q_ASSERT(nsview); - if (!nsview) { - return nil; - } - return [nsview window]; -} - -static inline void cleanupProxy() -{ - if (g_macUtilsData()->isEmpty()) { - return; - } - const auto &data = *g_macUtilsData(); - for (auto &&proxy : std::as_const(data)) { - Q_ASSERT(proxy); - if (!proxy) { - continue; - } - delete proxy; - } - g_macUtilsData()->clear(); -} - -[[nodiscard]] static inline NSWindowProxy *ensureWindowProxy(const WId windowId) -{ - Q_ASSERT(windowId); - if (!windowId) { - return nil; - } - auto it = g_macUtilsData()->find(windowId); - if (it == g_macUtilsData()->end()) { - QWindow * const qwindow = Utils::findWindow(windowId); - Q_ASSERT(qwindow); - if (!qwindow) { - return nil; - } - NSWindow * const nswindow = mac_getNSWindow(windowId); - Q_ASSERT(nswindow); - if (!nswindow) { - return nil; - } - const auto proxy = new NSWindowProxy(qwindow, nswindow); - it = g_macUtilsData()->insert(windowId, proxy); - } - static bool cleanerInstalled = false; - if (!cleanerInstalled) { - cleanerInstalled = true; - qAddPostRoutine(cleanupProxy); - } - return it.value(); -} - -void Utils::setSystemTitleBarVisible(const WId windowId, const bool visible) -{ - Q_ASSERT(windowId); - if (!windowId) { - return; - } - NSWindowProxy * const proxy = ensureWindowProxy(windowId); - proxy->setSystemTitleBarVisible(visible); -} - -bool Utils::startSystemMove(QWindow *window, const QPoint &globalPos) -{ - Q_ASSERT(window); - if (!window) { - return false; - } -#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) - Q_UNUSED(globalPos); - return window->startSystemMove(); -#else - const NSWindow * const nswindow = mac_getNSWindow(window->winId()); - Q_ASSERT(nswindow); - if (!nswindow) { - return false; - } - const CGEventRef clickDown = CGEventCreateMouseEvent(NULL, kCGEventLeftMouseDown, - CGPointMake(globalPos.x(), globalPos.y()), kCGMouseButtonLeft); - NSEvent * const nsevent = [NSEvent eventWithCGEvent:clickDown]; - Q_ASSERT(nsevent); - if (!nsevent) { - CFRelease(clickDown); - return false; - } - [nswindow performWindowDragWithEvent:nsevent]; - CFRelease(clickDown); - return true; -#endif -} - -bool Utils::startSystemResize(QWindow *window, const Qt::Edges edges, const QPoint &globalPos) -{ - Q_ASSERT(window); - if (!window) { - return false; - } - if (edges == Qt::Edges{}) { - return false; - } -#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) - Q_UNUSED(globalPos); - // Actually Qt doesn't implement this function, it will do nothing and always returns false. - return window->startSystemResize(edges); -#else - // ### TODO - Q_UNUSED(globalPos); - return false; -#endif -} - -QColor Utils::getAccentColor_macos() -{ - return qt_mac_toQColor([NSColor controlAccentColor]); -} - -bool Utils::isTitleBarColorized() -{ - return false; -} - -bool Utils::shouldAppsUseDarkMode_macos() -{ -#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) - return qt_mac_applicationIsInDarkMode(); -#else - const auto appearance = [NSApp.effectiveAppearance bestMatchFromAppearancesWithNames: - @[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]]; - return [appearance isEqualToString:NSAppearanceNameDarkAqua]; -#endif -} - -bool Utils::setBlurBehindWindowEnabled(const WId windowId, const BlurMode mode, const QColor &color) -{ - Q_UNUSED(color); - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - const auto blurMode = [mode]() -> BlurMode { - if ((mode == BlurMode::Disable) || (mode == BlurMode::Default)) { - return mode; - } - WARNING << "The BlurMode::Windows_* enum values are not supported on macOS."; - return BlurMode::Default; - }(); - NSWindowProxy * const proxy = ensureWindowProxy(windowId); - proxy->setBlurBehindWindowEnabled(blurMode == BlurMode::Default); - return true; -} - -QString Utils::getWallpaperFilePath() -{ -#if 0 - const NSWorkspace * const sharedWorkspace = [NSWorkspace sharedWorkspace]; - if (!sharedWorkspace) { - WARNING << "Failed to retrieve the shared workspace."; - return {}; - } - NSScreen * const mainScreen = [NSScreen mainScreen]; - if (!mainScreen) { - WARNING << "Failed to retrieve the main screen."; - return {}; - } - const NSURL * const url = [sharedWorkspace desktopImageURLForScreen:mainScreen]; - if (!url) { - WARNING << "Failed to retrieve the desktop image URL."; - return {}; - } - const QUrl path = QUrl::fromNSURL(url); - if (!path.isValid()) { - WARNING << "The converted QUrl is not valid."; - return {}; - } - return path.toLocalFile(); -#else - // ### TODO - return {}; -#endif -} - -WallpaperAspectStyle Utils::getWallpaperAspectStyle() -{ - return WallpaperAspectStyle::Stretch; -} - -bool Utils::isBlurBehindWindowSupported() -{ - static const auto result = []() -> bool { - if (FramelessConfig::instance()->isSet(Option::ForceNonNativeBackgroundBlur)) { - return false; - } -#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) - return (QOperatingSystemVersion::current() >= QOperatingSystemVersion::OSXYosemite); -#else - return (QSysInfo::macVersion() >= QSysInfo::MV_YOSEMITE); -#endif - }(); - return result; -} - -bool Utils::registerThemeChangeNotification() -{ - volatile static MacOSThemeObserver observer; - Q_UNUSED(observer); - return true; -} - -void Utils::removeWindowProxy(const WId windowId) -{ - Q_ASSERT(windowId); - if (!windowId) { - return; - } - const auto it = g_macUtilsData()->constFind(windowId); - if (it == g_macUtilsData()->constEnd()) { - return; - } - if (const auto proxy = it.value()) { - // We'll restore everything to default in the destructor, - // so no need to do it manually here. - delete proxy; - } - g_macUtilsData()->erase(it); -} - -QColor Utils::getFrameBorderColor(const bool active) -{ - return (active ? getAccentColor() : kDefaultDarkGrayColor); -} - -FRAMELESSHELPER_END_NAMESPACE - -#include "utils_mac.moc" - -#endif // Q_OS_MACOS diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/utils_win.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/core/utils_win.cpp deleted file mode 100644 index f5e46b69..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/utils_win.cpp +++ /dev/null @@ -1,3448 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "utils.h" - -#ifdef Q_OS_WINDOWS - -#include "framelesshelper_windows.h" -#include "framelessmanager.h" -#include "framelessmanager_p.h" -#include "framelessconfig_p.h" -#include "sysapiloader_p.h" -#include "registrykey_p.h" -#include "winverhelper_p.h" -#include "framelesshelpercore_global_p.h" -#include "versionnumber_p.h" -#include "scopeguard_p.h" -#include -#include -#include -#include -#include -#include -#include -#if FRAMELESSHELPER_CONFIG(private_qt) -# include -# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) -# include -# endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) -# include -# if (QT_VERSION < QT_VERSION_CHECK(6, 2, 0)) -# include -# else // (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)) -# include -# endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) -#endif -#include - -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) -Q_DECLARE_METATYPE(QMargins) -#endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcUtilsWin, "wangwenx190.framelesshelper.core.utils.win") -# define INFO qCInfo(lcUtilsWin) -# define DEBUG qCDebug(lcUtilsWin) -# define WARNING qCWarning(lcUtilsWin) -# define CRITICAL qCCritical(lcUtilsWin) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -static constexpr const char kDpiNoAccessErrorMessage[] = - "FramelessHelper doesn't have access to change the current process's DPI awareness mode," - " most likely due to it has been set externally already. Eg: application manifest file."; -static constexpr const char kQtWindowCustomMarginsVar[] = "_q_windowsCustomMargins"; -FRAMELESSHELPER_STRING_CONSTANT2(SuccessMessageText, "The operation completed successfully.") -FRAMELESSHELPER_STRING_CONSTANT2(ErrorMessageTemplate, "Function %1() failed with error code %2: %3.") -FRAMELESSHELPER_STRING_CONSTANT(Composition) -FRAMELESSHELPER_STRING_CONSTANT(ColorizationColor) -FRAMELESSHELPER_STRING_CONSTANT(AppsUseLightTheme) -FRAMELESSHELPER_STRING_CONSTANT(WindowsCustomMargins) -FRAMELESSHELPER_STRING_CONSTANT(user32) -FRAMELESSHELPER_STRING_CONSTANT(dwmapi) -FRAMELESSHELPER_STRING_CONSTANT(winmm) -FRAMELESSHELPER_STRING_CONSTANT(shcore) -FRAMELESSHELPER_STRING_CONSTANT(uxtheme) -FRAMELESSHELPER_STRING_CONSTANT(GetWindowRect) -FRAMELESSHELPER_STRING_CONSTANT(DwmIsCompositionEnabled) -FRAMELESSHELPER_STRING_CONSTANT(SetWindowPos) -FRAMELESSHELPER_STRING_CONSTANT(DwmExtendFrameIntoClientArea) -FRAMELESSHELPER_STRING_CONSTANT(DwmGetColorizationColor) -FRAMELESSHELPER_STRING_CONSTANT(PostMessageW) -FRAMELESSHELPER_STRING_CONSTANT(MonitorFromWindow) -FRAMELESSHELPER_STRING_CONSTANT(GetMonitorInfoW) -FRAMELESSHELPER_STRING_CONSTANT(GetWindowPlacement) -FRAMELESSHELPER_STRING_CONSTANT(QueryPerformanceFrequency) -FRAMELESSHELPER_STRING_CONSTANT(QueryPerformanceCounter) -FRAMELESSHELPER_STRING_CONSTANT(DwmGetCompositionTimingInfo) -FRAMELESSHELPER_STRING_CONSTANT(SystemParametersInfoW) -#ifdef Q_PROCESSOR_X86_64 - FRAMELESSHELPER_STRING_CONSTANT(GetClassLongPtrW) - FRAMELESSHELPER_STRING_CONSTANT(SetClassLongPtrW) - FRAMELESSHELPER_STRING_CONSTANT(GetWindowLongPtrW) - FRAMELESSHELPER_STRING_CONSTANT(SetWindowLongPtrW) -#else // !Q_PROCESSOR_X86_64 - // WinUser.h defines G/SetClassLongPtr as G/SetClassLong due to the - // "Ptr" suffixed APIs are not available on 32-bit platforms, so we - // have to add the following workaround. Undefine the macros and then - // redefine them is also an option but the following solution is more simple. - FRAMELESSHELPER_STRING_CONSTANT2(GetClassLongPtrW, "GetClassLongW") - FRAMELESSHELPER_STRING_CONSTANT2(SetClassLongPtrW, "SetClassLongW") - FRAMELESSHELPER_STRING_CONSTANT2(GetWindowLongPtrW, "GetWindowLongW") - FRAMELESSHELPER_STRING_CONSTANT2(SetWindowLongPtrW, "SetWindowLongW") -#endif // Q_PROCESSOR_X86_64 -FRAMELESSHELPER_STRING_CONSTANT(ReleaseCapture) -FRAMELESSHELPER_STRING_CONSTANT(SetWindowTheme) -FRAMELESSHELPER_STRING_CONSTANT(SetProcessDpiAwarenessContext) -FRAMELESSHELPER_STRING_CONSTANT(SetProcessDpiAwareness) -FRAMELESSHELPER_STRING_CONSTANT(SetProcessDPIAware) -FRAMELESSHELPER_STRING_CONSTANT(GetDpiForMonitor) -FRAMELESSHELPER_STRING_CONSTANT(GetDC) -FRAMELESSHELPER_STRING_CONSTANT(ReleaseDC) -FRAMELESSHELPER_STRING_CONSTANT(GetDeviceCaps) -FRAMELESSHELPER_STRING_CONSTANT(DwmSetWindowAttribute) -FRAMELESSHELPER_STRING_CONSTANT(EnableMenuItem) -FRAMELESSHELPER_STRING_CONSTANT(SetMenuDefaultItem) -FRAMELESSHELPER_STRING_CONSTANT(HiliteMenuItem) -FRAMELESSHELPER_STRING_CONSTANT(TrackPopupMenu) -FRAMELESSHELPER_STRING_CONSTANT(DrawMenuBar) -FRAMELESSHELPER_STRING_CONSTANT(DeleteMenu) -FRAMELESSHELPER_STRING_CONSTANT(RemoveMenu) -FRAMELESSHELPER_STRING_CONSTANT(ClientToScreen) -FRAMELESSHELPER_STRING_CONSTANT(DwmEnableBlurBehindWindow) -FRAMELESSHELPER_STRING_CONSTANT(SetWindowCompositionAttribute) -FRAMELESSHELPER_STRING_CONSTANT(GetSystemMetricsForDpi) -FRAMELESSHELPER_STRING_CONSTANT(timeGetDevCaps) -FRAMELESSHELPER_STRING_CONSTANT(timeBeginPeriod) -FRAMELESSHELPER_STRING_CONSTANT(timeEndPeriod) -FRAMELESSHELPER_STRING_CONSTANT(GetDpiForWindow) -FRAMELESSHELPER_STRING_CONSTANT(GetSystemDpiForProcess) -FRAMELESSHELPER_STRING_CONSTANT(GetDpiForSystem) -FRAMELESSHELPER_STRING_CONSTANT(DwmGetWindowAttribute) -FRAMELESSHELPER_STRING_CONSTANT(ntdll) -FRAMELESSHELPER_STRING_CONSTANT(RtlGetVersion) -FRAMELESSHELPER_STRING_CONSTANT(GetModuleHandleW) -FRAMELESSHELPER_STRING_CONSTANT(RegisterClassExW) -FRAMELESSHELPER_STRING_CONSTANT(CreateWindowExW) -FRAMELESSHELPER_STRING_CONSTANT(AccentColor) -FRAMELESSHELPER_STRING_CONSTANT(GetScaleFactorForMonitor) -FRAMELESSHELPER_STRING_CONSTANT(WallpaperStyle) -FRAMELESSHELPER_STRING_CONSTANT(TileWallpaper) -FRAMELESSHELPER_STRING_CONSTANT(UnregisterClassW) -FRAMELESSHELPER_STRING_CONSTANT(DestroyWindow) -FRAMELESSHELPER_STRING_CONSTANT(SetWindowThemeAttribute) -FRAMELESSHELPER_STRING_CONSTANT(CreateDCW) -FRAMELESSHELPER_STRING_CONSTANT(DeleteDC) -FRAMELESSHELPER_STRING_CONSTANT(d2d1) -FRAMELESSHELPER_STRING_CONSTANT(D2D1CreateFactory) -FRAMELESSHELPER_STRING_CONSTANT(ReloadSystemMetrics) -FRAMELESSHELPER_STRING_CONSTANT(SetPreferredAppMode) -FRAMELESSHELPER_STRING_CONSTANT(AllowDarkModeForApp) -FRAMELESSHELPER_STRING_CONSTANT(AllowDarkModeForWindow) -FRAMELESSHELPER_STRING_CONSTANT(FlushMenuThemes) -FRAMELESSHELPER_STRING_CONSTANT(RefreshImmersiveColorPolicyState) -FRAMELESSHELPER_STRING_CONSTANT(SetPropW) -FRAMELESSHELPER_STRING_CONSTANT(GetIsImmersiveColorUsingHighContrast) -FRAMELESSHELPER_STRING_CONSTANT(EnableNonClientDpiScaling) -FRAMELESSHELPER_STRING_CONSTANT(GetWindowDpiAwarenessContext) -FRAMELESSHELPER_STRING_CONSTANT(GetAwarenessFromDpiAwarenessContext) -FRAMELESSHELPER_STRING_CONSTANT(GetThreadDpiAwarenessContext) -FRAMELESSHELPER_STRING_CONSTANT(GetDpiAwarenessContextForProcess) -FRAMELESSHELPER_STRING_CONSTANT(GetCurrentProcess) -FRAMELESSHELPER_STRING_CONSTANT(GetProcessDpiAwareness) -FRAMELESSHELPER_STRING_CONSTANT(IsProcessDPIAware) -FRAMELESSHELPER_STRING_CONSTANT(AreDpiAwarenessContextsEqual) -FRAMELESSHELPER_STRING_CONSTANT(GetWindowDPI) -FRAMELESSHELPER_STRING_CONSTANT(AdjustWindowRectExForDpi) -FRAMELESSHELPER_STRING_CONSTANT(GetDpiMetrics) -FRAMELESSHELPER_STRING_CONSTANT(EnablePerMonitorDialogScaling) -FRAMELESSHELPER_STRING_CONSTANT(EnableChildWindowDpiMessage) -FRAMELESSHELPER_STRING_CONSTANT(GetForegroundWindow) -FRAMELESSHELPER_STRING_CONSTANT(SendMessageTimeoutW) -FRAMELESSHELPER_STRING_CONSTANT(AttachThreadInput) -FRAMELESSHELPER_STRING_CONSTANT(BringWindowToTop) -FRAMELESSHELPER_STRING_CONSTANT(SetActiveWindow) -FRAMELESSHELPER_STRING_CONSTANT(RedrawWindow) -FRAMELESSHELPER_STRING_CONSTANT(ScreenToClient) -FRAMELESSHELPER_STRING_CONSTANT(DwmFlush) -FRAMELESSHELPER_STRING_CONSTANT(GetCursorPos) -FRAMELESSHELPER_STRING_CONSTANT(DeleteObject) - -struct UtilsWinExtraData : public FramelessExtraData -{ - WNDPROC qtWindowProc = nullptr; - bool windowProcHooked = false; - bool mica = false; - - UtilsWinExtraData(); - ~UtilsWinExtraData() override; - - [[nodiscard]] static FramelessExtraDataPtr create(); -}; -using UtilsWinExtraDataPtr = std::shared_ptr; - -UtilsWinExtraData::UtilsWinExtraData() = default; - -UtilsWinExtraData::~UtilsWinExtraData() = default; - -FramelessExtraDataPtr UtilsWinExtraData::create() -{ - return std::make_shared(); -} - -[[nodiscard]] static inline UtilsWinExtraDataPtr tryGetExtraData(const FramelessDataPtr &data, const bool create) -{ - Q_ASSERT(data); - if (!data) { - return nullptr; - } - auto it = data->extraData.find(ExtraDataType::WindowsUtilities); - if (it == data->extraData.end()) { - if (create) { - it = data->extraData.insert(ExtraDataType::WindowsUtilities, UtilsWinExtraData::create()); - } else { - return nullptr; - } - } - return std::dynamic_pointer_cast(it.value()); -} - -struct Win32Message -{ - UINT Code = 0; - LPCSTR Str = nullptr; - - [[nodiscard]] friend inline constexpr bool operator==(const Win32Message &lhs, const Win32Message &rhs) noexcept - { - return (lhs.Code == rhs.Code); - } - - [[nodiscard]] friend inline constexpr bool operator!=(const Win32Message &lhs, const Win32Message &rhs) noexcept - { - return !operator==(lhs, rhs); - } - - [[nodiscard]] friend inline constexpr bool operator>(const Win32Message &lhs, const Win32Message &rhs) noexcept - { - return (lhs.Code > rhs.Code); - } - - [[nodiscard]] friend inline constexpr bool operator>=(const Win32Message &lhs, const Win32Message &rhs) noexcept - { - return (operator>(lhs, rhs) || operator==(lhs, rhs)); - } - - [[nodiscard]] friend inline constexpr bool operator<(const Win32Message &lhs, const Win32Message &rhs) noexcept - { - return (operator!=(lhs, rhs) && !operator>(lhs, rhs)); - } - - [[nodiscard]] friend inline constexpr bool operator<=(const Win32Message &lhs, const Win32Message &rhs) noexcept - { - return (operator<(lhs, rhs) || operator==(lhs, rhs)); - } -}; - -#define DEFINE_WIN32_MESSAGE(Message) Win32Message{ Message, #Message }, -static constexpr const std::array g_win32MessageMap = -{ - DEFINE_WIN32_MESSAGE(WM_NULL) - DEFINE_WIN32_MESSAGE(WM_CREATE) - DEFINE_WIN32_MESSAGE(WM_DESTROY) - DEFINE_WIN32_MESSAGE(WM_MOVE) - DEFINE_WIN32_MESSAGE(WM_SIZE) - DEFINE_WIN32_MESSAGE(WM_ACTIVATE) - DEFINE_WIN32_MESSAGE(WM_SETFOCUS) - DEFINE_WIN32_MESSAGE(WM_KILLFOCUS) - DEFINE_WIN32_MESSAGE(WM_ENABLE) - DEFINE_WIN32_MESSAGE(WM_SETREDRAW) - DEFINE_WIN32_MESSAGE(WM_SETTEXT) - DEFINE_WIN32_MESSAGE(WM_GETTEXT) - DEFINE_WIN32_MESSAGE(WM_GETTEXTLENGTH) - DEFINE_WIN32_MESSAGE(WM_PAINT) - DEFINE_WIN32_MESSAGE(WM_CLOSE) - DEFINE_WIN32_MESSAGE(WM_QUERYENDSESSION) - DEFINE_WIN32_MESSAGE(WM_QUERYOPEN) - DEFINE_WIN32_MESSAGE(WM_ENDSESSION) - DEFINE_WIN32_MESSAGE(WM_QUIT) - DEFINE_WIN32_MESSAGE(WM_ERASEBKGND) - DEFINE_WIN32_MESSAGE(WM_SYSCOLORCHANGE) - DEFINE_WIN32_MESSAGE(WM_SHOWWINDOW) - DEFINE_WIN32_MESSAGE(WM_SETTINGCHANGE) // WM_WININICHANGE - DEFINE_WIN32_MESSAGE(WM_DEVMODECHANGE) - DEFINE_WIN32_MESSAGE(WM_ACTIVATEAPP) - DEFINE_WIN32_MESSAGE(WM_FONTCHANGE) - DEFINE_WIN32_MESSAGE(WM_TIMECHANGE) - DEFINE_WIN32_MESSAGE(WM_CANCELMODE) - DEFINE_WIN32_MESSAGE(WM_SETCURSOR) - DEFINE_WIN32_MESSAGE(WM_MOUSEACTIVATE) - DEFINE_WIN32_MESSAGE(WM_CHILDACTIVATE) - DEFINE_WIN32_MESSAGE(WM_QUEUESYNC) - DEFINE_WIN32_MESSAGE(WM_GETMINMAXINFO) - DEFINE_WIN32_MESSAGE(WM_PAINTICON) - DEFINE_WIN32_MESSAGE(WM_ICONERASEBKGND) - DEFINE_WIN32_MESSAGE(WM_NEXTDLGCTL) - DEFINE_WIN32_MESSAGE(WM_SPOOLERSTATUS) - DEFINE_WIN32_MESSAGE(WM_DRAWITEM) - DEFINE_WIN32_MESSAGE(WM_MEASUREITEM) - DEFINE_WIN32_MESSAGE(WM_DELETEITEM) - DEFINE_WIN32_MESSAGE(WM_VKEYTOITEM) - DEFINE_WIN32_MESSAGE(WM_CHARTOITEM) - DEFINE_WIN32_MESSAGE(WM_SETFONT) - DEFINE_WIN32_MESSAGE(WM_GETFONT) - DEFINE_WIN32_MESSAGE(WM_SETHOTKEY) - DEFINE_WIN32_MESSAGE(WM_GETHOTKEY) - DEFINE_WIN32_MESSAGE(WM_QUERYDRAGICON) - DEFINE_WIN32_MESSAGE(WM_COMPAREITEM) - DEFINE_WIN32_MESSAGE(WM_GETOBJECT) - DEFINE_WIN32_MESSAGE(WM_COMPACTING) - DEFINE_WIN32_MESSAGE(WM_COMMNOTIFY) - DEFINE_WIN32_MESSAGE(WM_WINDOWPOSCHANGING) - DEFINE_WIN32_MESSAGE(WM_WINDOWPOSCHANGED) - DEFINE_WIN32_MESSAGE(WM_POWER) - DEFINE_WIN32_MESSAGE(WM_COPYDATA) - DEFINE_WIN32_MESSAGE(WM_CANCELJOURNAL) - DEFINE_WIN32_MESSAGE(WM_NOTIFY) - DEFINE_WIN32_MESSAGE(WM_INPUTLANGCHANGEREQUEST) - DEFINE_WIN32_MESSAGE(WM_INPUTLANGCHANGE) - DEFINE_WIN32_MESSAGE(WM_TCARD) - DEFINE_WIN32_MESSAGE(WM_HELP) - DEFINE_WIN32_MESSAGE(WM_USERCHANGED) - DEFINE_WIN32_MESSAGE(WM_NOTIFYFORMAT) - DEFINE_WIN32_MESSAGE(WM_CONTEXTMENU) - DEFINE_WIN32_MESSAGE(WM_STYLECHANGING) - DEFINE_WIN32_MESSAGE(WM_STYLECHANGED) - DEFINE_WIN32_MESSAGE(WM_DISPLAYCHANGE) - DEFINE_WIN32_MESSAGE(WM_GETICON) - DEFINE_WIN32_MESSAGE(WM_SETICON) - DEFINE_WIN32_MESSAGE(WM_NCCREATE) - DEFINE_WIN32_MESSAGE(WM_NCDESTROY) - DEFINE_WIN32_MESSAGE(WM_NCCALCSIZE) - DEFINE_WIN32_MESSAGE(WM_NCHITTEST) - DEFINE_WIN32_MESSAGE(WM_NCPAINT) - DEFINE_WIN32_MESSAGE(WM_NCACTIVATE) - DEFINE_WIN32_MESSAGE(WM_GETDLGCODE) - DEFINE_WIN32_MESSAGE(WM_SYNCPAINT) - DEFINE_WIN32_MESSAGE(WM_NCMOUSEMOVE) - DEFINE_WIN32_MESSAGE(WM_NCLBUTTONDOWN) - DEFINE_WIN32_MESSAGE(WM_NCLBUTTONUP) - DEFINE_WIN32_MESSAGE(WM_NCLBUTTONDBLCLK) - DEFINE_WIN32_MESSAGE(WM_NCRBUTTONDOWN) - DEFINE_WIN32_MESSAGE(WM_NCRBUTTONUP) - DEFINE_WIN32_MESSAGE(WM_NCRBUTTONDBLCLK) - DEFINE_WIN32_MESSAGE(WM_NCMBUTTONDOWN) - DEFINE_WIN32_MESSAGE(WM_NCMBUTTONUP) - DEFINE_WIN32_MESSAGE(WM_NCMBUTTONDBLCLK) - DEFINE_WIN32_MESSAGE(WM_NCXBUTTONDOWN) - DEFINE_WIN32_MESSAGE(WM_NCXBUTTONUP) - DEFINE_WIN32_MESSAGE(WM_NCXBUTTONDBLCLK) - DEFINE_WIN32_MESSAGE(WM_INPUT_DEVICE_CHANGE) - DEFINE_WIN32_MESSAGE(WM_INPUT) - DEFINE_WIN32_MESSAGE(WM_KEYDOWN) // WM_KEYFIRST - DEFINE_WIN32_MESSAGE(WM_KEYUP) - DEFINE_WIN32_MESSAGE(WM_CHAR) - DEFINE_WIN32_MESSAGE(WM_DEADCHAR) - DEFINE_WIN32_MESSAGE(WM_SYSKEYDOWN) - DEFINE_WIN32_MESSAGE(WM_SYSKEYUP) - DEFINE_WIN32_MESSAGE(WM_SYSCHAR) - DEFINE_WIN32_MESSAGE(WM_SYSDEADCHAR) - DEFINE_WIN32_MESSAGE(WM_UNICHAR) // WM_KEYLAST - DEFINE_WIN32_MESSAGE(WM_IME_STARTCOMPOSITION) - DEFINE_WIN32_MESSAGE(WM_IME_ENDCOMPOSITION) - DEFINE_WIN32_MESSAGE(WM_IME_COMPOSITION) // WM_IME_KEYLAST - DEFINE_WIN32_MESSAGE(WM_INITDIALOG) - DEFINE_WIN32_MESSAGE(WM_COMMAND) - DEFINE_WIN32_MESSAGE(WM_SYSCOMMAND) - DEFINE_WIN32_MESSAGE(WM_TIMER) - DEFINE_WIN32_MESSAGE(WM_HSCROLL) - DEFINE_WIN32_MESSAGE(WM_VSCROLL) - DEFINE_WIN32_MESSAGE(WM_INITMENU) - DEFINE_WIN32_MESSAGE(WM_INITMENUPOPUP) -#if (WINVER >= _WIN32_WINNT_WIN7) - DEFINE_WIN32_MESSAGE(WM_GESTURE) - DEFINE_WIN32_MESSAGE(WM_GESTURENOTIFY) -#endif - DEFINE_WIN32_MESSAGE(WM_MENUSELECT) - DEFINE_WIN32_MESSAGE(WM_MENUCHAR) - DEFINE_WIN32_MESSAGE(WM_ENTERIDLE) - DEFINE_WIN32_MESSAGE(WM_MENURBUTTONUP) - DEFINE_WIN32_MESSAGE(WM_MENUDRAG) - DEFINE_WIN32_MESSAGE(WM_MENUGETOBJECT) - DEFINE_WIN32_MESSAGE(WM_UNINITMENUPOPUP) - DEFINE_WIN32_MESSAGE(WM_MENUCOMMAND) - DEFINE_WIN32_MESSAGE(WM_CHANGEUISTATE) - DEFINE_WIN32_MESSAGE(WM_UPDATEUISTATE) - DEFINE_WIN32_MESSAGE(WM_QUERYUISTATE) - DEFINE_WIN32_MESSAGE(WM_CTLCOLORMSGBOX) - DEFINE_WIN32_MESSAGE(WM_CTLCOLOREDIT) - DEFINE_WIN32_MESSAGE(WM_CTLCOLORLISTBOX) - DEFINE_WIN32_MESSAGE(WM_CTLCOLORBTN) - DEFINE_WIN32_MESSAGE(WM_CTLCOLORDLG) - DEFINE_WIN32_MESSAGE(WM_CTLCOLORSCROLLBAR) - DEFINE_WIN32_MESSAGE(WM_CTLCOLORSTATIC) - DEFINE_WIN32_MESSAGE(WM_MOUSEMOVE) // WM_MOUSEFIRST - DEFINE_WIN32_MESSAGE(WM_LBUTTONDOWN) - DEFINE_WIN32_MESSAGE(WM_LBUTTONUP) - DEFINE_WIN32_MESSAGE(WM_LBUTTONDBLCLK) - DEFINE_WIN32_MESSAGE(WM_RBUTTONDOWN) - DEFINE_WIN32_MESSAGE(WM_RBUTTONUP) - DEFINE_WIN32_MESSAGE(WM_RBUTTONDBLCLK) - DEFINE_WIN32_MESSAGE(WM_MBUTTONDOWN) - DEFINE_WIN32_MESSAGE(WM_MBUTTONUP) - DEFINE_WIN32_MESSAGE(WM_MBUTTONDBLCLK) - DEFINE_WIN32_MESSAGE(WM_MOUSEWHEEL) - DEFINE_WIN32_MESSAGE(WM_XBUTTONDOWN) - DEFINE_WIN32_MESSAGE(WM_XBUTTONUP) - DEFINE_WIN32_MESSAGE(WM_XBUTTONDBLCLK) - DEFINE_WIN32_MESSAGE(WM_MOUSEHWHEEL) // WM_MOUSELAST - DEFINE_WIN32_MESSAGE(WM_PARENTNOTIFY) - DEFINE_WIN32_MESSAGE(WM_ENTERMENULOOP) - DEFINE_WIN32_MESSAGE(WM_EXITMENULOOP) - DEFINE_WIN32_MESSAGE(WM_NEXTMENU) - DEFINE_WIN32_MESSAGE(WM_SIZING) - DEFINE_WIN32_MESSAGE(WM_CAPTURECHANGED) - DEFINE_WIN32_MESSAGE(WM_MOVING) - DEFINE_WIN32_MESSAGE(WM_POWERBROADCAST) - DEFINE_WIN32_MESSAGE(WM_DEVICECHANGE) - DEFINE_WIN32_MESSAGE(WM_MDICREATE) - DEFINE_WIN32_MESSAGE(WM_MDIDESTROY) - DEFINE_WIN32_MESSAGE(WM_MDIACTIVATE) - DEFINE_WIN32_MESSAGE(WM_MDIRESTORE) - DEFINE_WIN32_MESSAGE(WM_MDINEXT) - DEFINE_WIN32_MESSAGE(WM_MDIMAXIMIZE) - DEFINE_WIN32_MESSAGE(WM_MDITILE) - DEFINE_WIN32_MESSAGE(WM_MDICASCADE) - DEFINE_WIN32_MESSAGE(WM_MDIICONARRANGE) - DEFINE_WIN32_MESSAGE(WM_MDIGETACTIVE) - DEFINE_WIN32_MESSAGE(WM_MDISETMENU) - DEFINE_WIN32_MESSAGE(WM_ENTERSIZEMOVE) - DEFINE_WIN32_MESSAGE(WM_EXITSIZEMOVE) - DEFINE_WIN32_MESSAGE(WM_DROPFILES) - DEFINE_WIN32_MESSAGE(WM_MDIREFRESHMENU) -#if (WINVER >= _WIN32_WINNT_WIN8) - DEFINE_WIN32_MESSAGE(WM_POINTERDEVICECHANGE) - DEFINE_WIN32_MESSAGE(WM_POINTERDEVICEINRANGE) - DEFINE_WIN32_MESSAGE(WM_POINTERDEVICEOUTOFRANGE) -#endif -#if (WINVER >= _WIN32_WINNT_WIN7) - DEFINE_WIN32_MESSAGE(WM_TOUCH) -#endif -#if (WINVER >= _WIN32_WINNT_WIN8) - DEFINE_WIN32_MESSAGE(WM_NCPOINTERUPDATE) - DEFINE_WIN32_MESSAGE(WM_NCPOINTERDOWN) - DEFINE_WIN32_MESSAGE(WM_NCPOINTERUP) - DEFINE_WIN32_MESSAGE(WM_POINTERUPDATE) - DEFINE_WIN32_MESSAGE(WM_POINTERDOWN) - DEFINE_WIN32_MESSAGE(WM_POINTERUP) - DEFINE_WIN32_MESSAGE(WM_POINTERENTER) - DEFINE_WIN32_MESSAGE(WM_POINTERLEAVE) - DEFINE_WIN32_MESSAGE(WM_POINTERACTIVATE) - DEFINE_WIN32_MESSAGE(WM_POINTERCAPTURECHANGED) - DEFINE_WIN32_MESSAGE(WM_TOUCHHITTESTING) - DEFINE_WIN32_MESSAGE(WM_POINTERWHEEL) - DEFINE_WIN32_MESSAGE(WM_POINTERHWHEEL) -#endif -#ifdef WM_POINTERROUTEDTO - DEFINE_WIN32_MESSAGE(WM_POINTERROUTEDTO) -#endif -#ifdef WM_POINTERROUTEDAWAY - DEFINE_WIN32_MESSAGE(WM_POINTERROUTEDAWAY) -#endif -#ifdef WM_POINTERROUTEDRELEASED - DEFINE_WIN32_MESSAGE(WM_POINTERROUTEDRELEASED) -#endif - DEFINE_WIN32_MESSAGE(WM_IME_SETCONTEXT) - DEFINE_WIN32_MESSAGE(WM_IME_NOTIFY) - DEFINE_WIN32_MESSAGE(WM_IME_CONTROL) - DEFINE_WIN32_MESSAGE(WM_IME_COMPOSITIONFULL) - DEFINE_WIN32_MESSAGE(WM_IME_SELECT) - DEFINE_WIN32_MESSAGE(WM_IME_CHAR) - DEFINE_WIN32_MESSAGE(WM_IME_REQUEST) - DEFINE_WIN32_MESSAGE(WM_IME_KEYDOWN) - DEFINE_WIN32_MESSAGE(WM_IME_KEYUP) - DEFINE_WIN32_MESSAGE(WM_MOUSEHOVER) - DEFINE_WIN32_MESSAGE(WM_MOUSELEAVE) - DEFINE_WIN32_MESSAGE(WM_NCMOUSEHOVER) - DEFINE_WIN32_MESSAGE(WM_NCMOUSELEAVE) - DEFINE_WIN32_MESSAGE(WM_WTSSESSION_CHANGE) - DEFINE_WIN32_MESSAGE(WM_TABLET_FIRST) - DEFINE_WIN32_MESSAGE(WM_TABLET_LAST) - DEFINE_WIN32_MESSAGE(WM_DPICHANGED) -#ifdef WM_DPICHANGED_BEFOREPARENT - DEFINE_WIN32_MESSAGE(WM_DPICHANGED_BEFOREPARENT) -#endif -#ifdef WM_DPICHANGED_AFTERPARENT - DEFINE_WIN32_MESSAGE(WM_DPICHANGED_AFTERPARENT) -#endif - DEFINE_WIN32_MESSAGE(WM_GETDPISCALEDSIZE) - DEFINE_WIN32_MESSAGE(WM_CUT) - DEFINE_WIN32_MESSAGE(WM_COPY) - DEFINE_WIN32_MESSAGE(WM_PASTE) - DEFINE_WIN32_MESSAGE(WM_CLEAR) - DEFINE_WIN32_MESSAGE(WM_UNDO) - DEFINE_WIN32_MESSAGE(WM_RENDERFORMAT) - DEFINE_WIN32_MESSAGE(WM_RENDERALLFORMATS) - DEFINE_WIN32_MESSAGE(WM_DESTROYCLIPBOARD) - DEFINE_WIN32_MESSAGE(WM_DRAWCLIPBOARD) - DEFINE_WIN32_MESSAGE(WM_PAINTCLIPBOARD) - DEFINE_WIN32_MESSAGE(WM_VSCROLLCLIPBOARD) - DEFINE_WIN32_MESSAGE(WM_SIZECLIPBOARD) - DEFINE_WIN32_MESSAGE(WM_ASKCBFORMATNAME) - DEFINE_WIN32_MESSAGE(WM_CHANGECBCHAIN) - DEFINE_WIN32_MESSAGE(WM_HSCROLLCLIPBOARD) - DEFINE_WIN32_MESSAGE(WM_QUERYNEWPALETTE) - DEFINE_WIN32_MESSAGE(WM_PALETTEISCHANGING) - DEFINE_WIN32_MESSAGE(WM_PALETTECHANGED) - DEFINE_WIN32_MESSAGE(WM_HOTKEY) - DEFINE_WIN32_MESSAGE(WM_PRINT) - DEFINE_WIN32_MESSAGE(WM_PRINTCLIENT) - DEFINE_WIN32_MESSAGE(WM_APPCOMMAND) - DEFINE_WIN32_MESSAGE(WM_THEMECHANGED) - DEFINE_WIN32_MESSAGE(WM_CLIPBOARDUPDATE) - DEFINE_WIN32_MESSAGE(WM_DWMCOMPOSITIONCHANGED) -#ifdef WM_DWMNCRENDERINGCHANGED - DEFINE_WIN32_MESSAGE(WM_DWMNCRENDERINGCHANGED) -#endif - DEFINE_WIN32_MESSAGE(WM_DWMCOLORIZATIONCOLORCHANGED) -#ifdef WM_DWMWINDOWMAXIMIZEDCHANGE - DEFINE_WIN32_MESSAGE(WM_DWMWINDOWMAXIMIZEDCHANGE) -#endif -#ifdef WM_DWMSENDICONICTHUMBNAIL - DEFINE_WIN32_MESSAGE(WM_DWMSENDICONICTHUMBNAIL) -#endif -#ifdef WM_DWMSENDICONICLIVEPREVIEWBITMAP - DEFINE_WIN32_MESSAGE(WM_DWMSENDICONICLIVEPREVIEWBITMAP) -#endif -#ifdef WM_GETTITLEBARINFOEX - DEFINE_WIN32_MESSAGE(WM_GETTITLEBARINFOEX) -#endif - DEFINE_WIN32_MESSAGE(WM_HANDHELDFIRST) - DEFINE_WIN32_MESSAGE(WM_HANDHELDLAST) - DEFINE_WIN32_MESSAGE(WM_AFXFIRST) - DEFINE_WIN32_MESSAGE(WM_AFXLAST) - DEFINE_WIN32_MESSAGE(WM_PENWINFIRST) - DEFINE_WIN32_MESSAGE(WM_PENWINLAST) - DEFINE_WIN32_MESSAGE(WM_APP) - DEFINE_WIN32_MESSAGE(WM_USER) - // Undocumented messages: - DEFINE_WIN32_MESSAGE(WM_SIZEWAIT) - DEFINE_WIN32_MESSAGE(WM_SETVISIBLE) - DEFINE_WIN32_MESSAGE(WM_SYSTEMERROR) - DEFINE_WIN32_MESSAGE(WM_CTLCOLOR) - DEFINE_WIN32_MESSAGE(WM_LOGOFF) - DEFINE_WIN32_MESSAGE(WM_ALTTABACTIVE) - DEFINE_WIN32_MESSAGE(WM_SHELLNOTIFY) - DEFINE_WIN32_MESSAGE(WM_ISACTIVEICON) - DEFINE_WIN32_MESSAGE(WM_QUERYPARKICON) - DEFINE_WIN32_MESSAGE(WM_WINHELP) - DEFINE_WIN32_MESSAGE(WM_FULLSCREEN) - DEFINE_WIN32_MESSAGE(WM_CLIENTSHUTDOWN) - DEFINE_WIN32_MESSAGE(WM_DDEMLEVENT) - DEFINE_WIN32_MESSAGE(WM_TESTING) - DEFINE_WIN32_MESSAGE(WM_OTHERWINDOWCREATED) - DEFINE_WIN32_MESSAGE(WM_OTHERWINDOWDESTROYED) - DEFINE_WIN32_MESSAGE(WM_COPYGLOBALDATA) - DEFINE_WIN32_MESSAGE(WM_KEYF1) - DEFINE_WIN32_MESSAGE(WM_ACCESS_WINDOW) - DEFINE_WIN32_MESSAGE(WM_FINALDESTROY) - DEFINE_WIN32_MESSAGE(WM_MEASUREITEM_CLIENTDATA) - DEFINE_WIN32_MESSAGE(WM_SYNCTASK) - DEFINE_WIN32_MESSAGE(WM_KLUDGEMINRECT) - DEFINE_WIN32_MESSAGE(WM_LPKDRAWSWITCHWND) - DEFINE_WIN32_MESSAGE(WM_UAHDESTROYWINDOW) - DEFINE_WIN32_MESSAGE(WM_UAHDRAWMENU) - DEFINE_WIN32_MESSAGE(WM_UAHDRAWMENUITEM) - DEFINE_WIN32_MESSAGE(WM_UAHINITMENU) - DEFINE_WIN32_MESSAGE(WM_UAHMEASUREMENUITEM) - DEFINE_WIN32_MESSAGE(WM_UAHNCPAINTMENUPOPUP) - DEFINE_WIN32_MESSAGE(WM_UAHUPDATE) - DEFINE_WIN32_MESSAGE(WM_NCUAHDRAWCAPTION) - DEFINE_WIN32_MESSAGE(WM_NCUAHDRAWFRAME) - DEFINE_WIN32_MESSAGE(WM_YOMICHAR) - DEFINE_WIN32_MESSAGE(WM_CONVERTREQUEST) - DEFINE_WIN32_MESSAGE(WM_CONVERTRESULT) - DEFINE_WIN32_MESSAGE(WM_INTERIM) - DEFINE_WIN32_MESSAGE(WM_SYSTIMER) - DEFINE_WIN32_MESSAGE(WM_GESTUREINPUT) - DEFINE_WIN32_MESSAGE(WM_GESTURENOTIFIED) - DEFINE_WIN32_MESSAGE(WM_LBTRACKPOINT) - DEFINE_WIN32_MESSAGE(WM_DROPOBJECT) - DEFINE_WIN32_MESSAGE(WM_QUERYDROPOBJECT) - DEFINE_WIN32_MESSAGE(WM_BEGINDRAG) - DEFINE_WIN32_MESSAGE(WM_DRAGLOOP) - DEFINE_WIN32_MESSAGE(WM_DRAGSELECT) - DEFINE_WIN32_MESSAGE(WM_DRAGMOVE) - DEFINE_WIN32_MESSAGE(WM_STOPINERTIA) - DEFINE_WIN32_MESSAGE(WM_ENDINERTIA) - DEFINE_WIN32_MESSAGE(WM_EDGYINERTIA) - DEFINE_WIN32_MESSAGE(WM_VISIBILITYCHANGED) - DEFINE_WIN32_MESSAGE(WM_VIEWSTATECHANGED) - DEFINE_WIN32_MESSAGE(WM_UNREGISTER_WINDOW_SERVICES) - DEFINE_WIN32_MESSAGE(WM_CONSOLIDATED) - DEFINE_WIN32_MESSAGE(WM_IME_REPORT) - DEFINE_WIN32_MESSAGE(WM_IME_SYSTEM) - DEFINE_WIN32_MESSAGE(WM_POINTERDEVICEADDED) - DEFINE_WIN32_MESSAGE(WM_POINTERDEVICEDELETED) - DEFINE_WIN32_MESSAGE(WM_FLICK) - DEFINE_WIN32_MESSAGE(WM_FLICKINTERNAL) - DEFINE_WIN32_MESSAGE(WM_BRIGHTNESSCHANGED) - DEFINE_WIN32_MESSAGE(WM_SYSMENU) - DEFINE_WIN32_MESSAGE(WM_HOOKMSG) - DEFINE_WIN32_MESSAGE(WM_EXITPROCESS) - DEFINE_WIN32_MESSAGE(WM_WAKETHREAD) - DEFINE_WIN32_MESSAGE(WM_UAHINIT) - DEFINE_WIN32_MESSAGE(WM_DESKTOPNOTIFY) - DEFINE_WIN32_MESSAGE(WM_DWMEXILEFRAME) - DEFINE_WIN32_MESSAGE(WM_MAGNIFICATION_STARTED) - DEFINE_WIN32_MESSAGE(WM_MAGNIFICATION_ENDED) - DEFINE_WIN32_MESSAGE(WM_DWMTHUMBNAILSIZECHANGED) - DEFINE_WIN32_MESSAGE(WM_MAGNIFICATION_OUTPUT) - DEFINE_WIN32_MESSAGE(WM_BSDRDATA) - DEFINE_WIN32_MESSAGE(WM_DWMTRANSITIONSTATECHANGED) - DEFINE_WIN32_MESSAGE(WM_KEYBOARDCORRECTIONCALLOUT) - DEFINE_WIN32_MESSAGE(WM_KEYBOARDCORRECTIONACTION) - DEFINE_WIN32_MESSAGE(WM_UIACTION) - DEFINE_WIN32_MESSAGE(WM_ROUTED_UI_EVENT) - DEFINE_WIN32_MESSAGE(WM_MEASURECONTROL) - DEFINE_WIN32_MESSAGE(WM_GETACTIONTEXT) - DEFINE_WIN32_MESSAGE(WM_FORWARDKEYDOWN) - DEFINE_WIN32_MESSAGE(WM_FORWARDKEYUP) - DEFINE_WIN32_MESSAGE(WM_NOTIFYWOW) -}; -#undef DEFINE_WIN32_MESSAGE - -[[nodiscard]] std::optional getMonitorForWindow(const HWND hwnd) -{ - Q_ASSERT(hwnd); - if (!hwnd) { - return std::nullopt; - } - // Use "MONITOR_DEFAULTTONEAREST" here so that we can still get the correct - // monitor even if the window is minimized. - const HMONITOR monitor = ::MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); - if (!monitor) { - WARNING << Utils::getSystemErrorMessage(kMonitorFromWindow); - return std::nullopt; - } - MONITORINFOEXW monitorInfo; - SecureZeroMemory(&monitorInfo, sizeof(monitorInfo)); - monitorInfo.cbSize = sizeof(monitorInfo); - if (::GetMonitorInfoW(monitor, &monitorInfo) == FALSE) { - WARNING << Utils::getSystemErrorMessage(kGetMonitorInfoW); - return std::nullopt; - } - return monitorInfo; -}; - -[[maybe_unused]] [[nodiscard]] static inline QString qtWindowCustomMarginsProp() -{ - static const QString prop = QString::fromUtf8(kQtWindowCustomMarginsVar); - return prop; -} - -[[nodiscard]] static inline QString dwmRegistryKey() -{ - static const QString key = QString::fromWCharArray(kDwmRegistryKey); - return key; -} - -[[nodiscard]] static inline QString personalizeRegistryKey() -{ - static const QString key = QString::fromWCharArray(kPersonalizeRegistryKey); - return key; -} - -[[nodiscard]] static inline QString desktopRegistryKey() -{ - static const QString key = QString::fromWCharArray(kDesktopRegistryKey); - return key; -} - -[[nodiscard]] static inline QString dwmColorKeyName() -{ - static const QString name = QString::fromWCharArray(kDwmColorKeyName); - return name; -} - -[[nodiscard]] static inline bool doCompareWindowsVersion(const VersionNumber &targetOsVer) -{ - static const auto currentOsVer = []() -> std::optional { - if (API_NT_AVAILABLE(RtlGetVersion)) { - using RtlGetVersionPtr = _NTSTATUS(WINAPI *)(PRTL_OSVERSIONINFOW); - const auto pRtlGetVersion = reinterpret_cast(SysApiLoader::instance()->get(kntdll, kRtlGetVersion)); - RTL_OSVERSIONINFOEXW osvi; - SecureZeroMemory(&osvi, sizeof(osvi)); - osvi.dwOSVersionInfoSize = sizeof(osvi); - if (pRtlGetVersion(reinterpret_cast(&osvi)) == _STATUS_SUCCESS) { - return VersionNumber{ osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber }; - } - } - return std::nullopt; - }(); - if (currentOsVer.has_value()) { - return (currentOsVer >= targetOsVer); - } - // We can fallback to "VerifyVersionInfoW" if we can't determine the current system - // version, but this function will be affected by the manifest file of your application. - // For example, if you don't claim your application supports Windows 10 explicitly - // in the manifest file, Windows will assume your application only supports up to Windows - // 8.1, so this function will be told the current system is at most Windows 8.1, to keep - // good backward-compatiability. This behavior usually won't cause any issues if you - // always use an appropriate manifest file for your application, however, it does cause - // some issues for people who don't use the manifest file at all. There have been some - // bug reports about it already. - OSVERSIONINFOEXW osvi; - SecureZeroMemory(&osvi, sizeof(osvi)); - osvi.dwOSVersionInfoSize = sizeof(osvi); - osvi.dwMajorVersion = targetOsVer.Major; - osvi.dwMinorVersion = targetOsVer.Minor; - osvi.dwBuildNumber = targetOsVer.Patch; - DWORDLONG dwlConditionMask = 0; - static constexpr const auto op = VER_GREATER_EQUAL; - VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, op); - VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, op); - VER_SET_CONDITION(dwlConditionMask, VER_BUILDNUMBER, op); - return (::VerifyVersionInfoW(&osvi, (VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER), dwlConditionMask) != FALSE); -} - -[[nodiscard]] static inline QString getSystemErrorMessageImpl(const QString &function, const DWORD code) -{ - Q_ASSERT(!function.isEmpty()); - if (function.isEmpty()) { - return {}; - } - if (code == ERROR_SUCCESS) { - return kSuccessMessageText; - } -#if FRAMELESSHELPER_CONFIG(private_qt) - const QString errorText = QSystemError::windowsString(code); - return kErrorMessageTemplate.arg(function, QString::number(code), errorText); -#else // !FRAMELESSHELPER_CONFIG(private_qt) - LPWSTR buf = nullptr; - if (::FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast(&buf), 0, nullptr) == 0) { - return FRAMELESSHELPER_STRING_LITERAL("FormatMessageW() returned empty string."); - } - const QString errorText = QString::fromWCharArray(buf).trimmed(); - ::LocalFree(buf); - buf = nullptr; - return kErrorMessageTemplate.arg(function, QString::number(code), errorText); -#endif // FRAMELESSHELPER_CONFIG(private_qt) -} - -[[nodiscard]] static inline QString getSystemErrorMessageImpl(const QString &function, const HRESULT hr) -{ - Q_ASSERT(!function.isEmpty()); - if (function.isEmpty()) { - return {}; - } - if (SUCCEEDED(hr)) { - return kSuccessMessageText; - } - const DWORD dwError = HRESULT_CODE(hr); - return getSystemErrorMessageImpl(function, dwError); -} - -[[nodiscard]] static inline bool moveWindowToMonitor(const HWND hwnd, const MONITORINFOEXW &activeMonitor) -{ - Q_ASSERT(hwnd); - if (!hwnd) { - return false; - } - const std::optional currentMonitor = getMonitorForWindow(hwnd); - if (!currentMonitor.has_value()) { - WARNING << "Failed to retrieve the window's monitor."; - return false; - } - const RECT currentMonitorRect = currentMonitor.value().rcMonitor; - const RECT activeMonitorRect = activeMonitor.rcMonitor; - // We are in the same monitor, nothing to adjust here. - if (currentMonitorRect == activeMonitorRect) { - return true; - } - RECT currentWindowRect = {}; - if (::GetWindowRect(hwnd, ¤tWindowRect) == FALSE) { - WARNING << Utils::getSystemErrorMessage(kGetWindowRect); - return false; - } - const int currentWindowWidth = (currentWindowRect.right - currentWindowRect.left); - const int currentWindowHeight = (currentWindowRect.bottom - currentWindowRect.top); - const int currentWindowOffsetX = (currentWindowRect.left - currentMonitorRect.left); - const int currentWindowOffsetY = (currentWindowRect.top - currentMonitorRect.top); - const int newWindowX = (activeMonitorRect.left + currentWindowOffsetX); - const int newWindowY = (activeMonitorRect.top + currentWindowOffsetY); - static constexpr const UINT flags = - (SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER); - if (::SetWindowPos(hwnd, nullptr, newWindowX, newWindowY, currentWindowWidth, currentWindowHeight, flags) == FALSE) { - WARNING << Utils::getSystemErrorMessage(kSetWindowPos); - return false; - } - return true; -} - -[[nodiscard]] static inline int getSystemMetrics2(const int index, const bool horizontal, const quint32 dpi) -{ - Q_ASSERT(dpi != 0); - if (dpi == 0) { - return 0; - } - if (const int result = _GetSystemMetricsForDpi2(index, dpi); result > 0) { - return result; - } - static constexpr const auto defaultDpi = qreal(USER_DEFAULT_SCREEN_DPI); - const qreal currentDpr = (qreal(Utils::getPrimaryScreenDpi(horizontal)) / defaultDpi); - const qreal requestedDpr = (qreal(dpi) / defaultDpi); - return std::round(qreal(::GetSystemMetrics(index)) / currentDpr * requestedDpr); -} - -[[nodiscard]] static inline int getSystemMetrics2(const WId windowId, const int index, const bool horizontal, const bool scaled) -{ - Q_ASSERT(windowId); - if (!windowId) { - return 0; - } - const UINT realDpi = Utils::getWindowDpi(windowId, horizontal); - { - const UINT dpi = (scaled ? realDpi : USER_DEFAULT_SCREEN_DPI); - if (const int result = _GetSystemMetricsForDpi2(index, dpi); result > 0) { - return result; - } - } - // GetSystemMetrics() will always return a scaled value, so if we want to get an unscaled - // one, we have to calculate it ourself. - const qreal dpr = (scaled ? qreal(1) : (qreal(realDpi) / qreal(USER_DEFAULT_SCREEN_DPI))); - return std::round(qreal(::GetSystemMetrics(index)) / dpr); -} - -[[maybe_unused]] [[nodiscard]] static inline constexpr - DWORD qtEdgesToWin32Orientation(const Qt::Edges edges) -{ - if (edges == Qt::Edges{}) { - return 0; - } else if (edges == (Qt::LeftEdge)) { - return SC_SIZELEFT; - } else if (edges == (Qt::RightEdge)) { - return SC_SIZERIGHT; - } else if (edges == (Qt::TopEdge)) { - return SC_SIZETOP; - } else if (edges == (Qt::TopEdge | Qt::LeftEdge)) { - return SC_SIZETOPLEFT; - } else if (edges == (Qt::TopEdge | Qt::RightEdge)) { - return SC_SIZETOPRIGHT; - } else if (edges == (Qt::BottomEdge)) { - return SC_SIZEBOTTOM; - } else if (edges == (Qt::BottomEdge | Qt::LeftEdge)) { - return SC_SIZEBOTTOMLEFT; - } else if (edges == (Qt::BottomEdge | Qt::RightEdge)) { - return SC_SIZEBOTTOMRIGHT; - } else { - return SC_SIZE; - } -} - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[nodiscard]] static inline bool isWin32MessageDebuggingEnabled() -{ - static const bool result = (qEnvironmentVariableIntValue("FRAMELESSHELPER_ENABLE_WIN32_MESSAGE_DEBUGGING") != 0); - return result; -} -#endif - -[[nodiscard]] static inline QByteArray qtNativeEventType() -{ - static const auto result = FRAMELESSHELPER_BYTEARRAY_LITERAL("windows_generic_MSG"); - return result; -} - -[[nodiscard]] static inline constexpr bool isNonClientMessage(const UINT message) -{ - if (((message >= WM_NCCREATE) && (message <= WM_NCACTIVATE)) - || ((message >= WM_NCMOUSEMOVE) && (message <= WM_NCMBUTTONDBLCLK)) - || ((message >= WM_NCXBUTTONDOWN) && (message <= WM_NCXBUTTONDBLCLK)) -#if (WINVER >= _WIN32_WINNT_WIN8) - || ((message >= WM_NCPOINTERUPDATE) && (message <= WM_NCPOINTERUP)) -#endif - || ((message == WM_NCMOUSEHOVER) || (message == WM_NCMOUSELEAVE))) { - return true; - } else { - return false; - } -} - -[[nodiscard]] static inline constexpr bool isMouseMessage(const UINT message, bool *isNonClient = nullptr) -{ - if (((message >= WM_MOUSEFIRST) && (message <= WM_MOUSELAST)) - || ((message == WM_MOUSEHOVER) || (message == WM_MOUSELEAVE))) { - if (isNonClient) { - *isNonClient = false; - } - return true; - } else if (((message >= WM_NCMOUSEMOVE) && (message <= WM_NCMBUTTONDBLCLK)) - || ((message >= WM_NCXBUTTONDOWN) && (message <= WM_NCXBUTTONDBLCLK)) - || ((message == WM_NCMOUSEHOVER) || (message == WM_NCMOUSELEAVE))) { - if (isNonClient) { - *isNonClient = true; - } - return true; - } else { - return false; - } -} - -[[nodiscard]] static inline LRESULT CALLBACK FramelessHelperHookWindowProc - (const HWND hWnd, const UINT uMsg, const WPARAM wParam, const LPARAM lParam) -{ - Q_ASSERT(hWnd); - if (!hWnd) { - return FALSE; - } -#if FRAMELESSHELPER_CONFIG(debug_output) - if (isWin32MessageDebuggingEnabled()) { - MSG message; - SecureZeroMemory(&message, sizeof(message)); - message.hwnd = hWnd; - message.message = uMsg; - message.wParam = wParam; - message.lParam = lParam; - // The time and pt members are not used. - Utils::printWin32Message(&message); - } -#endif - const auto defaultWindowProcessing = [hWnd, uMsg, wParam, lParam]() -> LRESULT { return ::DefWindowProcW(hWnd, uMsg, wParam, lParam); }; - const auto windowId = reinterpret_cast(hWnd); - const QObject *window = FramelessManagerPrivate::getWindow(windowId); - if (!window) { - return defaultWindowProcessing(); - } - const FramelessDataPtr data = FramelessManagerPrivate::getData(window); - if (!data || !data->frameless || !data->callbacks) { - return defaultWindowProcessing(); - } - const UtilsWinExtraDataPtr extraData = tryGetExtraData(data, false); - Q_ASSERT(extraData); - if (!extraData) { - return defaultWindowProcessing(); - } - const QWindow *qWindow = data->callbacks->getWindowHandle(); - Q_ASSERT(qWindow); - if (!qWindow) { - return defaultWindowProcessing(); - } -#if FRAMELESSHELPER_CONFIG(native_impl) - // https://github.com/qt/qtbase/blob/e26a87f1ecc40bc8c6aa5b889fce67410a57a702/src/plugins/platforms/windows/qwindowscontext.cpp#L1025 - // We can see from the source code that Qt will filter out some messages first and then send the unfiltered - // messages to the event dispatcher. To activate the Snap Layout feature on Windows 11, we must process - // some non-client area messages ourself, but unfortunately these messages have been filtered out already - // in that line and thus we'll never have the chance to process them ourself. This is Qt's low level platform - // specific code so we don't have any official ways to change this behavior. But luckily we can replace the - // window procedure function of Qt's windows, and in this hooked window procedure function, we finally have - // the chance to process window messages before Qt touches them. So we reconstruct the MSG structure and - // send it to our own custom native event filter to do all the magic works. But since the system menu feature - // doesn't necessarily belong to the native implementation, we seperate the handling code and always process - // the system menu part in this function for both implementations. - // - // https://github.com/qt/qtbase/blob/946f15efb76fffda37b77f7d194d679b904305b1/src/plugins/platforms/windows/qwindowscontext.cpp#L1541 - // However, we can't just do this when the message is non-client area size re-calculating, because Qt QPA will - // do some extra work after native event filter's handling to ensure Qt windows always have correct frame margins - // (and correct client area size, especially when the window is maximized/fullscreen). So we still go through - // the normal code path of the original qWindowsWndProc() function, but only for this specific message. It should - // be OK because Qt won't prevent us from handling WM_NCCALCSIZE. - if (uMsg != WM_NCCALCSIZE) { - MSG message; - SecureZeroMemory(&message, sizeof(message)); - message.hwnd = hWnd; - message.message = uMsg; - message.wParam = wParam; - message.lParam = lParam; - message.time = ::GetMessageTime(); -#if 1 - const DWORD dwScreenPos = ::GetMessagePos(); - message.pt.x = GET_X_LPARAM(dwScreenPos); - message.pt.y = GET_Y_LPARAM(dwScreenPos); -#else - if (::GetCursorPos(&message.pt) == FALSE) { - WARNING << Utils::getSystemErrorMessage(kGetCursorPos); - message.pt = {}; - } -#endif - if (!isNonClientMessage(uMsg)) { - if (::ScreenToClient(hWnd, &message.pt) == FALSE) { - WARNING << Utils::getSystemErrorMessage(kScreenToClient); - message.pt = {}; - } - } - QT_NATIVE_EVENT_RESULT_TYPE filterResult = 0; - const auto dispatcher = QAbstractEventDispatcher::instance(); - if (dispatcher && dispatcher->filterNativeEvent(qtNativeEventType(), &message, &filterResult)) { - return LRESULT(filterResult); - } - } -#endif // native_impl - const auto getNativePosFromMouse = [lParam]() -> QPoint { - return {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; - }; - const auto getNativeGlobalPosFromKeyboard = [hWnd, windowId]() -> QPoint { - RECT windowPos = {}; - if (::GetWindowRect(hWnd, &windowPos) == FALSE) { - WARNING << Utils::getSystemErrorMessage(kGetWindowRect); - return {}; - } - const bool maxOrFull = (IsMaximized(hWnd) || Utils::isFullScreen(windowId)); - const int frameSizeX = Utils::getResizeBorderThickness(windowId, true, true); - const bool frameBorderVisible = Utils::isWindowFrameBorderVisible(); - const int horizontalOffset = ((maxOrFull || !frameBorderVisible) ? 0 : frameSizeX); - const auto verticalOffset = [windowId, frameBorderVisible, maxOrFull]() -> int { - const int titleBarHeight = Utils::getTitleBarHeight(windowId, true); - if (!frameBorderVisible) { - return titleBarHeight; - } - const int frameSizeY = Utils::getResizeBorderThickness(windowId, false, true); - if (WindowsVersionHelper::isWin11OrGreater()) { - if (maxOrFull) { - return (titleBarHeight + frameSizeY); - } - return titleBarHeight; - } - if (maxOrFull) { - return titleBarHeight; - } - return (titleBarHeight - frameSizeY); - }(); - return {windowPos.left + horizontalOffset, windowPos.top + verticalOffset}; - }; - bool shouldShowSystemMenu = false; - bool broughtByKeyboard = false; - QPoint nativeGlobalPos = {}; - switch (uMsg) { - case WM_RBUTTONUP: { - const QPoint nativeLocalPos = getNativePosFromMouse(); - const QPoint qtScenePos = Utils::fromNativeLocalPosition(qWindow, nativeLocalPos); - if (data->callbacks->isInsideTitleBarDraggableArea(qtScenePos)) { - POINT pos = {nativeLocalPos.x(), nativeLocalPos.y()}; - if (::ClientToScreen(hWnd, &pos) == FALSE) { - WARNING << Utils::getSystemErrorMessage(kClientToScreen); - break; - } - shouldShowSystemMenu = true; - nativeGlobalPos = {pos.x, pos.y}; - } - } break; - case WM_NCRBUTTONUP: - if (wParam == HTCAPTION) { - shouldShowSystemMenu = true; - nativeGlobalPos = getNativePosFromMouse(); - } - break; - case WM_SYSCOMMAND: { - const WPARAM filteredWParam = (wParam & 0xFFF0); - if ((filteredWParam == SC_KEYMENU) && (lParam == VK_SPACE)) { - shouldShowSystemMenu = true; - broughtByKeyboard = true; - nativeGlobalPos = getNativeGlobalPosFromKeyboard(); - } - } break; - case WM_KEYDOWN: - case WM_SYSKEYDOWN: { - const bool altPressed = ((wParam == VK_MENU) || (::GetKeyState(VK_MENU) < 0)); - const bool spacePressed = ((wParam == VK_SPACE) || (::GetKeyState(VK_SPACE) < 0)); - if (altPressed && spacePressed) { - shouldShowSystemMenu = true; - broughtByKeyboard = true; - nativeGlobalPos = getNativeGlobalPosFromKeyboard(); - } - } break; - default: - break; - } - if (shouldShowSystemMenu) { - std::ignore = Utils::showSystemMenu(windowId, nativeGlobalPos, broughtByKeyboard); - // QPA's internal code will handle system menu events separately, and its - // behavior is not what we would want to see because it doesn't know our - // window doesn't have any window frame now, so return early here to avoid - // entering Qt's own handling logic. - return FALSE; // Return 0 means we have handled this event. - } - Q_ASSERT(extraData->qtWindowProc); - if (extraData->qtWindowProc) { - // Hand over to Qt's original window proc function for events we are not - // interested in. - return ::CallWindowProcW(extraData->qtWindowProc, hWnd, uMsg, wParam, lParam); - } else { - return defaultWindowProcessing(); - } -} - -bool Utils::isWindowsVersionOrGreater(const WindowsVersion version) -{ - return doCompareWindowsVersion(WindowsVersions.at(static_cast(version))); -} - -bool Utils::isDwmCompositionEnabled() -{ - // DWM composition is always enabled and can't be disabled since Windows 8. - if (WindowsVersionHelper::isWin8OrGreater()) { - return true; - } - const auto resultFromRegistry = []() -> bool { - const RegistryKey registry(RegistryRootKey::CurrentUser, dwmRegistryKey()); - if (!registry.isValid()) { - return false; - } - const DWORD value = registry.value(kComposition).value_or(0); - return (value != 0); - }; - if (!API_DWM_AVAILABLE(DwmIsCompositionEnabled)) { - return resultFromRegistry(); - } - BOOL enabled = FALSE; - const HRESULT hr = API_CALL_FUNCTION(dwmapi, DwmIsCompositionEnabled, &enabled); - if (FAILED(hr)) { - WARNING << getSystemErrorMessageImpl(kDwmIsCompositionEnabled, hr); - return resultFromRegistry(); - } - return (enabled != FALSE); -} - -bool Utils::triggerFrameChange(const WId windowId) -{ - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - const auto hwnd = reinterpret_cast(windowId); - static constexpr const UINT swpFlags = (SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER); - if (::SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, swpFlags) == FALSE) { - WARNING << getSystemErrorMessage(kSetWindowPos); - return false; - } - static constexpr const UINT rdwFlags = (RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); - if (::RedrawWindow(hwnd, nullptr, nullptr, rdwFlags) == FALSE) { - WARNING << getSystemErrorMessage(kRedrawWindow); - return false; - } - return true; -} - -bool Utils::updateWindowFrameMargins(const WId windowId, const bool reset) -{ - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - if (!API_DWM_AVAILABLE(DwmExtendFrameIntoClientArea)) { - return false; - } - // We can't extend the window frame when DWM composition is disabled anyway. - // No need to try further in this case. - if (!isDwmCompositionEnabled()) { - return false; - } - const QObject *window = FramelessManagerPrivate::getWindow(windowId); - if (!window) { - return false; - } - const FramelessDataPtr data = FramelessManagerPrivate::getData(window); - if (!data) { - return false; - } - const UtilsWinExtraDataPtr extraData = tryGetExtraData(data, false); - Q_ASSERT(extraData); - if (!extraData) { - return false; - } - const auto margins = [&extraData, reset]() -> MARGINS { - // To make Mica/Mica Alt work for normal Win32 windows, we have to - // let the window frame extend to the whole window (or disable the - // redirection surface, but this will break GDI's rendering, so we - // can't do this, unfortunately), so we can't change the window frame - // margins in this case, otherwise Mica/Mica Alt will be broken. - if (extraData->mica) { - return {-1, -1, -1, -1}; - } - if (reset || isWindowFrameBorderVisible()) { - return {0, 0, 0, 0}; - } - return {1, 1, 1, 1}; - }(); - const auto hwnd = reinterpret_cast(windowId); - const HRESULT hr = API_CALL_FUNCTION(dwmapi, DwmExtendFrameIntoClientArea, hwnd, &margins); - if (FAILED(hr)) { - WARNING << getSystemErrorMessageImpl(kDwmExtendFrameIntoClientArea, hr); - return false; - } - return triggerFrameChange(windowId); -} - -bool Utils::updateInternalWindowFrameMargins(QWindow *window, const bool enable) -{ - Q_ASSERT(window); - if (!window) { - return false; - } - const WId windowId = window->winId(); - const auto margins = [enable, windowId]() -> QMargins { - if (!enable) { - return {}; - } - const int titleBarHeight = getTitleBarHeight(windowId, true); - if (isWindowFrameBorderVisible()) { - return {0, -titleBarHeight, 0, 0}; - } else { - const int frameSizeX = getResizeBorderThickness(windowId, true, true); - const int frameSizeY = getResizeBorderThickness(windowId, false, true); - return {-frameSizeX, -titleBarHeight, -frameSizeX, -frameSizeY}; - } - }(); - const QVariant marginsVar = QVariant::fromValue(margins); - window->setProperty(kQtWindowCustomMarginsVar, marginsVar); -#if FRAMELESSHELPER_CONFIG(private_qt) -# if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - if (QPlatformWindow *platformWindow = window->handle()) { - if (const auto ni = QGuiApplication::platformNativeInterface()) { - ni->setWindowProperty(platformWindow, qtWindowCustomMarginsProp(), marginsVar); - } else { - WARNING << "Failed to retrieve the platform native interface."; - return false; - } - } else { - WARNING << "Failed to retrieve the platform window."; - return false; - } -# else // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - if (const auto platformWindow = dynamic_cast(window->handle())) { - platformWindow->setCustomMargins(margins); - } else { - WARNING << "Failed to retrieve the platform window."; - return false; - } -# endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) -#endif // FRAMELESSHELPER_CONFIG(private_qt) - return triggerFrameChange(windowId); -} - -QString Utils::getSystemErrorMessage(const QString &function) -{ - Q_ASSERT(!function.isEmpty()); - if (function.isEmpty()) { - return {}; - } - const DWORD code = ::GetLastError(); - if (code == ERROR_SUCCESS) { - return kSuccessMessageText; - } - return getSystemErrorMessageImpl(function, code); -} - -QColor Utils::getDwmColorizationColor(bool *opaque, bool *ok) -{ - const auto resultFromRegistry = []() -> QColor { - const RegistryKey registry(RegistryRootKey::CurrentUser, dwmRegistryKey()); - if (!registry.isValid()) { - return kDefaultDarkGrayColor; - } - const QVariant value = registry.value(kColorizationColor); - if (!value.isValid()) { - return kDefaultDarkGrayColor; - } - return QColor::fromRgba(qvariant_cast(value)); - }; - if (!API_DWM_AVAILABLE(DwmGetColorizationColor)) { - if (ok) { - *ok = false; - } - return resultFromRegistry(); - } - DWORD color = 0; - BOOL bOpaque = FALSE; - const HRESULT hr = API_CALL_FUNCTION(dwmapi, DwmGetColorizationColor, &color, &bOpaque); - if (FAILED(hr)) { - WARNING << getSystemErrorMessageImpl(kDwmGetColorizationColor, hr); - if (ok) { - *ok = false; - } - return resultFromRegistry(); - } - if (opaque) { - *opaque = (bOpaque != FALSE); - } - if (ok) { - *ok = true; - } - return QColor::fromRgba(color); -} - -DwmColorizationArea Utils::getDwmColorizationArea() -{ - // It's a Win10 only feature. (TO BE VERIFIED) - if (!WindowsVersionHelper::isWin10OrGreater()) { - return DwmColorizationArea::None; - } - const RegistryKey themeRegistry(RegistryRootKey::CurrentUser, personalizeRegistryKey()); - const DWORD themeValue = themeRegistry.isValid() ? themeRegistry.value(dwmColorKeyName()).value_or(0) : 0; - const RegistryKey dwmRegistry(RegistryRootKey::CurrentUser, dwmRegistryKey()); - const DWORD dwmValue = dwmRegistry.isValid() ? dwmRegistry.value(dwmColorKeyName()).value_or(0) : 0; - const bool theme = (themeValue != 0); - const bool dwm = (dwmValue != 0); - if (theme && dwm) { - return DwmColorizationArea::All; - } else if (theme) { - return DwmColorizationArea::StartMenu_TaskBar_ActionCenter; - } else if (dwm) { - return DwmColorizationArea::TitleBar_WindowBorder; - } - return DwmColorizationArea::None; -} - -bool Utils::showSystemMenu(const WId windowId, const QPoint &pos, const bool selectFirstEntry) -{ - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - - const QObject *window = FramelessManagerPrivate::getWindow(windowId); - if (!window) { - return false; - } - const FramelessDataPtr data = FramelessManagerPrivate::getData(window); - if (!data || !data->frameless || !data->callbacks) { - return false; - } - - const auto hWnd = reinterpret_cast(windowId); - const HMENU hMenu = ::GetSystemMenu(hWnd, FALSE); - if (!hMenu) { - // The corresponding window doesn't have a system menu, most likely due to the - // lack of the "WS_SYSMENU" window style. This situation should not be treated - // as an error so just ignore it and return early. - return true; - } - - // Tweak the menu items according to the current window status and user settings. - const bool disableClose = data->callbacks->getProperty(kSysMenuDisableCloseVar, false).toBool(); - const bool disableRestore = data->callbacks->getProperty(kSysMenuDisableRestoreVar, false).toBool(); - const bool disableMinimize = data->callbacks->getProperty(kSysMenuDisableMinimizeVar, false).toBool(); - const bool disableMaximize = data->callbacks->getProperty(kSysMenuDisableMaximizeVar, false).toBool(); - const bool disableSize = data->callbacks->getProperty(kSysMenuDisableSizeVar, false).toBool(); - const bool disableMove = data->callbacks->getProperty(kSysMenuDisableMoveVar, false).toBool(); - const bool removeClose = data->callbacks->getProperty(kSysMenuRemoveCloseVar, false).toBool(); - const bool removeSeparator = data->callbacks->getProperty(kSysMenuRemoveSeparatorVar, false).toBool(); - const bool removeRestore = data->callbacks->getProperty(kSysMenuRemoveRestoreVar, false).toBool(); - const bool removeMinimize = data->callbacks->getProperty(kSysMenuRemoveMinimizeVar, false).toBool(); - const bool removeMaximize = data->callbacks->getProperty(kSysMenuRemoveMaximizeVar, false).toBool(); - const bool removeSize = data->callbacks->getProperty(kSysMenuRemoveSizeVar, false).toBool(); - const bool removeMove = data->callbacks->getProperty(kSysMenuRemoveMoveVar, false).toBool(); - const bool maxOrFull = (IsMaximized(hWnd) || isFullScreen(windowId)); - const bool fixedSize = data->callbacks->isWindowFixedSize(); - if (removeClose) { - if (::DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND) == FALSE) { - //WARNING << getSystemErrorMessage(kDeleteMenu); - } - } else { - ::EnableMenuItem(hMenu, SC_CLOSE, (MF_BYCOMMAND | (disableClose ? MFS_DISABLED : MFS_ENABLED))); - } - if (removeSeparator) { - // Looks like we must use 0 for the second parameter here, otherwise we can't remove the separator. - if (::DeleteMenu(hMenu, 0, MFT_SEPARATOR) == FALSE) { - //WARNING << getSystemErrorMessage(kDeleteMenu); - } - } - if (removeMaximize) { - if (::DeleteMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND) == FALSE) { - //WARNING << getSystemErrorMessage(kDeleteMenu); - } - } else { - ::EnableMenuItem(hMenu, SC_MAXIMIZE, (MF_BYCOMMAND | ((!maxOrFull && !fixedSize && !disableMaximize) ? MFS_ENABLED : MFS_DISABLED))); - } - if (removeRestore) { - if (::DeleteMenu(hMenu, SC_RESTORE, MF_BYCOMMAND) == FALSE) { - //WARNING << getSystemErrorMessage(kDeleteMenu); - } - } else { - ::EnableMenuItem(hMenu, SC_RESTORE, (MF_BYCOMMAND | ((maxOrFull && !fixedSize && !disableRestore) ? MFS_ENABLED : MFS_DISABLED))); - // The first menu item should be selected by default if the menu is brought - // up by keyboard. I don't know how to pre-select a menu item but it seems - // highlight can do the job. However, there's an annoying issue if we do - // this manually: the highlighted menu item is really only highlighted, - // not selected, so even if the mouse cursor hovers on other menu items - // or the user navigates to other menu items through keyboard, the original - // highlight bar will not move accordingly, the OS will generate another - // highlight bar to indicate the current selected menu item, which will make - // the menu look kind of weird. Currently I don't know how to fix this issue. - ::HiliteMenuItem(hWnd, hMenu, SC_RESTORE, (MF_BYCOMMAND | (selectFirstEntry ? MFS_HILITE : MFS_UNHILITE))); - } - if (removeMinimize) { - if (::DeleteMenu(hMenu, SC_MINIMIZE, MF_BYCOMMAND) == FALSE) { - //WARNING << getSystemErrorMessage(kDeleteMenu); - } - } else { - ::EnableMenuItem(hMenu, SC_MINIMIZE, (MF_BYCOMMAND | (disableMinimize ? MFS_DISABLED : MFS_ENABLED))); - } - if (removeSize) { - if (::DeleteMenu(hMenu, SC_SIZE, MF_BYCOMMAND) == FALSE) { - //WARNING << getSystemErrorMessage(kDeleteMenu); - } - } else { - ::EnableMenuItem(hMenu, SC_SIZE, (MF_BYCOMMAND | ((!maxOrFull && !fixedSize && !(disableSize || disableMinimize || disableMaximize)) ? MFS_ENABLED : MFS_DISABLED))); - } - if (removeMove) { - if (::DeleteMenu(hMenu, SC_MOVE, MF_BYCOMMAND) == FALSE) { - //WARNING << getSystemErrorMessage(kDeleteMenu); - } - } else { - ::EnableMenuItem(hMenu, SC_MOVE, (MF_BYCOMMAND | ((disableMove || maxOrFull) ? MFS_DISABLED : MFS_ENABLED))); - } - - // The default menu item will appear in bold font. There can only be one default - // menu item per menu at most. Set the item ID to "UINT_MAX" (or simply "-1") - // can clear the default item for the given menu. - std::optional defaultItemId = std::nullopt; - if (WindowsVersionHelper::isWin11OrGreater()) { - if (maxOrFull) { - if (!removeRestore) { - defaultItemId = SC_RESTORE; - } - } else { - if (!removeMaximize) { - defaultItemId = SC_MAXIMIZE; - } - } - } - if (!(defaultItemId.has_value() || removeClose)) { - defaultItemId = SC_CLOSE; - } - if (::SetMenuDefaultItem(hMenu, defaultItemId.value_or(UINT_MAX), FALSE) == FALSE) { - WARNING << getSystemErrorMessage(kSetMenuDefaultItem); - } - - if (::DrawMenuBar(hWnd) == FALSE) { - WARNING << getSystemErrorMessage(kDrawMenuBar); - } - - // Popup the system menu at the required position. - const int result = ::TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), pos.x(), pos.y(), 0, hWnd, nullptr); - - if (!removeRestore) { - // Unhighlight the first menu item after the popup menu is closed, otherwise it will keep - // highlighting until we unhighlight it manually. - ::HiliteMenuItem(hWnd, hMenu, SC_RESTORE, (MF_BYCOMMAND | MFS_UNHILITE)); - } - - if (result == FALSE) { - // The user canceled the menu, no need to continue. - return true; - } - - // Send the command that the user choses to the corresponding window. - if (::PostMessageW(hWnd, WM_SYSCOMMAND, result, 0) == FALSE) { - WARNING << getSystemErrorMessage(kPostMessageW); - return false; - } - - return true; -} - -bool Utils::isFullScreen(const WId windowId) -{ - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - const auto hwnd = reinterpret_cast(windowId); - RECT windowRect = {}; - if (::GetWindowRect(hwnd, &windowRect) == FALSE) { - WARNING << getSystemErrorMessage(kGetWindowRect); - return false; - } - const std::optional mi = getMonitorForWindow(hwnd); - if (!mi.has_value()) { - WARNING << "Failed to retrieve the window's monitor."; - return false; - } - // Compare to the full area of the screen, not the work area. - return (windowRect == mi.value().rcMonitor); -} - -bool Utils::isWindowNoState(const WId windowId) -{ - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - const auto hwnd = reinterpret_cast(windowId); -#if 0 - WINDOWPLACEMENT wp; - SecureZeroMemory(&wp, sizeof(wp)); - wp.length = sizeof(wp); // This line is important! Don't miss it! - if (::GetWindowPlacement(hwnd, &wp) == FALSE) { - WARNING << getSystemErrorMessage(kGetWindowPlacement); - return false; - } - return ((wp.showCmd == SW_NORMAL) || (wp.showCmd == SW_RESTORE)); -#else - ::SetLastError(ERROR_SUCCESS); - const auto style = static_cast(::GetWindowLongPtrW(hwnd, GWL_STYLE)); - if (style == 0) { - WARNING << getSystemErrorMessage(kGetWindowLongPtrW); - return false; - } - return (!(style & (WS_MINIMIZE | WS_MAXIMIZE))); -#endif -} - -bool Utils::syncWmPaintWithDwm() -{ - if (!(API_WINMM_AVAILABLE(timeGetDevCaps) - && API_WINMM_AVAILABLE(timeBeginPeriod) - && API_WINMM_AVAILABLE(timeEndPeriod) - && API_DWM_AVAILABLE(DwmGetCompositionTimingInfo))) { - return false; - } - // No need to sync with DWM if DWM composition is disabled. - if (!isDwmCompositionEnabled()) { - return false; - } - // Dirty hack to workaround the resize flicker caused by DWM. - LARGE_INTEGER freq = {}; - if (::QueryPerformanceFrequency(&freq) == FALSE) { - WARNING << getSystemErrorMessage(kQueryPerformanceFrequency); - return false; - } - _TIMECAPS tc = {}; - if (API_CALL_FUNCTION4(winmm, timeGetDevCaps, &tc, sizeof(tc)) != MMSYSERR_NOERROR) { - WARNING << "timeGetDevCaps() failed."; - return false; - } - const UINT ms_granularity = tc.wPeriodMin; - if (API_CALL_FUNCTION4(winmm, timeBeginPeriod, ms_granularity) != TIMERR_NOERROR) { - WARNING << "timeBeginPeriod() failed."; - return false; - } - LARGE_INTEGER now0 = {}; - if (::QueryPerformanceCounter(&now0) == FALSE) { - WARNING << getSystemErrorMessage(kQueryPerformanceCounter); - return false; - } - // ask DWM where the vertical blank falls - DWM_TIMING_INFO dti; - SecureZeroMemory(&dti, sizeof(dti)); - dti.cbSize = sizeof(dti); - const HRESULT hr = API_CALL_FUNCTION(dwmapi, DwmGetCompositionTimingInfo, nullptr, &dti); - if (FAILED(hr)) { - WARNING << getSystemErrorMessage(kDwmGetCompositionTimingInfo); - return false; - } - LARGE_INTEGER now1 = {}; - if (::QueryPerformanceCounter(&now1) == FALSE) { - WARNING << getSystemErrorMessage(kQueryPerformanceCounter); - return false; - } - // - DWM told us about SOME vertical blank - // - past or future, possibly many frames away - // - convert that into the NEXT vertical blank - const auto period = qreal(dti.qpcRefreshPeriod); - const auto dt = qreal(dti.qpcVBlank - now1.QuadPart); - const qreal ratio = (dt / period); - auto w = qreal(0); - auto m = qreal(0); - if ((dt > qreal(0)) || qFuzzyIsNull(dt)) { - w = ratio; - } else { - // reach back to previous period - // - so m represents consistent position within phase - w = (ratio - qreal(1)); - } - m = (dt - (period * w)); - //Q_ASSERT((m > qreal(0)) || qFuzzyIsNull(m)); - //Q_ASSERT(m < period); - if ((m < qreal(0)) || qFuzzyCompare(m, period) || (m > period)) { - return false; - } - const qreal m_ms = (qreal(1000) * m / qreal(freq.QuadPart)); - ::Sleep(static_cast(std::round(m_ms))); - if (API_CALL_FUNCTION4(winmm, timeEndPeriod, ms_granularity) != TIMERR_NOERROR) { - WARNING << "timeEndPeriod() failed."; - return false; - } - return true; -} - -bool Utils::isHighContrastModeEnabled() -{ - HIGHCONTRASTW hc; - SecureZeroMemory(&hc, sizeof(hc)); - hc.cbSize = sizeof(hc); - if (::SystemParametersInfoW(SPI_GETHIGHCONTRAST, sizeof(hc), &hc, FALSE) == FALSE) { - WARNING << getSystemErrorMessage(kSystemParametersInfoW); - return false; - } - return (hc.dwFlags & HCF_HIGHCONTRASTON); -} - -quint32 Utils::getPrimaryScreenDpi(const bool horizontal) -{ - // GetDesktopWindow(): The desktop window will always be in the primary monitor. - if (const HMONITOR hMonitor = MonitorFromWindow(GetDesktopWindow(), MONITOR_DEFAULTTOPRIMARY)) { - // GetDpiForMonitor() is only available on Windows 8 and onwards. - if (API_SHCORE_AVAILABLE(GetDpiForMonitor)) { - UINT dpiX = 0, dpiY = 0; - const HRESULT hr = API_CALL_FUNCTION4(shcore, GetDpiForMonitor, hMonitor, _MDT_EFFECTIVE_DPI, &dpiX, &dpiY); - if (SUCCEEDED(hr) && (dpiX > 0) && (dpiY > 0)) { - return (horizontal ? dpiX : dpiY); - } else { - WARNING << getSystemErrorMessageImpl(kGetDpiForMonitor, hr); - } - } - // GetScaleFactorForMonitor() is only available on Windows 8 and onwards. - if (API_SHCORE_AVAILABLE(GetScaleFactorForMonitor)) { - _DEVICE_SCALE_FACTOR factor = _DEVICE_SCALE_FACTOR_INVALID; - const HRESULT hr = API_CALL_FUNCTION4(shcore, GetScaleFactorForMonitor, hMonitor, &factor); - if (SUCCEEDED(hr) && (factor != _DEVICE_SCALE_FACTOR_INVALID)) { - return quint32(std::round(qreal(USER_DEFAULT_SCREEN_DPI) * qreal(factor) / qreal(100))); - } else { - WARNING << getSystemErrorMessageImpl(kGetScaleFactorForMonitor, hr); - } - } - // This solution is supported on Windows 2000 and onwards. - MONITORINFOEXW monitorInfo; - SecureZeroMemory(&monitorInfo, sizeof(monitorInfo)); - monitorInfo.cbSize = sizeof(monitorInfo); - if (::GetMonitorInfoW(hMonitor, &monitorInfo) != FALSE) { - if (const HDC hdc = ::CreateDCW(monitorInfo.szDevice, monitorInfo.szDevice, nullptr, nullptr)) { - bool valid = false; - const int dpiX = ::GetDeviceCaps(hdc, LOGPIXELSX); - const int dpiY = ::GetDeviceCaps(hdc, LOGPIXELSY); - if ((dpiX > 0) && (dpiY > 0)) { - valid = true; - } else { - WARNING << getSystemErrorMessage(kGetDeviceCaps); - } - if (::DeleteDC(hdc) == FALSE) { - WARNING << getSystemErrorMessage(kDeleteDC); - } - if (valid) { - return (horizontal ? dpiX : dpiY); - } - } else { - WARNING << getSystemErrorMessage(kCreateDCW); - } - } else { - WARNING << getSystemErrorMessage(kGetMonitorInfoW); - } - } else { - WARNING << getSystemErrorMessage(kMonitorFromWindow); - } - - // Using Direct2D to get the primary monitor's DPI is only available on Windows 7 - // and onwards, but it has been marked as deprecated by Microsoft. - if (API_D2D_AVAILABLE(D2D1CreateFactory)) { - using D2D1CreateFactoryPtr = HRESULT(WINAPI *)(D2D1_FACTORY_TYPE, REFIID, CONST D2D1_FACTORY_OPTIONS *, void **); - const auto pD2D1CreateFactory = reinterpret_cast(SysApiLoader::instance()->get(kd2d1, kD2D1CreateFactory)); - ID2D1Factory *d2dFactory = nullptr; - HRESULT hr = pD2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, __uuidof(ID2D1Factory), nullptr, reinterpret_cast(&d2dFactory)); - if (SUCCEEDED(hr)) { - // We want to get the newest system DPI, so refresh the system metrics - // manually to ensure that. - hr = d2dFactory->ReloadSystemMetrics(); - if (SUCCEEDED(hr)) { - FLOAT dpiX = FLOAT(0), dpiY = FLOAT(0); - QT_WARNING_PUSH - QT_WARNING_DISABLE_DEPRECATED - d2dFactory->GetDesktopDpi(&dpiX, &dpiY); - QT_WARNING_POP - if ((dpiX > FLOAT(0)) && (dpiY > FLOAT(0))) { - return (horizontal ? quint32(std::round(dpiX)) : quint32(std::round(dpiY))); - } else { - WARNING << "GetDesktopDpi() failed."; - } - } else { - WARNING << getSystemErrorMessageImpl(kReloadSystemMetrics, hr); - } - } else { - WARNING << getSystemErrorMessageImpl(kD2D1CreateFactory, hr); - } - if (d2dFactory) { - d2dFactory->Release(); - d2dFactory = nullptr; - } - } - - // Our last hope to get the DPI of the primary monitor, if all the above - // solutions failed, however, it won't happen in most cases. - if (const HDC hdc = ::GetDC(nullptr)) { - bool valid = false; - const int dpiX = ::GetDeviceCaps(hdc, LOGPIXELSX); - const int dpiY = ::GetDeviceCaps(hdc, LOGPIXELSY); - if ((dpiX > 0) && (dpiY > 0)) { - valid = true; - } else { - WARNING << getSystemErrorMessage(kGetDeviceCaps); - } - if (::ReleaseDC(nullptr, hdc) == 0) { - WARNING << getSystemErrorMessage(kReleaseDC); - } - if (valid) { - return (horizontal ? dpiX : dpiY); - } - } else { - WARNING << getSystemErrorMessage(kGetDC); - } - - // We should never go here, but let's make it extra safe. Just assume we - // are not scaled (96 DPI) if we really can't get the real DPI. - return USER_DEFAULT_SCREEN_DPI; -} - -quint32 Utils::getWindowDpi(const WId windowId, const bool horizontal) -{ - Q_ASSERT(windowId); - if (!windowId) { - return USER_DEFAULT_SCREEN_DPI; - } - const auto hwnd = reinterpret_cast(windowId); - { - if (const UINT dpi = _GetDpiForWindow2(hwnd)) { - return dpi; - } - // ERROR_CALL_NOT_IMPLEMENTED: the function is not available on - // current platform, not an error. - if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) { - WARNING << getSystemErrorMessage(kGetDpiForWindow); - } - } - if (API_USER_AVAILABLE(GetSystemDpiForProcess)) { - const HANDLE process = ::GetCurrentProcess(); - if (process) { - const UINT dpi = API_CALL_FUNCTION4(user32, GetSystemDpiForProcess, process); - if (dpi > 0) { - return dpi; - } else { - WARNING << getSystemErrorMessage(kGetSystemDpiForProcess); - } - } else { - WARNING << getSystemErrorMessage(kGetCurrentProcess); - } - } - if (API_USER_AVAILABLE(GetDpiForSystem)) { - const UINT dpi = API_CALL_FUNCTION4(user32, GetDpiForSystem); - if (dpi > 0) { - return dpi; - } else { - WARNING << getSystemErrorMessage(kGetDpiForSystem); - } - } - if (const HDC hdc = ::GetDC(hwnd)) { - bool valid = false; - const int dpiX = ::GetDeviceCaps(hdc, LOGPIXELSX); - const int dpiY = ::GetDeviceCaps(hdc, LOGPIXELSY); - if ((dpiX > 0) && (dpiY > 0)) { - valid = true; - } else { - WARNING << getSystemErrorMessage(kGetDeviceCaps); - } - if (::ReleaseDC(hwnd, hdc) == 0) { - WARNING << getSystemErrorMessage(kReleaseDC); - } - if (valid) { - return (horizontal ? dpiX : dpiY); - } - } else { - WARNING << getSystemErrorMessage(kGetDC); - } - return getPrimaryScreenDpi(horizontal); -} - -quint32 Utils::getResizeBorderThicknessForDpi(const bool horizontal, const quint32 dpi) -{ - Q_ASSERT(dpi != 0); - if (dpi == 0) { - return 0; - } - if (horizontal) { - return (getSystemMetrics2(SM_CXSIZEFRAME, true, dpi) + getSystemMetrics2(SM_CXPADDEDBORDER, true, dpi)); - } else { - return (getSystemMetrics2(SM_CYSIZEFRAME, false, dpi) + getSystemMetrics2(SM_CYPADDEDBORDER, false, dpi)); - } -} - -quint32 Utils::getResizeBorderThickness(const WId windowId, const bool horizontal, const bool scaled) -{ - Q_ASSERT(windowId); - if (!windowId) { - return 0; - } - if (horizontal) { - return (getSystemMetrics2(windowId, SM_CXSIZEFRAME, true, scaled) + getSystemMetrics2(windowId, SM_CXPADDEDBORDER, true, scaled)); - } else { - return (getSystemMetrics2(windowId, SM_CYSIZEFRAME, false, scaled) + getSystemMetrics2(windowId, SM_CYPADDEDBORDER, false, scaled)); - } -} - -quint32 Utils::getCaptionBarHeightForDpi(const quint32 dpi) -{ - Q_ASSERT(dpi != 0); - if (dpi == 0) { - return 0; - } - return getSystemMetrics2(SM_CYCAPTION, false, dpi); -} - -quint32 Utils::getCaptionBarHeight(const WId windowId, const bool scaled) -{ - Q_ASSERT(windowId); - if (!windowId) { - return 0; - } - return getSystemMetrics2(windowId, SM_CYCAPTION, false, scaled); -} - -quint32 Utils::getTitleBarHeightForDpi(const quint32 dpi) -{ - Q_ASSERT(dpi != 0); - if (dpi == 0) { - return 0; - } - return (getCaptionBarHeightForDpi(dpi) + getResizeBorderThicknessForDpi(false, dpi)); -} - -quint32 Utils::getTitleBarHeight(const WId windowId, const bool scaled) -{ - Q_ASSERT(windowId); - if (!windowId) { - return 0; - } - return (getCaptionBarHeight(windowId, scaled) + getResizeBorderThickness(windowId, false, scaled)); -} - -quint32 Utils::getFrameBorderThicknessForDpi(const quint32 dpi) -{ - Q_ASSERT(dpi != 0); - if (dpi == 0) { - return 0; - } - // There's no window frame border before Windows 10. - if (!WindowsVersionHelper::isWin10OrGreater()) { - return 0; - } - const qreal dpr = (qreal(dpi) / qreal(USER_DEFAULT_SCREEN_DPI)); - return std::round(qreal(kDefaultWindowFrameBorderThickness) * dpr); -} - -quint32 Utils::getFrameBorderThickness(const WId windowId, const bool scaled) -{ - Q_ASSERT(windowId); - if (!windowId) { - return 0; - } - // There's no window frame border before Windows 10. - if (!WindowsVersionHelper::isWin10OrGreater()) { - return 0; - } - if (!API_DWM_AVAILABLE(DwmGetWindowAttribute)) { - return 0; - } - const UINT dpi = getWindowDpi(windowId, true); - const qreal scaleFactor = (qreal(dpi) / qreal(USER_DEFAULT_SCREEN_DPI)); - const auto hwnd = reinterpret_cast(windowId); - UINT value = 0; - const HRESULT hr = API_CALL_FUNCTION(dwmapi, DwmGetWindowAttribute, hwnd, _DWMWA_VISIBLE_FRAME_BORDER_THICKNESS, &value, sizeof(value)); - if (SUCCEEDED(hr)) { - const qreal dpr = (scaled ? qreal(1) : scaleFactor); - return std::round(qreal(value) / dpr); - } else { - const qreal dpr = (scaled ? scaleFactor : qreal(1)); - return std::round(qreal(kDefaultWindowFrameBorderThickness) * dpr); - } -} - -QColor Utils::getFrameBorderColor(const bool active) -{ - // There's no window frame border before Windows 10. - // So we just return a default value which is based on most window managers. - if (!WindowsVersionHelper::isWin10OrGreater()) { - return (active ? kDefaultBlackColor : kDefaultDarkGrayColor); - } - const bool dark = (FramelessManager::instance()->systemTheme() == SystemTheme::Dark); - if (active) { - if (isFrameBorderColorized()) { - return getAccentColor(); - } - return (dark ? kDefaultFrameBorderActiveColorDark : kDefaultFrameBorderActiveColorLight); - } else { - return (dark ? kDefaultFrameBorderInactiveColorDark : kDefaultFrameBorderInactiveColorLight); - } -} - -bool Utils::maybeFixupQtInternals(const WId windowId) -{ - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - static const bool dont = (qEnvironmentVariableIntValue("FRAMELESSHELPER_WINDOWS_DONT_FIX_QT") != 0); - if (dont) { - return true; - } - const auto hwnd = reinterpret_cast(windowId); -#if 0 - ::SetLastError(ERROR_SUCCESS); - const auto classStyle = static_cast(::GetClassLongPtrW(hwnd, GCL_STYLE)); - if (classStyle != 0) { - // CS_HREDRAW/CS_VREDRAW will trigger a repaint event when the window size changes - // horizontally/vertically, which will cause flicker and jitter during window resizing, - // mostly for the applications which do all the painting by themselves (eg: Qt). - // So we remove these flags from the window class here. Qt by default won't add them - // but let's make it extra safe in case the user may add them by accident. - static constexpr const DWORD badClassStyle = (CS_HREDRAW | CS_VREDRAW); - if (classStyle & badClassStyle) { - ::SetLastError(ERROR_SUCCESS); - if (::SetClassLongPtrW(hwnd, GCL_STYLE, (classStyle & ~badClassStyle)) == 0) { - WARNING << getSystemErrorMessage(kSetClassLongPtrW); - return false; - } - } - } else { - WARNING << getSystemErrorMessage(kGetClassLongPtrW); - return false; - } -#endif - ::SetLastError(ERROR_SUCCESS); - const auto windowStyle = static_cast(::GetWindowLongPtrW(hwnd, GWL_STYLE)); - if (windowStyle == 0) { - WARNING << getSystemErrorMessage(kGetWindowLongPtrW); - return false; - } else { - // Qt by default adds the "WS_POPUP" flag to all Win32 windows it created and maintained, - // which is not a good thing (although it won't cause any obvious issues in most cases - // either), because popup windows have some different behavior with normal overlapped - // windows, for example, it will affect DWM's default policy. And Qt will also lack some - // necessary window styles in some cases (caused by misconfigured setWindowFlag(s) calls) - // and this will also break the normal functionalities for our windows, so we do the - // correction here unconditionally. - static constexpr const DWORD badWindowStyle = WS_POPUP; - static constexpr const DWORD goodWindowStyle = (WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); - if ((windowStyle & badWindowStyle) || !(windowStyle & goodWindowStyle)) { - ::SetLastError(ERROR_SUCCESS); - if (::SetWindowLongPtrW(hwnd, GWL_STYLE, ((windowStyle & ~badWindowStyle) | goodWindowStyle)) == 0) { - WARNING << getSystemErrorMessage(kSetWindowLongPtrW); - return false; - } - } - } - ::SetLastError(ERROR_SUCCESS); - const auto extendedWindowStyle = static_cast(::GetWindowLongPtrW(hwnd, GWL_EXSTYLE)); - if (extendedWindowStyle == 0) { - WARNING << getSystemErrorMessage(kGetWindowLongPtrW); - return false; - } else { - static constexpr const DWORD badWindowStyle = (WS_EX_OVERLAPPEDWINDOW | WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME | WS_EX_CONTEXTHELP); - static constexpr const DWORD goodWindowStyle = WS_EX_APPWINDOW; - if ((extendedWindowStyle & badWindowStyle) || !(extendedWindowStyle & goodWindowStyle)) { - ::SetLastError(ERROR_SUCCESS); - if (::SetWindowLongPtrW(hwnd, GWL_EXSTYLE, ((extendedWindowStyle & ~badWindowStyle) | goodWindowStyle)) == 0) { - WARNING << getSystemErrorMessage(kSetWindowLongPtrW); - return false; - } - } - } - return triggerFrameChange(windowId); -} - -bool Utils::startSystemMove(QWindow *window, const QPoint &globalPos) -{ - Q_UNUSED(globalPos); - Q_ASSERT(window); - if (!window) { - return false; - } -#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) - return window->startSystemMove(); -#else - if (::ReleaseCapture() == FALSE) { - WARNING << getSystemErrorMessage(kReleaseCapture); - return false; - } - const auto hwnd = reinterpret_cast(window->winId()); - if (::PostMessageW(hwnd, WM_SYSCOMMAND, SC_DRAGMOVE, 0) == FALSE) { - WARNING << getSystemErrorMessage(kPostMessageW); - return false; - } - return true; -#endif -} - -bool Utils::startSystemResize(QWindow *window, const Qt::Edges edges, const QPoint &globalPos) -{ - Q_UNUSED(globalPos); - Q_ASSERT(window); - if (!window) { - return false; - } - if (edges == Qt::Edges{}) { - return false; - } -#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) - return window->startSystemResize(edges); -#else - if (::ReleaseCapture() == FALSE) { - WARNING << getSystemErrorMessage(kReleaseCapture); - return false; - } - const auto hwnd = reinterpret_cast(window->winId()); - if (::PostMessageW(hwnd, WM_SYSCOMMAND, qtEdgesToWin32Orientation(edges), 0) == FALSE) { - WARNING << getSystemErrorMessage(kPostMessageW); - return false; - } - return true; -#endif -} - -bool Utils::isWindowFrameBorderVisible() -{ - static const auto result = []() -> bool { -#if FRAMELESSHELPER_CONFIG(native_impl) - const FramelessConfig * const config = FramelessConfig::instance(); - if (config->isSet(Option::ForceShowWindowFrameBorder)) { - return true; - } - if (config->isSet(Option::ForceHideWindowFrameBorder)) { - return false; - } - return WindowsVersionHelper::isWin10OrGreater(); -#else - return false; -#endif - }(); - return result; -} - -bool Utils::isTitleBarColorized() -{ - // CHECK: is it supported on win7? - if (!WindowsVersionHelper::isWin10OrGreater()) { - return false; - } - const DwmColorizationArea area = getDwmColorizationArea(); - return ((area == DwmColorizationArea::TitleBar_WindowBorder) || (area == DwmColorizationArea::All)); -} - -bool Utils::isFrameBorderColorized() -{ - return isTitleBarColorized(); -} - -bool Utils::installWindowProcHook(const WId windowId) -{ - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - const QObject *window = FramelessManagerPrivate::getWindow(windowId); - Q_ASSERT(window); - if (!window) { - return false; - } - const FramelessDataPtr data = FramelessManagerPrivate::getData(window); - Q_ASSERT(data); - if (!data || data->frameless) { - return false; - } - const UtilsWinExtraDataPtr extraData = tryGetExtraData(data, true); - Q_ASSERT(extraData); - if (!extraData) { - return false; - } - const auto hwnd = reinterpret_cast(windowId); - if (!extraData->qtWindowProc) { - ::SetLastError(ERROR_SUCCESS); - const auto qtWindowProc = reinterpret_cast(::GetWindowLongPtrW(hwnd, GWLP_WNDPROC)); - Q_ASSERT(qtWindowProc); - if (!qtWindowProc) { - WARNING << getSystemErrorMessage(kGetWindowLongPtrW); - return false; - } - extraData->qtWindowProc = qtWindowProc; - } - if (!extraData->windowProcHooked) { - ::SetLastError(ERROR_SUCCESS); - if (::SetWindowLongPtrW(hwnd, GWLP_WNDPROC, reinterpret_cast(FramelessHelperHookWindowProc)) == 0) { - WARNING << getSystemErrorMessage(kSetWindowLongPtrW); - return false; - } - extraData->windowProcHooked = true; - } - return true; -} - -bool Utils::uninstallWindowProcHook(const WId windowId) -{ - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - const QObject *window = FramelessManagerPrivate::getWindow(windowId); - if (!window) { - return false; - } - const FramelessDataPtr data = FramelessManagerPrivate::getData(window); - if (!data || !data->frameless) { - return false; - } - const UtilsWinExtraDataPtr extraData = tryGetExtraData(data, false); - if (!extraData || !extraData->windowProcHooked) { - return false; - } - Q_ASSERT(extraData->qtWindowProc); - if (!extraData->qtWindowProc) { - return false; - } - const auto hwnd = reinterpret_cast(windowId); - ::SetLastError(ERROR_SUCCESS); - if (::SetWindowLongPtrW(hwnd, GWLP_WNDPROC, reinterpret_cast(extraData->qtWindowProc)) == 0) { - WARNING << getSystemErrorMessage(kSetWindowLongPtrW); - return false; - } - extraData->qtWindowProc = nullptr; - extraData->windowProcHooked = false; - return true; -} - -bool Utils::setAeroSnappingEnabled(const WId windowId, const bool enable) -{ - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - const auto hwnd = reinterpret_cast(windowId); - ::SetLastError(ERROR_SUCCESS); - const auto oldWindowStyle = static_cast(::GetWindowLongPtrW(hwnd, GWL_STYLE)); - if (oldWindowStyle == 0) { - WARNING << getSystemErrorMessage(kGetWindowLongPtrW); - return false; - } - // The key is the existence of the "WS_THICKFRAME" flag. - // But we should also disallow window maximize if Aero Snapping is disabled. - static constexpr const DWORD resizableFlags = (WS_THICKFRAME | WS_MAXIMIZEBOX); - const auto newWindowStyle = [enable, oldWindowStyle]() -> DWORD { - if (enable) { - return ((oldWindowStyle & ~WS_POPUP) | resizableFlags); - } else { - return ((oldWindowStyle & ~resizableFlags) | WS_POPUP); - } - }(); - ::SetLastError(ERROR_SUCCESS); - if (::SetWindowLongPtrW(hwnd, GWL_STYLE, static_cast(newWindowStyle)) == 0) { - WARNING << getSystemErrorMessage(kSetWindowLongPtrW); - return false; - } - return triggerFrameChange(windowId); -} - -bool Utils::tryToEnableHighestDpiAwarenessLevel() -{ - bool isHighestAlready = false; - const DpiAwareness currentAwareness = getDpiAwarenessForCurrentProcess(&isHighestAlready); - DEBUG << "Current DPI awareness mode:" << currentAwareness; - if (isHighestAlready) { - return true; - } - if (API_USER_AVAILABLE(SetProcessDpiAwarenessContext)) { - const auto SetProcessDpiAwarenessContext2 = [](const _DPI_AWARENESS_CONTEXT context) -> bool { - Q_ASSERT(context); - if (!context) { - return false; - } - if (API_CALL_FUNCTION4(user32, SetProcessDpiAwarenessContext, context) != FALSE) { - return true; - } - const DWORD dwError = ::GetLastError(); - // "ERROR_ACCESS_DENIED" means set externally (mostly due to manifest file). - // Any attempt to change the DPI awareness mode through API will always fail, - // so we treat this situation as succeeded. - if (dwError == ERROR_ACCESS_DENIED) { - DEBUG << kDpiNoAccessErrorMessage; - return true; - } - WARNING << getSystemErrorMessageImpl(kSetProcessDpiAwarenessContext, dwError); - return false; - }; - if (currentAwareness == DpiAwareness::PerMonitorVersion2) { - return true; - } - if (SetProcessDpiAwarenessContext2(_DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2)) { - return true; - } - if (currentAwareness == DpiAwareness::PerMonitor) { - return true; - } - if (SetProcessDpiAwarenessContext2(_DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE)) { - return true; - } - if (currentAwareness == DpiAwareness::System) { - return true; - } - if (SetProcessDpiAwarenessContext2(_DPI_AWARENESS_CONTEXT_SYSTEM_AWARE)) { - return true; - } - if (currentAwareness == DpiAwareness::Unaware_GdiScaled) { - return true; - } - if (SetProcessDpiAwarenessContext2(_DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED)) { - return true; - } - } - if (API_SHCORE_AVAILABLE(SetProcessDpiAwareness)) { - const auto SetProcessDpiAwareness2 = [](const _PROCESS_DPI_AWARENESS pda) -> bool { - const HRESULT hr = API_CALL_FUNCTION4(shcore, SetProcessDpiAwareness, pda); - if (SUCCEEDED(hr)) { - return true; - } - // "E_ACCESSDENIED" means set externally (mostly due to manifest file). - // Any attempt to change the DPI awareness mode through API will always fail, - // so we treat this situation as succeeded. - if (hr == E_ACCESSDENIED) { - DEBUG << kDpiNoAccessErrorMessage; - return true; - } - WARNING << getSystemErrorMessageImpl(kSetProcessDpiAwareness, hr); - return false; - }; - if (currentAwareness == DpiAwareness::PerMonitorVersion2) { - return true; - } - if (SetProcessDpiAwareness2(_PROCESS_PER_MONITOR_V2_DPI_AWARE)) { - return true; - } - if (currentAwareness == DpiAwareness::PerMonitor) { - return true; - } - if (SetProcessDpiAwareness2(_PROCESS_PER_MONITOR_DPI_AWARE)) { - return true; - } - if (currentAwareness == DpiAwareness::System) { - return true; - } - if (SetProcessDpiAwareness2(_PROCESS_SYSTEM_DPI_AWARE)) { - return true; - } - if (currentAwareness == DpiAwareness::Unaware_GdiScaled) { - return true; - } - if (SetProcessDpiAwareness2(_PROCESS_DPI_UNAWARE_GDISCALED)) { - return true; - } - } - // Some really old MinGW SDK may lack this function, we workaround this - // issue by always load it dynamically at runtime. - if (API_USER_AVAILABLE(SetProcessDPIAware)) { - if (currentAwareness == DpiAwareness::System) { - return true; - } - if (API_CALL_FUNCTION4(user32, SetProcessDPIAware) != FALSE) { - return true; - } - WARNING << getSystemErrorMessage(kSetProcessDPIAware); - } - return false; -} - -bool Utils::updateGlobalWin32ControlsTheme(const WId windowId, const bool dark) -{ - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - // There's no global dark theme for common Win32 controls before Win10 1809. - if (!WindowsVersionHelper::isWin10RS5OrGreater()) { - return false; - } - if (!API_THEME_AVAILABLE(SetWindowTheme)) { - return false; - } - const auto hwnd = reinterpret_cast(windowId); - const HRESULT hr = API_CALL_FUNCTION(uxtheme, SetWindowTheme, hwnd, - (dark ? kSystemDarkThemeResourceName : kSystemLightThemeResourceName), nullptr); - if (FAILED(hr)) { - WARNING << getSystemErrorMessageImpl(kSetWindowTheme, hr); - return false; - } - return true; -} - -bool Utils::shouldAppsUseDarkMode_windows() -{ - // The global dark mode was first introduced in Windows 10 1607. - if (!WindowsVersionHelper::isWin10RS1OrGreater() || isHighContrastModeEnabled()) { - return false; - } -#if FRAMELESSHELPER_CONFIG(private_qt) -# if (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)) - if (const auto app = qApp->nativeInterface()) { - return app->isDarkMode(); - } else { - WARNING << "QWindowsApplication is not available."; - } -# elif (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) - if (const auto ni = QGuiApplication::platformNativeInterface()) { - return ni->property("darkMode").toBool(); - } else { - WARNING << "Failed to retrieve the platform native interface."; - } -# else // (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) - // Qt gained the ability to detect the system dark mode setting only since 5.15. - // We should detect it ourself on versions below that. -# endif // (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)) -#endif // FRAMELESSHELPER_CONFIG(private_qt) - // Starting from Windows 10 1903, "ShouldAppsUseDarkMode()" (exported by UXTHEME.DLL, - // ordinal number 132) always return "TRUE" (actually, a random non-zero number at - // runtime), so we can't use it due to this unreliability. In this case, we just simply - // read the user's setting from the registry instead, it's not elegant but at least - // it works well. - // However, reverse engineering of Win11's Task Manager reveals that Microsoft still - // uses this function internally to determine the system theme, and the Task Manager - // can correctly respond to the theme change event indeed. But strangely, I've checked - // that it's still broken on Win11 22H2. What's going on here? - if (WindowsVersionHelper::isWin10RS5OrGreater() - && !WindowsVersionHelper::isWin1019H1OrGreater()) { - return (_ShouldAppsUseDarkMode() != FALSE); - } - const auto resultFromRegistry = []() -> bool { - const RegistryKey registry(RegistryRootKey::CurrentUser, personalizeRegistryKey()); - if (!registry.isValid()) { - return false; - } - const DWORD value = registry.value(kAppsUseLightTheme).value_or(0); - return (value == 0); - }; - return resultFromRegistry(); -} - -bool Utils::setCornerStyleForWindow(const WId windowId, const WindowCornerStyle style) -{ - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - // We cannot change the window corner style until Windows 11. - if (!WindowsVersionHelper::isWin11OrGreater()) { - return false; - } - if (!API_DWM_AVAILABLE(DwmSetWindowAttribute)) { - return false; - } - const auto hwnd = reinterpret_cast(windowId); - const auto wcp = [style]() -> _DWM_WINDOW_CORNER_PREFERENCE { - switch (style) { - case WindowCornerStyle::Default: - return _DWMWCP_DEFAULT; - case WindowCornerStyle::Square: - return _DWMWCP_DONOTROUND; - case WindowCornerStyle::Round: - return _DWMWCP_ROUND; - } - QT_WARNING_PUSH - QT_WARNING_DISABLE_MSVC(4702) - Q_UNREACHABLE_RETURN(_DWMWCP_DEFAULT); - QT_WARNING_POP - }(); - const HRESULT hr = API_CALL_FUNCTION(dwmapi, DwmSetWindowAttribute, - hwnd, _DWMWA_WINDOW_CORNER_PREFERENCE, &wcp, sizeof(wcp)); - if (FAILED(hr)) { - WARNING << getSystemErrorMessageImpl(kDwmSetWindowAttribute, hr); - return false; - } - return true; -} - -bool Utils::setBlurBehindWindowEnabled(const WId windowId, const BlurMode mode, const QColor &color) -{ - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - const QObject *window = FramelessManagerPrivate::getWindow(windowId); - if (!window) { - return false; - } - const FramelessDataPtr data = FramelessManagerPrivate::getData(window); - if (!data) { - return false; - } - const UtilsWinExtraDataPtr extraData = tryGetExtraData(data, false); - // Don't assert here, the user may be using pure Qt solution. - if (!extraData) { - return false; - } - const auto hwnd = reinterpret_cast(windowId); - if (WindowsVersionHelper::isWin8OrGreater()) { - if (!(API_DWM_AVAILABLE(DwmSetWindowAttribute) - && API_DWM_AVAILABLE(DwmExtendFrameIntoClientArea))) { - WARNING << "Blur behind window is not available on current platform."; - return false; - } - const auto restoreWindowFrameMargins = [windowId, &extraData]() -> void { - extraData->mica = false; - std::ignore = updateWindowFrameMargins(windowId, false); - }; - static const auto userPreferredBlurMode = []() -> std::optional { - const QString option = qEnvironmentVariable("FRAMELESSHELPER_BLUR_MODE"); - if (option.isEmpty()) { - return std::nullopt; - } - if (option.contains(FRAMELESSHELPER_STRING_LITERAL("MICAALT"), Qt::CaseInsensitive)) { - return BlurMode::Windows_MicaAlt; - } - if (option.contains(FRAMELESSHELPER_STRING_LITERAL("MICA"), Qt::CaseInsensitive)) { - return BlurMode::Windows_Mica; - } - if (option.contains(FRAMELESSHELPER_STRING_LITERAL("ACRYLIC"), Qt::CaseInsensitive)) { - return BlurMode::Windows_Acrylic; - } - if (option.contains(FRAMELESSHELPER_STRING_LITERAL("AERO"), Qt::CaseInsensitive)) { - return BlurMode::Windows_Aero; - } - return std::nullopt; - }(); - static constexpr const auto kDefaultAcrylicOpacity = 0.8f; - static const auto acrylicOpacity = []() -> float { - const QString option = qEnvironmentVariable("FRAMELESSHELPER_ACRYLIC_OPACITY"); - if (option.isEmpty()) { - return kDefaultAcrylicOpacity; - } - bool ok = false; - const float num = option.toFloat(&ok); - if (ok && !qIsNaN(num) && (num > float(0)) && (num < float(1))) { - return num; - } - return kDefaultAcrylicOpacity; - }(); - static const bool preferMicaAlt = (qEnvironmentVariableIntValue("FRAMELESSHELPER_PREFER_MICA_ALT") != 0); - const auto recommendedBlurMode = [mode]() -> BlurMode { - if ((mode == BlurMode::Disable) || (mode == BlurMode::Windows_Aero)) { - return mode; - } - if (((mode == BlurMode::Windows_Mica) || (mode == BlurMode::Windows_MicaAlt)) - && !WindowsVersionHelper::isWin11OrGreater()) { - WARNING << "The Mica material is not supported on your system, fallback to the Acrylic blur instead..."; - if (WindowsVersionHelper::isWin10OrGreater()) { - return BlurMode::Windows_Acrylic; - } - WARNING << "The Acrylic blur is not supported on your system, fallback to the traditional DWM blur instead..."; - return BlurMode::Windows_Aero; - } - if ((mode == BlurMode::Windows_Acrylic) && !WindowsVersionHelper::isWin10OrGreater()) { - WARNING << "The Acrylic blur is not supported on your system, fallback to the traditional DWM blur instead..."; - return BlurMode::Windows_Aero; - } - if (mode == BlurMode::Default) { - if (WindowsVersionHelper::isWin11OrGreater()) { - return (preferMicaAlt ? BlurMode::Windows_MicaAlt : BlurMode::Windows_Mica); - } - if (WindowsVersionHelper::isWin10OrGreater()) { - return BlurMode::Windows_Acrylic; - } - return BlurMode::Windows_Aero; - } - QT_WARNING_PUSH - QT_WARNING_DISABLE_MSVC(4702) - Q_UNREACHABLE_RETURN(BlurMode::Default); - QT_WARNING_POP - }(); - const BlurMode blurMode = ((recommendedBlurMode == BlurMode::Disable) ? BlurMode::Disable : userPreferredBlurMode.value_or(recommendedBlurMode)); - if (blurMode == BlurMode::Disable) { - bool result = true; - if (WindowsVersionHelper::isWin1122H2OrGreater()) { - const _DWM_SYSTEMBACKDROP_TYPE dwmsbt = _DWMSBT_NONE; - const HRESULT hr = API_CALL_FUNCTION(dwmapi, DwmSetWindowAttribute, - hwnd, _DWMWA_SYSTEMBACKDROP_TYPE, &dwmsbt, sizeof(dwmsbt)); - if (FAILED(hr)) { - result = false; - WARNING << getSystemErrorMessageImpl(kDwmSetWindowAttribute, hr); - } - } else if (WindowsVersionHelper::isWin11OrGreater()) { - const BOOL enable = FALSE; - HRESULT hr = API_CALL_FUNCTION(dwmapi, DwmSetWindowAttribute, - hwnd, _DWMWA_MICA_EFFECT, &enable, sizeof(enable)); - if (FAILED(hr)) { - result = false; - WARNING << getSystemErrorMessageImpl(kDwmSetWindowAttribute, hr); - } - } else { - ACCENT_POLICY policy; - SecureZeroMemory(&policy, sizeof(policy)); - policy.dwAccentState = ACCENT_DISABLED; - policy.dwAccentFlags = ACCENT_NONE; - WINDOWCOMPOSITIONATTRIBDATA wcad; - SecureZeroMemory(&wcad, sizeof(wcad)); - wcad.Attrib = WCA_ACCENT_POLICY; - wcad.pvData = &policy; - wcad.cbData = sizeof(policy); - if (_SetWindowCompositionAttribute(hwnd, &wcad) == FALSE) { - result = false; - WARNING << getSystemErrorMessage(kSetWindowCompositionAttribute); - } - } - if (WindowsVersionHelper::isWin11OrGreater()) { - restoreWindowFrameMargins(); - } - return result; - } else { - if ((blurMode == BlurMode::Windows_Mica) || (blurMode == BlurMode::Windows_MicaAlt)) { - extraData->mica = true; - // By giving a negative value, DWM will extend the window frame into the whole - // client area. We need this step because the Mica material can only be applied - // to the non-client area of a window. Without this step, you'll get a window - // with a pure black background. - // Actually disabling the redirection surface (by enabling WS_EX_NOREDIRECTIONBITMAP - // when you call CreateWindow(), it won't have any effect if you set it after the - // window has been created) can achieve the same effect with extending the window - // frame, however, it will completely break GDI's rendering, so sadly we can't choose - // this solution. But this can be used if you can make sure your application don't - // use GDI at all, for example, you only use Direct3D to draw your window (like - // UWP/WPF applications). And one additional note, it will also break OpenGL and Vulkan - // due to they also use the legacy swap chain model. In theory you can try this flag - // for Qt Quick applications when the rhi backend is Direct3D, however, some elements - // will still be broken because Qt Quick still use GDI to render some native controls - // such as the window menu. - const MARGINS margins = {-1, -1, -1, -1}; - HRESULT hr = API_CALL_FUNCTION(dwmapi, DwmExtendFrameIntoClientArea, hwnd, &margins); - if (SUCCEEDED(hr)) { - if (WindowsVersionHelper::isWin1122H2OrGreater()) { - const auto dwmsbt = ( - ((blurMode == BlurMode::Windows_MicaAlt) || preferMicaAlt) - ? _DWMSBT_TABBEDWINDOW : _DWMSBT_MAINWINDOW); - hr = API_CALL_FUNCTION(dwmapi, DwmSetWindowAttribute, hwnd, - _DWMWA_SYSTEMBACKDROP_TYPE, &dwmsbt, sizeof(dwmsbt)); - if (SUCCEEDED(hr)) { - return true; - } else { - WARNING << getSystemErrorMessageImpl(kDwmSetWindowAttribute, hr); - } - } else { - const BOOL enable = TRUE; - hr = API_CALL_FUNCTION(dwmapi, DwmSetWindowAttribute, - hwnd, _DWMWA_MICA_EFFECT, &enable, sizeof(enable)); - if (SUCCEEDED(hr)) { - return true; - } else { - WARNING << getSystemErrorMessageImpl(kDwmSetWindowAttribute, hr); - } - } - } else { - WARNING << getSystemErrorMessageImpl(kDwmExtendFrameIntoClientArea, hr); - } - restoreWindowFrameMargins(); - } else { - ACCENT_POLICY policy; - SecureZeroMemory(&policy, sizeof(policy)); - if (blurMode == BlurMode::Windows_Acrylic) { - policy.dwAccentState = ACCENT_ENABLE_ACRYLICBLURBEHIND; - policy.dwAccentFlags = ACCENT_ENABLE_ACRYLIC_WITH_LUMINOSITY; - const auto gradientColor = [&color]() -> QColor { - if (color.isValid()) { - return color; - } - QColor clr = ((FramelessManager::instance()->systemTheme() == SystemTheme::Dark) ? kDefaultSystemDarkColor : kDefaultSystemLightColor); - clr.setAlphaF(acrylicOpacity); - return clr; - }(); - // This API expects the #AABBGGRR format. - policy.dwGradientColor = DWORD(qRgba(gradientColor.blue(), - gradientColor.green(), gradientColor.red(), gradientColor.alpha())); - } else if (blurMode == BlurMode::Windows_Aero) { - policy.dwAccentState = ACCENT_ENABLE_BLURBEHIND; - policy.dwAccentFlags = ACCENT_NONE; - } else { - QT_WARNING_PUSH - QT_WARNING_DISABLE_MSVC(4702) - Q_UNREACHABLE_RETURN(false); - QT_WARNING_POP - } - WINDOWCOMPOSITIONATTRIBDATA wcad; - SecureZeroMemory(&wcad, sizeof(wcad)); - wcad.Attrib = WCA_ACCENT_POLICY; - wcad.pvData = &policy; - wcad.cbData = sizeof(policy); - if (_SetWindowCompositionAttribute(hwnd, &wcad) != FALSE) { - if ((blurMode == BlurMode::Windows_Acrylic) - && !WindowsVersionHelper::isWin11OrGreater()) { - DEBUG << "Enabling the Acrylic blur for Win32 windows on Windows 10 " - "is very buggy. The only recommended way by Microsoft is to " - "use the XAML Island technology or use pure UWP instead. If " - "you find your window becomes very laggy during moving and " - "resizing, please disable the Acrylic blur immediately (or " - "disable the transparent effect in your personalize settings)."; - } - return true; - } - WARNING << getSystemErrorMessage(kSetWindowCompositionAttribute); - } - } - } else { - // We prefer to use "DwmEnableBlurBehindWindow" on Windows 7 because it behaves - // better than the undocumented API. - if (!API_DWM_AVAILABLE(DwmEnableBlurBehindWindow)) { - WARNING << "Blur behind window is not available on current platform."; - return false; - } - DWM_BLURBEHIND dwmbb; - SecureZeroMemory(&dwmbb, sizeof(dwmbb)); - dwmbb.dwFlags = DWM_BB_ENABLE; - dwmbb.fEnable = [mode]() -> BOOL { - if (mode == BlurMode::Disable) { - return FALSE; - } - if ((mode != BlurMode::Default) && (mode != BlurMode::Windows_Aero)) { - WARNING << "The only supported blur mode on Windows 7 is the traditional DWM blur."; - } - return TRUE; - }(); - const HRESULT hr = API_CALL_FUNCTION(dwmapi, DwmEnableBlurBehindWindow, hwnd, &dwmbb); - if (SUCCEEDED(hr)) { - return true; - } - WARNING << getSystemErrorMessageImpl(kDwmEnableBlurBehindWindow, hr); - } - return false; -} - -QColor Utils::getAccentColor_windows() -{ - // According to my experiments, this AccentColor will be exactly the same with - // ColorizationColor, what's the meaning of it? But Microsoft products - // usually read this setting instead of using DwmGetColorizationColor(), - // so we'd better also do the same thing. - // There's no Windows API to get this value, so we can only read it - // directly from the registry. - const QColor alternative = getDwmColorizationColor(); - const RegistryKey registry(RegistryRootKey::CurrentUser, dwmRegistryKey()); - if (!registry.isValid()) { - return alternative; - } - const QVariant value = registry.value(kAccentColor); - if (!value.isValid()) { - return alternative; - } - // The retrieved value is in the #AABBGGRR format, we need to - // convert it to the #AARRGGBB format which Qt expects. - const QColor abgr = QColor::fromRgba(qvariant_cast(value)); - if (!abgr.isValid()) { - return alternative; - } - return QColor(abgr.blue(), abgr.green(), abgr.red(), abgr.alpha()); -} - -QString Utils::getWallpaperFilePath() -{ - wchar_t path[MAX_PATH] = {}; - if (::SystemParametersInfoW(SPI_GETDESKWALLPAPER, MAX_PATH, path, FALSE) == FALSE) { - WARNING << getSystemErrorMessage(kSystemParametersInfoW); - return {}; - } - return QString::fromWCharArray(path); -} - -WallpaperAspectStyle Utils::getWallpaperAspectStyle() -{ - static constexpr const auto defaultStyle = WallpaperAspectStyle::Fill; - const RegistryKey registry(RegistryRootKey::CurrentUser, desktopRegistryKey()); - if (!registry.isValid()) { - return defaultStyle; - } - const DWORD wallpaperStyle = registry.value(kWallpaperStyle).value_or(0); - switch (wallpaperStyle) { - case 0: { - const DWORD tileWallpaper = registry.value(kTileWallpaper).value_or(0); - if (tileWallpaper != 0) { - return WallpaperAspectStyle::Tile; - } - return WallpaperAspectStyle::Center; - } - case 2: - return WallpaperAspectStyle::Stretch; // Ignore aspect ratio to fill. - case 6: - return WallpaperAspectStyle::Fit; // Keep aspect ratio to fill, but don't expand/crop. - case 10: - return WallpaperAspectStyle::Fill; // Keep aspect ratio to fill, expand/crop if necessary. - case 22: - return WallpaperAspectStyle::Span; // ??? - default: - return defaultStyle; - } -} - -bool Utils::isBlurBehindWindowSupported() -{ - static const auto result = []() -> bool { - if (FramelessConfig::instance()->isSet(Option::ForceNativeBackgroundBlur)) { - return true; - } - if (FramelessConfig::instance()->isSet(Option::ForceNonNativeBackgroundBlur)) { - return false; - } - // Enabling Mica on Win11 make it very hard to hide the original three caption buttons, - // and enabling Acrylic on Win10 makes the window very laggy during moving and resizing. - //return WindowsVersionHelper::isWin10OrGreater(); - return false; - }(); - return result; -} - -bool Utils::hideOriginalTitleBarElements(const WId windowId, const bool disable) -{ - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - const auto hwnd = reinterpret_cast(windowId); - static constexpr const DWORD validBits = (WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON | WTNCA_NOSYSMENU); - const DWORD mask = (disable ? validBits : 0); - const HRESULT hr = _SetWindowThemeNonClientAttributes(hwnd, mask, mask); - if (FAILED(hr)) { - WARNING << getSystemErrorMessageImpl(kSetWindowThemeAttribute, hr); - return false; - } - return true; -} - -bool Utils::setQtDarkModeAwareEnabled(const bool enable) -{ -#if FRAMELESSHELPER_CONFIG(private_qt) -# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - // We'll call QPA functions, so we have to ensure that the QGuiApplication - // instance has already been created and initialized, because the platform - // integration infrastructure is created and maintained by QGuiApplication. - if (!qGuiApp) { - return false; - } - using App = QNativeInterface::Private::QWindowsApplication; - if (const auto app = qApp->nativeInterface()) { - app->setDarkModeHandling([enable]() -> App::DarkModeHandling { - if (!enable) { - return {}; // Clear the flags. - } -# if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)) - // Enabling the DarkModeWindowFrames flag will save us the call of the - // DwmSetWindowAttribute function. Qt will adjust the non-client area - // (title bar & frame border) automatically. - // Enabling the DarkModeStyle flag will make Qt Widgets apply dark theme - // automatically when the system is in dark mode, but before Qt6.5 it's - // own dark theme is really broken, so don't use it before 6.5. - // There's no global dark theme for Qt Quick applications, so setting this - // flag has no effect for pure Qt Quick applications. - return {App::DarkModeWindowFrames | App::DarkModeStyle}; -# else // (QT_VERSION < QT_VERSION_CHECK(6, 5, 0)) \ - // Don't try to use the broken dark theme for Qt Widgets applications. \ - // For Qt Quick applications this is also enough. There's no global dark \ - // theme for them anyway. - return {App::DarkModeWindowFrames}; -# endif // (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)) - }()); - return true; - } else { - WARNING << "QWindowsApplication is not available."; - return false; - } -# else // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - Q_UNUSED(enable); - return true; -# endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) -#else // !FRAMELESSHELPER_CONFIG(private_qt) - Q_UNUSED(enable); - return true; -#endif // FRAMELESSHELPER_CONFIG(private_qt) -} - -bool Utils::registerThemeChangeNotification() -{ - // On Windows we don't need to subscribe to the theme change event - // manually. Windows will send the theme change notification to all - // top level windows by default. - return true; -} - -bool Utils::refreshWin32ThemeResources(const WId windowId, const bool dark) -{ - // Code learned from the following repositories. Thank very much for their great effort! - // https://github.com/ysc3839/win32-darkmode/blob/master/win32-darkmode/DarkMode.h - // https://github.com/TortoiseGit/TortoiseGit/blob/master/src/TortoiseGitBlame/MainFrm.cpp - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - // We have no way to adjust such things until Win10 1809. - if (!WindowsVersionHelper::isWin10RS5OrGreater()) { - return false; - } - if (!API_DWM_AVAILABLE(DwmSetWindowAttribute)) { - return false; - } - const auto hWnd = reinterpret_cast(windowId); - const DWORD borderFlag = (WindowsVersionHelper::isWin1020H1OrGreater() - ? _DWMWA_USE_IMMERSIVE_DARK_MODE : _DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1); - const BOOL darkFlag = (dark ? TRUE : FALSE); - WINDOWCOMPOSITIONATTRIBDATA wcad; - SecureZeroMemory(&wcad, sizeof(wcad)); - wcad.Attrib = WCA_USEDARKMODECOLORS; - wcad.pvData = const_cast(&darkFlag); - wcad.cbData = sizeof(darkFlag); - if (dark) { - if (_AllowDarkModeForWindow(hWnd, darkFlag) == FALSE) { - WARNING << getSystemErrorMessage(kAllowDarkModeForWindow); - } - if (WindowsVersionHelper::isWin1019H1OrGreater()) { - if (_SetWindowCompositionAttribute(hWnd, &wcad) == FALSE) { - WARNING << getSystemErrorMessage(kSetWindowCompositionAttribute); - } - } else { - if (::SetPropW(hWnd, kDarkModePropertyName, - reinterpret_cast(static_cast(darkFlag))) == FALSE) { - WARNING << getSystemErrorMessage(kSetPropW); - } - } - const HRESULT hr = API_CALL_FUNCTION(dwmapi, DwmSetWindowAttribute, hWnd, borderFlag, &darkFlag, sizeof(darkFlag)); - if (FAILED(hr)) { - WARNING << getSystemErrorMessageImpl(kDwmSetWindowAttribute, hr); - } - ::SetLastError(ERROR_SUCCESS); - _FlushMenuThemes(); - if (GetLastError() != ERROR_SUCCESS) { - WARNING << getSystemErrorMessage(kFlushMenuThemes); - } - ::SetLastError(ERROR_SUCCESS); - _RefreshImmersiveColorPolicyState(); - if (::GetLastError() != ERROR_SUCCESS) { - WARNING << getSystemErrorMessage(kRefreshImmersiveColorPolicyState); - } - } else { - if (_AllowDarkModeForWindow(hWnd, darkFlag) == FALSE) { - WARNING << getSystemErrorMessage(kAllowDarkModeForWindow); - } - if (WindowsVersionHelper::isWin1019H1OrGreater()) { - if (_SetWindowCompositionAttribute(hWnd, &wcad) == FALSE) { - WARNING << getSystemErrorMessage(kSetWindowCompositionAttribute); - } - } else { - if (::SetPropW(hWnd, kDarkModePropertyName, - reinterpret_cast(static_cast(darkFlag))) == FALSE) { - WARNING << getSystemErrorMessage(kSetPropW); - } - } - const HRESULT hr = API_CALL_FUNCTION(dwmapi, DwmSetWindowAttribute, hWnd, borderFlag, &darkFlag, sizeof(darkFlag)); - if (FAILED(hr)) { - WARNING << getSystemErrorMessageImpl(kDwmSetWindowAttribute, hr); - } - ::SetLastError(ERROR_SUCCESS); - _FlushMenuThemes(); - if (::GetLastError() != ERROR_SUCCESS) { - WARNING << getSystemErrorMessage(kFlushMenuThemes); - } - ::SetLastError(ERROR_SUCCESS); - _RefreshImmersiveColorPolicyState(); - if (::GetLastError() != ERROR_SUCCESS) { - WARNING << getSystemErrorMessage(kRefreshImmersiveColorPolicyState); - } - } - return true; -} - -bool Utils::enableNonClientAreaDpiScalingForWindow(const WId windowId) -{ - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - if (!API_USER_AVAILABLE(EnableNonClientDpiScaling)) { - return false; - } - // The PMv2 DPI awareness mode will take care of it for us. - if (getDpiAwarenessForCurrentProcess() == DpiAwareness::PerMonitorVersion2) { - return true; - } - const auto hwnd = reinterpret_cast(windowId); - if (API_CALL_FUNCTION4(user32, EnableNonClientDpiScaling, hwnd) == FALSE) { - WARNING << getSystemErrorMessage(kEnableNonClientDpiScaling); - return false; - } - return true; -} - -DpiAwareness Utils::getDpiAwarenessForCurrentProcess(bool *highest) -{ - if ((API_USER_AVAILABLE(GetDpiAwarenessContextForProcess) - || API_USER_AVAILABLE(GetThreadDpiAwarenessContext)) - && API_USER_AVAILABLE(AreDpiAwarenessContextsEqual) - && API_USER_AVAILABLE(GetAwarenessFromDpiAwarenessContext)) { - const auto context = []() -> _DPI_AWARENESS_CONTEXT { - if (API_USER_AVAILABLE(GetDpiAwarenessContextForProcess)) { - const HANDLE process = ::GetCurrentProcess(); - if (process) { - const _DPI_AWARENESS_CONTEXT result = API_CALL_FUNCTION4(user32, GetDpiAwarenessContextForProcess, process); - if (result) { - return result; - } - WARNING << getSystemErrorMessage(kGetDpiAwarenessContextForProcess); - } else { - WARNING << getSystemErrorMessage(kGetCurrentProcess); - } - } - const _DPI_AWARENESS_CONTEXT result = API_CALL_FUNCTION4(user32, GetThreadDpiAwarenessContext); - if (result) { - return result; - } - WARNING << getSystemErrorMessage(kGetThreadDpiAwarenessContext); - return nullptr; - }(); - if (!context) { - return DpiAwareness::Unknown; - } - auto result = DpiAwareness::Unknown; - // We have to use another API to compare PMv2 and GdiScaled because it seems the - // GetAwarenessFromDpiAwarenessContext() function won't give us these two values. - if (API_CALL_FUNCTION4(user32, AreDpiAwarenessContextsEqual, context, - _DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) != FALSE) { - result = DpiAwareness::PerMonitorVersion2; - } else if (API_CALL_FUNCTION4(user32, AreDpiAwarenessContextsEqual, context, - _DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED) != FALSE) { - result = DpiAwareness::Unaware_GdiScaled; - } else { - const _DPI_AWARENESS awareness = API_CALL_FUNCTION4(user32, GetAwarenessFromDpiAwarenessContext, context); - switch (awareness) { - case _DPI_AWARENESS_INVALID: - break; - case _DPI_AWARENESS_UNAWARE: - result = DpiAwareness::Unaware; - break; - case _DPI_AWARENESS_SYSTEM_AWARE: - result = DpiAwareness::System; - break; - case _DPI_AWARENESS_PER_MONITOR_AWARE: - result = DpiAwareness::PerMonitor; - break; - case _DPI_AWARENESS_PER_MONITOR_V2_AWARE: - result = DpiAwareness::PerMonitorVersion2; - break; - case _DPI_AWARENESS_UNAWARE_GDISCALED: - result = DpiAwareness::Unaware_GdiScaled; - break; - } - } - if (highest) { - *highest = (result == DpiAwareness::PerMonitorVersion2); - } - return result; - } - if (API_SHCORE_AVAILABLE(GetProcessDpiAwareness)) { - _PROCESS_DPI_AWARENESS pda = _PROCESS_DPI_UNAWARE; - const HRESULT hr = API_CALL_FUNCTION4(shcore, GetProcessDpiAwareness, nullptr, &pda); - if (FAILED(hr)) { - WARNING << getSystemErrorMessageImpl(kGetProcessDpiAwareness, hr); - return DpiAwareness::Unknown; - } - auto result = DpiAwareness::Unknown; - switch (pda) { - case _PROCESS_DPI_UNAWARE: - result = DpiAwareness::Unaware; - break; - case _PROCESS_SYSTEM_DPI_AWARE: - result = DpiAwareness::System; - break; - case _PROCESS_PER_MONITOR_DPI_AWARE: - result = DpiAwareness::PerMonitor; - break; - case _PROCESS_PER_MONITOR_V2_DPI_AWARE: - result = DpiAwareness::PerMonitorVersion2; - break; - case _PROCESS_DPI_UNAWARE_GDISCALED: - result = DpiAwareness::Unaware_GdiScaled; - break; - } - if (highest) { - *highest = (result == DpiAwareness::PerMonitor); - } - return result; - } - if (API_USER_AVAILABLE(IsProcessDPIAware)) { - const BOOL isAware = API_CALL_FUNCTION(user32, IsProcessDPIAware); - const auto result = ((isAware == FALSE) ? DpiAwareness::Unaware : DpiAwareness::System); - if (highest) { - *highest = (result == DpiAwareness::System); - } - return result; - } - return DpiAwareness::Unknown; -} - -bool Utils::fixupChildWindowsDpiMessage(const WId windowId) -{ - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - // This hack is only available on Windows 10 and newer, and starting from - // Win10 build 14986 it become useless due to the PMv2 DPI awareness mode - // already takes care of it for us. - if (!WindowsVersionHelper::isWin10OrGreater() - || (WindowsVersionHelper::isWin10RS2OrGreater() - && (getDpiAwarenessForCurrentProcess() == DpiAwareness::PerMonitorVersion2))) { - return true; - } - const auto hwnd = reinterpret_cast(windowId); - if (_EnableChildWindowDpiMessage2(hwnd, TRUE) != FALSE) { - return true; - } - // This API is not available on current platform, it's fine. - if (::GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) { - return true; - } - WARNING << getSystemErrorMessage(kEnableChildWindowDpiMessage); - return false; -} - -bool Utils::fixupDialogsDpiScaling() -{ - // This hack is only available on Windows 10 and newer, and starting from - // Win10 build 14986 it become useless due to the PMv2 DPI awareness mode - // already takes care of it for us. - if (!WindowsVersionHelper::isWin10OrGreater() - || (WindowsVersionHelper::isWin10RS2OrGreater() - && (getDpiAwarenessForCurrentProcess() == DpiAwareness::PerMonitorVersion2))) { - return true; - } - if (_EnablePerMonitorDialogScaling2() != FALSE) { - return true; - } - // This API is not available on current platform, it's fine. - if (::GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) { - return true; - } - WARNING << getSystemErrorMessage(kEnablePerMonitorDialogScaling); - return false; -} - -bool Utils::setDarkModeAllowedForApp(const bool allow) -{ - // This hack is only available since Win10 1809. - if (!WindowsVersionHelper::isWin10RS5OrGreater()) { - return false; - } - // This hack is necessary to let AllowDarkModeForWindow() work ... - if (WindowsVersionHelper::isWin1019H1OrGreater()) { - if (_SetPreferredAppMode(allow ? PAM_AUTO : PAM_DEFAULT) == PAM_MAX) { - WARNING << getSystemErrorMessage(kSetPreferredAppMode); - return false; - } - } else { - if (_AllowDarkModeForApp(allow ? TRUE : FALSE) == FALSE) { - WARNING << getSystemErrorMessage(kAllowDarkModeForApp); - return false; - } - } - return true; -} - -bool Utils::bringWindowToFront(const WId windowId) -{ - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - const auto hwnd = reinterpret_cast(windowId); - const HWND oldForegroundWindow = ::GetForegroundWindow(); - if (!oldForegroundWindow) { - // The foreground window can be NULL, it's not an API error. - return true; - } - const std::optional activeMonitor = getMonitorForWindow(oldForegroundWindow); - if (!activeMonitor.has_value()) { - WARNING << "Failed to retrieve the window's monitor."; - return false; - } - // We need to show the window first, otherwise we won't be able to bring it to front. - if (::IsWindowVisible(hwnd) == FALSE) { - ::ShowWindow(hwnd, SW_SHOW); - } - if (IsMinimized(hwnd)) { - // Restore the window if it is minimized. - ::ShowWindow(hwnd, SW_RESTORE); - // Once we've been restored, throw us on the active monitor. - // When the window is restored, it will always become the foreground window. - // So return early here, we don't need the following code to bring it to front. - return moveWindowToMonitor(hwnd, activeMonitor.value()); - } - // OK, our window is not minimized, so now we will try to bring it to front manually. - // First try to send a message to the current foreground window to check whether - // it is currently hanging or not. - static constexpr const UINT kTimeout = 1000; - if (::SendMessageTimeoutW(oldForegroundWindow, WM_NULL, 0, 0, - SMTO_BLOCK | SMTO_ABORTIFHUNG | SMTO_NOTIMEOUTIFNOTHUNG, kTimeout, nullptr) == 0) { - if (::GetLastError() == ERROR_TIMEOUT) { - WARNING << "The foreground window hangs, can't activate current window."; - } else { - WARNING << getSystemErrorMessage(kSendMessageTimeoutW); - } - return false; - } - const DWORD windowThreadProcessId = ::GetWindowThreadProcessId(oldForegroundWindow, nullptr); - const DWORD currentThreadId = ::GetCurrentThreadId(); - // We won't be able to change a window's Z order if it's not our own window, - // so we use this small technique to pretend the foreground window is ours. - if (::AttachThreadInput(windowThreadProcessId, currentThreadId, TRUE) == FALSE) { - WARNING << getSystemErrorMessage(kAttachThreadInput); - return false; - } - // And also don't forget to disconnect from it. - volatile const auto cleanup = qScopeGuard([windowThreadProcessId, currentThreadId]() -> void { - if (::AttachThreadInput(windowThreadProcessId, currentThreadId, FALSE) == FALSE) { - WARNING << getSystemErrorMessage(kAttachThreadInput); - } - }); - Q_UNUSED(cleanup); - // Make our window be the first one in the Z order. - if (::BringWindowToTop(hwnd) == FALSE) { - WARNING << getSystemErrorMessage(kBringWindowToTop); - return false; - } - // Activate the window too. This will force us to the virtual desktop this - // window is on, if it's on another virtual desktop. - if (::SetActiveWindow(hwnd) == nullptr) { - WARNING << getSystemErrorMessage(kSetActiveWindow); - return false; - } - // Throw us on the active monitor. - return moveWindowToMonitor(hwnd, activeMonitor.value()); -} - -QPoint Utils::getWindowPlacementOffset(const WId windowId) -{ - Q_ASSERT(windowId); - if (!windowId) { - return {}; - } - const auto hwnd = reinterpret_cast(windowId); - ::SetLastError(ERROR_SUCCESS); - const auto exStyle = static_cast(::GetWindowLongPtrW(hwnd, GWL_EXSTYLE)); - if (exStyle == 0) { - WARNING << getSystemErrorMessage(kGetWindowLongPtrW); - return {}; - } - // Tool windows are special and they don't need any offset. - if (exStyle & WS_EX_TOOLWINDOW) { - return {}; - } - const std::optional mi = getMonitorForWindow(hwnd); - if (!mi.has_value()) { - WARNING << "Failed to retrieve the window's monitor."; - return {}; - } - const RECT work = mi.value().rcWork; - const RECT total = mi.value().rcMonitor; - return {work.left - total.left, work.top - total.top}; -} - -QRect Utils::getWindowRestoreGeometry(const WId windowId) -{ - Q_ASSERT(windowId); - if (!windowId) { - return {}; - } - const auto hwnd = reinterpret_cast(windowId); - WINDOWPLACEMENT wp; - SecureZeroMemory(&wp, sizeof(wp)); - wp.length = sizeof(wp); - if (::GetWindowPlacement(hwnd, &wp) == FALSE) { - WARNING << getSystemErrorMessage(kGetWindowPlacement); - return {}; - } - return rect2qrect(wp.rcNormalPosition).translated(getWindowPlacementOffset(windowId)); -} - -quint64 Utils::getKeyState() -{ - quint64 result = 0; - const auto get = [](const int virtualKey) -> bool { - return (::GetAsyncKeyState(virtualKey) < 0); - }; - const bool buttonSwapped = (::GetSystemMetrics(SM_SWAPBUTTON) != FALSE); - if (get(VK_LBUTTON)) { - result |= (buttonSwapped ? MK_RBUTTON : MK_LBUTTON); - } - if (get(VK_RBUTTON)) { - result |= (buttonSwapped ? MK_LBUTTON : MK_RBUTTON); - } - if (get(VK_SHIFT)) { - result |= MK_SHIFT; - } - if (get(VK_CONTROL)) { - result |= MK_CONTROL; - } - if (get(VK_MBUTTON)) { - result |= MK_MBUTTON; - } - if (get(VK_XBUTTON1)) { - result |= MK_XBUTTON1; - } - if (get(VK_XBUTTON2)) { - result |= MK_XBUTTON2; - } - return result; -} - -bool Utils::isValidWindow(const WId windowId, const bool checkVisible, const bool checkTopLevel) -{ - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - const auto hwnd = reinterpret_cast(windowId); - if (::IsWindow(hwnd) == FALSE) { - return false; - } - const LONG_PTR styles = ::GetWindowLongPtrW(hwnd, GWL_STYLE); - if ((styles == 0) || (styles & WS_DISABLED)) { - return false; - } - const LONG_PTR exStyles = ::GetWindowLongPtrW(hwnd, GWL_EXSTYLE); - if ((exStyles == 0) || (exStyles & WS_EX_TOOLWINDOW)) { - return false; - } - RECT rect = { 0, 0, 0, 0 }; - if (::GetWindowRect(hwnd, &rect) == FALSE) { - return false; - } - if ((rect.left >= rect.right) || (rect.top >= rect.bottom)) { - return false; - } - if (checkVisible) { - if (::IsWindowVisible(hwnd) == FALSE) { - return false; - } - } - if (checkTopLevel) { - if (::GetAncestor(hwnd, GA_ROOT) != hwnd) { - return false; - } - } - return true; -} - -bool Utils::updateFramebufferTransparency(const WId windowId) -{ - Q_ASSERT(windowId); - if (!windowId) { - return false; - } - if (!API_DWM_AVAILABLE(DwmEnableBlurBehindWindow)) { - return false; - } - // DwmEnableBlurBehindWindow() won't be functional if DWM composition - // is not enabled, so we bail out early if this is the case. - if (!isDwmCompositionEnabled()) { - return false; - } - const auto hwnd = reinterpret_cast(windowId); - bool opaque = false; - bool ok = false; - std::ignore = getDwmColorizationColor(&opaque, &ok); - if (WindowsVersionHelper::isWin8OrGreater() || (ok && !opaque)) { - DWM_BLURBEHIND bb; - SecureZeroMemory(&bb, sizeof(bb)); - bb.dwFlags = (DWM_BB_ENABLE | DWM_BB_BLURREGION); - bb.hRgnBlur = ::CreateRectRgn(0, 0, -1, -1); - bb.fEnable = TRUE; - const HRESULT hr = API_CALL_FUNCTION(dwmapi, DwmEnableBlurBehindWindow, hwnd, &bb); - if (bb.hRgnBlur) { - if (::DeleteObject(bb.hRgnBlur) == FALSE) { - WARNING << getSystemErrorMessage(kDeleteObject); - } - } - if (FAILED(hr)) { - WARNING << getSystemErrorMessageImpl(kDwmEnableBlurBehindWindow, hr); - return false; - } - } else { - // HACK: Disable framebuffer transparency on Windows 7 when the - // colorization color is opaque, because otherwise the window - // contents is blended additively with the previous frame instead - // of replacing it - DWM_BLURBEHIND bb; - SecureZeroMemory(&bb, sizeof(bb)); - bb.dwFlags = DWM_BB_ENABLE; - bb.fEnable = FALSE; - const HRESULT hr = API_CALL_FUNCTION(dwmapi, DwmEnableBlurBehindWindow, hwnd, &bb); - if (FAILED(hr)) { - WARNING << getSystemErrorMessageImpl(kDwmEnableBlurBehindWindow, hr); - return false; - } - } - return true; -} - -QMargins Utils::getWindowSystemFrameMargins(const WId windowId) -{ - Q_ASSERT(windowId); - if (!windowId) { - return {}; - } - const auto horizontalMargin = int(getResizeBorderThickness(windowId, true, true)); - const auto verticalMargin = int(getResizeBorderThickness(windowId, false, true)); - return QMargins{ horizontalMargin, verticalMargin, horizontalMargin, verticalMargin }; -} - -QMargins Utils::getWindowCustomFrameMargins(const QWindow *window) -{ - Q_ASSERT(window); - if (!window) { - return {}; - } -#if FRAMELESSHELPER_CONFIG(private_qt) -# if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - if (QPlatformWindow *platformWindow = window->handle()) { - if (const auto ni = QGuiApplication::platformNativeInterface()) { - const QVariant marginsVar = ni->windowProperty(platformWindow, qtWindowCustomMarginsProp()); - if (marginsVar.isValid() && !marginsVar.isNull()) { - return qvariant_cast(marginsVar); - } - } else { - WARNING << "Failed to retrieve the platform native interface."; - } - } else { - WARNING << "Failed to retrieve the platform window."; - } -# else // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - if (const auto platformWindow = dynamic_cast(window->handle())) { - return platformWindow->customMargins(); - } else { - WARNING << "Failed to retrieve the platform window."; - } -# endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) -#endif // FRAMELESSHELPER_CONFIG(private_qt) - const QVariant marginsVar = window->property(kQtWindowCustomMarginsVar); - if (marginsVar.isValid() && !marginsVar.isNull()) { - return qvariant_cast(marginsVar); - } - return {}; -} - -bool Utils::updateAllDirectXSurfaces() -{ - if (!API_DWM_AVAILABLE(DwmFlush)) { - return false; - } - const HRESULT hr = API_CALL_FUNCTION(dwmapi, DwmFlush); - if (FAILED(hr)) { - WARNING << getSystemErrorMessageImpl(kDwmFlush, hr); - return false; - } - return true; -} - -void Utils::printWin32Message(void *msgPtr) -{ - Q_ASSERT(msgPtr); - if (!msgPtr) { - return; - } - const auto msg = static_cast(msgPtr); - const HWND hWnd = msg->hwnd; - const UINT uMsg = msg->message; - const WPARAM wParam = msg->wParam; - const LPARAM lParam = msg->lParam; - const QString messageCodeHex = FRAMELESSHELPER_STRING_LITERAL("0x") + QString::number(uMsg, 16).toUpper().rightJustified(4, u'0'); - QString text = {}; - QTextStream stream(&text, QIODevice::WriteOnly); - stream << "Windows message received: window handle: " << hwnd2str(hWnd) << ", message: "; - if (uMsg >= WM_APP) { - const UINT diff = (uMsg - WM_APP); - stream << "WM_APP + " << diff << " (" << messageCodeHex - << ") [private message owned by current application]"; - } else if (uMsg >= WM_USER) { - const UINT diff = (uMsg - WM_USER); - stream << "WM_USER + " << diff << " (" << messageCodeHex - << ") [private message owned by all kinds of controls]"; - } else { - const auto it = std::find(g_win32MessageMap.cbegin(), g_win32MessageMap.cend(), Win32Message{ uMsg, nullptr }); - if (it == g_win32MessageMap.cend()) { - stream << "UNKNOWN"; - } else { - stream << it->Str; - } - stream << " (" << messageCodeHex << ')'; - auto screenPos = POINT{ 0, 0 }; - auto clientPos = POINT{ 0, 0 }; - bool isNonClientMouseMessage = false; - if (isMouseMessage(uMsg, &isNonClientMouseMessage)) { - if (isNonClientMouseMessage) { - screenPos = [uMsg, lParam]() -> POINT { - if (uMsg == WM_NCMOUSELEAVE) { - const DWORD dwScreenPos = ::GetMessagePos(); - return POINT{ GET_X_LPARAM(dwScreenPos), GET_Y_LPARAM(dwScreenPos) }; - } else { - return POINT{ GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; - } - }(); - clientPos = screenPos; - if (::ScreenToClient(hWnd, &clientPos) == FALSE) { - WARNING << Utils::getSystemErrorMessage(kScreenToClient); - clientPos = {}; - } - } else { - if (uMsg == WM_MOUSELEAVE) { - const DWORD dwScreenPos = ::GetMessagePos(); - screenPos = POINT{ GET_X_LPARAM(dwScreenPos), GET_Y_LPARAM(dwScreenPos) }; - clientPos = screenPos; - if (::ScreenToClient(hWnd, &clientPos) == FALSE) { - WARNING << Utils::getSystemErrorMessage(kScreenToClient); - clientPos = {}; - } - } else { - clientPos = POINT{ GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; - screenPos = clientPos; - if (::ClientToScreen(hWnd, &screenPos) == FALSE) { - WARNING << Utils::getSystemErrorMessage(kClientToScreen); - screenPos = {}; - } - } - } - stream << ", screen coordinate: POINT(x: " << screenPos.x << ", y: " - << screenPos.y << "), client coordinate: POINT(x: " - << clientPos.x << ", y: " << clientPos.y << ')'; - } else { - stream << ", wParam: " << wParam << ", lParam: " << lParam; - } - } - DEBUG.noquote() << text; -} - -FRAMELESSHELPER_END_NAMESPACE - -#endif // Q_OS_WINDOWS diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/versionnumber_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/core/versionnumber_p.h deleted file mode 100644 index 5281dd98..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/versionnumber_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Core/private/versionnumber_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/windowborderpainter.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/core/windowborderpainter.cpp deleted file mode 100644 index 205ad37a..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/windowborderpainter.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "windowborderpainter.h" -#include "windowborderpainter_p.h" - -#if FRAMELESSHELPER_CONFIG(border_painter) - -#include "utils.h" -#include "framelessmanager.h" -#ifdef Q_OS_WINDOWS -# include "winverhelper_p.h" -#endif -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcWindowBorderPainter, "wangwenx190.framelesshelper.core.windowborderpainter") -# define INFO qCInfo(lcWindowBorderPainter) -# define DEBUG qCDebug(lcWindowBorderPainter) -# define WARNING qCWarning(lcWindowBorderPainter) -# define CRITICAL qCCritical(lcWindowBorderPainter) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -static constexpr const int kMaximumBorderThickness = 100; - -WindowBorderPainterPrivate::WindowBorderPainterPrivate(WindowBorderPainter *q) : QObject(q) -{ - Q_ASSERT(q); - if (!q) { - return; - } - q_ptr = q; -} - -WindowBorderPainterPrivate::~WindowBorderPainterPrivate() = default; - -WindowBorderPainterPrivate *WindowBorderPainterPrivate::get(WindowBorderPainter *q) -{ - Q_ASSERT(q); - if (!q) { - return nullptr; - } - return q->d_func(); -} - -const WindowBorderPainterPrivate *WindowBorderPainterPrivate::get(const WindowBorderPainter *q) -{ - Q_ASSERT(q); - if (!q) { - return nullptr; - } - return q->d_func(); -} - -WindowBorderPainter::WindowBorderPainter(QObject *parent) - : QObject(parent), d_ptr(std::make_unique(this)) -{ - connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged, this, &WindowBorderPainter::nativeBorderChanged); - connect(this, &WindowBorderPainter::nativeBorderChanged, this, &WindowBorderPainter::shouldRepaint); -} - -WindowBorderPainter::~WindowBorderPainter() = default; - -int WindowBorderPainter::thickness() const -{ - Q_D(const WindowBorderPainter); - return d->thickness.value_or(nativeThickness()); -} - -WindowEdges WindowBorderPainter::edges() const -{ - Q_D(const WindowBorderPainter); - return d->edges.value_or(nativeEdges()); -} - -QColor WindowBorderPainter::activeColor() const -{ - Q_D(const WindowBorderPainter); - return d->activeColor.value_or(nativeActiveColor()); -} - -QColor WindowBorderPainter::inactiveColor() const -{ - Q_D(const WindowBorderPainter); - return d->inactiveColor.value_or(nativeInactiveColor()); -} - -int WindowBorderPainter::nativeThickness() const -{ -#ifdef Q_OS_WINDOWS - // Qt will scale it to the appropriate value for us automatically, - // based on the current system DPI and scale factor rounding policy. - return kDefaultWindowFrameBorderThickness; -#else - return 0; -#endif -} - -WindowEdges WindowBorderPainter::nativeEdges() const -{ -#ifdef Q_OS_WINDOWS - if (Utils::isWindowFrameBorderVisible() && !WindowsVersionHelper::isWin11OrGreater()) { - return { WindowEdge::Top }; - } -#endif - return {}; -} - -QColor WindowBorderPainter::nativeActiveColor() const -{ - return Utils::getFrameBorderColor(true); -} - -QColor WindowBorderPainter::nativeInactiveColor() const -{ - return Utils::getFrameBorderColor(false); -} - -void WindowBorderPainter::paint(QPainter *painter, const QSize &size, const bool active) -{ - Q_ASSERT(painter); - Q_ASSERT(!size.isEmpty()); - if (!painter || size.isEmpty()) { - return; - } - Q_D(WindowBorderPainter); -#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - QList lines = {}; -#else - QVector lines = {}; -#endif - static constexpr const auto gap = qreal(0.5); - const auto leftTop = QPointF{ gap, gap }; - const auto rightTop = QPointF{ qreal(size.width()) - gap, leftTop.y() }; - const auto rightBottom = QPointF{ rightTop.x(), qreal(size.height()) - gap }; - const auto leftBottom = QPointF{ leftTop.x(), rightBottom.y() }; - const WindowEdges edges = d->edges.value_or(nativeEdges()); - if (edges & WindowEdge::Left) { - lines.append({leftBottom, leftTop}); - } - if (edges & WindowEdge::Top) { - lines.append({leftTop, rightTop}); - } - if (edges & WindowEdge::Right) { - lines.append({rightTop, rightBottom}); - } - if (edges & WindowEdge::Bottom) { - lines.append({rightBottom, leftBottom}); - } - if (lines.isEmpty()) { - return; - } - painter->save(); - painter->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); - QPen pen = {}; - pen.setColor([this, d, active]() -> QColor { - QColor color = {}; - if (active) { - color = d->activeColor.value_or(nativeActiveColor()); - } else { - color = d->inactiveColor.value_or(nativeInactiveColor()); - } - if (color.isValid()) { - return color; - } - return (active ? kDefaultBlackColor : kDefaultDarkGrayColor); - }()); - pen.setWidth(d->thickness.value_or(nativeThickness())); - painter->setPen(pen); - painter->drawLines(lines); - painter->restore(); -} - -void WindowBorderPainter::setThickness(const int value) -{ - Q_ASSERT(value >= 0); - Q_ASSERT(value < kMaximumBorderThickness); - if ((value < 0) || (value >= kMaximumBorderThickness)) { - return; - } - if (thickness() == value) { - return; - } - Q_D(WindowBorderPainter); - d->thickness = value; - Q_EMIT thicknessChanged(); - Q_EMIT shouldRepaint(); -} - -void WindowBorderPainter::setEdges(const Global::WindowEdges value) -{ - if (edges() == value) { - return; - } - Q_D(WindowBorderPainter); - d->edges = value; - Q_EMIT edgesChanged(); - Q_EMIT shouldRepaint(); -} - -void WindowBorderPainter::setActiveColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - if (activeColor() == value) { - return; - } - Q_D(WindowBorderPainter); - d->activeColor = value; - Q_EMIT activeColorChanged(); - Q_EMIT shouldRepaint(); -} - -void WindowBorderPainter::setInactiveColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - if (inactiveColor() == value) { - return; - } - Q_D(WindowBorderPainter); - d->inactiveColor = value; - Q_EMIT inactiveColorChanged(); - Q_EMIT shouldRepaint(); -} - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/windowborderpainter.h b/src/SARibbonBar/3rdparty/framelesshelper/src/core/windowborderpainter.h deleted file mode 100644 index 060e9c72..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/windowborderpainter.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Core/windowborderpainter.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/windowborderpainter_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/core/windowborderpainter_p.h deleted file mode 100644 index 3e0bdc75..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/windowborderpainter_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Core/private/windowborderpainter_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/winverhelper.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/core/winverhelper.cpp deleted file mode 100644 index dbee1ea5..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/winverhelper.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "winverhelper_p.h" - -#ifdef Q_OS_WINDOWS - -#include "utils.h" -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -using namespace Global; - -class WinVerHelper -{ - FRAMELESSHELPER_CLASS(WinVerHelper) - -public: - explicit WinVerHelper(); - ~WinVerHelper(); - - [[nodiscard]] bool check(const WindowsVersion version) const; - -private: - void initialize(); - -private: - std::array(WindowsVersion::Latest) + 1> m_flags = {}; -}; - -WinVerHelper::WinVerHelper() -{ - initialize(); -} - -WinVerHelper::~WinVerHelper() = default; - -bool WinVerHelper::check(const WindowsVersion version) const -{ - return m_flags.at(static_cast(version)); -} - -void WinVerHelper::initialize() -{ - const auto fill = [this](const int no) -> void { - static const auto size = int(std::size(m_flags)); - if ((no <= 0) || (no >= size)) { - return; - } - for (int i = 0; i != size; ++i) { - m_flags.at(i) = (i <= no); - } - }; -#define ELIF(Version) \ - else if (Utils::isWindowsVersionOrGreater(WindowsVersion::_##Version)) { \ - fill(static_cast(WindowsVersion::_##Version)); \ - } - if (false) { /* Dummy */ } - ELIF(11_22H2) - ELIF(11_21H2) - ELIF(10_22H2) - ELIF(10_21H2) - ELIF(10_21H1) - ELIF(10_20H2) - ELIF(10_2004) - ELIF(10_1909) - ELIF(10_1903) - ELIF(10_1809) - ELIF(10_1803) - ELIF(10_1709) - ELIF(10_1703) - ELIF(10_1607) - ELIF(10_1511) - ELIF(10_1507) - ELIF(8_1_Update1) - ELIF(8_1) - ELIF(8) - ELIF(7_SP1) - ELIF(7) - ELIF(Vista_SP2) - ELIF(Vista_SP1) - ELIF(Vista) - ELIF(XP_64) - ELIF(XP) - ELIF(2000) - else { /* Dummy */ } -#undef ELIF -} - -Q_GLOBAL_STATIC(WinVerHelper, g_winVerHelper) - -#define IMPL(Name, Version) \ - bool WindowsVersionHelper::isWin##Name##OrGreater() \ - { \ - static const bool result = g_winVerHelper()->check(WindowsVersion::_##Version); \ - return result; \ - } - -IMPL(2K, 2000) -IMPL(XP, XP) -IMPL(XP64, XP_64) -IMPL(Vista, Vista) -IMPL(VistaSP1, Vista_SP1) -IMPL(VistaSP2, Vista_SP2) -IMPL(7, 7) -IMPL(7SP1, 7_SP1) -IMPL(8, 8) -IMPL(8Point1, 8_1) -IMPL(8Point1Update1, 8_1_Update1) -IMPL(10, 10) -IMPL(10TH1, 10_1507) -IMPL(10TH2, 10_1511) -IMPL(10RS1, 10_1607) -IMPL(10RS2, 10_1703) -IMPL(10RS3, 10_1709) -IMPL(10RS4, 10_1803) -IMPL(10RS5, 10_1809) -IMPL(1019H1, 10_1903) -IMPL(1019H2, 10_1909) -IMPL(1020H1, 10_2004) -IMPL(1020H2, 10_20H2) -IMPL(1021H1, 10_21H1) -IMPL(1021H2, 10_21H2) -IMPL(1022H2, 10_22H2) -IMPL(11, 11) -IMPL(1121H2, 11_21H2) -IMPL(1122H2, 11_22H2) - -#undef IMPL - -FRAMELESSHELPER_END_NAMESPACE - -#endif // Q_OS_WINDOWS diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/core/winverhelper_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/core/winverhelper_p.h deleted file mode 100644 index 478c775e..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/core/winverhelper_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Core/private/winverhelper_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/CMakeLists.txt b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/CMakeLists.txt deleted file mode 100644 index 71f3f9f5..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/CMakeLists.txt +++ /dev/null @@ -1,301 +0,0 @@ -#[[ - MIT License - - Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -]] - -if(FRAMELESSHELPER_ENABLE_UNIVERSAL_BUILD) - set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE) -endif() - -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS QuickTemplates2 QuickControls2) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS QuickTemplates2 QuickControls2) - -set(SUB_MODULE Quick) -set(SUB_MODULE_FULL_NAME ${PROJECT_NAME}${SUB_MODULE}) -set(SUB_MODULE_TARGET ${SUB_MODULE_FULL_NAME}) -set(SUB_MODULE_PATH ${PROJECT_NAME}/${SUB_MODULE}) - -set(INCLUDE_PREFIX ../../include/${SUB_MODULE_PATH}) - -set(PUBLIC_HEADERS - ${INCLUDE_PREFIX}/framelesshelperquick_global.h - ${INCLUDE_PREFIX}/framelessquickmodule.h - ${INCLUDE_PREFIX}/framelessquickhelper.h - ${INCLUDE_PREFIX}/framelessquickutils.h -) - -set(PUBLIC_HEADERS_ALIAS - ${INCLUDE_PREFIX}/Global - ${INCLUDE_PREFIX}/FramelessQuickModule - ${INCLUDE_PREFIX}/FramelessQuickHelper - ${INCLUDE_PREFIX}/FramelessQuickUtils -) - -set(PRIVATE_HEADERS - ${INCLUDE_PREFIX}/private/framelessquickhelper_p.h - ${INCLUDE_PREFIX}/private/quickimageitem_p.h -) - -set(SOURCES - framelessquickutils.cpp - framelessquickhelper.cpp - framelesshelperquick_global.cpp - quickimageitem.cpp -) - -if(NOT FRAMELESSHELPER_NO_SYSTEM_BUTTON) - list(APPEND PRIVATE_HEADERS ${INCLUDE_PREFIX}/private/quickstandardsystembutton_p.h) - list(APPEND SOURCES quickstandardsystembutton.cpp) -endif() - -if(NOT FRAMELESSHELPER_NO_TITLEBAR) - list(APPEND PUBLIC_HEADERS ${INCLUDE_PREFIX}/quickchromepalette.h) - list(APPEND PUBLIC_HEADERS_ALIAS ${INCLUDE_PREFIX}/QuickChromePalette) - list(APPEND PRIVATE_HEADERS ${INCLUDE_PREFIX}/private/quickstandardtitlebar_p.h) - list(APPEND SOURCES quickchromepalette.cpp quickstandardtitlebar.cpp) -endif() - -if(NOT FRAMELESSHELPER_NO_WINDOW) - list(APPEND PRIVATE_HEADERS - ${INCLUDE_PREFIX}/private/framelessquickwindow_p.h - ${INCLUDE_PREFIX}/private/framelessquickwindow_p_p.h - ${INCLUDE_PREFIX}/private/framelessquickapplicationwindow_p.h - ${INCLUDE_PREFIX}/private/framelessquickapplicationwindow_p_p.h - ) - list(APPEND SOURCES framelessquickwindow.cpp framelessquickapplicationwindow.cpp) -endif() - -if(NOT FRAMELESSHELPER_NO_MICA_MATERIAL) - list(APPEND PUBLIC_HEADERS ${INCLUDE_PREFIX}/quickmicamaterial.h) - list(APPEND PUBLIC_HEADERS_ALIAS ${INCLUDE_PREFIX}/QuickMicaMaterial) - list(APPEND PRIVATE_HEADERS ${INCLUDE_PREFIX}/private/quickmicamaterial_p.h) - list(APPEND SOURCES quickmicamaterial.cpp) -endif() - -if(NOT FRAMELESSHELPER_NO_BORDER_PAINTER) - list(APPEND PUBLIC_HEADERS ${INCLUDE_PREFIX}/quickwindowborder.h) - list(APPEND PUBLIC_HEADERS_ALIAS ${INCLUDE_PREFIX}/QuickWindowBorder) - list(APPEND PRIVATE_HEADERS ${INCLUDE_PREFIX}/private/quickwindowborder_p.h) - list(APPEND SOURCES quickwindowborder.cpp) -endif() - -if(WIN32 AND NOT FRAMELESSHELPER_BUILD_STATIC) - set(__rc_path "${CMAKE_CURRENT_BINARY_DIR}/${SUB_MODULE_FULL_NAME}.rc") - if(NOT EXISTS "${__rc_path}") - generate_win32_rc_file( - PATH "${__rc_path}" - VERSION "${PROJECT_VERSION}" - COMPANY "wangwenx190" - DESCRIPTION "${PROJECT_NAME} ${SUB_MODULE} Module" - COPYRIGHT "MIT License" - ORIGINAL_FILENAME "${SUB_MODULE_FULL_NAME}.dll" - PRODUCT "${PROJECT_NAME}" - COMMENTS "Who don't love Raiden Shogun ?" - LIBRARY - ) - endif() - list(APPEND SOURCES "${__rc_path}") -endif() - -set(ALL_SOURCES ${PUBLIC_HEADERS} ${PRIVATE_HEADERS} ${SOURCES}) - -if(FRAMELESSHELPER_BUILD_STATIC) - set(SUB_MOD_LIB_TYPE "STATIC") -else() - set(SUB_MOD_LIB_TYPE "SHARED") -endif() -add_library(${SUB_MODULE_TARGET} ${SUB_MOD_LIB_TYPE} ${ALL_SOURCES}) -add_library(${PROJECT_NAME}::${SUB_MODULE} ALIAS ${SUB_MODULE_TARGET}) -add_library(${PROJECT_NAME}::${SUB_MODULE_FULL_NAME} ALIAS ${SUB_MODULE_TARGET}) - -set_target_properties(${SUB_MODULE_TARGET} PROPERTIES - VERSION "${PROJECT_VERSION}" - SOVERSION "${PROJECT_VERSION_MAJOR}" - OUTPUT_NAME "${SUB_MODULE_TARGET}${FRAMELESSHELPER_64BIT_POSTFIX}" -) - -set(__export_targets ${SUB_MODULE_TARGET}) - -set(__import_base_dir "${PROJECT_BINARY_DIR}/imports") -if(DEFINED FRAMELESSHELPER_IMPORT_DIR) - set(__import_base_dir "${FRAMELESSHELPER_IMPORT_DIR}") -endif() - -# qt_add_qml_module() was introduced in Qt 6.2 but qt_query_qml_module() -# was introduced in 6.3, to simplify the CMake code, I decide to limit the -# version check to 6.3, otherwise we'll need a lot of code to query and -# calculate the generated files, which will also break Ninja Multi-Config -# builds. -if(QT_VERSION VERSION_GREATER_EQUAL "6.3") - qt_add_qml_module(${SUB_MODULE_TARGET} - URI "org.wangwenx190.${PROJECT_NAME}" - VERSION "1.0" - OUTPUT_DIRECTORY "${__import_base_dir}/org/wangwenx190/${PROJECT_NAME}" - RESOURCE_PREFIX "/" - TYPEINFO "plugins.qmltypes" # This is the default type info file name since at least Qt5, some tools won't recognize other names. - #NO_RESOURCE_TARGET_PATH # Can't be used for non-executable targets. - OUTPUT_TARGETS __qml_targets - IMPORTS - QtQml - QtQuick - QtQuick.Controls.Basic - ) - if(__qml_targets) - list(APPEND __export_targets ${__qml_targets}) - # We have some resources bundled into the library, - # however, for static builds, the object files will - # not be packed into our final static library file, - # and thus it causes linker errors for our users, - # so we need this hack here. - if(FRAMELESSHELPER_BUILD_STATIC) - foreach(__target ${__qml_targets}) - target_sources(${SUB_MODULE_TARGET} PRIVATE - $ - ) - endforeach() - endif() - endif() - if(NOT FRAMELESSHELPER_NO_INSTALL) - qt_query_qml_module(${SUB_MODULE_TARGET} - URI module_uri - VERSION module_version - PLUGIN_TARGET module_plugin_target - TARGET_PATH module_target_path - QMLDIR module_qmldir - TYPEINFO module_typeinfo - #QML_FILES module_qml_files - #QML_FILES_DEPLOY_PATHS module_qml_files_deploy_paths - #RESOURCES module_resources - #RESOURCES_DEPLOY_PATHS module_resources_deploy_paths - ) - if(module_target_path) - set(__qml_plugin_dir "qml/${module_target_path}") - if(module_plugin_target) - install(TARGETS ${module_plugin_target} - RUNTIME DESTINATION "${__qml_plugin_dir}" - LIBRARY DESTINATION "${__qml_plugin_dir}" - ARCHIVE DESTINATION "${__qml_plugin_dir}" - ) - endif() - if(module_qmldir) - install(FILES "${module_qmldir}" DESTINATION "${__qml_plugin_dir}") - endif() - if(module_typeinfo) - install(FILES "${module_typeinfo}" DESTINATION "${__qml_plugin_dir}") - endif() - if(module_qml_files) - list(LENGTH module_qml_files num_files) - math(EXPR last_index "${num_files} - 1") - foreach(i RANGE 0 ${last_index}) - list(GET module_qml_files ${i} src_file) - list(GET module_qml_files_deploy_paths ${i} deploy_path) - get_filename_component(dest_dir "${deploy_path}" DIRECTORY) - install(FILES "${src_file}" DESTINATION "${__qml_plugin_dir}/${dest_dir}") - endforeach() - endif() - if(module_resources) - list(LENGTH module_resources num_files) - math(EXPR last_index "${num_files} - 1") - foreach(i RANGE 0 ${last_index}) - list(GET module_resources ${i} src_file) - list(GET module_resources_deploy_paths ${i} deploy_path) - get_filename_component(dest_dir "${deploy_path}" DIRECTORY) - install(FILES "${src_file}" DESTINATION "${__qml_plugin_dir}/${dest_dir}") - endforeach() - endif() - endif() - endif() -endif() - -target_compile_definitions(${SUB_MODULE_TARGET} PRIVATE - FRAMELESSHELPER_QUICK_LIBRARY -) - -if(FRAMELESSHELPER_NO_PRIVATE) - target_link_libraries(${SUB_MODULE_TARGET} PRIVATE - Qt${QT_VERSION_MAJOR}::Quick - ) -else() - target_link_libraries(${SUB_MODULE_TARGET} PRIVATE - Qt${QT_VERSION_MAJOR}::QuickPrivate - Qt${QT_VERSION_MAJOR}::QuickTemplates2Private - Qt${QT_VERSION_MAJOR}::QuickControls2Private - ) -endif() - -target_link_libraries(${SUB_MODULE_TARGET} PRIVATE - ${PROJECT_NAME}::Core -) - -include(GNUInstallDirs) -target_include_directories(${SUB_MODULE_TARGET} PUBLIC - "$" - "$" - "$" - "$" - "$" - "$" -) - -if(NOT FRAMELESSHELPER_BUILD_STATIC) - setup_target_rpaths(TARGETS ${SUB_MODULE_TARGET}) -endif() - -setup_qt_stuff(TARGETS ${SUB_MODULE_TARGET} ALLOW_KEYWORD) -setup_custom_moc_macros(TARGETS ${SUB_MODULE_TARGET}) - -set(__extra_flags "") -if(NOT FRAMELESSHELPER_NO_PERMISSIVE_CHECKS) - list(APPEND __extra_flags PERMISSIVE) -endif() -if(FRAMELESSHELPER_ENABLE_SPECTRE) - list(APPEND __extra_flags SPECTRE) -endif() -if(FRAMELESSHELPER_ENABLE_EHCONTGUARD) - list(APPEND __extra_flags EHCONTGUARD) -endif() -if(FRAMELESSHELPER_ENABLE_INTELCET) - list(APPEND __extra_flags INTELCET) -endif() -if(FRAMELESSHELPER_ENABLE_CFGUARD) - list(APPEND __extra_flags CFGUARD) -endif() -if(FRAMELESSHELPER_FORCE_LTO) - list(APPEND __extra_flags FORCE_LTO) -endif() -setup_compile_params(TARGETS ${SUB_MODULE_TARGET} ${__extra_flags}) - -if(NOT FRAMELESSHELPER_NO_INSTALL) - setup_package_export( - TARGETS ${__export_targets} - NAMESPACE ${PROJECT_NAME} - PACKAGE_NAME ${PROJECT_NAME} - COMPONENT ${SUB_MODULE} - PUBLIC_HEADERS ${PUBLIC_HEADERS} - ALIAS_HEADERS ${PUBLIC_HEADERS_ALIAS} - PRIVATE_HEADERS ${PRIVATE_HEADERS} - ) -endif() - -if(NOT FRAMELESSHELPER_NO_SUMMARY) - dump_target_info(TARGETS ${SUB_MODULE_TARGET}) -endif() diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelesshelperquick_global.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelesshelperquick_global.cpp deleted file mode 100644 index d565c259..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelesshelperquick_global.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "framelesshelperquick_global.h" -#include "framelessquickhelper.h" -#include "framelessquickutils.h" -#include "quickimageitem_p.h" -#if FRAMELESSHELPER_CONFIG(titlebar) -# include "quickchromepalette.h" -#endif -#if FRAMELESSHELPER_CONFIG(mica_material) -# include "quickmicamaterial.h" -#endif -#if FRAMELESSHELPER_CONFIG(border_painter) -# include "quickwindowborder.h" -#endif -#if FRAMELESSHELPER_CONFIG(private_qt) -# if FRAMELESSHELPER_CONFIG(window) -# include "framelessquickwindow_p.h" -# endif -# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) -# if FRAMELESSHELPER_CONFIG(window) -# include "framelessquickapplicationwindow_p.h" -# endif -# if FRAMELESSHELPER_CONFIG(system_button) -# include "quickstandardsystembutton_p.h" -# endif -# if FRAMELESSHELPER_CONFIG(titlebar) -# include "quickstandardtitlebar_p.h" -# endif -# endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) -#endif -#include - -#ifndef QUICK_URI_SHORT -# define QUICK_URI_SHORT FRAMELESSHELPER_QUICK_URI, FRAMELESSHELPER_QUICK_VERSION_MAJOR -#endif - -#ifndef QUICK_URI_FULL -# define QUICK_URI_FULL QUICK_URI_SHORT, FRAMELESSHELPER_QUICK_VERSION_MINOR -#endif - -#ifndef QUICK_URI_EXPAND -# define QUICK_URI_EXPAND(name) QUICK_URI_FULL, name -#endif - -#ifndef REG_META_TYPE -# define REG_META_TYPE(Type) qRegisterMetaType(#Type) -#endif - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcQuickGlobal, "wangwenx190.framelesshelper.quick.global") -# define INFO qCInfo(lcQuickGlobal) -# define DEBUG qCDebug(lcQuickGlobal) -# define WARNING qCWarning(lcQuickGlobal) -# define CRITICAL qCCritical(lcQuickGlobal) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -QuickGlobal::QuickGlobal(QObject *parent) : QObject(parent) -{ -} - -QuickGlobal::~QuickGlobal() = default; - -void FramelessHelperQuickInitialize() -{ - static bool inited = false; - if (inited) { - return; - } - inited = true; - - FramelessHelperCoreInitialize(); - - // Registering meta types only causes troubles in Qt6. -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - REG_META_TYPE(QuickGlobal::SystemTheme); - REG_META_TYPE(QuickGlobal::SystemButtonType); - REG_META_TYPE(QuickGlobal::ButtonState); - REG_META_TYPE(QuickGlobal::BlurMode); - REG_META_TYPE(QuickGlobal::WindowEdge); -#endif -} - -void FramelessHelperQuickUninitialize() -{ - static bool uninited = false; - if (uninited) { - return; - } - uninited = true; - - // ### TODO: The Quick module-specific uninitialization. - - FramelessHelperCoreUninitialize(); -} - -void FramelessHelperQuickRegisterTypes(QQmlEngine *engine) -{ - Q_ASSERT(engine); - if (!engine) { - return; - } - - // In most cases we don't need to register the QML types for multiple times. - static bool reg = false; - if (reg) { - return; - } - reg = true; - - // @uri org.wangwenx190.FramelessHelper - qmlRegisterUncreatableType(QUICK_URI_FULL, "FramelessHelperConstants", - FRAMELESSHELPER_STRING_LITERAL("The FramelessHelperConstants namespace is not creatable, you can only use it to access it's enums.")); - - qmlRegisterSingletonType(QUICK_URI_EXPAND("FramelessUtils"), - [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * { - Q_UNUSED(engine); - Q_UNUSED(scriptEngine); - return new FramelessQuickUtils; - }); - - qmlRegisterType(QUICK_URI_EXPAND("FramelessHelper")); - qmlRegisterType(QUICK_URI_EXPAND("ImageItem")); - -#if FRAMELESSHELPER_CONFIG(titlebar) - qmlRegisterAnonymousType(QUICK_URI_SHORT); -#endif -#if FRAMELESSHELPER_CONFIG(mica_material) - qmlRegisterType(QUICK_URI_EXPAND("MicaMaterial")); -#endif -#if FRAMELESSHELPER_CONFIG(border_painter) - qmlRegisterType(QUICK_URI_EXPAND("WindowBorder")); -#endif - -#if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(window)) - qmlRegisterType(QUICK_URI_EXPAND("FramelessWindow")); -#else - qmlRegisterTypeNotAvailable(QUICK_URI_EXPAND("FramelessWindow"), - FRAMELESSHELPER_STRING_LITERAL("FramelessWindow is not available.")); -#endif - -#if ((QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) && FRAMELESSHELPER_CONFIG(private_qt)) -# if FRAMELESSHELPER_CONFIG(window) - qmlRegisterType(QUICK_URI_EXPAND("FramelessApplicationWindow")); -# endif -# if FRAMELESSHELPER_CONFIG(system_button) - qmlRegisterType(QUICK_URI_EXPAND("StandardSystemButton")); -# endif -# if FRAMELESSHELPER_CONFIG(titlebar) - qmlRegisterType(QUICK_URI_EXPAND("StandardTitleBar")); -# endif -#else -# if FRAMELESSHELPER_CONFIG(window) - qmlRegisterTypeNotAvailable(QUICK_URI_EXPAND("FramelessApplicationWindow"), - FRAMELESSHELPER_STRING_LITERAL("FramelessApplicationWindow is not available.")); -# endif -# if FRAMELESSHELPER_CONFIG(system_button) - qmlRegisterTypeNotAvailable(QUICK_URI_EXPAND("StandardSystemButton"), - FRAMELESSHELPER_STRING_LITERAL("StandardSystemButton is not available.")); -# endif -# if FRAMELESSHELPER_CONFIG(titlebar) - qmlRegisterTypeNotAvailable(QUICK_URI_EXPAND("StandardTitleBar"), - FRAMELESSHELPER_STRING_LITERAL("StandardTitleBar is not available.")); -# endif -#endif - - qmlRegisterModule(QUICK_URI_FULL); -} - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelesshelperquick_global.h b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelesshelperquick_global.h deleted file mode 100644 index 9485ee0f..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelesshelperquick_global.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Quick/framelesshelperquick_global.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickapplicationwindow.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickapplicationwindow.cpp deleted file mode 100644 index 0c151893..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickapplicationwindow.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "framelessquickapplicationwindow_p.h" -#include "framelessquickapplicationwindow_p_p.h" - -#if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(window) && (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))) - -#include "framelessquickhelper.h" -#if FRAMELESSHELPER_CONFIG(border_painter) -# include "quickwindowborder.h" -#endif -#ifdef Q_OS_WINDOWS -# include -#endif // Q_OS_WINDOWS -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcFramelessQuickApplicationWindow, "wangwenx190.framelesshelper.quick.framelessquickapplicationwindow") -# define INFO qCInfo(lcFramelessQuickApplicationWindow) -# define DEBUG qCDebug(lcFramelessQuickApplicationWindow) -# define WARNING qCWarning(lcFramelessQuickApplicationWindow) -# define CRITICAL qCCritical(lcFramelessQuickApplicationWindow) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -FramelessQuickApplicationWindowPrivate::FramelessQuickApplicationWindowPrivate(FramelessQuickApplicationWindow *q) : QObject(q) -{ - Q_ASSERT(q); - if (!q) { - return; - } - q_ptr = q; -} - -FramelessQuickApplicationWindowPrivate::~FramelessQuickApplicationWindowPrivate() = default; - -FramelessQuickApplicationWindowPrivate *FramelessQuickApplicationWindowPrivate::get(FramelessQuickApplicationWindow *pub) -{ - Q_ASSERT(pub); - if (!pub) { - return nullptr; - } - return pub->d_func(); -} - -const FramelessQuickApplicationWindowPrivate *FramelessQuickApplicationWindowPrivate::get(const FramelessQuickApplicationWindow *pub) -{ - Q_ASSERT(pub); - if (!pub) { - return nullptr; - } - return pub->d_func(); -} - -FramelessQuickApplicationWindow::FramelessQuickApplicationWindow(QWindow *parent) - : QQuickApplicationWindow(parent), d_ptr(std::make_unique(this)) -{ - QQuickItem * const rootItem = contentItem(); - FramelessQuickHelper::get(rootItem)->extendsContentIntoTitleBar(); -#if FRAMELESSHELPER_CONFIG(border_painter) - Q_D(FramelessQuickApplicationWindow); - d->windowBorder = new QuickWindowBorder; - d->windowBorder->setParent(rootItem); - d->windowBorder->setParentItem(rootItem); - d->windowBorder->setZ(999); // Make sure it always stays on the top. - QQuickItemPrivate::get(d->windowBorder)->anchors()->setFill(rootItem); -#endif - connect(this, &FramelessQuickApplicationWindow::visibilityChanged, this, [this](){ - Q_EMIT hiddenChanged(); - Q_EMIT normalChanged(); - Q_EMIT minimizedChanged(); - Q_EMIT maximizedChanged(); - Q_EMIT zoomedChanged(); - Q_EMIT fullScreenChanged(); - }); -} - -FramelessQuickApplicationWindow::~FramelessQuickApplicationWindow() = default; - -bool FramelessQuickApplicationWindow::isHidden() const -{ - return (visibility() == FramelessQuickApplicationWindow::Hidden); -} - -bool FramelessQuickApplicationWindow::isNormal() const -{ - return (visibility() == FramelessQuickApplicationWindow::Windowed); -} - -bool FramelessQuickApplicationWindow::isMinimized() const -{ - return (visibility() == FramelessQuickApplicationWindow::Minimized); -} - -bool FramelessQuickApplicationWindow::isMaximized() const -{ - return (visibility() == FramelessQuickApplicationWindow::Maximized); -} - -bool FramelessQuickApplicationWindow::isZoomed() const -{ - return (isMaximized() || (visibility() == FramelessQuickApplicationWindow::FullScreen)); -} - -bool FramelessQuickApplicationWindow::isFullScreen() const -{ - return (visibility() == FramelessQuickApplicationWindow::FullScreen); -} - -void FramelessQuickApplicationWindow::showMinimized2() -{ -#ifdef Q_OS_WINDOWS - // Work-around a QtQuick bug: https://bugreports.qt.io/browse/QTBUG-69711 - // Don't use "SW_SHOWMINIMIZED" because it will activate the current window - // instead of the next window in the Z order, which is not the default behavior - // of native Win32 applications. - ::ShowWindow(reinterpret_cast(winId()), SW_MINIMIZE); -#else - showMinimized(); -#endif -} - -void FramelessQuickApplicationWindow::toggleMaximized() -{ - if (isMaximized()) { - showNormal(); - } else { - showMaximized(); - } -} - -void FramelessQuickApplicationWindow::toggleFullScreen() -{ - Q_D(FramelessQuickApplicationWindow); - if (isFullScreen()) { - setVisibility(d->savedVisibility); - } else { - d->savedVisibility = visibility(); - showFullScreen(); - } -} - -void FramelessQuickApplicationWindow::classBegin() -{ - QQuickApplicationWindow::classBegin(); -} - -void FramelessQuickApplicationWindow::componentComplete() -{ - QQuickApplicationWindow::componentComplete(); -} - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickapplicationwindow_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickapplicationwindow_p.h deleted file mode 100644 index 0d9440e2..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickapplicationwindow_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickapplicationwindow_p_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickapplicationwindow_p_p.h deleted file mode 100644 index d6a25013..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickapplicationwindow_p_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickhelper.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickhelper.cpp deleted file mode 100644 index bf95aeab..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickhelper.cpp +++ /dev/null @@ -1,1053 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "framelessquickhelper.h" -#include "framelessquickhelper_p.h" -#if FRAMELESSHELPER_CONFIG(mica_material) -# include "quickmicamaterial.h" -#endif -#if FRAMELESSHELPER_CONFIG(border_painter) -# include "quickwindowborder.h" -#endif -#include -#include -#include -#include -#include -#ifdef Q_OS_WINDOWS -# include -#endif // Q_OS_WINDOWS -#include -#include -#include -#include -#if FRAMELESSHELPER_CONFIG(private_qt) -# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) -# include // For QWINDOWSIZE_MAX -# else // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) -# include // For QWINDOWSIZE_MAX -# endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) -# include -#endif - -#ifndef QWINDOWSIZE_MAX -# define QWINDOWSIZE_MAX ((1 << 24) - 1) -#endif // QWINDOWSIZE_MAX - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcFramelessQuickHelper, "wangwenx190.framelesshelper.quick.framelessquickhelper") -# define INFO qCInfo(lcFramelessQuickHelper) -# define DEBUG qCDebug(lcFramelessQuickHelper) -# define WARNING qCWarning(lcFramelessQuickHelper) -# define CRITICAL qCCritical(lcFramelessQuickHelper) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -static constexpr const auto kRepaintTimerInterval = 300; - -struct FramelessQuickHelperExtraData : public FramelessExtraData -{ - QPointer titleBarItem = nullptr; - QList> hitTestVisibleItems = {}; - QPointer windowIconButton = nullptr; - QPointer contextHelpButton = nullptr; - QPointer minimizeButton = nullptr; - QPointer maximizeButton = nullptr; - QPointer closeButton = nullptr; - QList hitTestVisibleRects = {}; - - FramelessQuickHelperExtraData(); - ~FramelessQuickHelperExtraData() override; - - [[nodiscard]] static FramelessExtraDataPtr create(); -}; -using FramelessQuickHelperExtraDataPtr = std::shared_ptr; - -FramelessQuickHelperExtraData::FramelessQuickHelperExtraData() = default; - -FramelessQuickHelperExtraData::~FramelessQuickHelperExtraData() = default; - -FramelessExtraDataPtr FramelessQuickHelperExtraData::create() -{ - return std::make_shared(); -} - -[[nodiscard]] static inline FramelessQuickHelperExtraDataPtr tryGetExtraData(const FramelessDataPtr &data, const bool create) -{ - Q_ASSERT(data); - if (!data) { - return nullptr; - } - auto it = data->extraData.find(ExtraDataType::FramelessQuickHelper); - if (it == data->extraData.end()) { - if (create) { - it = data->extraData.insert(ExtraDataType::FramelessQuickHelper, FramelessQuickHelperExtraData::create()); - } else { - return nullptr; - } - } - return std::dynamic_pointer_cast(it.value()); -} - -[[nodiscard]] static inline FramelessQuickHelperExtraDataPtr tryGetExtraData(const QQuickWindow *window, const bool create) -{ - Q_ASSERT(window); - if (!window) { - return nullptr; - } - const FramelessDataPtr data = FramelessManagerPrivate::getData(window); - if (!data) { - return nullptr; - } - return tryGetExtraData(data, create); -} - -FramelessQuickHelperPrivate::FramelessQuickHelperPrivate(FramelessQuickHelper *q) : QObject(q) -{ - Q_ASSERT(q); - if (!q) { - return; - } - q_ptr = q; - repaintTimer.setTimerType(Qt::VeryCoarseTimer); - repaintTimer.setInterval(kRepaintTimerInterval); - connect(&repaintTimer, &QTimer::timeout, this, &FramelessQuickHelperPrivate::doRepaintAllChildren); - // Workaround a MOC limitation: we can't emit a signal from the parent class. - connect(q_ptr, &FramelessQuickHelper::windowChanged, q_ptr, &FramelessQuickHelper::windowChanged2); -} - -FramelessQuickHelperPrivate::~FramelessQuickHelperPrivate() -{ - detach(); -} - -FramelessQuickHelperPrivate *FramelessQuickHelperPrivate::get(FramelessQuickHelper *pub) -{ - Q_ASSERT(pub); - if (!pub) { - return nullptr; - } - return pub->d_func(); -} - -const FramelessQuickHelperPrivate *FramelessQuickHelperPrivate::get(const FramelessQuickHelper *pub) -{ - Q_ASSERT(pub); - if (!pub) { - return nullptr; - } - return pub->d_func(); -} - -void FramelessQuickHelperPrivate::attach() -{ - Q_Q(FramelessQuickHelper); - QQuickWindow *window = q->window(); - Q_ASSERT(window); - if (!window) { - return; - } - const WId windowId = window->winId(); - - const FramelessDataPtr data = FramelessManagerPrivate::createData(window, windowId); - Q_ASSERT(data); - if (!data || data->frameless) { - return; - } - - if (!data->callbacks) { - QPointer w = window; - data->callbacks = FramelessCallbacks::create(); - data->callbacks->getWindowId = [window]() -> WId { return window->winId(); }; - data->callbacks->getWindowFlags = [window]() -> Qt::WindowFlags { return window->flags(); }; - data->callbacks->setWindowFlags = [window](const Qt::WindowFlags flags) -> void { window->setFlags(flags); }; - data->callbacks->getWindowSize = [window]() -> QSize { return window->size(); }; - data->callbacks->setWindowSize = [window](const QSize &size) -> void { window->resize(size); }; - data->callbacks->getWindowPosition = [window]() -> QPoint { return window->position(); }; - data->callbacks->setWindowPosition = [window](const QPoint &pos) -> void { window->setX(pos.x()); window->setY(pos.y()); }; - data->callbacks->getWindowScreen = [window]() -> QScreen * { return window->screen(); }; - data->callbacks->isWindowFixedSize = [q]() -> bool { return q->isWindowFixedSize(); }; - data->callbacks->setWindowFixedSize = [q](const bool value) -> void { q->setWindowFixedSize(value); }; - data->callbacks->getWindowState = [window]() -> Qt::WindowState { return window->windowState(); }; - data->callbacks->setWindowState = [window](const Qt::WindowState state) -> void { window->setWindowState(state); }; - data->callbacks->getWindowHandle = [w]() -> QWindow * { return w; }; - data->callbacks->windowToScreen = [window](const QPoint &pos) -> QPoint { return window->mapToGlobal(pos); }; - data->callbacks->screenToWindow = [window](const QPoint &pos) -> QPoint { return window->mapFromGlobal(pos); }; - data->callbacks->isInsideSystemButtons = [this](const QPoint &pos, SystemButtonType *button) -> bool { - QuickGlobal::SystemButtonType button2 = QuickGlobal::SystemButtonType::Unknown; - const bool result = isInSystemButtons(pos, &button2); - *button = FRAMELESSHELPER_ENUM_QUICK_TO_CORE(SystemButtonType, button2); - return result; - }; - data->callbacks->isInsideTitleBarDraggableArea = [this](const QPoint &pos) -> bool { return isInTitleBarDraggableArea(pos); }; - data->callbacks->getWindowDevicePixelRatio = [window]() -> qreal { return window->effectiveDevicePixelRatio(); }; - data->callbacks->setSystemButtonState = [this](const SystemButtonType button, const ButtonState state) -> void { - setSystemButtonState(FRAMELESSHELPER_ENUM_CORE_TO_QUICK(SystemButtonType, button), FRAMELESSHELPER_ENUM_CORE_TO_QUICK(ButtonState, state)); - }; - data->callbacks->shouldIgnoreMouseEvents = [this](const QPoint &pos) -> bool { return shouldIgnoreMouseEvents(pos); }; - data->callbacks->showSystemMenu = [q](const QPoint &pos) -> void { q->showSystemMenu(pos); }; - data->callbacks->setProperty = [this](const char *name, const QVariant &value) -> void { setProperty(name, value); }; - data->callbacks->getProperty = [this](const char *name, const QVariant &defaultValue) -> QVariant { return getProperty(name, defaultValue); }; - data->callbacks->setCursor = [window](const QCursor &cursor) -> void { window->setCursor(cursor); }; - data->callbacks->unsetCursor = [window]() -> void { window->unsetCursor(); }; - data->callbacks->getWidgetHandle = []() -> QObject * { return nullptr; }; - data->callbacks->forceChildrenRepaint = [this]() -> void { repaintAllChildren(); }; - data->callbacks->resetQtGrabbedControl = []() -> bool { return false; }; - } - - std::ignore = tryGetExtraData(data, true); - - std::ignore = FramelessManager::instance()->addWindow(window, windowId); - - // We have to wait for a little time before moving the top level window - // , because the platform window may not finish initializing by the time - // we reach here, and all the modifications from the Qt side will be lost - // due to QPA will reset the position and size of the window during it's - // initialization process. - QTimer::singleShot(qpaWaitTime, this, [this, q](){ - qpaReady = true; - if (FramelessConfig::instance()->isSet(Option::CenterWindowBeforeShow)) { - q->moveWindowToDesktopCenter(); - } - if (FramelessConfig::instance()->isSet(Option::EnableBlurBehindWindow)) { - q->setBlurBehindWindowEnabled(true); - } - emitSignalForAllInstances("ready"); - }); -} - -void FramelessQuickHelperPrivate::detach() -{ - Q_Q(FramelessQuickHelper); - const QQuickWindow *window = q->window(); - if (!window) { - return; - } - std::ignore = FramelessManager::instance()->removeWindow(window); -} - -void FramelessQuickHelperPrivate::emitSignalForAllInstances(const char *signal) -{ - Q_ASSERT(signal); - Q_ASSERT(*signal != '\0'); - if (!signal || (*signal == '\0')) { - return; - } - Q_Q(FramelessQuickHelper); - const QQuickWindow * const window = q->window(); - if (!window) { - return; - } - const auto rootObject = (window->contentItem() ? - qobject_cast(window->contentItem()) - : qobject_cast(window)); - const auto instances = rootObject->findChildren(); - if (instances.isEmpty()) { - return; - } - for (auto &&instance : std::as_const(instances)) { - QMetaObject::invokeMethod(instance, signal); - } -} - -void FramelessQuickHelperPrivate::setProperty(const char *name, const QVariant &value) -{ - Q_ASSERT(name); - Q_ASSERT(*name != '\0'); - Q_ASSERT(value.isValid()); - Q_ASSERT(!value.isNull()); - if (!name || (*name == '\0') || !value.isValid() || value.isNull()) { - return; - } - Q_Q(FramelessQuickHelper); - QQuickWindow * const window = q->window(); - if (!window) { - return; - } - window->setProperty(name, value); -} - -QVariant FramelessQuickHelperPrivate::getProperty(const char *name, const QVariant &defaultValue) -{ - Q_ASSERT(name); - Q_ASSERT(*name != '\0'); - if (!name || (*name == '\0')) { - return {}; - } - Q_Q(FramelessQuickHelper); - const QQuickWindow * const window = q->window(); - if (!window) { - return {}; - } - const QVariant value = window->property(name); - return ((value.isValid() && !value.isNull()) ? value : defaultValue); -} - -#if FRAMELESSHELPER_CONFIG(mica_material) -QuickMicaMaterial *FramelessQuickHelperPrivate::findOrCreateMicaMaterial() const -{ - Q_Q(const FramelessQuickHelper); - const QQuickWindow * const window = q->window(); - if (!window) { - return nullptr; - } - QQuickItem * const rootItem = window->contentItem(); - if (const auto item = rootItem->findChild()) { - return item; - } - if (const auto item = window->findChild()) { - return item; - } - const auto item = new QuickMicaMaterial; - item->setParent(rootItem); - item->setParentItem(rootItem); - item->setZ(-999); // Make sure it always stays on the bottom. -#if FRAMELESSHELPER_CONFIG(private_qt) - QQuickItemPrivate::get(item)->anchors()->setFill(rootItem); -#endif - return item; -} -#endif - -#if FRAMELESSHELPER_CONFIG(border_painter) -QuickWindowBorder *FramelessQuickHelperPrivate::findOrCreateWindowBorder() const -{ - Q_Q(const FramelessQuickHelper); - const QQuickWindow * const window = q->window(); - if (!window) { - return nullptr; - } - QQuickItem * const rootItem = window->contentItem(); - if (const auto item = rootItem->findChild()) { - return item; - } - if (const auto item = window->findChild()) { - return item; - } - const auto item = new QuickWindowBorder; - item->setParent(rootItem); - item->setParentItem(rootItem); - item->setZ(999); // Make sure it always stays on the top. -#if FRAMELESSHELPER_CONFIG(private_qt) - QQuickItemPrivate::get(item)->anchors()->setFill(rootItem); -#endif - return item; -} -#endif - -FramelessQuickHelper *FramelessQuickHelperPrivate::findOrCreateFramelessHelper(QObject *object) -{ - Q_ASSERT(object); - if (!object) { - return nullptr; - } - QObject *parent = nullptr; - QQuickItem *parentItem = nullptr; - if (const auto objWindow = qobject_cast(object)) { - if (QQuickItem * const item = objWindow->contentItem()) { - parent = item; - parentItem = item; - } else { - parent = objWindow; - } - } else if (const auto item = qobject_cast(object)) { - if (QQuickWindow * const itemWindow = item->window()) { - if (QQuickItem * const contentItem = itemWindow->contentItem()) { - parent = contentItem; - parentItem = contentItem; - } else { - parent = itemWindow; - parentItem = item; - } - } else { - parent = item; - parentItem = item; - } - } else { - parent = object; - } - FramelessQuickHelper *instance = parent->findChild(); - if (!instance) { - instance = new FramelessQuickHelper; - instance->setParentItem(parentItem); - instance->setParent(parent); - // No need to do this here, we'll do it once the item has been assigned to a specific window. - //instance->extendsContentIntoTitleBar(); - } - return instance; -} - -void FramelessQuickHelperPrivate::repaintAllChildren() -{ - repaintTimer.start(); -} - -void FramelessQuickHelperPrivate::doRepaintAllChildren() -{ - repaintTimer.stop(); - Q_Q(const FramelessQuickHelper); - QQuickWindow *window = q->window(); - if (!window) { - return; - } -#if (defined(Q_OS_WINDOWS) && (QT_VERSION != QT_VERSION_CHECK(6, 5, 3)) && (QT_VERSION != QT_VERSION_CHECK(6, 6, 0))) - // Sync the internal window frame margins with the latest DPI, otherwise - // we will get wrong window sizes after the DPI change. - std::ignore = Utils::updateInternalWindowFrameMargins(window, true); -#endif // Q_OS_WINDOWS - // No need to repaint the window when it's hidden. - if (!window->isVisible()) { - return; - } - if (!((window->windowState() & (Qt::WindowMinimized | Qt::WindowMaximized | Qt::WindowFullScreen)) || q->isWindowFixedSize())) { - const QSize originalSize = window->size(); - static constexpr const auto margins = QMargins{ 1, 1, 1, 1 }; - window->resize(originalSize.shrunkBy(margins)); - window->resize(originalSize.grownBy(margins)); - window->resize(originalSize); - } - window->requestUpdate(); -#if 0 // Calling QWindow::requestUpdate() should be enough. - const QList items = window->findChildren(); - for (auto &&item : std::as_const(items)) { - // Only items with the "QQuickItem::ItemHasContents" flag enabled are allowed to call "update()". - // And don't repaint the item if it's hidden. - if ((item->flags() & QQuickItem::ItemHasContents) && item->isVisible()) { - item->update(); - } - } -#endif -} - -quint32 FramelessQuickHelperPrivate::readyWaitTime() const -{ - return qpaWaitTime; -} - -void FramelessQuickHelperPrivate::setReadyWaitTime(const quint32 time) -{ - if (qpaWaitTime == time) { - return; - } - qpaWaitTime = time; -} - -QRect FramelessQuickHelperPrivate::mapItemGeometryToScene(const QQuickItem * const item) const -{ - Q_ASSERT(item); - if (!item) { - return {}; - } - const QPointF originPoint = item->mapToScene(QPointF(0.0, 0.0)); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) - const QSizeF size = item->size(); -#else - const QSizeF size = {item->width(), item->height()}; -#endif - return QRectF(originPoint, size).toRect(); -} - -bool FramelessQuickHelperPrivate::isInSystemButtons(const QPoint &pos, QuickGlobal::SystemButtonType *button) const -{ - Q_ASSERT(button); - if (!button) { - return false; - } - Q_Q(const FramelessQuickHelper); - const QQuickWindow * const window = q->window(); - if (!window) { - return false; - } - const FramelessQuickHelperExtraDataPtr extraData = tryGetExtraData(window, false); - Q_ASSERT(extraData); - if (!extraData) { - return false; - } - *button = QuickGlobal::SystemButtonType::Unknown; - if (extraData->windowIconButton && extraData->windowIconButton->isVisible() && extraData->windowIconButton->isEnabled()) { - if (mapItemGeometryToScene(extraData->windowIconButton).contains(pos)) { - *button = QuickGlobal::SystemButtonType::WindowIcon; - return true; - } - } - if (extraData->contextHelpButton && extraData->contextHelpButton->isVisible() && extraData->contextHelpButton->isEnabled()) { - if (mapItemGeometryToScene(extraData->contextHelpButton).contains(pos)) { - *button = QuickGlobal::SystemButtonType::Help; - return true; - } - } - if (extraData->minimizeButton && extraData->minimizeButton->isVisible() && extraData->minimizeButton->isEnabled()) { - if (mapItemGeometryToScene(extraData->minimizeButton).contains(pos)) { - *button = QuickGlobal::SystemButtonType::Minimize; - return true; - } - } - if (extraData->maximizeButton && extraData->maximizeButton->isVisible() && extraData->maximizeButton->isEnabled()) { - if (mapItemGeometryToScene(extraData->maximizeButton).contains(pos)) { - *button = QuickGlobal::SystemButtonType::Maximize; - return true; - } - } - if (extraData->closeButton && extraData->closeButton->isVisible() && extraData->closeButton->isEnabled()) { - if (mapItemGeometryToScene(extraData->closeButton).contains(pos)) { - *button = QuickGlobal::SystemButtonType::Close; - return true; - } - } - return false; -} - -bool FramelessQuickHelperPrivate::isInTitleBarDraggableArea(const QPoint &pos) const -{ - Q_Q(const FramelessQuickHelper); - const QQuickWindow * const window = q->window(); - if (!window) { - // The FramelessQuickHelper item has not been attached to a specific window yet, - // so we assume there's no title bar. - return false; - } - const FramelessQuickHelperExtraDataPtr extraData = tryGetExtraData(window, false); - Q_ASSERT(extraData); - if (!extraData) { - return false; - } - if (!extraData->titleBarItem) { - // There's no title bar at all, the mouse will always be in the client area. - return false; - } - if (!extraData->titleBarItem->isVisible() || !extraData->titleBarItem->isEnabled()) { - // The title bar is hidden or disabled for some reason, treat it as there's no title bar. - return false; - } - const QRect windowRect = {QPoint(0, 0), window->size()}; - const QRect titleBarRect = mapItemGeometryToScene(extraData->titleBarItem); - if (!titleBarRect.intersects(windowRect)) { - // The title bar is totally outside of the window for some reason, - // also treat it as there's no title bar. - return false; - } - QRegion region = titleBarRect; - const auto systemButtons = { - extraData->windowIconButton, extraData->contextHelpButton, - extraData->minimizeButton, extraData->maximizeButton, - extraData->closeButton - }; - for (auto &&button : std::as_const(systemButtons)) { - if (button && button->isVisible() && button->isEnabled()) { - region -= mapItemGeometryToScene(button); - } - } - if (!extraData->hitTestVisibleItems.isEmpty()) { - for (auto &&item : std::as_const(extraData->hitTestVisibleItems)) { - if (item && item->isVisible() && item->isEnabled()) { - region -= mapItemGeometryToScene(item); - } - } - } - if (!extraData->hitTestVisibleRects.isEmpty()) { - for (auto &&rect : std::as_const(extraData->hitTestVisibleRects)) { - if (rect.isValid()) { - region -= rect; - } - } - } - return region.contains(pos); -} - -bool FramelessQuickHelperPrivate::shouldIgnoreMouseEvents(const QPoint &pos) const -{ - Q_Q(const FramelessQuickHelper); - const QQuickWindow * const window = q->window(); - if (!window) { - return false; - } - const auto withinFrameBorder = [q, &pos, window]() -> bool { - if (q->isWindowFixedSize()) { - return false; - } - if (pos.y() < kDefaultResizeBorderThickness) { - return true; - } -#ifdef Q_OS_WINDOWS - if (Utils::isWindowFrameBorderVisible()) { - return false; - } -#endif - return ((pos.x() < kDefaultResizeBorderThickness) - || (pos.x() >= (window->width() - kDefaultResizeBorderThickness))); - }(); - return ((window->visibility() == QQuickWindow::Windowed) && withinFrameBorder); -} - -void FramelessQuickHelperPrivate::setSystemButtonState(const QuickGlobal::SystemButtonType button, - const QuickGlobal::ButtonState state) -{ - Q_UNUSED(button); - Q_UNUSED(state); -} - -void FramelessQuickHelperPrivate::rebindWindow() -{ - Q_Q(FramelessQuickHelper); - QQuickWindow * const window = q->window(); - if (!window) { - return; - } - QQuickItem * const rootItem = window->contentItem(); - const QObject * const p = q->parent(); - const QQuickItem * const pItem = q->parentItem(); - if (rootItem) { - if ((pItem != rootItem) || (p != rootItem)) { - q->setParentItem(rootItem); - q->setParent(rootItem); - } - } else { - if (pItem != nullptr) { - q->setParentItem(nullptr); - } - if (p != window) { - q->setParent(window); - } - } - if (extendIntoTitleBar.value_or(true)) { - q->extendsContentIntoTitleBar(true); - } -} - -FramelessQuickHelper::FramelessQuickHelper(QQuickItem *parent) - : QQuickItem(parent), d_ptr(std::make_unique(this)) -{ -} - -FramelessQuickHelper::~FramelessQuickHelper() = default; - -FramelessQuickHelper *FramelessQuickHelper::get(QObject *object) -{ - Q_ASSERT(object); - if (!object) { - return nullptr; - } - return FramelessQuickHelperPrivate::findOrCreateFramelessHelper(object); -} - -FramelessQuickHelper *FramelessQuickHelper::qmlAttachedProperties(QObject *parentObject) -{ - Q_ASSERT(parentObject); - if (!parentObject) { - return nullptr; - } - return get(parentObject); -} - -#if FRAMELESSHELPER_CONFIG(mica_material) -QuickMicaMaterial *FramelessQuickHelper::micaMaterial() const -{ - Q_D(const FramelessQuickHelper); - return d->findOrCreateMicaMaterial(); -} -#endif - -#if FRAMELESSHELPER_CONFIG(border_painter) -QuickWindowBorder *FramelessQuickHelper::windowBorder() const -{ - Q_D(const FramelessQuickHelper); - return d->findOrCreateWindowBorder(); -} -#endif - -void FramelessQuickHelper::setHitTestVisible(QQuickItem *item, const bool visible) -{ - setHitTestVisible_item(item, visible); -} - -void FramelessQuickHelper::setHitTestVisible_item(QQuickItem *item, const bool visible) -{ - Q_ASSERT(item); - if (!item) { - return; - } - const QQuickWindow * const w = window(); - if (!w) { - return; - } - const FramelessQuickHelperExtraDataPtr extraData = tryGetExtraData(w, false); - Q_ASSERT(extraData); - if (!extraData) { - return; - } - if (visible) { - extraData->hitTestVisibleItems.append(item); - } else { - extraData->hitTestVisibleItems.removeAll(item); - } -} - -void FramelessQuickHelper::setHitTestVisible_rect(const QRect &rect, const bool visible) -{ - Q_ASSERT(Utils::isValidGeometry(rect)); - if (!Utils::isValidGeometry(rect)) { - return; - } - const QQuickWindow * const w = window(); - if (!w) { - return; - } - const FramelessQuickHelperExtraDataPtr extraData = tryGetExtraData(w, false); - Q_ASSERT(extraData); - if (!extraData) { - return; - } - if (visible) { - extraData->hitTestVisibleRects.append(rect); - } else { - extraData->hitTestVisibleRects.removeAll(rect); - } -} - -void FramelessQuickHelper::setHitTestVisible_object(QObject *object, const bool visible) -{ - Q_ASSERT(object); - if (!object) { - return; - } - const auto item = qobject_cast(object); - Q_ASSERT(item); - if (!item) { - return; - } - setHitTestVisible_item(item, visible); -} - -bool FramelessQuickHelper::isContentExtendedIntoTitleBar() const -{ - const QQuickWindow * const w = window(); - if (!w) { - return false; - } - const FramelessDataPtr data = FramelessManagerPrivate::getData(w); - return (data && data->frameless); -} - -void FramelessQuickHelper::extendsContentIntoTitleBar(const bool value) -{ - if (isContentExtendedIntoTitleBar() == value) { - return; - } - Q_D(FramelessQuickHelper); - if (value) { - d->attach(); - } else { - d->detach(); - } - d->extendIntoTitleBar = value; - d->emitSignalForAllInstances("extendsContentIntoTitleBarChanged"); -} - -QQuickItem *FramelessQuickHelper::titleBarItem() const -{ - const QQuickWindow * const w = window(); - if (!w) { - return nullptr; - } - const FramelessQuickHelperExtraDataPtr extraData = tryGetExtraData(w, false); - Q_ASSERT(extraData); - if (!extraData) { - return nullptr; - } - return extraData->titleBarItem; -} - -void FramelessQuickHelper::setTitleBarItem(QQuickItem *value) -{ - Q_ASSERT(value); - if (!value) { - return; - } - const QQuickWindow * const w = window(); - if (!w) { - return; - } - const FramelessQuickHelperExtraDataPtr extraData = tryGetExtraData(w, false); - Q_ASSERT(extraData); - if (!extraData || (extraData->titleBarItem == value)) { - return; - } - extraData->titleBarItem = value; - Q_D(FramelessQuickHelper); - d->emitSignalForAllInstances("titleBarItemChanged"); -} - -void FramelessQuickHelper::setSystemButton(QQuickItem *item, const QuickGlobal::SystemButtonType buttonType) -{ - Q_ASSERT(item); - Q_ASSERT(buttonType != QuickGlobal::SystemButtonType::Unknown); - if (!item || (buttonType == QuickGlobal::SystemButtonType::Unknown)) { - return; - } - const QQuickWindow * const w = window(); - if (!w) { - return; - } - const FramelessQuickHelperExtraDataPtr extraData = tryGetExtraData(w, false); - Q_ASSERT(extraData); - if (!extraData) { - return; - } - switch (buttonType) { - case QuickGlobal::SystemButtonType::WindowIcon: - extraData->windowIconButton = item; - break; - case QuickGlobal::SystemButtonType::Help: - extraData->contextHelpButton = item; - break; - case QuickGlobal::SystemButtonType::Minimize: - extraData->minimizeButton = item; - break; - case QuickGlobal::SystemButtonType::Maximize: - case QuickGlobal::SystemButtonType::Restore: - extraData->maximizeButton = item; - break; - case QuickGlobal::SystemButtonType::Close: - extraData->closeButton = item; - break; - case QuickGlobal::SystemButtonType::Unknown: - Q_UNREACHABLE(); - } -} - -void FramelessQuickHelper::showSystemMenu(const QPoint &pos) -{ - const QQuickWindow * const w = window(); - if (!w) { - return; - } - const WId windowId = w->winId(); - const QPoint nativePos = Utils::toNativeGlobalPosition(w, pos); -#ifdef Q_OS_WINDOWS - std::ignore = Utils::showSystemMenu(windowId, nativePos, false); -#elif (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) - Utils::openSystemMenu(windowId, nativePos); -#else - Q_UNUSED(windowId); - Q_UNUSED(nativePos); -#endif -} - -void FramelessQuickHelper::windowStartSystemMove2(const QPoint &pos) -{ - QQuickWindow * const w = window(); - if (!w) { - return; - } - std::ignore = Utils::startSystemMove(w, pos); -} - -void FramelessQuickHelper::windowStartSystemResize2(const Qt::Edges edges, const QPoint &pos) -{ - QQuickWindow * const w = window(); - if (!w) { - return; - } - if (edges == Qt::Edges{}) { - return; - } - std::ignore = Utils::startSystemResize(w, edges, pos); -} - -void FramelessQuickHelper::moveWindowToDesktopCenter() -{ - const QQuickWindow * const w = window(); - if (!w) { - return; - } - std::ignore = Utils::moveWindowToDesktopCenter(w->winId(), true); -} - -void FramelessQuickHelper::bringWindowToFront() -{ - QQuickWindow * const w = window(); - if (!w) { - return; - } -#ifdef Q_OS_WINDOWS - std::ignore = Utils::bringWindowToFront(w->winId()); -#else - if (w->visibility() == QQuickWindow::Hidden) { - w->show(); - } - if (w->visibility() == QQuickWindow::Minimized) { -# if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) - w->setWindowStates(w->windowStates() & ~Qt::WindowMinimized); -# else - w->showNormal(); -# endif - } - w->raise(); - w->requestActivate(); -#endif -} - -bool FramelessQuickHelper::isWindowFixedSize() const -{ - const QQuickWindow * const w = window(); - if (!w) { - return false; - } - if (w->flags() & Qt::MSWindowsFixedSizeDialogHint) { - return true; - } - const QSize minSize = w->minimumSize(); - const QSize maxSize = w->maximumSize(); - if (!minSize.isEmpty() && !maxSize.isEmpty() && (minSize == maxSize)) { - return true; - } - return false; -} - -void FramelessQuickHelper::setWindowFixedSize(const bool value) -{ - QQuickWindow * const w = window(); - if (!w) { - return; - } - if (isWindowFixedSize() == value) { - return; - } - if (value) { - const QSize size = w->size(); - w->setMinimumSize(size); - w->setMaximumSize(size); - } else { - w->setMinimumSize(kDefaultWindowSize); - w->setMaximumSize(QSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX)); - } -#ifdef Q_OS_WINDOWS - std::ignore = Utils::setAeroSnappingEnabled(w->winId(), !value); -#endif - Q_D(FramelessQuickHelper); - d->emitSignalForAllInstances("windowFixedSizeChanged"); -} - -bool FramelessQuickHelper::isBlurBehindWindowEnabled() const -{ - Q_D(const FramelessQuickHelper); - return d->blurBehindWindowEnabled; -} - -void FramelessQuickHelper::setBlurBehindWindowEnabled(const bool value) -{ -#if (!defined(Q_OS_WINDOWS) || FRAMELESSHELPER_CONFIG(native_impl)) - QQuickWindow * const w = window(); - if (!w) { - return; - } - Q_D(FramelessQuickHelper); - if (d->blurBehindWindowEnabled == value) { - return; - } - if (Utils::isBlurBehindWindowSupported()) { - QuickGlobal::BlurMode mode = QuickGlobal::BlurMode::Disable; - if (value) { - if (!d->savedWindowBackgroundColor.isValid()) { - d->savedWindowBackgroundColor = w->color(); - } - w->setColor(kDefaultTransparentColor); - mode = QuickGlobal::BlurMode::Default; - } else { - if (d->savedWindowBackgroundColor.isValid()) { - w->setColor(d->savedWindowBackgroundColor); - d->savedWindowBackgroundColor = {}; - } - mode = QuickGlobal::BlurMode::Disable; - } - if (Utils::setBlurBehindWindowEnabled(w->winId(), FRAMELESSHELPER_ENUM_QUICK_TO_CORE(BlurMode, mode), {})) { - d->blurBehindWindowEnabled = value; - d->emitSignalForAllInstances("blurBehindWindowEnabledChanged"); - } else { - WARNING << "Failed to enable/disable blur behind window."; - } - } else { - d->blurBehindWindowEnabled = value; -#if FRAMELESSHELPER_CONFIG(mica_material) - micaMaterial()->setVisible(d->blurBehindWindowEnabled); -#endif - d->emitSignalForAllInstances("blurBehindWindowEnabledChanged"); - } -#else // Windows && !native_impl - Q_UNUSED(value); -#endif -} - -bool FramelessQuickHelper::isReady() const -{ - Q_D(const FramelessQuickHelper); - return d->qpaReady; -} - -void FramelessQuickHelper::waitForReady() -{ - Q_D(FramelessQuickHelper); - if (d->qpaReady) { - return; - } -#if 1 - QEventLoop loop{}; - const QMetaObject::Connection connection = connect(this, &FramelessQuickHelper::ready, &loop, &QEventLoop::quit); - loop.exec(); - disconnect(connection); -#else - while (!d->qpaReady) { - QCoreApplication::processEvents(); - } -#endif -} - -void FramelessQuickHelper::itemChange(const ItemChange change, const ItemChangeData &value) -{ - QQuickItem::itemChange(change, value); - if ((change == ItemSceneChange) && value.window) { - Q_D(FramelessQuickHelper); - d->rebindWindow(); - } -} - -void FramelessQuickHelper::classBegin() -{ - QQuickItem::classBegin(); -} - -void FramelessQuickHelper::componentComplete() -{ - QQuickItem::componentComplete(); -} - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickhelper.h b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickhelper.h deleted file mode 100644 index d77b6689..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickhelper.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Quick/framelessquickhelper.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickhelper_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickhelper_p.h deleted file mode 100644 index 4b0ffc50..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickhelper_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Quick/private/framelessquickhelper_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickmodule.h b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickmodule.h deleted file mode 100644 index 4ff36226..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickmodule.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Quick/framelessquickmodule.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickutils.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickutils.cpp deleted file mode 100644 index 432e04da..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickutils.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "framelessquickutils.h" -#include -#include -#ifdef Q_OS_WINDOWS -# include -#endif // Q_OS_WINDOWS -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcFramelessQuickUtils, "wangwenx190.framelesshelper.quick.framelessquickutils") -# define INFO qCInfo(lcFramelessQuickUtils) -# define DEBUG qCDebug(lcFramelessQuickUtils) -# define WARNING qCWarning(lcFramelessQuickUtils) -# define CRITICAL qCCritical(lcFramelessQuickUtils) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -FramelessQuickUtils::FramelessQuickUtils(QObject *parent) : QObject(parent) -{ - connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged, this, [this](){ - Q_EMIT systemThemeChanged(); - Q_EMIT systemAccentColorChanged(); - Q_EMIT titleBarColorizedChanged(); - }); -} - -FramelessQuickUtils::~FramelessQuickUtils() = default; - -qreal FramelessQuickUtils::titleBarHeight() const -{ - return kDefaultTitleBarHeight; -} - -bool FramelessQuickUtils::frameBorderVisible() const -{ -#ifdef Q_OS_WINDOWS - return (Utils::isWindowFrameBorderVisible() && !WindowsVersionHelper::isWin11OrGreater()); -#else - return false; -#endif -} - -qreal FramelessQuickUtils::frameBorderThickness() const -{ -#ifdef Q_OS_WINDOWS - return kDefaultWindowFrameBorderThickness; -#else - return 0; -#endif -} - -QuickGlobal::SystemTheme FramelessQuickUtils::systemTheme() const -{ - return FRAMELESSHELPER_ENUM_CORE_TO_QUICK(SystemTheme, FramelessManager::instance()->systemTheme()); -} - -void FramelessQuickUtils::setOverrideTheme(const QuickGlobal::SystemTheme theme) -{ - FramelessManager::instance()->setOverrideTheme(FRAMELESSHELPER_ENUM_QUICK_TO_CORE(SystemTheme, theme)); -} - -QColor FramelessQuickUtils::systemAccentColor() const -{ - return Utils::getAccentColor(); -} - -bool FramelessQuickUtils::titleBarColorized() const -{ - return Utils::isTitleBarColorized(); -} - -QColor FramelessQuickUtils::defaultSystemLightColor() const -{ - return kDefaultSystemLightColor; -} - -QColor FramelessQuickUtils::defaultSystemDarkColor() const -{ - return kDefaultSystemDarkColor; -} - -QSizeF FramelessQuickUtils::defaultSystemButtonSize() const -{ - return kDefaultSystemButtonSize; -} - -QSizeF FramelessQuickUtils::defaultSystemButtonIconSize() const -{ - return kDefaultSystemButtonIconSize; -} - -QColor FramelessQuickUtils::defaultSystemButtonBackgroundColor() const -{ - return kDefaultSystemButtonBackgroundColor; -} - -QColor FramelessQuickUtils::defaultSystemCloseButtonBackgroundColor() const -{ - return kDefaultSystemCloseButtonBackgroundColor; -} - -bool FramelessQuickUtils::blurBehindWindowSupported() const -{ - return Utils::isBlurBehindWindowSupported(); -} - -QColor FramelessQuickUtils::getSystemButtonBackgroundColor(const QuickGlobal::SystemButtonType button, - const QuickGlobal::ButtonState state) -{ - return Utils::calculateSystemButtonBackgroundColor( - FRAMELESSHELPER_ENUM_QUICK_TO_CORE(SystemButtonType, button), - FRAMELESSHELPER_ENUM_QUICK_TO_CORE(ButtonState, state)); -} - -void FramelessQuickUtils::classBegin() -{ -} - -void FramelessQuickUtils::componentComplete() -{ -} - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickutils.h b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickutils.h deleted file mode 100644 index d765638c..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickutils.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Quick/framelessquickutils.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickwindow.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickwindow.cpp deleted file mode 100644 index 05855ed2..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickwindow.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "framelessquickwindow_p.h" -#include "framelessquickwindow_p_p.h" - -#if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(window)) - -#include "framelessquickhelper.h" -#if FRAMELESSHELPER_CONFIG(border_painter) -# include "quickwindowborder.h" -#endif -#ifdef Q_OS_WINDOWS -# include -#endif // Q_OS_WINDOWS -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcFramelessQuickWindow, "wangwenx190.framelesshelper.quick.framelessquickwindow") -# define INFO qCInfo(lcFramelessQuickWindow) -# define DEBUG qCDebug(lcFramelessQuickWindow) -# define WARNING qCWarning(lcFramelessQuickWindow) -# define CRITICAL qCCritical(lcFramelessQuickWindow) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -FramelessQuickWindowPrivate::FramelessQuickWindowPrivate(FramelessQuickWindow *q) : QObject(q) -{ - Q_ASSERT(q); - if (!q) { - return; - } - q_ptr = q; -} - -FramelessQuickWindowPrivate::~FramelessQuickWindowPrivate() = default; - -FramelessQuickWindowPrivate *FramelessQuickWindowPrivate::get(FramelessQuickWindow *pub) -{ - Q_ASSERT(pub); - if (!pub) { - return nullptr; - } - return pub->d_func(); -} - -const FramelessQuickWindowPrivate *FramelessQuickWindowPrivate::get(const FramelessQuickWindow *pub) -{ - Q_ASSERT(pub); - if (!pub) { - return nullptr; - } - return pub->d_func(); -} - -FramelessQuickWindow::FramelessQuickWindow(QWindow *parent) - : QQuickWindowQmlImpl(parent), d_ptr(std::make_unique(this)) -{ - QQuickItem * const rootItem = contentItem(); - FramelessQuickHelper::get(rootItem)->extendsContentIntoTitleBar(); -#if FRAMELESSHELPER_CONFIG(border_painter) - Q_D(FramelessQuickWindow); - d->windowBorder = new QuickWindowBorder; - d->windowBorder->setParent(rootItem); - d->windowBorder->setParentItem(rootItem); - d->windowBorder->setZ(999); // Make sure it always stays on the top. - QQuickItemPrivate::get(d->windowBorder)->anchors()->setFill(rootItem); -#endif - connect(this, &FramelessQuickWindow::visibilityChanged, this, [this](){ - Q_EMIT hiddenChanged(); - Q_EMIT normalChanged(); - Q_EMIT minimizedChanged(); - Q_EMIT maximizedChanged(); - Q_EMIT zoomedChanged(); - Q_EMIT fullScreenChanged(); - }); -} - -FramelessQuickWindow::~FramelessQuickWindow() = default; - -bool FramelessQuickWindow::isHidden() const -{ - return (visibility() == FramelessQuickWindow::Hidden); -} - -bool FramelessQuickWindow::isNormal() const -{ - return (visibility() == FramelessQuickWindow::Windowed); -} - -bool FramelessQuickWindow::isMinimized() const -{ - return (visibility() == FramelessQuickWindow::Minimized); -} - -bool FramelessQuickWindow::isMaximized() const -{ - return (visibility() == FramelessQuickWindow::Maximized); -} - -bool FramelessQuickWindow::isZoomed() const -{ - return (isMaximized() || (visibility() == FramelessQuickWindow::FullScreen)); -} - -bool FramelessQuickWindow::isFullScreen() const -{ - return (visibility() == FramelessQuickWindow::FullScreen); -} - -void FramelessQuickWindow::showMinimized2() -{ -#ifdef Q_OS_WINDOWS - // Work-around a QtQuick bug: https://bugreports.qt.io/browse/QTBUG-69711 - // Don't use "SW_SHOWMINIMIZED" because it will activate the current window - // instead of the next window in the Z order, which is not the default behavior - // of native Win32 applications. - ::ShowWindow(reinterpret_cast(winId()), SW_MINIMIZE); -#else - showMinimized(); -#endif -} - -void FramelessQuickWindow::toggleMaximized() -{ - if (isMaximized()) { - showNormal(); - } else { - showMaximized(); - } -} - -void FramelessQuickWindow::toggleFullScreen() -{ - Q_D(FramelessQuickWindow); - if (isFullScreen()) { - setVisibility(d->savedVisibility); - } else { - d->savedVisibility = visibility(); - showFullScreen(); - } -} - -void FramelessQuickWindow::classBegin() -{ - QQuickWindowQmlImpl::classBegin(); -} - -void FramelessQuickWindow::componentComplete() -{ - QQuickWindowQmlImpl::componentComplete(); -} - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickwindow_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickwindow_p.h deleted file mode 100644 index dfe7fbff..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickwindow_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Quick/private/framelessquickwindow_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickwindow_p_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickwindow_p_p.h deleted file mode 100644 index 51f24e01..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/framelessquickwindow_p_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Quick/private/framelessquickwindow_p_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickchromepalette.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickchromepalette.cpp deleted file mode 100644 index 3d7db306..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickchromepalette.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "quickchromepalette.h" - -#if FRAMELESSHELPER_CONFIG(titlebar) - -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcQuickChromePalette, "wangwenx190.framelesshelper.quick.quickchromepalette") -# define INFO qCInfo(lcQuickChromePalette) -# define DEBUG qCDebug(lcQuickChromePalette) -# define WARNING qCWarning(lcQuickChromePalette) -# define CRITICAL qCCritical(lcQuickChromePalette) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -QuickChromePalette::QuickChromePalette(QObject *parent) : ChromePalette(parent) -{ -} - -QuickChromePalette::~QuickChromePalette() = default; - -void QuickChromePalette::classBegin() -{ -} - -void QuickChromePalette::componentComplete() -{ -} - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickchromepalette.h b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickchromepalette.h deleted file mode 100644 index a1d5ba7a..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickchromepalette.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Quick/quickchromepalette.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickimageitem.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickimageitem.cpp deleted file mode 100644 index 096389d7..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickimageitem.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "quickimageitem_p.h" -#include -#include -#include -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcQuickImageItem, "wangwenx190.framelesshelper.quick.quickimageitem") -# define INFO qCInfo(lcQuickImageItem) -# define DEBUG qCDebug(lcQuickImageItem) -# define WARNING qCWarning(lcQuickImageItem) -# define CRITICAL qCCritical(lcQuickImageItem) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -FRAMELESSHELPER_STRING_CONSTANT2(QrcPrefix, "qrc:") -FRAMELESSHELPER_STRING_CONSTANT2(FileSystemPrefix, ":") -FRAMELESSHELPER_STRING_CONSTANT2(UrlPrefix, ":///") -FRAMELESSHELPER_STRING_CONSTANT2(FilePathPrefix, ":/") - -QuickImageItem::QuickImageItem(QQuickItem *parent) : QQuickPaintedItem(parent) -{ - setAntialiasing(true); - setSmooth(true); - setMipmap(true); - setClip(true); -} - -QuickImageItem::~QuickImageItem() = default; - -void QuickImageItem::paint(QPainter *painter) -{ - Q_ASSERT(painter); - if (!painter) { - return; - } - if (!m_source.isValid() || m_source.isNull()) { - return; - } - painter->save(); - painter->setRenderHints(QPainter::Antialiasing | - QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); - switch (m_source.userType()) { - case QMetaType::QUrl: - fromUrl(m_source.toUrl(), painter); - break; - case QMetaType::QString: - fromString(m_source.toString(), painter); - break; - case QMetaType::QImage: - fromImage(qvariant_cast(m_source), painter); - break; - case QMetaType::QPixmap: - fromPixmap(qvariant_cast(m_source), painter); - break; - case QMetaType::QIcon: - fromIcon(qvariant_cast(m_source), painter); - break; - default: - WARNING << "Unsupported type:" << m_source.typeName(); - break; - } - painter->restore(); -} - -QVariant QuickImageItem::source() const -{ - return m_source; -} - -void QuickImageItem::setSource(const QVariant &value) -{ - Q_ASSERT(value.isValid()); - Q_ASSERT(!value.isNull()); - if (!value.isValid() || value.isNull()) { - return; - } - if (m_source == value) { - return; - } - m_source = value; - update(); - Q_EMIT sourceChanged(); -} - -void QuickImageItem::fromUrl(const QUrl &value, QPainter *painter) const -{ - Q_ASSERT(value.isValid()); - Q_ASSERT(painter); - if (!value.isValid() || !painter) { - return; - } - fromString((value.isLocalFile() ? value.toLocalFile() : value.toString()), painter); -} - -void QuickImageItem::fromString(const QString &value, QPainter *painter) const -{ - Q_ASSERT(!value.isEmpty()); - Q_ASSERT(painter); - if (value.isEmpty() || !painter) { - return; - } - return fromPixmap(QPixmap([&value]() -> QString { - // For most Qt classes, the "qrc:///" prefix won't be recognized as a valid - // file system path, unless it accepts a QUrl object. For QString constructors - // we can only use ":/" to represent the file system path. - QString path = value; - if (path.startsWith(kQrcPrefix, Qt::CaseInsensitive)) { - path.replace(kQrcPrefix, kFileSystemPrefix, Qt::CaseInsensitive); - } - if (path.startsWith(kUrlPrefix, Qt::CaseInsensitive)) { - path.replace(kUrlPrefix, kFilePathPrefix, Qt::CaseInsensitive); - } - return path; - }()), painter); -} - -void QuickImageItem::fromImage(const QImage &value, QPainter *painter) const -{ - Q_ASSERT(!value.isNull()); - Q_ASSERT(painter); - if (value.isNull() || !painter) { - return; - } - fromPixmap(QPixmap::fromImage(value), painter); -} - -void QuickImageItem::fromPixmap(const QPixmap &value, QPainter *painter) const -{ - Q_ASSERT(!value.isNull()); - Q_ASSERT(painter); - if (value.isNull() || !painter) { - return; - } - const QRectF paintRect = paintArea(); - const QSize paintSize = paintRect.size().toSize(); - painter->drawPixmap(paintRect.topLeft(), (value.size() == paintSize ? value : value.scaled(paintSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation))); -} - -void QuickImageItem::fromIcon(const QIcon &value, QPainter *painter) const -{ - Q_ASSERT(!value.isNull()); - Q_ASSERT(painter); - if (value.isNull() || !painter) { - return; - } - fromPixmap(value.pixmap(paintArea().size().toSize()), painter); -} - -QRectF QuickImageItem::paintArea() const -{ -#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) - const QSizeF s = size(); -#else - const QSizeF s = {width(), height()}; -#endif - return {QPointF(0, 0), s}; -} - -void QuickImageItem::classBegin() -{ - QQuickPaintedItem::classBegin(); -} - -void QuickImageItem::componentComplete() -{ - QQuickPaintedItem::componentComplete(); -} - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickimageitem.h b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickimageitem.h deleted file mode 100644 index 01f435c8..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickimageitem.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Quick/quickimageitem.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickimageitem_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickimageitem_p.h deleted file mode 100644 index cb6238f2..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickimageitem_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Quick/private/quickimageitem_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickmicamaterial.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickmicamaterial.cpp deleted file mode 100644 index 674ff95a..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickmicamaterial.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "quickmicamaterial.h" -#include "quickmicamaterial_p.h" - -#if FRAMELESSHELPER_CONFIG(mica_material) - -#include -#include -#include -#if FRAMELESSHELPER_CONFIG(private_qt) -# include -# include -#endif // FRAMELESSHELPER_QUICK_NO_PRIVATE - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcQuickMicaMaterial, "wangwenx190.framelesshelper.quick.quickmicamaterial") -# define INFO qCInfo(lcQuickMicaMaterial) -# define DEBUG qCDebug(lcQuickMicaMaterial) -# define WARNING qCWarning(lcQuickMicaMaterial) -# define CRITICAL qCCritical(lcQuickMicaMaterial) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -QuickMicaMaterialPrivate::QuickMicaMaterialPrivate(QuickMicaMaterial *q) : QObject(q) -{ - Q_ASSERT(q); - if (!q) { - return; - } - q_ptr = q; - initialize(); -} - -QuickMicaMaterialPrivate::~QuickMicaMaterialPrivate() = default; - -QuickMicaMaterialPrivate *QuickMicaMaterialPrivate::get(QuickMicaMaterial *q) -{ - Q_ASSERT(q); - if (!q) { - return nullptr; - } - return q->d_func(); -} - -const QuickMicaMaterialPrivate *QuickMicaMaterialPrivate::get(const QuickMicaMaterial *q) -{ - Q_ASSERT(q); - if (!q) { - return nullptr; - } - return q->d_func(); -} - -void QuickMicaMaterialPrivate::initialize() -{ - Q_Q(QuickMicaMaterial); - - // No smooth needed. The blurry image is already low quality, enabling - // smooth won't help much and we also don't want it to slow down the - // general performance. - q->setSmooth(false); - // We don't need anti-aliasing. Same reason as above. - q->setAntialiasing(false); - // Enable clipping, to improve performance in some certain cases. - q->setClip(true); - // Disable mipmap, we don't need high quality scaling here. - q->setMipmap(false); - // Mica material should not be translucent anyway, enabling this option - // will disable the alpha blending of this item, which can also improve - // the rendering performance. - q->setOpaquePainting(true); - // Set an invalid fill color to prevent QQuickPaintedItem from drawing the background, - // we don't need it anyway and it can improve the general performance as well. - q->setFillColor(QColor{}); - - micaMaterial = new MicaMaterial(this); - connect(micaMaterial, &MicaMaterial::tintColorChanged, q, &QuickMicaMaterial::tintColorChanged); - connect(micaMaterial, &MicaMaterial::tintOpacityChanged, q, &QuickMicaMaterial::tintOpacityChanged); - connect(micaMaterial, &MicaMaterial::fallbackColorChanged, q, &QuickMicaMaterial::fallbackColorChanged); - connect(micaMaterial, &MicaMaterial::noiseOpacityChanged, q, &QuickMicaMaterial::noiseOpacityChanged); - connect(micaMaterial, &MicaMaterial::fallbackEnabledChanged, q, &QuickMicaMaterial::fallbackEnabledChanged); - connect(micaMaterial, &MicaMaterial::shouldRedraw, q, [q](){ q->update(); }); -} - -void QuickMicaMaterialPrivate::rebindWindow() -{ - Q_Q(QuickMicaMaterial); - const QQuickWindow * const window = q->window(); - if (!window) { - return; - } - QQuickItem * const rootItem = window->contentItem(); - q->setParent(rootItem); - q->setParentItem(rootItem); -#if FRAMELESSHELPER_CONFIG(private_qt) - QQuickItemPrivate::get(q)->anchors()->setFill(rootItem); -#endif // FRAMELESSHELPER_QUICK_NO_PRIVATE - q->setZ(-999); // Make sure we always stays on the bottom most place. - if (rootWindowXChangedConnection) { - disconnect(rootWindowXChangedConnection); - rootWindowXChangedConnection = {}; - } - if (rootWindowYChangedConnection) { - disconnect(rootWindowYChangedConnection); - rootWindowYChangedConnection = {}; - } - if (rootWindowActiveChangedConnection) { - disconnect(rootWindowActiveChangedConnection); - rootWindowActiveChangedConnection = {}; - } - rootWindowXChangedConnection = connect(window, &QQuickWindow::xChanged, q, [q](){ q->update(); }); - rootWindowYChangedConnection = connect(window, &QQuickWindow::yChanged, q, [q](){ q->update(); }); - rootWindowActiveChangedConnection = connect(window, &QQuickWindow::activeChanged, q, [q](){ q->update(); }); -} - -QuickMicaMaterial::QuickMicaMaterial(QQuickItem *parent) - : QQuickPaintedItem(parent), d_ptr(std::make_unique(this)) -{ -} - -QuickMicaMaterial::~QuickMicaMaterial() = default; - -void QuickMicaMaterial::paint(QPainter *painter) -{ - Q_ASSERT(painter); - if (!painter) { - return; - } - Q_D(QuickMicaMaterial); - const bool isActive = window() ? window()->isActive() : false; - const QPoint originPoint = mapToGlobal(QPointF{ 0, 0 }).toPoint(); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) - const QSize s = size().toSize(); -#else // (QT_VERSION < QT_VERSION_CHECK(5, 10, 0)) - const QSize s = QSizeF{ width(), height() }.toSize(); -#endif // (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) - d->micaMaterial->paint(painter, QRect{ originPoint, s }, isActive); -} - -QColor QuickMicaMaterial::tintColor() const -{ - Q_D(const QuickMicaMaterial); - return d->micaMaterial->tintColor(); -} - -void QuickMicaMaterial::setTintColor(const QColor &value) -{ - Q_D(QuickMicaMaterial); - d->micaMaterial->setTintColor(value); -} - -qreal QuickMicaMaterial::tintOpacity() const -{ - Q_D(const QuickMicaMaterial); - return d->micaMaterial->tintOpacity(); -} - -void QuickMicaMaterial::setTintOpacity(const qreal value) -{ - Q_D(QuickMicaMaterial); - d->micaMaterial->setTintOpacity(value); -} - -QColor QuickMicaMaterial::fallbackColor() const -{ - Q_D(const QuickMicaMaterial); - return d->micaMaterial->fallbackColor(); -} - -void QuickMicaMaterial::setFallbackColor(const QColor &value) -{ - Q_D(QuickMicaMaterial); - d->micaMaterial->setFallbackColor(value); -} - -qreal QuickMicaMaterial::noiseOpacity() const -{ - Q_D(const QuickMicaMaterial); - return d->micaMaterial->noiseOpacity(); -} - -void QuickMicaMaterial::setNoiseOpacity(const qreal value) -{ - Q_D(QuickMicaMaterial); - d->micaMaterial->setNoiseOpacity(value); -} - -bool QuickMicaMaterial::isFallbackEnabled() const -{ - Q_D(const QuickMicaMaterial); - return d->micaMaterial->isFallbackEnabled(); -} - -void QuickMicaMaterial::setFallbackEnabled(const bool value) -{ - Q_D(QuickMicaMaterial); - d->micaMaterial->setFallbackEnabled(value); -} - -void QuickMicaMaterial::itemChange(const ItemChange change, const ItemChangeData &value) -{ - QQuickPaintedItem::itemChange(change, value); - Q_D(QuickMicaMaterial); - switch (change) { - case ItemDevicePixelRatioHasChanged: - update(); // Force re-paint immediately. - break; - case ItemSceneChange: - if (value.window) { - d->rebindWindow(); - } - break; - default: - break; - } -} - -void QuickMicaMaterial::classBegin() -{ - QQuickPaintedItem::classBegin(); -} - -void QuickMicaMaterial::componentComplete() -{ - QQuickPaintedItem::componentComplete(); -} - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickmicamaterial.h b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickmicamaterial.h deleted file mode 100644 index cff5c54d..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickmicamaterial.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Quick/quickmicamaterial.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickmicamaterial_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickmicamaterial_p.h deleted file mode 100644 index 3ed20c13..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickmicamaterial_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Quick/private/quickmicamaterial_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickstandardsystembutton.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickstandardsystembutton.cpp deleted file mode 100644 index 9890ae67..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickstandardsystembutton.cpp +++ /dev/null @@ -1,308 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "quickstandardsystembutton_p.h" - -#if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(system_button) && (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))) - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcQuickStandardSystemButton, "wangwenx190.framelesshelper.quick.quickstandardsystembutton") -# define INFO qCInfo(lcQuickStandardSystemButton) -# define DEBUG qCDebug(lcQuickStandardSystemButton) -# define WARNING qCWarning(lcQuickStandardSystemButton) -# define CRITICAL qCCritical(lcQuickStandardSystemButton) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -QuickStandardSystemButton::QuickStandardSystemButton(QQuickItem *parent) : QQuickButton(parent) -{ - initialize(); -} - -QuickStandardSystemButton::QuickStandardSystemButton(const QuickGlobal::SystemButtonType type, QQuickItem *parent) : QuickStandardSystemButton(parent) -{ - setButtonType(type); -} - -QuickStandardSystemButton::~QuickStandardSystemButton() = default; - -QuickGlobal::SystemButtonType QuickStandardSystemButton::buttonType() const -{ - return m_buttonType; -} - -QString QuickStandardSystemButton::glyph() const -{ - return m_glyph; -} - -QColor QuickStandardSystemButton::normalColor() const -{ - return m_normalColor; -} - -QColor QuickStandardSystemButton::hoverColor() const -{ - return m_hoverColor; -} - -QColor QuickStandardSystemButton::pressColor() const -{ - return m_pressColor; -} - -QColor QuickStandardSystemButton::activeForegroundColor() const -{ - return m_activeForegroundColor; -} - -QColor QuickStandardSystemButton::inactiveForegroundColor() const -{ - return m_inactiveForegroundColor; -} - -qreal QuickStandardSystemButton::glyphSize() const -{ - if (!m_contentItem) { - return -1; - } - const QFont font = m_contentItem->font(); - const qreal point = font.pointSizeF(); - if (point > 0) { - return point; - } - const int pixel = font.pixelSize(); - if (pixel > 0) { - return pixel; - } - return -1; -} - -void QuickStandardSystemButton::setButtonType(const QuickGlobal::SystemButtonType type) -{ - Q_ASSERT(type != QuickGlobal::SystemButtonType::Unknown); - if (type == QuickGlobal::SystemButtonType::Unknown) { - return; - } - if (m_buttonType == type) { - return; - } - m_buttonType = type; - setGlyph(Utils::getSystemButtonGlyph( - FRAMELESSHELPER_ENUM_QUICK_TO_CORE(SystemButtonType, m_buttonType))); - Q_EMIT buttonTypeChanged(); -} - -void QuickStandardSystemButton::setGlyph(const QString &value) -{ - Q_ASSERT(!value.isEmpty()); - if (value.isEmpty()) { - return; - } - if (m_glyph == value) { - return; - } - m_glyph = value; - m_contentItem->setText(m_glyph); - Q_EMIT glyphChanged(); -} - -void QuickStandardSystemButton::setNormalColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - if (m_normalColor == value) { - return; - } - m_normalColor = value; - updateColor(); - Q_EMIT normalColorChanged(); -} - -void QuickStandardSystemButton::setHoverColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - if (m_hoverColor == value) { - return; - } - m_hoverColor = value; - updateColor(); - Q_EMIT hoverColorChanged(); -} - -void QuickStandardSystemButton::setPressColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - if (m_pressColor == value) { - return; - } - m_pressColor = value; - updateColor(); - Q_EMIT pressColorChanged(); -} - -void QuickStandardSystemButton::setActiveForegroundColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - if (m_activeForegroundColor == value) { - return; - } - m_activeForegroundColor = value; - updateColor(); - Q_EMIT activeForegroundColorChanged(); -} - -void QuickStandardSystemButton::setInactiveForegroundColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - if (m_inactiveForegroundColor == value) { - return; - } - m_inactiveForegroundColor = value; - updateColor(); - Q_EMIT inactiveForegroundColorChanged(); -} - -void QuickStandardSystemButton::setGlyphSize(const qreal value) -{ - Q_ASSERT(value > 0); - if (qFuzzyIsNull(value) || (value < 0)) { - return; - } - if (qFuzzyCompare(glyphSize(), value)) { - return; - } - QFont font = m_contentItem->font(); - font.setPointSizeF(value); - m_contentItem->setFont(font); - Q_EMIT glyphSizeChanged(); -} - -void QuickStandardSystemButton::updateColor() -{ - const bool hover = isHovered(); - const bool press = isPressed(); - m_contentItem->setColor([this, hover]() -> QColor { - const bool active = (window() ? window()->isActive() : false); - if (!hover && !active && m_inactiveForegroundColor.isValid()) { - return m_inactiveForegroundColor; - } - if ((m_buttonType == QuickGlobal::SystemButtonType::Close) && hover) { - return kDefaultWhiteColor; - } - if (m_activeForegroundColor.isValid()) { - return m_activeForegroundColor; - } - return kDefaultBlackColor; - }()); - m_backgroundItem->setColor([this, hover, press]() -> QColor { - if (press && m_pressColor.isValid()) { - return m_pressColor; - } - if (hover && m_hoverColor.isValid()) { - return m_hoverColor; - } - if (m_normalColor.isValid()) { - return m_normalColor; - } - return kDefaultTransparentColor; - }()); - qobject_cast(qmlAttachedPropertiesObject(this))->setVisible(hover || press); -} - -void QuickStandardSystemButton::initialize() -{ - FramelessManagerPrivate::initializeIconFont(); - - setAntialiasing(true); - setSmooth(true); - setClip(true); - - setImplicitWidth(kDefaultSystemButtonSize.width()); - setImplicitHeight(kDefaultSystemButtonSize.height()); - - m_contentItem = new QQuickText(this); - m_contentItem->setFont(FramelessManagerPrivate::getIconFont()); - m_contentItem->setHAlign(QQuickText::AlignHCenter); - m_contentItem->setVAlign(QQuickText::AlignVCenter); - QQuickItemPrivate::get(m_contentItem)->anchors()->setFill(this); - - m_backgroundItem = new QQuickRectangle(this); - QQuickPen * const border = m_backgroundItem->border(); - border->setWidth(0.0); - border->setColor(kDefaultTransparentColor); - connect(this, &QuickStandardSystemButton::hoveredChanged, this, &QuickStandardSystemButton::updateColor); - connect(this, &QuickStandardSystemButton::pressedChanged, this, &QuickStandardSystemButton::updateColor); - - updateColor(); - - setContentItem(m_contentItem); - setBackground(m_backgroundItem); -} - -void QuickStandardSystemButton::classBegin() -{ - QQuickButton::classBegin(); -} - -void QuickStandardSystemButton::componentComplete() -{ - QQuickButton::componentComplete(); -} - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickstandardsystembutton_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickstandardsystembutton_p.h deleted file mode 100644 index d5450a09..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickstandardsystembutton_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Quick/private/quickstandardsystembutton_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickstandardtitlebar.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickstandardtitlebar.cpp deleted file mode 100644 index 352e26bd..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickstandardtitlebar.cpp +++ /dev/null @@ -1,635 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "quickstandardtitlebar_p.h" - -#if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(titlebar) && (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))) - -#include "quickimageitem_p.h" -#include "framelessquickhelper.h" -#if FRAMELESSHELPER_CONFIG(system_button) -# include "quickstandardsystembutton_p.h" -#endif -#if FRAMELESSHELPER_CONFIG(window) -# include "framelessquickwindow_p.h" -# include "framelessquickapplicationwindow_p.h" -#endif -#include -#include -#include -#include -#include -#include -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcQuickStandardTitleBar, "wangwenx190.framelesshelper.quick.quickstandardtitlebar") -# define INFO qCInfo(lcQuickStandardTitleBar) -# define DEBUG qCDebug(lcQuickStandardTitleBar) -# define WARNING qCWarning(lcQuickStandardTitleBar) -# define CRITICAL qCCritical(lcQuickStandardTitleBar) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -QuickStandardTitleBar::QuickStandardTitleBar(QQuickItem *parent) : QQuickRectangle(parent) -{ - initialize(); -} - -QuickStandardTitleBar::~QuickStandardTitleBar() = default; - -Qt::Alignment QuickStandardTitleBar::titleLabelAlignment() const -{ - return m_labelAlignment; -} - -void QuickStandardTitleBar::setTitleLabelAlignment(const Qt::Alignment value) -{ - if (m_labelAlignment == value) { - return; - } - m_labelAlignment = value; - QQuickAnchors * const labelAnchors = QQuickItemPrivate::get(m_windowTitleLabel)->anchors(); - labelAnchors->resetFill(); - labelAnchors->resetCenterIn(); - labelAnchors->resetHorizontalCenter(); - labelAnchors->resetVerticalCenter(); - labelAnchors->resetTop(); - labelAnchors->resetBottom(); - labelAnchors->resetLeft(); - labelAnchors->resetRight(); - labelAnchors->setMargins(0); - m_windowTitleLabel->setVAlign(QQuickLabel::AlignVCenter); - const QQuickItemPrivate * const titleBarPriv = QQuickItemPrivate::get(this); - labelAnchors->setVerticalCenter(titleBarPriv->verticalCenter()); - if ((m_labelAlignment & Qt::AlignLeft) || (m_labelAlignment & Qt::AlignRight) || (m_labelAlignment & Qt::AlignHCenter)) { - if (m_windowIcon->isVisible()) { - labelAnchors->setLeft(QQuickItemPrivate::get(m_windowIcon)->right()); - } else { - labelAnchors->setLeft(titleBarPriv->left()); - } - labelAnchors->setLeftMargin(kDefaultTitleBarContentsMargin); -#ifdef Q_OS_MACOS - labelAnchors->setRight(titleBarPriv->right()); -#elif FRAMELESSHELPER_CONFIG(system_button) - labelAnchors->setRight(QQuickItemPrivate::get(m_systemButtonsRow)->left()); -#endif - labelAnchors->setRightMargin(kDefaultTitleBarContentsMargin); - if (m_labelAlignment & Qt::AlignLeft) { - m_windowTitleLabel->setHAlign(QQuickLabel::AlignLeft); - } else if (m_labelAlignment & Qt::AlignRight) { - m_windowTitleLabel->setHAlign(QQuickLabel::AlignRight); - } else { - m_windowTitleLabel->setHAlign(QQuickLabel::AlignHCenter); - } - } else { - WARNING << "The alignment for the title label is not set!"; - labelAnchors->setLeft(titleBarPriv->left()); - m_windowTitleLabel->setHAlign(QQuickLabel::AlignLeft); - } - Q_EMIT titleLabelAlignmentChanged(); -} - -QQuickLabel *QuickStandardTitleBar::titleLabel() const -{ - return m_windowTitleLabel; -} - -#if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button)) -QuickStandardSystemButton *QuickStandardTitleBar::minimizeButton() const -{ - return m_minimizeButton; -} - -QuickStandardSystemButton *QuickStandardTitleBar::maximizeButton() const -{ - return m_maximizeButton; -} - -QuickStandardSystemButton *QuickStandardTitleBar::closeButton() const -{ - return m_closeButton; -} -#endif - -bool QuickStandardTitleBar::isExtended() const -{ - return m_extended; -} - -void QuickStandardTitleBar::setExtended(const bool value) -{ - if (m_extended == value) { - return; - } - m_extended = value; - setHeight(m_extended ? kDefaultExtendedTitleBarHeight : kDefaultTitleBarHeight); - Q_EMIT extendedChanged(); -} - -bool QuickStandardTitleBar::isHideWhenClose() const -{ - return m_hideWhenClose; -} - -void QuickStandardTitleBar::setHideWhenClose(const bool value) -{ - if (m_hideWhenClose == value) { - return; - } - m_hideWhenClose = value; - Q_EMIT hideWhenCloseChanged(); -} - -QuickChromePalette *QuickStandardTitleBar::chromePalette() const -{ - return m_chromePalette; -} - -QSizeF QuickStandardTitleBar::windowIconSize() const -{ -#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) - return m_windowIcon->size(); -#else - return {m_windowIcon->width(), m_windowIcon->height()}; -#endif -} - -void QuickStandardTitleBar::setWindowIconSize(const QSizeF &value) -{ - Q_ASSERT(!value.isEmpty()); - if (value.isEmpty()) { - return; - } - if (windowIconSize() == value) { - return; - } -#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) - m_windowIcon->setSize(value); -#else - m_windowIcon->setWidth(value.width()); - m_windowIcon->setHeight(value.height()); -#endif -} - -bool QuickStandardTitleBar::windowIconVisible() const -{ - return m_windowIcon->isVisible(); -} - -void QuickStandardTitleBar::setWindowIconVisible(const bool value) -{ - if (m_windowIcon->isVisible() == value) { - return; - } - m_windowIcon->setVisible(value); -#ifndef Q_OS_MACOS - if (m_labelAlignment & Qt::AlignLeft) { - QQuickAnchors * const labelAnchors = QQuickItemPrivate::get(m_windowTitleLabel)->anchors(); - if (value) { - labelAnchors->setLeft(QQuickItemPrivate::get(m_windowIcon)->right()); - } else { - labelAnchors->setLeft(QQuickItemPrivate::get(this)->left()); - } - } - FramelessQuickHelper::get(this)->setHitTestVisible_rect(windowIconRect(), windowIconVisible_real()); -#endif // Q_OS_MACOS -} - -QVariant QuickStandardTitleBar::windowIcon() const -{ - return m_windowIcon->source(); -} - -void QuickStandardTitleBar::setWindowIcon(const QVariant &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - if (m_windowIcon->source() == value) { - return; - } - m_windowIcon->setSource(value); -} - -void QuickStandardTitleBar::updateMaximizeButton() -{ -#if (FRAMELESSHELPER_CONFIG(system_button) && defined(Q_OS_LINUX)) - const QQuickWindow * const w = window(); - if (!w) { - return; - } - const bool max = (w->visibility() == QQuickWindow::Maximized); - m_maximizeButton->setButtonType(max ? QuickGlobal::SystemButtonType::Restore : QuickGlobal::SystemButtonType::Maximize); - qobject_cast(qmlAttachedPropertiesObject(m_maximizeButton))->setText(max ? tr("Restore") : tr("Maximize")); -#endif -} - -void QuickStandardTitleBar::updateTitleLabelText() -{ - const QQuickWindow * const w = window(); - if (!w) { - return; - } - m_windowTitleLabel->setText(w->title()); -} - -void QuickStandardTitleBar::updateTitleBarColor() -{ - const QQuickWindow * const w = window(); - if (!w) { - return; - } - const bool active = w->isActive(); - const QColor backgroundColor = (active ? - m_chromePalette->titleBarActiveBackgroundColor() : - m_chromePalette->titleBarInactiveBackgroundColor()); - const QColor foregroundColor = (active ? - m_chromePalette->titleBarActiveForegroundColor() : - m_chromePalette->titleBarInactiveForegroundColor()); - setColor(backgroundColor); - m_windowTitleLabel->setColor(foregroundColor); -} - -void QuickStandardTitleBar::updateChromeButtonColor() -{ -#if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button)) - const QQuickWindow * const w = window(); - if (!w) { - return; - } - const QColor activeForeground = m_chromePalette->titleBarActiveForegroundColor(); - const QColor inactiveForeground = m_chromePalette->titleBarInactiveForegroundColor(); - const QColor normal = m_chromePalette->chromeButtonNormalColor(); - const QColor hover = m_chromePalette->chromeButtonHoverColor(); - const QColor press = m_chromePalette->chromeButtonPressColor(); - m_minimizeButton->setActiveForegroundColor(activeForeground); - m_minimizeButton->setInactiveForegroundColor(inactiveForeground); - m_minimizeButton->setNormalColor(normal); - m_minimizeButton->setHoverColor(hover); - m_minimizeButton->setPressColor(press); - m_minimizeButton->updateColor(); - m_maximizeButton->setActiveForegroundColor(activeForeground); - m_maximizeButton->setInactiveForegroundColor(inactiveForeground); - m_maximizeButton->setNormalColor(normal); - m_maximizeButton->setHoverColor(hover); - m_maximizeButton->setPressColor(press); - m_maximizeButton->updateColor(); - m_closeButton->setActiveForegroundColor(activeForeground); - m_closeButton->setInactiveForegroundColor(inactiveForeground); - m_closeButton->setNormalColor(m_chromePalette->closeButtonNormalColor()); - m_closeButton->setHoverColor(m_chromePalette->closeButtonHoverColor()); - m_closeButton->setPressColor(m_chromePalette->closeButtonPressColor()); - m_closeButton->updateColor(); -#endif -} - -void QuickStandardTitleBar::clickMinimizeButton() -{ - QQuickWindow * const w = window(); - if (!w) { - return; - } -#if FRAMELESSHELPER_CONFIG(window) - if (const auto _w = qobject_cast(w)) { - _w->showMinimized2(); - } else if (const auto _w2 = qobject_cast(w)) { - _w2->showMinimized2(); - } else -#endif - { - w->setVisibility(QQuickWindow::Minimized); - } -} - -void QuickStandardTitleBar::clickMaximizeButton() -{ - QQuickWindow * const w = window(); - if (!w) { - return; - } - if (w->visibility() == QQuickWindow::Maximized) { - w->setVisibility(QQuickWindow::Windowed); - } else { - w->setVisibility(QQuickWindow::Maximized); - } -} - -void QuickStandardTitleBar::clickCloseButton() -{ - QQuickWindow * const w = window(); - if (!w) { - return; - } - if (m_hideWhenClose) { - w->hide(); - } else { - w->close(); - } -} - -void QuickStandardTitleBar::retranslateUi() -{ -#if (FRAMELESSHELPER_CONFIG(system_button) && defined(Q_OS_LINUX)) - qobject_cast(qmlAttachedPropertiesObject(m_minimizeButton))->setText(tr("Minimize")); - qobject_cast(qmlAttachedPropertiesObject(m_maximizeButton))->setText([this]() -> QString { - if (const QQuickWindow * const w = window()) { - if (w->visibility() == QQuickWindow::Maximized) { - return tr("Restore"); - } - } - return tr("Maximize"); - }()); - qobject_cast(qmlAttachedPropertiesObject(m_closeButton))->setText(tr("Close")); -#endif -} - -void QuickStandardTitleBar::updateWindowIcon() -{ - // The user has set an icon explicitly, don't override it. - if (m_windowIcon->source().isValid()) { - return; - } - const QIcon icon = (window() ? window()->icon() : QIcon()); - if (icon.isNull()) { - return; - } - m_windowIcon->setSource(icon); -} - -bool QuickStandardTitleBar::mouseEventHandler(QMouseEvent *event) -{ -#ifdef Q_OS_MACOS - Q_UNUSED(event); - return false; -#else // !Q_OS_MACOS - Q_ASSERT(event); - if (!event) { - return false; - } - const Qt::MouseButton button = event->button(); -#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - const QPoint scenePos = event->scenePosition().toPoint(); -#else - const QPoint scenePos = event->windowPos().toPoint(); -#endif - const bool interestArea = isInTitleBarIconArea(scenePos); - switch (event->type()) { - case QEvent::MouseButtonRelease: - if (interestArea) { - // Sadly the mouse release events are always triggered before the - // mouse double click events, and if we intercept the mouse release - // events here, we'll never get the double click events afterwards, - // so we have to wait for a little bit to make sure the double - // click events are handled first, before we actually handle the - // mouse release events here. - // We need to wait long enough because the time interval between these - // events is really really short, if the delay time is not long enough, - // we still can't trigger the double click event due to we have handled - // the mouse release events here already. But we also can't wait too - // long, otherwise the system menu will show up too late, which is not - // a good user experience. In my experiments, I found that 150ms is - // the minimum value we can use here. - // We need a copy of the "scenePos" variable here, otherwise it will - // soon fall out of scope when the lambda function actually runs. - QTimer::singleShot(150, this, [this, button, scenePos](){ - // The close event is already triggered, don't try to show the - // system menu anymore, otherwise it will prevent our window - // from closing. - if (m_closeTriggered) { - return; - } - FramelessQuickHelper::get(this)->showSystemMenu([this, button, &scenePos]() -> QPoint { - QPoint pos = scenePos; - if (button == Qt::LeftButton) { - pos = {0, int(std::round(height()))}; - } - return mapToGlobal(pos).toPoint(); - }()); - }); - // Don't eat this event, we have not handled it yet. - } - break; - case QEvent::MouseButtonDblClick: - if (QQuickWindow * const w = window()) { - if ((button == Qt::LeftButton) && interestArea) { - m_closeTriggered = true; - w->close(); - // Eat this event, we have handled it here. - event->accept(); - return true; - } - } - break; - default: - break; - } - return false; -#endif // Q_OS_MACOS -} - -QRect QuickStandardTitleBar::windowIconRect() const -{ -#if 0 - const QSizeF size = windowIconSize(); - const qreal y = ((height() - size.height()) / qreal(2)); - return QRectF(QPointF(kDefaultTitleBarContentsMargin, y), size).toRect(); -#else - return QRectF(QPointF(m_windowIcon->x(), m_windowIcon->y()), windowIconSize()).toRect(); -#endif -} - -bool QuickStandardTitleBar::windowIconVisible_real() const -{ - if (!m_windowIcon || !m_windowIcon->isVisible() || !m_windowIcon->source().isValid()) { - return false; - } - return true; -} - -bool QuickStandardTitleBar::isInTitleBarIconArea(const QPoint &pos) const -{ - if (!windowIconVisible_real()) { - return false; - } - return windowIconRect().contains(pos); -} - -void QuickStandardTitleBar::initialize() -{ - setSmooth(true); - setClip(true); - setAntialiasing(true); - - m_chromePalette = new QuickChromePalette(this); - connect(m_chromePalette, &ChromePalette::titleBarColorChanged, - this, &QuickStandardTitleBar::updateTitleBarColor); - connect(m_chromePalette, &ChromePalette::chromeButtonColorChanged, - this, &QuickStandardTitleBar::updateChromeButtonColor); - - QQuickPen * const b = border(); - b->setWidth(0.0); - b->setColor(kDefaultTransparentColor); - setHeight(kDefaultTitleBarHeight); - - m_windowTitleLabel = new QQuickLabel(this); - m_windowTitleLabel->setMaximumLineCount(1); - m_windowTitleLabel->setElideMode(QQuickText::ElideRight); - QFont f = m_windowTitleLabel->font(); - f.setPointSize(kDefaultTitleBarFontPointSize); - m_windowTitleLabel->setFont(f); - - const QQuickItemPrivate * const thisPriv = QQuickItemPrivate::get(this); - - m_windowIcon = new QuickImageItem(this); - QQuickAnchors * const iconAnchors = QQuickItemPrivate::get(m_windowIcon)->anchors(); - iconAnchors->setVerticalCenter(thisPriv->verticalCenter()); -#ifdef Q_OS_MACOS - const QQuickItemPrivate * const labelPriv = QQuickItemPrivate::get(m_windowTitleLabel); - iconAnchors->setRight(labelPriv->left()); - iconAnchors->setRightMargin(kDefaultTitleBarContentsMargin); -#else // !Q_OS_MACOS - iconAnchors->setLeft(thisPriv->left()); - iconAnchors->setLeftMargin(kDefaultTitleBarContentsMargin); -#endif // Q_OS_MACOS - connect(m_windowIcon, &QuickImageItem::visibleChanged, this, &QuickStandardTitleBar::windowIconVisibleChanged); - connect(m_windowIcon, &QuickImageItem::sourceChanged, this, &QuickStandardTitleBar::windowIconChanged); - connect(m_windowIcon, &QuickImageItem::widthChanged, this, &QuickStandardTitleBar::windowIconSizeChanged); - connect(m_windowIcon, &QuickImageItem::heightChanged, this, &QuickStandardTitleBar::windowIconSizeChanged); - -#if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button)) - m_systemButtonsRow = new QQuickRow(this); - QQuickAnchors * const rowAnchors = QQuickItemPrivate::get(m_systemButtonsRow)->anchors(); - rowAnchors->setTop(thisPriv->top()); - rowAnchors->setRight(thisPriv->right()); - m_minimizeButton = new QuickStandardSystemButton(QuickGlobal::SystemButtonType::Minimize, m_systemButtonsRow); - connect(m_minimizeButton, &QuickStandardSystemButton::clicked, this, &QuickStandardTitleBar::clickMinimizeButton); - m_maximizeButton = new QuickStandardSystemButton(m_systemButtonsRow); - connect(m_maximizeButton, &QuickStandardSystemButton::clicked, this, &QuickStandardTitleBar::clickMaximizeButton); - m_closeButton = new QuickStandardSystemButton(QuickGlobal::SystemButtonType::Close, m_systemButtonsRow); - connect(m_closeButton, &QuickStandardSystemButton::clicked, this, &QuickStandardTitleBar::clickCloseButton); -#endif - - setWindowIconSize(kDefaultWindowIconSize); - setWindowIconVisible(false); -#ifdef Q_OS_MACOS - setTitleLabelAlignment(Qt::AlignCenter); -#else // !Q_OS_MACOS - setTitleLabelAlignment(Qt::AlignLeft | Qt::AlignVCenter); -#endif // Q_OS_MACOS - retranslateUi(); - updateAll(); -} - -void QuickStandardTitleBar::itemChange(const ItemChange change, const ItemChangeData &value) -{ - QQuickRectangle::itemChange(change, value); - if ((change == ItemSceneChange) && value.window) { - if (m_windowStateChangeConnection) { - disconnect(m_windowStateChangeConnection); - m_windowStateChangeConnection = {}; - } - if (m_windowActiveChangeConnection) { - disconnect(m_windowActiveChangeConnection); - m_windowActiveChangeConnection = {}; - } - if (m_windowTitleChangeConnection) { - disconnect(m_windowTitleChangeConnection); - m_windowTitleChangeConnection = {}; - } - m_windowStateChangeConnection = connect(value.window, &QQuickWindow::visibilityChanged, this, &QuickStandardTitleBar::updateMaximizeButton); - m_windowActiveChangeConnection = connect(value.window, &QQuickWindow::activeChanged, this, [this](){ - updateTitleBarColor(); - updateChromeButtonColor(); - }); - m_windowTitleChangeConnection = connect(value.window, &QQuickWindow::windowTitleChanged, this, &QuickStandardTitleBar::updateTitleLabelText); - updateAll(); - value.window->installEventFilter(this); - // The window has changed, we need to re-add or re-remove the window icon rect to - // the hit test visible whitelist. This is different with Qt Widgets. - FramelessQuickHelper::get(this)->setHitTestVisible_rect(windowIconRect(), windowIconVisible_real()); - } -} - -bool QuickStandardTitleBar::eventFilter(QObject *object, QEvent *event) -{ - Q_ASSERT(object); - Q_ASSERT(event); - if (!object || !event) { - return false; - } - if (!object->isWindowType()) { - return QQuickRectangle::eventFilter(object, event); - } - const auto w = qobject_cast(object); - if (w != window()) { - return QQuickRectangle::eventFilter(object, event); - } - const QEvent::Type type = event->type(); - if (type == QEvent::LanguageChange) { - retranslateUi(); - // Don't eat the event here, we need it to keep dispatching to other - // objects that may be interested in this event. - } else if ((type >= QEvent::MouseButtonPress) && (type <= QEvent::MouseMove)) { - const auto mouseEvent = static_cast(event); - if (mouseEventHandler(mouseEvent)) { - // We have handled the event already, stop dispatching. - return true; - } - } - return QQuickRectangle::eventFilter(object, event); -} - -void QuickStandardTitleBar::updateAll() -{ - updateWindowIcon(); - updateMaximizeButton(); - updateTitleLabelText(); - updateTitleBarColor(); - updateChromeButtonColor(); -} - -void QuickStandardTitleBar::classBegin() -{ - QQuickRectangle::classBegin(); -} - -void QuickStandardTitleBar::componentComplete() -{ - QQuickRectangle::componentComplete(); -} - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickstandardtitlebar_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickstandardtitlebar_p.h deleted file mode 100644 index 4b850729..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickstandardtitlebar_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Quick/private/quickstandardtitlebar_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickwindowborder.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickwindowborder.cpp deleted file mode 100644 index 2562c407..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickwindowborder.cpp +++ /dev/null @@ -1,309 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "quickwindowborder.h" -#include "quickwindowborder_p.h" - -#if FRAMELESSHELPER_CONFIG(border_painter) - -#include -#include -#include -#if FRAMELESSHELPER_CONFIG(private_qt) -# include -#endif - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcQuickWindowBorder, "wangwenx190.framelesshelper.quick.quickwindowborder") -# define INFO qCInfo(lcQuickWindowBorder) -# define DEBUG qCDebug(lcQuickWindowBorder) -# define WARNING qCWarning(lcQuickWindowBorder) -# define CRITICAL qCCritical(lcQuickWindowBorder) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -[[nodiscard]] static inline QuickGlobal::WindowEdges edgesToQuickEdges(const WindowEdges edges) -{ - QuickGlobal::WindowEdges result = {}; - if (edges & WindowEdge::Left) { - result |= QuickGlobal::WindowEdge::Left; - } - if (edges & WindowEdge::Top) { - result |= QuickGlobal::WindowEdge::Top; - } - if (edges & WindowEdge::Right) { - result |= QuickGlobal::WindowEdge::Right; - } - if (edges & WindowEdge::Bottom) { - result |= QuickGlobal::WindowEdge::Bottom; - } - return result; -} - -[[nodiscard]] static inline WindowEdges quickEdgesToEdges(const QuickGlobal::WindowEdges edges) -{ - WindowEdges result = {}; - if (edges & QuickGlobal::WindowEdge::Left) { - result |= WindowEdge::Left; - } - if (edges & QuickGlobal::WindowEdge::Top) { - result |= WindowEdge::Top; - } - if (edges & QuickGlobal::WindowEdge::Right) { - result |= WindowEdge::Right; - } - if (edges & QuickGlobal::WindowEdge::Bottom) { - result |= WindowEdge::Bottom; - } - return result; -} - -QuickWindowBorderPrivate::QuickWindowBorderPrivate(QuickWindowBorder *q) : QObject(q) -{ - Q_ASSERT(q); - if (!q) { - return; - } - q_ptr = q; - initialize(); -} - -QuickWindowBorderPrivate::~QuickWindowBorderPrivate() = default; - -QuickWindowBorderPrivate *QuickWindowBorderPrivate::get(QuickWindowBorder *q) -{ - Q_ASSERT(q); - if (!q) { - return nullptr; - } - return q->d_func(); -} - -const QuickWindowBorderPrivate *QuickWindowBorderPrivate::get(const QuickWindowBorder *q) -{ - Q_ASSERT(q); - if (!q) { - return nullptr; - } - return q->d_func(); -} - -void QuickWindowBorderPrivate::update() -{ - Q_Q(QuickWindowBorder); - const QQuickWindow * const window = q->window(); - if (!window) { - return; - } - q->update(); - q->setVisible(window->visibility() == QQuickWindow::Windowed); -} - -void QuickWindowBorderPrivate::initialize() -{ - Q_Q(QuickWindowBorder); - q->setClip(true); - q->setSmooth(true); - // We can't enable antialising for this element due to we are drawing - // some very thin lines that are too fragile. - q->setAntialiasing(false); - - borderPainter = new WindowBorderPainter(this); - connect(borderPainter, &WindowBorderPainter::thicknessChanged, - q, &QuickWindowBorder::thicknessChanged); - connect(borderPainter, &WindowBorderPainter::edgesChanged, - q, &QuickWindowBorder::edgesChanged); - connect(borderPainter, &WindowBorderPainter::activeColorChanged, - q, &QuickWindowBorder::activeColorChanged); - connect(borderPainter, &WindowBorderPainter::inactiveColorChanged, - q, &QuickWindowBorder::inactiveColorChanged); - connect(borderPainter, &WindowBorderPainter::nativeBorderChanged, - q, &QuickWindowBorder::nativeBorderChanged); - connect(borderPainter, &WindowBorderPainter::shouldRepaint, q, [q](){ q->update(); }); -} - -void QuickWindowBorderPrivate::rebindWindow() -{ - Q_Q(QuickWindowBorder); - const QQuickWindow * const window = q->window(); - if (!window) { - return; - } - QQuickItem * const rootItem = window->contentItem(); - q->setParent(rootItem); - q->setParentItem(rootItem); -#if FRAMELESSHELPER_CONFIG(private_qt) - QQuickItemPrivate::get(q)->anchors()->setFill(rootItem); -#endif - q->setZ(999); // Make sure we always stays on the top most place. - if (activeChangeConnection) { - disconnect(activeChangeConnection); - activeChangeConnection = {}; - } - if (visibilityChangeConnection) { - disconnect(visibilityChangeConnection); - visibilityChangeConnection = {}; - } - activeChangeConnection = connect(window, &QQuickWindow::activeChanged, - this, &QuickWindowBorderPrivate::update); - visibilityChangeConnection = connect(window, &QQuickWindow::visibilityChanged, - this, &QuickWindowBorderPrivate::update); -} - -QuickWindowBorder::QuickWindowBorder(QQuickItem *parent) - : QQuickPaintedItem(parent), d_ptr(std::make_unique(this)) -{ -} - -QuickWindowBorder::~QuickWindowBorder() = default; - -void QuickWindowBorder::paint(QPainter *painter) -{ - Q_ASSERT(painter); - if (!painter) { - return; - } - Q_D(QuickWindowBorder); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) - const QSize s = size().toSize(); -#else - const QSize s = QSizeF{ width(), height() }.toSize(); -#endif - d->borderPainter->paint(painter, s, (window() && window()->isActive())); -} - -qreal QuickWindowBorder::thickness() const -{ - Q_D(const QuickWindowBorder); - return d->borderPainter->thickness(); -} - -QuickGlobal::WindowEdges QuickWindowBorder::edges() const -{ - Q_D(const QuickWindowBorder); - return edgesToQuickEdges(d->borderPainter->edges()); -} - -QColor QuickWindowBorder::activeColor() const -{ - Q_D(const QuickWindowBorder); - return d->borderPainter->activeColor(); -} - -QColor QuickWindowBorder::inactiveColor() const -{ - Q_D(const QuickWindowBorder); - return d->borderPainter->inactiveColor(); -} - -qreal QuickWindowBorder::nativeThickness() const -{ - Q_D(const QuickWindowBorder); - return d->borderPainter->nativeThickness(); -} - -QuickGlobal::WindowEdges QuickWindowBorder::nativeEdges() const -{ - Q_D(const QuickWindowBorder); - return edgesToQuickEdges(d->borderPainter->nativeEdges()); -} - -QColor QuickWindowBorder::nativeActiveColor() const -{ - Q_D(const QuickWindowBorder); - return d->borderPainter->nativeActiveColor(); -} - -QColor QuickWindowBorder::nativeInactiveColor() const -{ - Q_D(const QuickWindowBorder); - return d->borderPainter->nativeInactiveColor(); -} - -void QuickWindowBorder::setThickness(const qreal value) -{ - Q_D(QuickWindowBorder); - if (qFuzzyCompare(thickness(), value)) { - return; - } - d->borderPainter->setThickness(std::round(value)); -} - -void QuickWindowBorder::setEdges(const QuickGlobal::WindowEdges value) -{ - Q_D(QuickWindowBorder); - if (edges() == value) { - return; - } - d->borderPainter->setEdges(quickEdgesToEdges(value)); -} - -void QuickWindowBorder::setActiveColor(const QColor &value) -{ - Q_D(QuickWindowBorder); - if (activeColor() == value) { - return; - } - d->borderPainter->setActiveColor(value); -} - -void QuickWindowBorder::setInactiveColor(const QColor &value) -{ - Q_D(QuickWindowBorder); - if (inactiveColor() == value) { - return; - } - d->borderPainter->setInactiveColor(value); -} - -void QuickWindowBorder::itemChange(const ItemChange change, const ItemChangeData &value) -{ - QQuickPaintedItem::itemChange(change, value); - if ((change == ItemSceneChange) && value.window) { - Q_D(QuickWindowBorder); - d->rebindWindow(); - } -} - -void QuickWindowBorder::classBegin() -{ - QQuickPaintedItem::classBegin(); -} - -void QuickWindowBorder::componentComplete() -{ - QQuickPaintedItem::componentComplete(); -} - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickwindowborder.h b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickwindowborder.h deleted file mode 100644 index 2bdda898..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickwindowborder.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Quick/quickwindowborder.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickwindowborder_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickwindowborder_p.h deleted file mode 100644 index fe339937..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/quick/quickwindowborder_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Quick/private/quickwindowborder_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/CMakeLists.txt b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/CMakeLists.txt deleted file mode 100644 index 91a1a5ce..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/CMakeLists.txt +++ /dev/null @@ -1,193 +0,0 @@ -#[[ - MIT License - - Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -]] - -if(FRAMELESSHELPER_ENABLE_UNIVERSAL_BUILD) - set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE) -endif() - -set(SUB_MODULE Widgets) -set(SUB_MODULE_FULL_NAME ${PROJECT_NAME}${SUB_MODULE}) -set(SUB_MODULE_TARGET ${SUB_MODULE_FULL_NAME}) -set(SUB_MODULE_PATH ${PROJECT_NAME}/${SUB_MODULE}) - -set(INCLUDE_PREFIX ../../include/${SUB_MODULE_PATH}) - -set(PUBLIC_HEADERS - ${INCLUDE_PREFIX}/framelesshelperwidgets_global.h - ${INCLUDE_PREFIX}/framelesswidgetshelper.h -) - -set(PUBLIC_HEADERS_ALIAS - ${INCLUDE_PREFIX}/Global - ${INCLUDE_PREFIX}/FramelessWidgetsHelper -) - -set(PRIVATE_HEADERS - ${INCLUDE_PREFIX}/private/framelesswidgetshelper_p.h - ${INCLUDE_PREFIX}/private/widgetssharedhelper_p.h -) - -set(SOURCES - framelesswidgetshelper.cpp - widgetssharedhelper.cpp - framelesshelperwidgets_global.cpp -) - -if(NOT FRAMELESSHELPER_NO_SYSTEM_BUTTON) - list(APPEND PUBLIC_HEADERS ${INCLUDE_PREFIX}/standardsystembutton.h) - list(APPEND PUBLIC_HEADERS_ALIAS ${INCLUDE_PREFIX}/StandardSystemButton) - list(APPEND PRIVATE_HEADERS ${INCLUDE_PREFIX}/private/standardsystembutton_p.h) - list(APPEND SOURCES standardsystembutton.cpp) -endif() - -if(NOT FRAMELESSHELPER_NO_TITLEBAR) - list(APPEND PUBLIC_HEADERS ${INCLUDE_PREFIX}/standardtitlebar.h) - list(APPEND PUBLIC_HEADERS_ALIAS ${INCLUDE_PREFIX}/StandardTitleBar) - list(APPEND PRIVATE_HEADERS ${INCLUDE_PREFIX}/private/standardtitlebar_p.h) - list(APPEND SOURCES standardtitlebar.cpp) -endif() - -if(NOT FRAMELESSHELPER_NO_WINDOW) - list(APPEND PUBLIC_HEADERS - ${INCLUDE_PREFIX}/framelessdialog.h - ${INCLUDE_PREFIX}/framelesswidget.h - ${INCLUDE_PREFIX}/framelessmainwindow.h - ) - list(APPEND PUBLIC_HEADERS_ALIAS - ${INCLUDE_PREFIX}/FramelessDialog - ${INCLUDE_PREFIX}/FramelessWidget - ${INCLUDE_PREFIX}/FramelessMainWindow - ) - list(APPEND PRIVATE_HEADERS - ${INCLUDE_PREFIX}/private/framelessdialog_p.h - ${INCLUDE_PREFIX}/private/framelesswidget_p.h - ${INCLUDE_PREFIX}/private/framelessmainwindow_p.h - ) - list(APPEND SOURCES - framelessdialog.cpp - framelesswidget.cpp - framelessmainwindow.cpp - ) -endif() - -if(WIN32 AND NOT FRAMELESSHELPER_BUILD_STATIC) - set(__rc_path "${CMAKE_CURRENT_BINARY_DIR}/${SUB_MODULE_FULL_NAME}.rc") - if(NOT EXISTS "${__rc_path}") - generate_win32_rc_file( - PATH "${__rc_path}" - VERSION "${PROJECT_VERSION}" - COMPANY "wangwenx190" - DESCRIPTION "${PROJECT_NAME} ${SUB_MODULE} Module" - COPYRIGHT "MIT License" - ORIGINAL_FILENAME "${SUB_MODULE_FULL_NAME}.dll" - PRODUCT "${PROJECT_NAME}" - COMMENTS "Who don't love Raiden Shogun ?" - LIBRARY - ) - endif() - list(APPEND SOURCES "${__rc_path}") -endif() - -set(ALL_SOURCES ${PUBLIC_HEADERS} ${PRIVATE_HEADERS} ${SOURCES}) - -if(FRAMELESSHELPER_BUILD_STATIC) - set(SUB_MOD_LIB_TYPE "STATIC") -else() - set(SUB_MOD_LIB_TYPE "SHARED") -endif() -add_library(${SUB_MODULE_TARGET} ${SUB_MOD_LIB_TYPE} ${ALL_SOURCES}) -add_library(${PROJECT_NAME}::${SUB_MODULE} ALIAS ${SUB_MODULE_TARGET}) -add_library(${PROJECT_NAME}::${SUB_MODULE_FULL_NAME} ALIAS ${SUB_MODULE_TARGET}) - -set_target_properties(${SUB_MODULE_TARGET} PROPERTIES - VERSION "${PROJECT_VERSION}" - SOVERSION "${PROJECT_VERSION_MAJOR}" - OUTPUT_NAME "${SUB_MODULE_TARGET}${FRAMELESSHELPER_64BIT_POSTFIX}" -) - -target_compile_definitions(${SUB_MODULE_TARGET} PRIVATE - FRAMELESSHELPER_WIDGETS_LIBRARY -) - -target_link_libraries(${SUB_MODULE_TARGET} PRIVATE - Qt${QT_VERSION_MAJOR}::Widgets -) - -target_link_libraries(${SUB_MODULE_TARGET} PRIVATE - ${PROJECT_NAME}::Core -) - -include(GNUInstallDirs) -target_include_directories(${SUB_MODULE_TARGET} PUBLIC - "$" - "$" - "$" - "$" - "$" - "$" -) - -if(NOT FRAMELESSHELPER_BUILD_STATIC) - setup_target_rpaths(TARGETS ${SUB_MODULE_TARGET}) -endif() - -setup_qt_stuff(TARGETS ${SUB_MODULE_TARGET}) -setup_custom_moc_macros(TARGETS ${SUB_MODULE_TARGET}) - -set(__extra_flags "") -if(NOT FRAMELESSHELPER_NO_PERMISSIVE_CHECKS) - list(APPEND __extra_flags PERMISSIVE) -endif() -if(FRAMELESSHELPER_ENABLE_SPECTRE) - list(APPEND __extra_flags SPECTRE) -endif() -if(FRAMELESSHELPER_ENABLE_EHCONTGUARD) - list(APPEND __extra_flags EHCONTGUARD) -endif() -if(FRAMELESSHELPER_ENABLE_INTELCET) - list(APPEND __extra_flags INTELCET) -endif() -if(FRAMELESSHELPER_ENABLE_CFGUARD) - list(APPEND __extra_flags CFGUARD) -endif() -if(FRAMELESSHELPER_FORCE_LTO) - list(APPEND __extra_flags FORCE_LTO) -endif() -setup_compile_params(TARGETS ${SUB_MODULE_TARGET} ${__extra_flags}) - -if(NOT FRAMELESSHELPER_NO_INSTALL) - setup_package_export( - TARGETS ${SUB_MODULE_TARGET} - NAMESPACE ${PROJECT_NAME} - PACKAGE_NAME ${PROJECT_NAME} - COMPONENT ${SUB_MODULE} - PUBLIC_HEADERS ${PUBLIC_HEADERS} - ALIAS_HEADERS ${PUBLIC_HEADERS_ALIAS} - PRIVATE_HEADERS ${PRIVATE_HEADERS} - ) -endif() - -if(NOT FRAMELESSHELPER_NO_SUMMARY) - dump_target_info(TARGETS ${SUB_MODULE_TARGET}) -endif() diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelessdialog.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelessdialog.cpp deleted file mode 100644 index 21ddd57d..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelessdialog.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "framelessdialog.h" -#include "framelessdialog_p.h" - -#if FRAMELESSHELPER_CONFIG(window) - -#include "framelesswidgetshelper.h" -#include "widgetssharedhelper_p.h" -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcFramelessDialog, "wangwenx190.framelesshelper.widgets.framelessdialog") -# define INFO qCInfo(lcFramelessDialog) -# define DEBUG qCDebug(lcFramelessDialog) -# define WARNING qCWarning(lcFramelessDialog) -# define CRITICAL qCCritical(lcFramelessDialog) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -FramelessDialogPrivate::FramelessDialogPrivate(FramelessDialog *q) : QObject(q) -{ - Q_ASSERT(q); - if (!q) { - return; - } - q_ptr = q; -} - -FramelessDialogPrivate::~FramelessDialogPrivate() = default; - -FramelessDialogPrivate *FramelessDialogPrivate::get(FramelessDialog *pub) -{ - Q_ASSERT(pub); - if (!pub) { - return nullptr; - } - return pub->d_func(); -} - -const FramelessDialogPrivate *FramelessDialogPrivate::get(const FramelessDialog *pub) -{ - Q_ASSERT(pub); - if (!pub) { - return nullptr; - } - return pub->d_func(); -} - -FramelessDialog::FramelessDialog(QWidget *parent) - : QDialog(parent), d_ptr(std::make_unique(this)) -{ - FramelessWidgetsHelper::get(this)->extendsContentIntoTitleBar(); - Q_D(FramelessDialog); - d->sharedHelper = new WidgetsSharedHelper(d); - d->sharedHelper->setup(this); -} - -FramelessDialog::~FramelessDialog() = default; - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelessdialog.h b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelessdialog.h deleted file mode 100644 index 4b5e2a85..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelessdialog.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Widgets/framelessdialog.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelessdialog_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelessdialog_p.h deleted file mode 100644 index f05c95e5..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelessdialog_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Widgets/private/framelessdialog_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesshelperwidgets_global.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesshelperwidgets_global.cpp deleted file mode 100644 index 5224013b..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesshelperwidgets_global.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "framelesshelperwidgets_global.h" -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcWidgetsGlobal, "wangwenx190.framelesshelper.widgets.global") -# define INFO qCInfo(lcWidgetsGlobal) -# define DEBUG qCDebug(lcWidgetsGlobal) -# define WARNING qCWarning(lcWidgetsGlobal) -# define CRITICAL qCCritical(lcWidgetsGlobal) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -void FramelessHelperWidgetsInitialize() -{ - static bool inited = false; - if (inited) { - return; - } - inited = true; - - FramelessHelperCoreInitialize(); -} - -void FramelessHelperWidgetsUninitialize() -{ - static bool uninited = false; - if (uninited) { - return; - } - uninited = true; - - // ### TODO: The Widgets module-specific uninitialization. - - FramelessHelperCoreUninitialize(); -} - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesshelperwidgets_global.h b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesshelperwidgets_global.h deleted file mode 100644 index bd9e3315..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesshelperwidgets_global.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Widgets/framelesshelperwidgets_global.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelessmainwindow.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelessmainwindow.cpp deleted file mode 100644 index 67725e4e..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelessmainwindow.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "framelessmainwindow.h" -#include "framelessmainwindow_p.h" - -#if FRAMELESSHELPER_CONFIG(window) - -#include "framelesswidgetshelper.h" -#include "widgetssharedhelper_p.h" -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcFramelessMainWindow, "wangwenx190.framelesshelper.widgets.framelessmainwindow") -# define INFO qCInfo(lcFramelessMainWindow) -# define DEBUG qCDebug(lcFramelessMainWindow) -# define WARNING qCWarning(lcFramelessMainWindow) -# define CRITICAL qCCritical(lcFramelessMainWindow) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -FramelessMainWindowPrivate::FramelessMainWindowPrivate(FramelessMainWindow *q) : QObject(q) -{ - Q_ASSERT(q); - if (!q) { - return; - } - q_ptr = q; -} - -FramelessMainWindowPrivate::~FramelessMainWindowPrivate() = default; - -FramelessMainWindowPrivate *FramelessMainWindowPrivate::get(FramelessMainWindow *pub) -{ - Q_ASSERT(pub); - if (!pub) { - return nullptr; - } - return pub->d_func(); -} - -const FramelessMainWindowPrivate *FramelessMainWindowPrivate::get(const FramelessMainWindow *pub) -{ - Q_ASSERT(pub); - if (!pub) { - return nullptr; - } - return pub->d_func(); -} - -FramelessMainWindow::FramelessMainWindow(QWidget *parent, const Qt::WindowFlags flags) - : QMainWindow(parent, flags), d_ptr(std::make_unique(this)) -{ - FramelessWidgetsHelper::get(this)->extendsContentIntoTitleBar(); - Q_D(FramelessMainWindow); - d->sharedHelper = new WidgetsSharedHelper(d); - d->sharedHelper->setup(this); -} - -FramelessMainWindow::~FramelessMainWindow() = default; - -bool FramelessMainWindow::isNormal() const -{ - return (Utils::windowStatesToWindowState(windowState()) == Qt::WindowNoState); -} - -bool FramelessMainWindow::isZoomed() const -{ - return (isMaximized() || isFullScreen()); -} - -void FramelessMainWindow::toggleMaximized() -{ - if (isMaximized()) { - showNormal(); - } else { - showMaximized(); - } -} - -void FramelessMainWindow::toggleFullScreen() -{ - Q_D(FramelessMainWindow); - if (isFullScreen()) { - setWindowState(d->savedWindowState); - } else { - d->savedWindowState = Utils::windowStatesToWindowState(windowState()); - showFullScreen(); - } -} - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelessmainwindow.h b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelessmainwindow.h deleted file mode 100644 index 150fc772..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelessmainwindow.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Widgets/framelessmainwindow.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelessmainwindow_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelessmainwindow_p.h deleted file mode 100644 index 4ba45e9e..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelessmainwindow_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Widgets/private/framelessmainwindow_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesswidget.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesswidget.cpp deleted file mode 100644 index b5732f96..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesswidget.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "framelesswidget.h" -#include "framelesswidget_p.h" - -#if FRAMELESSHELPER_CONFIG(window) - -#include "framelesswidgetshelper.h" -#include "widgetssharedhelper_p.h" -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcFramelessWidget, "wangwenx190.framelesshelper.widgets.framelesswidget") -# define INFO qCInfo(lcFramelessWidget) -# define DEBUG qCDebug(lcFramelessWidget) -# define WARNING qCWarning(lcFramelessWidget) -# define CRITICAL qCCritical(lcFramelessWidget) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -FramelessWidgetPrivate::FramelessWidgetPrivate(FramelessWidget *q) : QObject(q) -{ - Q_ASSERT(q); - if (!q) { - return; - } - q_ptr = q; -} - -FramelessWidgetPrivate::~FramelessWidgetPrivate() = default; - -FramelessWidgetPrivate *FramelessWidgetPrivate::get(FramelessWidget *pub) -{ - Q_ASSERT(pub); - if (!pub) { - return nullptr; - } - return pub->d_func(); -} - -const FramelessWidgetPrivate *FramelessWidgetPrivate::get(const FramelessWidget *pub) -{ - Q_ASSERT(pub); - if (!pub) { - return nullptr; - } - return pub->d_func(); -} - -FramelessWidget::FramelessWidget(QWidget *parent) - : QWidget(parent, Qt::Window), d_ptr(std::make_unique(this)) -{ - FramelessWidgetsHelper::get(this)->extendsContentIntoTitleBar(); - Q_D(FramelessWidget); - d->sharedHelper = new WidgetsSharedHelper(d); - d->sharedHelper->setup(this); -} - -FramelessWidget::~FramelessWidget() = default; - -bool FramelessWidget::isNormal() const -{ - return (Utils::windowStatesToWindowState(windowState()) == Qt::WindowNoState); -} - -bool FramelessWidget::isZoomed() const -{ - return (isMaximized() || isFullScreen()); -} - -void FramelessWidget::toggleMaximized() -{ - if (isMaximized()) { - showNormal(); - } else { - showMaximized(); - } -} - -void FramelessWidget::toggleFullScreen() -{ - Q_D(FramelessWidget); - if (isFullScreen()) { - setWindowState(d->savedWindowState); - } else { - d->savedWindowState = Utils::windowStatesToWindowState(windowState()); - showFullScreen(); - } -} - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesswidget.h b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesswidget.h deleted file mode 100644 index a256d8e2..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesswidget.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Widgets/framelesswidget.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesswidget_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesswidget_p.h deleted file mode 100644 index 041c187f..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesswidget_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Widgets/private/framelesswidget_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesswidgetshelper.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesswidgetshelper.cpp deleted file mode 100644 index c560d023..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesswidgetshelper.cpp +++ /dev/null @@ -1,1038 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "framelesswidgetshelper.h" -#include "framelesswidgetshelper_p.h" -#if FRAMELESSHELPER_CONFIG(window) -# include "framelesswidget.h" -# include "framelesswidget_p.h" -# include "framelessmainwindow.h" -# include "framelessmainwindow_p.h" -# include "framelessdialog.h" -# include "framelessdialog_p.h" -#endif -#include "widgetssharedhelper_p.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef QWIDGETSIZE_MAX -# define QWIDGETSIZE_MAX ((1 << 24) - 1) -#endif // QWIDGETSIZE_MAX - -extern Q_WIDGETS_EXPORT QWidget *qt_button_down; - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcFramelessWidgetsHelper, "wangwenx190.framelesshelper.widgets.framelesswidgetshelper") -# define INFO qCInfo(lcFramelessWidgetsHelper) -# define DEBUG qCDebug(lcFramelessWidgetsHelper) -# define WARNING qCWarning(lcFramelessWidgetsHelper) -# define CRITICAL qCCritical(lcFramelessWidgetsHelper) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -static constexpr const auto kRepaintTimerInterval = 300; - -struct FramelessWidgetsHelperExtraData : public FramelessExtraData -{ - QPointer titleBarWidget = nullptr; - QList> hitTestVisibleWidgets = {}; - QPointer windowIconButton = nullptr; - QPointer contextHelpButton = nullptr; - QPointer minimizeButton = nullptr; - QPointer maximizeButton = nullptr; - QPointer closeButton = nullptr; - QList hitTestVisibleRects = {}; - - FramelessWidgetsHelperExtraData(); - ~FramelessWidgetsHelperExtraData() override; - - [[nodiscard]] static FramelessExtraDataPtr create(); -}; -using FramelessWidgetsHelperExtraDataPtr = std::shared_ptr; - -FramelessWidgetsHelperExtraData::FramelessWidgetsHelperExtraData() = default; - -FramelessWidgetsHelperExtraData::~FramelessWidgetsHelperExtraData() = default; - -FramelessExtraDataPtr FramelessWidgetsHelperExtraData::create() -{ - return std::make_shared(); -} - -[[nodiscard]] static inline FramelessWidgetsHelperExtraDataPtr tryGetExtraData(const FramelessDataPtr &data, const bool create) -{ - Q_ASSERT(data); - if (!data) { - return nullptr; - } - auto it = data->extraData.find(ExtraDataType::FramelessWidgetsHelper); - if (it == data->extraData.end()) { - if (create) { - it = data->extraData.insert(ExtraDataType::FramelessWidgetsHelper, FramelessWidgetsHelperExtraData::create()); - } else { - return nullptr; - } - } - return std::dynamic_pointer_cast(it.value()); -} - -[[nodiscard]] static inline FramelessWidgetsHelperExtraDataPtr tryGetExtraData(const QWidget *window, const bool create) -{ - Q_ASSERT(window); - if (!window) { - return nullptr; - } - const FramelessDataPtr data = FramelessManagerPrivate::getData(window); - if (!data) { - return nullptr; - } - return tryGetExtraData(data, create); -} - -[[nodiscard]] static inline bool isWidgetFixedSize(const QWidget *widget) -{ - Q_ASSERT(widget); - if (!widget) { - return false; - } - // "Qt::MSWindowsFixedSizeDialogHint" is used cross-platform actually. - if (widget->windowFlags() & Qt::MSWindowsFixedSizeDialogHint) { - return true; - } - // Caused by setFixedWidth/Height/Size(). - const QSize minSize = widget->minimumSize(); - const QSize maxSize = widget->maximumSize(); - if (!minSize.isEmpty() && !maxSize.isEmpty() && (minSize == maxSize)) { - return true; - } - // Usually set by the user. - const QSizePolicy sizePolicy = widget->sizePolicy(); - if ((sizePolicy.horizontalPolicy() == QSizePolicy::Fixed) - && (sizePolicy.verticalPolicy() == QSizePolicy::Fixed)) { - return true; - } - return false; -} - -static inline void forceWidgetRepaint(QWidget *widget) -{ - Q_ASSERT(widget); - if (!widget) { - return; - } -#if (defined(Q_OS_WINDOWS) && (QT_VERSION != QT_VERSION_CHECK(6, 5, 3)) && (QT_VERSION != QT_VERSION_CHECK(6, 6, 0))) - // There's some additional things to do for top level windows on Windows. - if (widget->isWindow()) { - // Don't crash if the QWindow instance has not been created yet. - if (QWindow * const window = widget->windowHandle()) { - // Sync the internal window frame margins with the latest DPI, otherwise - // we will get wrong window sizes after the DPI change. - std::ignore = Utils::updateInternalWindowFrameMargins(window, true); - } - } -#endif // Q_OS_WINDOWS - // Don't do unnecessary repaints if the widget is hidden. - if (!widget->isVisible()) { - return; - } - // Tell the widget to repaint itself, but it may not happen due to QWidget's - // internal painting optimizations. - widget->update(); - // Try to force the widget to repaint itself, in case: - // (1) It's a child widget; - // (2) It's a top level window but not minimized/maximized/fullscreen. - if (!widget->isWindow() || !(widget->windowState() & (Qt::WindowMinimized | Qt::WindowMaximized | Qt::WindowFullScreen))) { - // A widget will most likely repaint itself if it's size is changed. - if (!isWidgetFixedSize(widget)) { - const QSize originalSize = widget->size(); - static constexpr const auto margins = QMargins{ 1, 1, 1, 1 }; - widget->resize(originalSize.shrunkBy(margins)); - widget->resize(originalSize.grownBy(margins)); - widget->resize(originalSize); - } - // However, some widgets won't repaint themselves unless their position is changed. - const QPoint originalPosition = widget->pos(); - static constexpr const auto offset = QPoint{10, 10}; - widget->move(originalPosition - offset); - widget->move(originalPosition + offset); - widget->move(originalPosition); - } - // Let's try again with the ordinary way. - widget->update(); - // ### TODO: I observed the font size is often wrong after DPI changes, - // do we need to refresh the font settings here as well? -} - -FramelessWidgetsHelperPrivate::FramelessWidgetsHelperPrivate(FramelessWidgetsHelper *q) : QObject(q) -{ - Q_ASSERT(q); - if (!q) { - return; - } - q_ptr = q; - repaintTimer.setTimerType(Qt::VeryCoarseTimer); - repaintTimer.setInterval(kRepaintTimerInterval); - connect(&repaintTimer, &QTimer::timeout, this, &FramelessWidgetsHelperPrivate::doRepaintAllChildren); -} - -FramelessWidgetsHelperPrivate::~FramelessWidgetsHelperPrivate() -{ - detach(); -} - -FramelessWidgetsHelperPrivate *FramelessWidgetsHelperPrivate::get(FramelessWidgetsHelper *pub) -{ - Q_ASSERT(pub); - if (!pub) { - return nullptr; - } - return pub->d_func(); -} - -const FramelessWidgetsHelperPrivate *FramelessWidgetsHelperPrivate::get(const FramelessWidgetsHelper *pub) -{ - Q_ASSERT(pub); - if (!pub) { - return nullptr; - } - return pub->d_func(); -} - -void FramelessWidgetsHelperPrivate::emitSignalForAllInstances(const char *signal) -{ - Q_ASSERT(signal); - Q_ASSERT(*signal != '\0'); - if (!signal || (*signal == '\0')) { - return; - } - if (!window) { - return; - } - const auto instances = window->findChildren(); - if (instances.isEmpty()) { - return; - } - for (auto &&instance : std::as_const(instances)) { - QMetaObject::invokeMethod(instance, signal); - } -} - -void FramelessWidgetsHelperPrivate::setProperty(const char *name, const QVariant &value) -{ - Q_ASSERT(name); - Q_ASSERT(*name != '\0'); - Q_ASSERT(value.isValid()); - Q_ASSERT(!value.isNull()); - if (!name || (*name == '\0') || !value.isValid() || value.isNull()) { - return; - } - Q_ASSERT(window); - if (!window) { - return; - } - window->setProperty(name, value); -} - -QVariant FramelessWidgetsHelperPrivate::getProperty(const char *name, const QVariant &defaultValue) -{ - Q_ASSERT(name); - Q_ASSERT(*name != '\0'); - if (!name || (*name == '\0')) { - return {}; - } - Q_ASSERT(window); - if (!window) { - return {}; - } - const QVariant value = window->property(name); - return ((value.isValid() && !value.isNull()) ? value : defaultValue); -} - -#if FRAMELESSHELPER_CONFIG(mica_material) -MicaMaterial *FramelessWidgetsHelperPrivate::getMicaMaterialIfAny() const -{ - if (!window) { - return nullptr; - } - if (const WidgetsSharedHelper * const helper = findOrCreateSharedHelper(window)) { - return helper->rawMicaMaterial(); - } - return nullptr; -} -#endif - -#if FRAMELESSHELPER_CONFIG(border_painter) -WindowBorderPainter *FramelessWidgetsHelperPrivate::getWindowBorderIfAny() const -{ - if (!window) { - return nullptr; - } - if (const WidgetsSharedHelper * const helper = findOrCreateSharedHelper(window)) { - return helper->rawWindowBorder(); - } - return nullptr; -} -#endif - -WidgetsSharedHelper *FramelessWidgetsHelperPrivate::findOrCreateSharedHelper(QWidget *window) -{ - Q_ASSERT(window); - if (!window) { - return nullptr; - } -#if FRAMELESSHELPER_CONFIG(window) - if (const auto widget = qobject_cast(window)) { - if (const auto widgetPriv = FramelessWidgetPrivate::get(widget)) { - return widgetPriv->sharedHelper; - } - } - if (const auto mainWindow = qobject_cast(window)) { - if (const auto mainWindowPriv = FramelessMainWindowPrivate::get(mainWindow)) { - return mainWindowPriv->sharedHelper; - } - } - if (const auto dialog = qobject_cast(window)) { - if (const auto dialogPriv = FramelessDialogPrivate::get(dialog)) { - return dialogPriv->sharedHelper; - } - } -#endif - QWidget * const topLevelWindow = window->window(); - WidgetsSharedHelper *helper = topLevelWindow->findChild(); - if (!helper) { - helper = new WidgetsSharedHelper(topLevelWindow); - helper->setup(topLevelWindow); - } - return helper; -} - -FramelessWidgetsHelper *FramelessWidgetsHelperPrivate::findOrCreateFramelessHelper(QObject *object) -{ - Q_ASSERT(object); - if (!object) { - return nullptr; - } - QObject *parent = nullptr; - if (const auto widget = qobject_cast(object)) { - parent = widget->window(); - } else { - parent = object; - } - FramelessWidgetsHelper *instance = parent->findChild(); - if (!instance) { - instance = new FramelessWidgetsHelper(parent); - instance->extendsContentIntoTitleBar(); - if (parent->inherits("QDialog")) { - instance->setWindowFixedSize(true); - } - } - return instance; -} - -void FramelessWidgetsHelperPrivate::repaintAllChildren() -{ - repaintTimer.start(); -} - -void FramelessWidgetsHelperPrivate::doRepaintAllChildren() -{ - repaintTimer.stop(); - if (!window) { - return; - } - forceWidgetRepaint(window); - const QList widgets = window->findChildren(); - for (auto &&widget : std::as_const(widgets)) { - forceWidgetRepaint(widget); - } -} - -quint32 FramelessWidgetsHelperPrivate::readyWaitTime() const -{ - return qpaWaitTime; -} - -void FramelessWidgetsHelperPrivate::setReadyWaitTime(const quint32 time) -{ - if (qpaWaitTime == time) { - return; - } - qpaWaitTime = time; -} - -void FramelessWidgetsHelperPrivate::attach() -{ - QWidget *tlw = findTopLevelWindow(); - Q_ASSERT(tlw); - if (!tlw) { - return; - } - if (window == tlw) { - return; - } - window = tlw; - - if (!window->testAttribute(Qt::WA_DontCreateNativeAncestors)) { - window->setAttribute(Qt::WA_DontCreateNativeAncestors); - } - if (!window->testAttribute(Qt::WA_NativeWindow)) { - window->setAttribute(Qt::WA_NativeWindow); - } - - const WId windowId = window->winId(); - const FramelessDataPtr data = FramelessManagerPrivate::createData(window, windowId); - Q_ASSERT(data); - if (!data || data->frameless) { - return; - } - - Q_Q(FramelessWidgetsHelper); - - if (!data->callbacks) { - data->callbacks = FramelessCallbacks::create(); - data->callbacks->getWindowId = [this]() -> WId { return window->winId(); }; - data->callbacks->getWindowFlags = [this]() -> Qt::WindowFlags { return window->windowFlags(); }; - data->callbacks->setWindowFlags = [this](const Qt::WindowFlags flags) -> void { window->setWindowFlags(flags); }; - data->callbacks->getWindowSize = [this]() -> QSize { return window->size(); }; - data->callbacks->setWindowSize = [this](const QSize &size) -> void { window->resize(size); }; - data->callbacks->getWindowPosition = [this]() -> QPoint { return window->pos(); }; - data->callbacks->setWindowPosition = [this](const QPoint &pos) -> void { window->move(pos); }; - data->callbacks->getWindowScreen = [this]() -> QScreen * { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) - return window->screen(); -#else - return window->windowHandle()->screen(); -#endif - }; - data->callbacks->isWindowFixedSize = [q]() -> bool { return q->isWindowFixedSize(); }; - data->callbacks->setWindowFixedSize = [q](const bool value) -> void { q->setWindowFixedSize(value); }; - data->callbacks->getWindowState = [this]() -> Qt::WindowState { return Utils::windowStatesToWindowState(window->windowState()); }; - data->callbacks->setWindowState = [this](const Qt::WindowState state) -> void { window->setWindowState(state); }; - data->callbacks->getWindowHandle = [this]() -> QWindow * { return window->windowHandle(); }; - data->callbacks->windowToScreen = [this](const QPoint &pos) -> QPoint { return window->mapToGlobal(pos); }; - data->callbacks->screenToWindow = [this](const QPoint &pos) -> QPoint { return window->mapFromGlobal(pos); }; - data->callbacks->isInsideSystemButtons = [this](const QPoint &pos, SystemButtonType *button) -> bool { return isInSystemButtons(pos, button); }; - data->callbacks->isInsideTitleBarDraggableArea = [this](const QPoint &pos) -> bool { return isInTitleBarDraggableArea(pos); }; - data->callbacks->getWindowDevicePixelRatio = [this]() -> qreal { return window->devicePixelRatioF(); }; - data->callbacks->setSystemButtonState = [this](const SystemButtonType button, const ButtonState state) -> void { setSystemButtonState(button, state); }; - data->callbacks->shouldIgnoreMouseEvents = [this](const QPoint &pos) -> bool { return shouldIgnoreMouseEvents(pos); }; - data->callbacks->showSystemMenu = [q](const QPoint &pos) -> void { q->showSystemMenu(pos); }; - data->callbacks->setProperty = [this](const char *name, const QVariant &value) -> void { setProperty(name, value); }; - data->callbacks->getProperty = [this](const char *name, const QVariant &defaultValue) -> QVariant { return getProperty(name, defaultValue); }; - data->callbacks->setCursor = [this](const QCursor &cursor) -> void { window->setCursor(cursor); }; - data->callbacks->unsetCursor = [this]() -> void { window->unsetCursor(); }; - data->callbacks->getWidgetHandle = [this]() -> QObject * { return window; }; - data->callbacks->forceChildrenRepaint = [this]() -> void { repaintAllChildren(); }; - data->callbacks->resetQtGrabbedControl = []() -> bool { - if (qt_button_down) { - static constexpr const auto invalidPos = QPoint{ -99999, -99999 }; - const auto event = new QMouseEvent( - QEvent::MouseButtonRelease, - invalidPos, - invalidPos, - invalidPos, - Qt::LeftButton, - QGuiApplication::mouseButtons() ^ Qt::LeftButton, - QGuiApplication::keyboardModifiers()); - QApplication::postEvent(qt_button_down, event); - qt_button_down = nullptr; - return true; - } - return false; - }; - } - - std::ignore = tryGetExtraData(data, true); - - std::ignore = FramelessManager::instance()->addWindow(window, windowId); - - // We have to wait for a little time before moving the top level window - // , because the platform window may not finish initializing by the time - // we reach here, and all the modifications from the Qt side will be lost - // due to QPA will reset the position and size of the window during it's - // initialization process. - QTimer::singleShot(qpaWaitTime, this, [this, q](){ - qpaReady = true; - if (FramelessConfig::instance()->isSet(Option::CenterWindowBeforeShow)) { - q->moveWindowToDesktopCenter(); - } - if (FramelessConfig::instance()->isSet(Option::EnableBlurBehindWindow)) { - q->setBlurBehindWindowEnabled(true); - } - emitSignalForAllInstances("windowChanged"); - emitSignalForAllInstances("ready"); - }); -} - -void FramelessWidgetsHelperPrivate::detach() -{ - if (!window) { - return; - } - std::ignore = FramelessManager::instance()->removeWindow(window); - window = nullptr; - emitSignalForAllInstances("windowChanged"); -} - -QWidget *FramelessWidgetsHelperPrivate::findTopLevelWindow() const -{ - Q_Q(const FramelessWidgetsHelper); - const QObject * const p = q->parent(); - Q_ASSERT(p); - if (p) { - if (const auto parentWidget = qobject_cast(p)) { - return parentWidget->window(); - } - } - return nullptr; -} - -QRect FramelessWidgetsHelperPrivate::mapWidgetGeometryToScene(const QWidget * const widget) const -{ - Q_ASSERT(widget); - if (!widget) { - return {}; - } - if (!window) { - return {}; - } - const QPoint originPoint = widget->mapTo(window, QPoint(0, 0)); - const QSize size = widget->size(); - return QRect(originPoint, size); -} - -bool FramelessWidgetsHelperPrivate::isInSystemButtons(const QPoint &pos, SystemButtonType *button) const -{ - Q_ASSERT(button); - if (!button) { - return false; - } - if (!window) { - return false; - } - const FramelessWidgetsHelperExtraDataPtr extraData = tryGetExtraData(window, false); - Q_ASSERT(extraData); - if (!extraData) { - return false; - } - *button = SystemButtonType::Unknown; - if (extraData->windowIconButton && extraData->windowIconButton->isVisible() && extraData->windowIconButton->isEnabled()) { - if (mapWidgetGeometryToScene(extraData->windowIconButton).contains(pos)) { - *button = SystemButtonType::WindowIcon; - return true; - } - } - if (extraData->contextHelpButton && extraData->contextHelpButton->isVisible() && extraData->contextHelpButton->isEnabled()) { - if (mapWidgetGeometryToScene(extraData->contextHelpButton).contains(pos)) { - *button = SystemButtonType::Help; - return true; - } - } - if (extraData->minimizeButton && extraData->minimizeButton->isVisible() && extraData->minimizeButton->isEnabled()) { - if (mapWidgetGeometryToScene(extraData->minimizeButton).contains(pos)) { - *button = SystemButtonType::Minimize; - return true; - } - } - if (extraData->maximizeButton && extraData->maximizeButton->isVisible() && extraData->maximizeButton->isEnabled()) { - if (mapWidgetGeometryToScene(extraData->maximizeButton).contains(pos)) { - *button = SystemButtonType::Maximize; - return true; - } - } - if (extraData->closeButton && extraData->closeButton->isVisible() && extraData->closeButton->isEnabled()) { - if (mapWidgetGeometryToScene(extraData->closeButton).contains(pos)) { - *button = SystemButtonType::Close; - return true; - } - } - return false; -} - -bool FramelessWidgetsHelperPrivate::isInTitleBarDraggableArea(const QPoint &pos) const -{ - if (!window) { - // The FramelessWidgetsHelper object has not been attached to a specific window yet, - // so we assume there's no title bar. - return false; - } - const FramelessWidgetsHelperExtraDataPtr extraData = tryGetExtraData(window, false); - Q_ASSERT(extraData); - if (!extraData) { - return false; - } - if (!extraData->titleBarWidget) { - // There's no title bar at all, the mouse will always be in the client area. - return false; - } - if (!extraData->titleBarWidget->isVisible() || !extraData->titleBarWidget->isEnabled()) { - // The title bar is hidden or disabled for some reason, treat it as there's no title bar. - return false; - } - const QRect windowRect = {QPoint(0, 0), window->size()}; - const QRect titleBarRect = mapWidgetGeometryToScene(extraData->titleBarWidget); - if (!titleBarRect.intersects(windowRect)) { - // The title bar is totally outside of the window for some reason, - // also treat it as there's no title bar. - return false; - } - QRegion region = titleBarRect; - const auto systemButtons = { - extraData->windowIconButton, extraData->contextHelpButton, - extraData->minimizeButton, extraData->maximizeButton, - extraData->closeButton - }; - for (auto &&button : std::as_const(systemButtons)) { - if (button && button->isVisible() && button->isEnabled()) { - region -= mapWidgetGeometryToScene(button); - } - } - if (!extraData->hitTestVisibleWidgets.isEmpty()) { - for (auto &&widget : std::as_const(extraData->hitTestVisibleWidgets)) { - if (widget && widget->isVisible() && widget->isEnabled()) { - region -= mapWidgetGeometryToScene(widget); - } - } - } - if (!extraData->hitTestVisibleRects.isEmpty()) { - for (auto &&rect : std::as_const(extraData->hitTestVisibleRects)) { - if (rect.isValid()) { - region -= rect; - } - } - } - return region.contains(pos); -} - -bool FramelessWidgetsHelperPrivate::shouldIgnoreMouseEvents(const QPoint &pos) const -{ - if (!window) { - return false; - } - const auto withinFrameBorder = [this, &pos]() -> bool { - if (isWidgetFixedSize(window)) { - return false; - } - if (pos.y() < kDefaultResizeBorderThickness) { - return true; - } -#ifdef Q_OS_WINDOWS - if (Utils::isWindowFrameBorderVisible()) { - return false; - } -#endif - return ((pos.x() < kDefaultResizeBorderThickness) - || (pos.x() >= (window->width() - kDefaultResizeBorderThickness))); - }(); - return ((Utils::windowStatesToWindowState(window->windowState()) == Qt::WindowNoState) && withinFrameBorder); -} - -void FramelessWidgetsHelperPrivate::setSystemButtonState(const SystemButtonType button, const ButtonState state) -{ - Q_UNUSED(button); - Q_UNUSED(state); -} - -void FramelessWidgetsHelper::moveWindowToDesktopCenter() -{ - Q_D(FramelessWidgetsHelper); - if (!d->window) { - return; - } - std::ignore = Utils::moveWindowToDesktopCenter(d->window->winId(), true); -} - -void FramelessWidgetsHelper::bringWindowToFront() -{ - Q_D(FramelessWidgetsHelper); - if (!d->window) { - return; - } -#ifdef Q_OS_WINDOWS - std::ignore = Utils::bringWindowToFront(d->window->winId()); -#else - if (d->window->isHidden()) { - d->window->show(); - } - if (d->window->isMinimized()) { - d->window->setWindowState(d->window->windowState() & ~Qt::WindowMinimized); - } - d->window->raise(); - d->window->activateWindow(); -#endif -} - -void FramelessWidgetsHelper::showSystemMenu(const QPoint &pos) -{ - Q_D(FramelessWidgetsHelper); - if (!d->window) { - return; - } - const WId windowId = d->window->winId(); - const QPoint nativePos = Utils::toNativeGlobalPosition(d->window->windowHandle(), pos); -#ifdef Q_OS_WINDOWS - std::ignore = Utils::showSystemMenu(windowId, nativePos, false); -#elif (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) - Utils::openSystemMenu(windowId, nativePos); -#else - Q_UNUSED(windowId); - Q_UNUSED(nativePos); -#endif -} - -void FramelessWidgetsHelper::windowStartSystemMove2(const QPoint &pos) -{ - Q_D(FramelessWidgetsHelper); - if (!d->window) { - return; - } - std::ignore = Utils::startSystemMove(d->window->windowHandle(), pos); -} - -void FramelessWidgetsHelper::windowStartSystemResize2(const Qt::Edges edges, const QPoint &pos) -{ - Q_D(FramelessWidgetsHelper); - if (!d->window) { - return; - } - if (edges == Qt::Edges{}) { - return; - } - std::ignore = Utils::startSystemResize(d->window->windowHandle(), edges, pos); -} - -void FramelessWidgetsHelper::setSystemButton(QWidget *widget, const SystemButtonType buttonType) -{ - Q_ASSERT(widget); - Q_ASSERT(buttonType != SystemButtonType::Unknown); - if (!widget || (buttonType == SystemButtonType::Unknown)) { - return; - } - Q_D(FramelessWidgetsHelper); - if (!d->window) { - return; - } - const FramelessWidgetsHelperExtraDataPtr extraData = tryGetExtraData(d->window, false); - Q_ASSERT(extraData); - if (!extraData) { - return; - } - switch (buttonType) { - case SystemButtonType::WindowIcon: - extraData->windowIconButton = widget; - break; - case SystemButtonType::Help: - extraData->contextHelpButton = widget; - break; - case SystemButtonType::Minimize: - extraData->minimizeButton = widget; - break; - case SystemButtonType::Maximize: - case SystemButtonType::Restore: - extraData->maximizeButton = widget; - break; - case SystemButtonType::Close: - extraData->closeButton = widget; - break; - case SystemButtonType::Unknown: - Q_UNREACHABLE(); - } -} - -FramelessWidgetsHelper::FramelessWidgetsHelper(QObject *parent) - : QObject(parent), d_ptr(std::make_unique(this)) -{ -} - -FramelessWidgetsHelper::~FramelessWidgetsHelper() = default; - -FramelessWidgetsHelper *FramelessWidgetsHelper::get(QObject *object) -{ - Q_ASSERT(object); - if (!object) { - return nullptr; - } - return FramelessWidgetsHelperPrivate::findOrCreateFramelessHelper(object); -} - -QWidget *FramelessWidgetsHelper::window() const -{ - Q_D(const FramelessWidgetsHelper); - return d->window; -} - -#if FRAMELESSHELPER_CONFIG(mica_material) -MicaMaterial *FramelessWidgetsHelper::micaMaterial() const -{ - Q_D(const FramelessWidgetsHelper); - return d->getMicaMaterialIfAny(); -} -#endif - -#if FRAMELESSHELPER_CONFIG(border_painter) -WindowBorderPainter *FramelessWidgetsHelper::windowBorder() const -{ - Q_D(const FramelessWidgetsHelper); - return d->getWindowBorderIfAny(); -} -#endif - -bool FramelessWidgetsHelper::isWindowFixedSize() const -{ - Q_D(const FramelessWidgetsHelper); - if (!d->window) { - return false; - } - return isWidgetFixedSize(d->window); -} - -void FramelessWidgetsHelper::setWindowFixedSize(const bool value) -{ - Q_D(FramelessWidgetsHelper); - if (!d->window) { - return; - } - if (isWindowFixedSize() == value) { - return; - } - if (value) { - d->savedSizePolicy = d->window->sizePolicy(); - d->window->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - d->window->setFixedSize(d->window->size()); - } else { - d->window->setSizePolicy(d->savedSizePolicy); - d->window->setMinimumSize(kDefaultWindowSize); - d->window->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); - } -#ifdef Q_OS_WINDOWS - std::ignore = Utils::setAeroSnappingEnabled(d->window->winId(), !value); -#endif - d->emitSignalForAllInstances("windowFixedSizeChanged"); -} - -bool FramelessWidgetsHelper::isBlurBehindWindowEnabled() const -{ - Q_D(const FramelessWidgetsHelper); - return d->blurBehindWindowEnabled; -} - -void FramelessWidgetsHelper::setBlurBehindWindowEnabled(const bool enable) -{ -#if (!defined(Q_OS_WINDOWS) || FRAMELESSHELPER_CONFIG(native_impl)) - Q_D(FramelessWidgetsHelper); - if (!d->window) { - return; - } - if (d->blurBehindWindowEnabled == enable) { - return; - } - if (Utils::isBlurBehindWindowSupported()) { - QPalette palette = d->window->palette(); - if (enable) { - d->savedWindowBackgroundColor = palette.color(QPalette::Window); - } - palette.setColor(QPalette::Window, (enable ? kDefaultTransparentColor : d->savedWindowBackgroundColor)); - d->window->setPalette(palette); - if (Utils::setBlurBehindWindowEnabled(d->window->winId(), (enable ? BlurMode::Default : BlurMode::Disable), {})) { - d->blurBehindWindowEnabled = enable; - d->emitSignalForAllInstances("blurBehindWindowEnabledChanged"); - } else { - WARNING << "Failed to enable/disable blur behind window."; - } - } else { - if (WidgetsSharedHelper * const helper = d->findOrCreateSharedHelper(d->window)) { - d->blurBehindWindowEnabled = enable; -#if FRAMELESSHELPER_CONFIG(mica_material) - helper->setMicaEnabled(d->blurBehindWindowEnabled); -#endif - d->emitSignalForAllInstances("blurBehindWindowEnabledChanged"); - } else { - DEBUG << "Blur behind window is not supported on current platform."; - } - } -#else // Windows && !native_impl - Q_UNUSED(enable); -#endif -} - -bool FramelessWidgetsHelper::isReady() const -{ - Q_D(const FramelessWidgetsHelper); - return d->qpaReady; -} - -void FramelessWidgetsHelper::waitForReady() -{ - Q_D(FramelessWidgetsHelper); - if (d->qpaReady) { - return; - } -#if 1 - QEventLoop loop{}; - const QMetaObject::Connection connection = connect(this, &FramelessWidgetsHelper::ready, &loop, &QEventLoop::quit); - loop.exec(); - disconnect(connection); -#else - while (!d->qpaReady) { - QCoreApplication::processEvents(); - } -#endif -} - -bool FramelessWidgetsHelper::isContentExtendedIntoTitleBar() const -{ - Q_D(const FramelessWidgetsHelper); - if (!d->window) { - return false; - } - const FramelessDataPtr data = FramelessManagerPrivate::getData(d->window); - return (data && data->frameless); -} - -void FramelessWidgetsHelper::setTitleBarWidget(QWidget *widget) -{ - Q_ASSERT(widget); - if (!widget) { - return; - } - Q_D(FramelessWidgetsHelper); - if (!d->window) { - return; - } - const FramelessWidgetsHelperExtraDataPtr extraData = tryGetExtraData(d->window, false); - Q_ASSERT(extraData); - if (!extraData || (extraData->titleBarWidget == widget)) { - return; - } - extraData->titleBarWidget = widget; - d->emitSignalForAllInstances("titleBarWidgetChanged"); -} - -QWidget *FramelessWidgetsHelper::titleBarWidget() const -{ - Q_D(const FramelessWidgetsHelper); - if (!d->window) { - return nullptr; - } - const FramelessWidgetsHelperExtraDataPtr extraData = tryGetExtraData(d->window, false); - Q_ASSERT(extraData); - if (!extraData) { - return nullptr; - } - return extraData->titleBarWidget; -} - -void FramelessWidgetsHelper::setHitTestVisible(QWidget *widget, const bool visible) -{ - Q_ASSERT(widget); - if (!widget) { - return; - } - Q_D(FramelessWidgetsHelper); - if (!d->window) { - return; - } - const FramelessWidgetsHelperExtraDataPtr extraData = tryGetExtraData(d->window, false); - Q_ASSERT(extraData); - if (!extraData) { - return; - } - if (visible) { - extraData->hitTestVisibleWidgets.append(widget); - } else { - extraData->hitTestVisibleWidgets.removeAll(widget); - } -} - -void FramelessWidgetsHelper::setHitTestVisible(const QRect &rect, const bool visible) -{ - Q_ASSERT(Utils::isValidGeometry(rect)); - if (!Utils::isValidGeometry(rect)) { - return; - } - Q_D(FramelessWidgetsHelper); - if (!d->window) { - return; - } - const FramelessWidgetsHelperExtraDataPtr extraData = tryGetExtraData(d->window, false); - Q_ASSERT(extraData); - if (!extraData) { - return; - } - if (visible) { - extraData->hitTestVisibleRects.append(rect); - } else { - extraData->hitTestVisibleRects.removeAll(rect); - } -} - -void FramelessWidgetsHelper::setHitTestVisible(QObject *object, const bool visible) -{ - Q_ASSERT(object); - if (!object) { - return; - } - const auto widget = qobject_cast(object); - Q_ASSERT(widget); - if (!widget) { - return; - } - setHitTestVisible(widget, visible); -} - -void FramelessWidgetsHelper::extendsContentIntoTitleBar(const bool value) -{ - if (isContentExtendedIntoTitleBar() == value) { - return; - } - Q_D(FramelessWidgetsHelper); - if (value) { - d->attach(); - } else { - d->detach(); - } - d->emitSignalForAllInstances("extendsContentIntoTitleBarChanged"); -} - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesswidgetshelper.h b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesswidgetshelper.h deleted file mode 100644 index 5417ab48..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesswidgetshelper.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Widgets/framelesswidgetshelper.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesswidgetshelper_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesswidgetshelper_p.h deleted file mode 100644 index e5cbbe41..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/framelesswidgetshelper_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Widgets/private/framelesswidgetshelper_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/standardsystembutton.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/standardsystembutton.cpp deleted file mode 100644 index 10f18d51..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/standardsystembutton.cpp +++ /dev/null @@ -1,354 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "standardsystembutton.h" -#include "standardsystembutton_p.h" - -#if FRAMELESSHELPER_CONFIG(system_button) - -#include -#include -#include -#include -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcStandardSystemButton, "wangwenx190.framelesshelper.widgets.standardsystembutton") -# define INFO qCInfo(lcStandardSystemButton) -# define DEBUG qCDebug(lcStandardSystemButton) -# define WARNING qCWarning(lcStandardSystemButton) -# define CRITICAL qCCritical(lcStandardSystemButton) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -StandardSystemButtonPrivate::StandardSystemButtonPrivate(StandardSystemButton *q) : QObject(q) -{ - Q_ASSERT(q); - if (!q) { - return; - } - q_ptr = q; -} - -StandardSystemButtonPrivate::~StandardSystemButtonPrivate() = default; - -StandardSystemButtonPrivate *StandardSystemButtonPrivate::get(StandardSystemButton *pub) -{ - Q_ASSERT(pub); - if (!pub) { - return nullptr; - } - return pub->d_func(); -} - -const StandardSystemButtonPrivate *StandardSystemButtonPrivate::get(const StandardSystemButton *pub) -{ - Q_ASSERT(pub); - if (!pub) { - return nullptr; - } - return pub->d_func(); -} - -QSize StandardSystemButtonPrivate::getRecommendedButtonSize() -{ - return kDefaultSystemButtonSize; -} - -StandardSystemButton::StandardSystemButton(QWidget *parent) - : QPushButton(parent), d_ptr(std::make_unique(this)) -{ - FramelessManagerPrivate::initializeIconFont(); - setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - setFixedSize(StandardSystemButtonPrivate::getRecommendedButtonSize()); - setIconSize(kDefaultSystemButtonIconSize); - setMouseTracking(true); - setAttribute(Qt::WA_Hover); -} - -StandardSystemButton::StandardSystemButton(const SystemButtonType type, QWidget *parent) - : StandardSystemButton(parent) -{ - setButtonType(type); -} - -StandardSystemButton::~StandardSystemButton() = default; - -QSize StandardSystemButton::sizeHint() const -{ - return StandardSystemButtonPrivate::getRecommendedButtonSize(); -} - -QString StandardSystemButton::glyph() const -{ - Q_D(const StandardSystemButton); - return d->glyph; -} - -void StandardSystemButton::setGlyph(const QString &value) -{ - Q_ASSERT(!value.isEmpty()); - if (value.isEmpty()) { - return; - } - Q_D(StandardSystemButton); - if (d->glyph == value) { - return; - } - d->glyph = value; - update(); - Q_EMIT glyphChanged(); -} - -SystemButtonType StandardSystemButton::buttonType() const -{ - Q_D(const StandardSystemButton); - return d->buttonType; -} - -void StandardSystemButton::setButtonType(const SystemButtonType type) -{ - Q_ASSERT(type != SystemButtonType::Unknown); - if (type == SystemButtonType::Unknown) { - return; - } - Q_D(StandardSystemButton); - if (d->buttonType == type) { - return; - } - d->buttonType = type; - setGlyph(Utils::getSystemButtonGlyph(d->buttonType)); - update(); -} - -QColor StandardSystemButton::hoverColor() const -{ - Q_D(const StandardSystemButton); - return d->hoverColor; -} - -QColor StandardSystemButton::pressColor() const -{ - Q_D(const StandardSystemButton); - return d->pressColor; -} - -QColor StandardSystemButton::normalColor() const -{ - Q_D(const StandardSystemButton); - return d->normalColor; -} - -QColor StandardSystemButton::activeForegroundColor() const -{ - Q_D(const StandardSystemButton); - return d->activeForegroundColor; -} - -QColor StandardSystemButton::inactiveForegroundColor() const -{ - Q_D(const StandardSystemButton); - return d->inactiveForegroundColor; -} - -bool StandardSystemButton::isActive() const -{ - Q_D(const StandardSystemButton); - return d->active; -} - -int StandardSystemButton::glyphSize() const -{ - Q_D(const StandardSystemButton); - return d->glyphSize.value_or(FramelessManagerPrivate::getIconFont().pointSize()); -} - -void StandardSystemButton::setHoverColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - Q_D(StandardSystemButton); - if (d->hoverColor == value) { - return; - } - d->hoverColor = value; - update(); - Q_EMIT hoverColorChanged(); -} - -void StandardSystemButton::setPressColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - Q_D(StandardSystemButton); - if (d->pressColor == value) { - return; - } - d->pressColor = value; - update(); - Q_EMIT pressColorChanged(); -} - -void StandardSystemButton::setNormalColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - Q_D(StandardSystemButton); - if (d->normalColor == value) { - return; - } - d->normalColor = value; - update(); - Q_EMIT normalColorChanged(); -} - -void StandardSystemButton::setActiveForegroundColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - Q_D(StandardSystemButton); - if (d->activeForegroundColor == value) { - return; - } - d->activeForegroundColor = value; - update(); - Q_EMIT activeForegroundColorChanged(); -} - -void StandardSystemButton::setInactiveForegroundColor(const QColor &value) -{ - Q_ASSERT(value.isValid()); - if (!value.isValid()) { - return; - } - Q_D(StandardSystemButton); - if (d->inactiveForegroundColor == value) { - return; - } - d->inactiveForegroundColor = value; - update(); - Q_EMIT inactiveForegroundColorChanged(); -} - -void StandardSystemButton::setActive(const bool value) -{ - Q_D(StandardSystemButton); - if (d->active == value) { - return; - } - d->active = value; - update(); - Q_EMIT activeChanged(); -} - -void StandardSystemButton::setGlyphSize(const int value) -{ - Q_ASSERT(value > 0); - if (value <= 0) { - return; - } - if (glyphSize() == value) { - return; - } - Q_D(StandardSystemButton); - d->glyphSize = value; - update(); - Q_EMIT glyphSizeChanged(); -} - -void StandardSystemButton::paintEvent(QPaintEvent *event) -{ - Q_ASSERT(event); - if (!event) { - return; - } - Q_D(StandardSystemButton); - QPainter painter(this); - painter.save(); - painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing - | QPainter::SmoothPixmapTransform); - const bool isHovering = underMouse(); - const auto backgroundColor = [isHovering, d, this]() -> QColor { - // The pressed state has higher priority than the hovered state. - if (isDown() && d->pressColor.isValid()) { - return d->pressColor; - } - if (isHovering && d->hoverColor.isValid()) { - return d->hoverColor; - } - if (d->normalColor.isValid()) { - return d->normalColor; - } - return {}; - }(); - const QRect buttonRect = {QPoint(0, 0), size()}; - if (backgroundColor.isValid()) { - painter.fillRect(buttonRect, backgroundColor); - } - if (!d->glyph.isEmpty()) { - painter.setPen([isHovering, d]() -> QColor { - if (!isHovering && !d->active && d->inactiveForegroundColor.isValid()) { - return d->inactiveForegroundColor; - } - if ((d->buttonType == SystemButtonType::Close) && isHovering) { - return kDefaultWhiteColor; - } - if (d->activeForegroundColor.isValid()) { - return d->activeForegroundColor; - } - return kDefaultBlackColor; - }()); - painter.setFont([d]() -> QFont { - QFont font = FramelessManagerPrivate::getIconFont(); - if (d->glyphSize.has_value()) { - font.setPointSize(d->glyphSize.value()); - } - return font; - }()); - painter.drawText(buttonRect, Qt::AlignCenter, d->glyph); - } - painter.restore(); - event->accept(); -} - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/standardsystembutton.h b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/standardsystembutton.h deleted file mode 100644 index e7263f51..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/standardsystembutton.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Widgets/standardsystembutton.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/standardsystembutton_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/standardsystembutton_p.h deleted file mode 100644 index c4433aea..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/standardsystembutton_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Widgets/private/standardsystembutton_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/standardtitlebar.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/standardtitlebar.cpp deleted file mode 100644 index fe0e0cb0..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/standardtitlebar.cpp +++ /dev/null @@ -1,703 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "standardtitlebar.h" -#include "standardtitlebar_p.h" - -#if FRAMELESSHELPER_CONFIG(titlebar) - -#if FRAMELESSHELPER_CONFIG(system_button) -# include "standardsystembutton.h" -#endif -#include "framelesswidgetshelper.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcStandardTitleBar, "wangwenx190.framelesshelper.widgets.standardtitlebar") -# define INFO qCInfo(lcStandardTitleBar) -# define DEBUG qCDebug(lcStandardTitleBar) -# define WARNING qCWarning(lcStandardTitleBar) -# define CRITICAL qCCritical(lcStandardTitleBar) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -static inline void emulateLeaveEvent(QWidget *widget) -{ - Q_ASSERT(widget); - if (!widget) { - return; - } - QTimer::singleShot(0, widget, [widget](){ -#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) - const QScreen *screen = widget->screen(); -#else - const QScreen *screen = widget->windowHandle()->screen(); -#endif - const QPoint globalPos = QCursor::pos(screen); - if (!QRect(widget->mapToGlobal(QPoint{ 0, 0 }), widget->size()).contains(globalPos)) { - QCoreApplication::postEvent(widget, new QEvent(QEvent::Leave)); - if (widget->testAttribute(Qt::WA_Hover)) { - const QPoint localPos = widget->mapFromGlobal(globalPos); - const QPoint scenePos = widget->window()->mapFromGlobal(globalPos); - static constexpr const auto oldPos = QPoint{}; - const Qt::KeyboardModifiers modifiers = QGuiApplication::keyboardModifiers(); -#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)) - const auto event = new QHoverEvent(QEvent::HoverLeave, scenePos, globalPos, oldPos, modifiers); - Q_UNUSED(localPos); -#elif (QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)) - const auto event = new QHoverEvent(QEvent::HoverLeave, localPos, globalPos, oldPos, modifiers); - Q_UNUSED(scenePos); -#else - const auto event = new QHoverEvent(QEvent::HoverLeave, localPos, oldPos, modifiers); - Q_UNUSED(scenePos); -#endif - QCoreApplication::postEvent(widget, event); - } - } - }); -} - -StandardTitleBarPrivate::StandardTitleBarPrivate(StandardTitleBar *q) : QObject(q) -{ - Q_ASSERT(q); - if (!q) { - return; - } - q_ptr = q; - initialize(); -} - -StandardTitleBarPrivate::~StandardTitleBarPrivate() = default; - -StandardTitleBarPrivate *StandardTitleBarPrivate::get(StandardTitleBar *pub) -{ - Q_ASSERT(pub); - if (!pub) { - return nullptr; - } - return pub->d_func(); -} - -const StandardTitleBarPrivate *StandardTitleBarPrivate::get(const StandardTitleBar *pub) -{ - Q_ASSERT(pub); - if (!pub) { - return nullptr; - } - return pub->d_func(); -} - -QFont StandardTitleBarPrivate::defaultFont() const -{ - Q_Q(const StandardTitleBar); - QFont font = q->font(); - font.setPointSize(kDefaultTitleBarFontPointSize); - return font; -} - -StandardTitleBarPrivate::FontMetrics StandardTitleBarPrivate::titleLabelSize() const -{ - if (!window) { - return {}; - } - const QString text = window->windowTitle(); - if (text.isEmpty()) { - return {}; - } - const QFont font = titleFont.value_or(defaultFont()); - const QFontMetrics fontMetrics(font); - const int textWidth = Utils::horizontalAdvance(fontMetrics, text); - return { - /* .width */ std::min(textWidth, titleLabelMaxWidth()), - /* .height */ fontMetrics.height(), - /* .ascent */ fontMetrics.ascent() - }; -} - -int StandardTitleBarPrivate::titleLabelMaxWidth() const -{ -#if (FRAMELESSHELPER_CONFIG(system_button) && !defined(Q_OS_MACOS)) - const int chromeButtonAreaWidth = (closeButton->x() + closeButton->width() - minimizeButton->x()); -#else - static constexpr const int chromeButtonAreaWidth = 70; -#endif - Q_Q(const StandardTitleBar); - int textMaxWidth = q->width(); - if ((labelAlignment & Qt::AlignLeft) || (labelAlignment & Qt::AlignRight)) { - textMaxWidth -= (windowIconRect().width() + chromeButtonAreaWidth + (kDefaultTitleBarContentsMargin * 2)); - } else if (labelAlignment & Qt::AlignHCenter) { - textMaxWidth -= ((chromeButtonAreaWidth + kDefaultTitleBarContentsMargin) * 2); - } else { - textMaxWidth = std::round(qreal(textMaxWidth) * qreal(0.8)); - } - return std::max(textMaxWidth, 0); -} - -bool StandardTitleBarPrivate::mouseEventHandler(QMouseEvent *event) -{ -#ifdef Q_OS_MACOS - Q_UNUSED(event); - return false; -#else // !Q_OS_MACOS - Q_ASSERT(event); - if (!event) { - return false; - } - Q_Q(const StandardTitleBar); - const Qt::MouseButton button = event->button(); -# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - const QPoint scenePos = event->scenePosition().toPoint(); -# else // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - const QPoint scenePos = event->windowPos().toPoint(); -# endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - const bool interestArea = isInTitleBarIconArea(scenePos); - switch (event->type()) { - case QEvent::MouseButtonRelease: - // We need a valid top level widget here. - if (window && interestArea) { - // Sadly the mouse release events are always triggered before the - // mouse double click events, and if we intercept the mouse release - // events here, we'll never get the double click events afterwards, - // so we have to wait for a little bit to make sure the double - // click events are handled first, before we actually handle the - // mouse release events here. - // We need to wait long enough because the time interval between these - // events is really really short, if the delay time is not long enough, - // we still can't trigger the double click event due to we have handled - // the mouse release events here already. But we also can't wait too - // long, otherwise the system menu will show up too late, which is not - // a good user experience. In my experiments, I found that 150ms is - // the minimum value we can use here. - // We need a copy of the "scenePos" variable here, otherwise it will - // soon fall out of scope when the lambda function actually runs. - QTimer::singleShot(150, this, [this, button, q, scenePos](){ - // The close event is already triggered, don't try to show the - // system menu anymore, otherwise it will prevent our window - // from closing. - if (closeTriggered) { - return; - } - // Please refer to the comments in StandardTitleBarPrivate::setWindowIconVisible(). - FramelessWidgetsHelper::get(window)->showSystemMenu([button, q, &scenePos, this]() -> QPoint { - QPoint pos = scenePos; - if (button == Qt::LeftButton) { - pos = {0, q->height()}; - } - return window->mapToGlobal(pos); - }()); - }); - // Don't eat this event, we have not handled it yet. - } - break; - case QEvent::MouseButtonDblClick: - // We need a valid top level widget here. - if (window && (button == Qt::LeftButton) && interestArea) { - closeTriggered = true; - window->close(); - // Eat this event, we have handled it here. - event->accept(); - return true; - } - break; - default: - break; - } - return false; -#endif // Q_OS_MACOS -} - -QRect StandardTitleBarPrivate::windowIconRect() const -{ - Q_Q(const StandardTitleBar); - if (!windowIconVisible_real()) { - return {}; - } - const QSize size = q->windowIconSize(); -#ifdef Q_OS_MACOS - const auto x = [this, q, &size]() -> int { - if (labelAlignment & Qt::AlignLeft) { - return (kMacOSChromeButtonAreaWidth + kDefaultTitleBarContentsMargin); - } - const int titleBarWidth = q->width(); - const int labelWidth = titleLabelSize().width; - if (labelAlignment & Qt::AlignRight) { - // We need two spacer here, one is on the right edge of the title bar, - // the other one is between the window icon and the window label. - return (titleBarWidth - kDefaultTitleBarContentsMargin - - labelWidth - kDefaultTitleBarContentsMargin - size.width()); - } - if (labelAlignment & Qt::AlignHCenter) { - const int centeredX = std::round(qreal(titleBarWidth - labelWidth) / qreal(2)); - return (centeredX - kDefaultTitleBarContentsMargin - size.width()); - } - WARNING << "The alignment for the title label is not set!"; - return 0; - }(); -#else // !Q_OS_MACOS - const int x = kDefaultTitleBarContentsMargin; -#endif // Q_OS_MACOS - const int y = std::round(qreal(q->height() - size.height()) / qreal(2)); - return {QPoint(x, y), size}; -} - -bool StandardTitleBarPrivate::windowIconVisible_real() const -{ - return (windowIconVisible && !window->windowIcon().isNull()); -} - -bool StandardTitleBarPrivate::isInTitleBarIconArea(const QPoint &pos) const -{ - if (!windowIconVisible_real()) { - return false; - } - return windowIconRect().contains(pos); -} - -void StandardTitleBarPrivate::updateMaximizeButton() -{ -#if (FRAMELESSHELPER_CONFIG(system_button) && defined(Q_OS_LINUX)) - const bool max = window->isMaximized(); - maximizeButton->setButtonType(max ? SystemButtonType::Restore : SystemButtonType::Maximize); - maximizeButton->setToolTip(max ? tr("Restore") : tr("Maximize")); -#endif -} - -void StandardTitleBarPrivate::updateTitleBarColor() -{ - Q_Q(StandardTitleBar); - q->update(); -} - -void StandardTitleBarPrivate::updateChromeButtonColor() -{ -#if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button)) - const bool active = window->isActiveWindow(); - const QColor activeForeground = chromePalette->titleBarActiveForegroundColor(); - const QColor inactiveForeground = chromePalette->titleBarInactiveForegroundColor(); - const QColor normal = chromePalette->chromeButtonNormalColor(); - const QColor hover = chromePalette->chromeButtonHoverColor(); - const QColor press = chromePalette->chromeButtonPressColor(); - minimizeButton->setActiveForegroundColor(activeForeground); - minimizeButton->setInactiveForegroundColor(inactiveForeground); - minimizeButton->setNormalColor(normal); - minimizeButton->setHoverColor(hover); - minimizeButton->setPressColor(press); - minimizeButton->setActive(active); - maximizeButton->setActiveForegroundColor(activeForeground); - maximizeButton->setInactiveForegroundColor(inactiveForeground); - maximizeButton->setNormalColor(normal); - maximizeButton->setHoverColor(hover); - maximizeButton->setPressColor(press); - maximizeButton->setActive(active); - closeButton->setActiveForegroundColor(activeForeground); - closeButton->setInactiveForegroundColor(inactiveForeground); - closeButton->setNormalColor(chromePalette->closeButtonNormalColor()); - closeButton->setHoverColor(chromePalette->closeButtonHoverColor()); - closeButton->setPressColor(chromePalette->closeButtonPressColor()); - closeButton->setActive(active); -#endif -} - -void StandardTitleBarPrivate::retranslateUi() -{ -#if (FRAMELESSHELPER_CONFIG(system_button) && defined(Q_OS_LINUX)) - minimizeButton->setToolTip(tr("Minimize")); - maximizeButton->setToolTip(window->isMaximized() ? tr("Restore") : tr("Maximize")); - closeButton->setToolTip(tr("Close")); -#endif -} - -bool StandardTitleBarPrivate::eventFilter(QObject *object, QEvent *event) -{ - Q_ASSERT(object); - Q_ASSERT(event); - if (!object || !event) { - return false; - } - if (!object->isWidgetType()) { - return QObject::eventFilter(object, event); - } - const auto widget = qobject_cast(object); - if (!widget->isWindow() || (widget != window)) { - return QObject::eventFilter(object, event); - } - switch (event->type()) { - case QEvent::WindowStateChange: - updateMaximizeButton(); - break; - case QEvent::ActivationChange: { - updateTitleBarColor(); - updateChromeButtonColor(); - } break; - case QEvent::LanguageChange: - retranslateUi(); - break; - default: - break; - } - return QObject::eventFilter(object, event); -} - -void StandardTitleBarPrivate::initialize() -{ - Q_Q(StandardTitleBar); - window = q->window(); - chromePalette = new ChromePalette(this); - connect(chromePalette, &ChromePalette::titleBarColorChanged, - this, &StandardTitleBarPrivate::updateTitleBarColor); - connect(chromePalette, &ChromePalette::chromeButtonColorChanged, - this, &StandardTitleBarPrivate::updateChromeButtonColor); - connect(window, &QWidget::windowIconChanged, this, [q](const QIcon &icon){ - Q_UNUSED(icon); - q->update(); - }); - connect(window, &QWidget::windowTitleChanged, this, [q](const QString &title){ - Q_UNUSED(title); - q->update(); - }); -#ifdef Q_OS_MACOS - const auto titleBarLayout = new QHBoxLayout(q); - titleBarLayout->setSpacing(0); - titleBarLayout->setContentsMargins(0, 0, 0, 0); -#elif FRAMELESSHELPER_CONFIG(system_button) - minimizeButton = new StandardSystemButton(SystemButtonType::Minimize, q); - connect(minimizeButton, &StandardSystemButton::clicked, window, &QWidget::showMinimized); - maximizeButton = new StandardSystemButton(SystemButtonType::Maximize, q); - updateMaximizeButton(); - connect(maximizeButton, &StandardSystemButton::clicked, this, [this](){ - if (window->isMaximized()) { - window->showNormal(); - } else { - window->showMaximized(); - } - - // It's a Qt issue that if a QAbstractButton::clicked triggers a window's maximization, - // the button remains to be hovered until the mouse move. As a result, we need to - // manully send leave events to the button. - emulateLeaveEvent(maximizeButton); - }); - closeButton = new StandardSystemButton(SystemButtonType::Close, q); - connect(closeButton, &StandardSystemButton::clicked, this, [this](){ - if (hideWhenClose) { - window->hide(); - } else { - window->close(); - } - }); - // According to the title bar design guidance, the system buttons should always be - // placed on the top-right corner of the window, so we need the following additional - // layouts to ensure this. - const auto systemButtonsInnerLayout = new QHBoxLayout; - systemButtonsInnerLayout->setSpacing(0); - systemButtonsInnerLayout->setContentsMargins(0, 0, 0, 0); - systemButtonsInnerLayout->addWidget(minimizeButton); - systemButtonsInnerLayout->addWidget(maximizeButton); - systemButtonsInnerLayout->addWidget(closeButton); - const auto systemButtonsOuterLayout = new QVBoxLayout; - systemButtonsOuterLayout->setSpacing(0); - systemButtonsOuterLayout->setContentsMargins(0, 0, 0, 0); - systemButtonsOuterLayout->addLayout(systemButtonsInnerLayout); - systemButtonsOuterLayout->addStretch(); - const auto titleBarLayout = new QHBoxLayout(q); - titleBarLayout->setSpacing(0); - titleBarLayout->setContentsMargins(0, 0, 0, 0); - titleBarLayout->addStretch(); - titleBarLayout->addLayout(systemButtonsOuterLayout); -#endif - retranslateUi(); - updateTitleBarColor(); - updateChromeButtonColor(); - window->installEventFilter(this); -} - -StandardTitleBar::StandardTitleBar(QWidget *parent) - : QWidget(parent), d_ptr(std::make_unique(this)) -{ - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - setFixedHeight(kDefaultTitleBarHeight); -#ifdef Q_OS_MACOS - setTitleLabelAlignment(Qt::AlignCenter); -#else - setTitleLabelAlignment(Qt::AlignLeft | Qt::AlignVCenter); -#endif -} - -StandardTitleBar::~StandardTitleBar() = default; - -#if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button)) -StandardSystemButton *StandardTitleBar::minimizeButton() const -{ - Q_D(const StandardTitleBar); - return d->minimizeButton; -} - -StandardSystemButton *StandardTitleBar::maximizeButton() const -{ - Q_D(const StandardTitleBar); - return d->maximizeButton; -} - -StandardSystemButton *StandardTitleBar::closeButton() const -{ - Q_D(const StandardTitleBar); - return d->closeButton; -} -#endif - -void StandardTitleBar::mouseReleaseEvent(QMouseEvent *event) -{ - QWidget::mouseReleaseEvent(event); - Q_D(StandardTitleBar); - std::ignore = d->mouseEventHandler(event); -} - -void StandardTitleBar::mouseDoubleClickEvent(QMouseEvent *event) -{ - QWidget::mouseDoubleClickEvent(event); - Q_D(StandardTitleBar); - std::ignore = d->mouseEventHandler(event); -} - -Qt::Alignment StandardTitleBar::titleLabelAlignment() const -{ - Q_D(const StandardTitleBar); - return d->labelAlignment; -} - -void StandardTitleBar::setTitleLabelAlignment(const Qt::Alignment value) -{ - Q_D(StandardTitleBar); - if (d->labelAlignment == value) { - return; - } - d->labelAlignment = value; - update(); - Q_EMIT titleLabelAlignmentChanged(); -} - -bool StandardTitleBar::isExtended() const -{ - Q_D(const StandardTitleBar); - return d->extended; -} - -void StandardTitleBar::setExtended(const bool value) -{ - Q_D(StandardTitleBar); - if (d->extended == value) { - return; - } - d->extended = value; - setFixedHeight(d->extended ? kDefaultExtendedTitleBarHeight : kDefaultTitleBarHeight); - Q_EMIT extendedChanged(); -} - -bool StandardTitleBar::isHideWhenClose() const -{ - Q_D(const StandardTitleBar); - return d->hideWhenClose; -} - -void StandardTitleBar::setHideWhenClose(const bool value) -{ - Q_D(StandardTitleBar); - if (d->hideWhenClose == value) { - return; - } - d->hideWhenClose = value; - Q_EMIT hideWhenCloseChanged(); -} - -ChromePalette *StandardTitleBar::chromePalette() const -{ - Q_D(const StandardTitleBar); - return d->chromePalette; -} - -void StandardTitleBar::paintEvent(QPaintEvent *event) -{ - Q_ASSERT(event); - if (!event) { - return; - } - Q_D(StandardTitleBar); - if (!d->window) { - return; - } - const bool active = d->window->isActiveWindow(); - const QColor backgroundColor = (active ? - d->chromePalette->titleBarActiveBackgroundColor() : - d->chromePalette->titleBarInactiveBackgroundColor()); - const QColor foregroundColor = (active ? - d->chromePalette->titleBarActiveForegroundColor() : - d->chromePalette->titleBarInactiveForegroundColor()); - QPainter painter(this); - painter.save(); - painter.setRenderHints(QPainter::Antialiasing | - QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); - painter.fillRect(QRect(QPoint(0, 0), size()), backgroundColor); - if (d->titleLabelVisible) { - const QString text = d->window->windowTitle(); - if (!text.isEmpty()) { - painter.setPen(foregroundColor); - painter.setFont(d->titleFont.value_or(d->defaultFont())); - const auto pos = [this, d]() -> QPoint { - const StandardTitleBarPrivate::FontMetrics labelSize = d->titleLabelSize(); - const int titleBarWidth = width(); - int x = 0; - if (d->labelAlignment & Qt::AlignLeft) { - x = (d->windowIconRect().right() + kDefaultTitleBarContentsMargin); - } else if (d->labelAlignment & Qt::AlignRight) { - x = (titleBarWidth - kDefaultTitleBarContentsMargin - labelSize.width); -#if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button)) - x -= (titleBarWidth - d->minimizeButton->x()); -#endif - } else if (d->labelAlignment & Qt::AlignHCenter) { - x = std::round(qreal(titleBarWidth - labelSize.width) / qreal(2)); - } else { - WARNING << "The alignment for the title label is not set!"; - } - const int y = std::round((qreal(height() - labelSize.height) / qreal(2)) + qreal(labelSize.ascent)); - return {x, y}; - }(); - const int textMaxWidth = d->titleLabelMaxWidth(); - const QString elidedText = painter.fontMetrics().elidedText(text, Qt::ElideRight, textMaxWidth, Qt::TextShowMnemonic); - // No need to draw the text if there's only the elide mark left (or even less). - if (elidedText.size() > 3) { - painter.drawText(pos, elidedText); - } - } - } - if (d->windowIconVisible) { - const QIcon icon = d->window->windowIcon(); - if (!icon.isNull()) { - icon.paint(&painter, d->windowIconRect()); - } - } - painter.restore(); - event->accept(); -} - -bool StandardTitleBar::titleLabelVisible() const -{ - Q_D(const StandardTitleBar); - return d->titleLabelVisible; -} - -void StandardTitleBar::setTitleLabelVisible(const bool value) -{ - Q_D(StandardTitleBar); - if (d->titleLabelVisible == value) { - return; - } - d->titleLabelVisible = value; - update(); - Q_EMIT titleLabelVisibleChanged(); -} - -QSize StandardTitleBar::windowIconSize() const -{ - Q_D(const StandardTitleBar); - return d->windowIconSize.value_or(kDefaultWindowIconSize); -} - -void StandardTitleBar::setWindowIconSize(const QSize &value) -{ - Q_ASSERT(!value.isEmpty()); - if (value.isEmpty()) { - return; - } - if (windowIconSize() == value) { - return; - } - Q_D(StandardTitleBar); - d->windowIconSize = value; - update(); - Q_EMIT windowIconSizeChanged(); -} - -bool StandardTitleBar::windowIconVisible() const -{ - Q_D(const StandardTitleBar); - return d->windowIconVisible; -} - -void StandardTitleBar::setWindowIconVisible(const bool value) -{ - Q_D(StandardTitleBar); - if (d->windowIconVisible == value) { - return; - } - d->windowIconVisible = value; - update(); - Q_EMIT windowIconVisibleChanged(); -#ifndef Q_OS_MACOS - // Ideally we should use FramelessWidgetsHelper::get(this) everywhere, but sadly when - // we call it here, it may be too early that FramelessWidgetsHelper has not attached - // to the top level widget yet, and thus it will trigger an assert error (the assert - // should not be suppressed, because it usually indicates there's something really - // wrong). So here we have to use the top level widget directly, as a special case. - // NOTE: In your own code, you should always use FramelessWidgetsHelper::get(this) - // if possible. - FramelessWidgetsHelper::get(d->window)->setHitTestVisible(d->windowIconRect(), d->windowIconVisible_real()); -#endif // Q_OS_MACOS -} - -QFont StandardTitleBar::titleFont() const -{ - Q_D(const StandardTitleBar); - return d->titleFont.value_or(QFont()); -} - -void StandardTitleBar::setTitleFont(const QFont &value) -{ - if (titleFont() == value) { - return; - } - Q_D(StandardTitleBar); - d->titleFont = value; - update(); - Q_EMIT titleFontChanged(); -} - -FRAMELESSHELPER_END_NAMESPACE - -#endif diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/standardtitlebar.h b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/standardtitlebar.h deleted file mode 100644 index 8379a496..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/standardtitlebar.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Widgets/standardtitlebar.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/standardtitlebar_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/standardtitlebar_p.h deleted file mode 100644 index 797d31d6..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/standardtitlebar_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Widgets/private/standardtitlebar_p.h" diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/widgetssharedhelper.cpp b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/widgetssharedhelper.cpp deleted file mode 100644 index ff0f45c2..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/widgetssharedhelper.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/* - * MIT License - * - * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "widgetssharedhelper_p.h" -#if FRAMELESSHELPER_CONFIG(mica_material) -# include -# include -#endif -#if FRAMELESSHELPER_CONFIG(border_painter) -# include -#endif -#include -#include -#ifdef Q_OS_WINDOWS -# include -#endif // Q_OS_WINDOWS -#include -#include -#include -#include -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -#if FRAMELESSHELPER_CONFIG(debug_output) -[[maybe_unused]] static Q_LOGGING_CATEGORY(lcWidgetsSharedHelper, "wangwenx190.framelesshelper.widgets.widgetssharedhelper") -# define INFO qCInfo(lcWidgetsSharedHelper) -# define DEBUG qCDebug(lcWidgetsSharedHelper) -# define WARNING qCWarning(lcWidgetsSharedHelper) -# define CRITICAL qCCritical(lcWidgetsSharedHelper) -#else -# define INFO QT_NO_QDEBUG_MACRO() -# define DEBUG QT_NO_QDEBUG_MACRO() -# define WARNING QT_NO_QDEBUG_MACRO() -# define CRITICAL QT_NO_QDEBUG_MACRO() -#endif - -using namespace Global; - -WidgetsSharedHelper::WidgetsSharedHelper(QObject *parent) : QObject(parent) -{ -} - -WidgetsSharedHelper::~WidgetsSharedHelper() = default; - -void WidgetsSharedHelper::setup(QWidget *widget) -{ - Q_ASSERT(widget); - if (!widget) { - return; - } - if (m_targetWidget && (m_targetWidget == widget)) { - return; - } - m_targetWidget = widget; -#if FRAMELESSHELPER_CONFIG(border_painter) - m_borderPainter = new WindowBorderPainter(this); - if (m_borderRepaintConnection) { - disconnect(m_borderRepaintConnection); - m_borderRepaintConnection = {}; - } - m_borderRepaintConnection = connect(m_borderPainter, - &WindowBorderPainter::shouldRepaint, this, [this](){ - if (m_targetWidget) { - m_targetWidget->update(); - } - }); -#endif -#if FRAMELESSHELPER_CONFIG(mica_material) - m_micaMaterial = new MicaMaterial(this); - if (m_micaRedrawConnection) { - disconnect(m_micaRedrawConnection); - m_micaRedrawConnection = {}; - } - m_micaRedrawConnection = connect(m_micaMaterial, &MicaMaterial::shouldRedraw, - this, [this](){ - if (m_targetWidget) { - m_targetWidget->update(); - } - }); -#endif - m_targetWidget->installEventFilter(this); - updateContentsMargins(); - m_targetWidget->update(); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) - QScreen *screen = m_targetWidget->screen(); -#else - QScreen *screen = m_targetWidget->windowHandle()->screen(); -#endif - handleScreenChanged(screen); - if (m_screenChangeConnection) { - disconnect(m_screenChangeConnection); - m_screenChangeConnection = {}; - } - m_screenChangeConnection = connect(m_targetWidget->windowHandle(), - &QWindow::screenChanged, this, &WidgetsSharedHelper::handleScreenChanged); -} - -#if FRAMELESSHELPER_CONFIG(mica_material) -bool WidgetsSharedHelper::isMicaEnabled() const -{ - return m_micaEnabled; -} - -void WidgetsSharedHelper::setMicaEnabled(const bool value) -{ - if (m_micaEnabled == value) { - return; - } - m_micaEnabled = value; - if (m_targetWidget) { - m_targetWidget->update(); - } - Q_EMIT micaEnabledChanged(); -} - -MicaMaterial *WidgetsSharedHelper::rawMicaMaterial() const -{ - return m_micaMaterial; -} -#endif - -#if FRAMELESSHELPER_CONFIG(border_painter) -WindowBorderPainter *WidgetsSharedHelper::rawWindowBorder() const -{ - return m_borderPainter; -} -#endif - -bool WidgetsSharedHelper::eventFilter(QObject *object, QEvent *event) -{ - Q_ASSERT(object); - Q_ASSERT(event); - if (!object || !event) { - return false; - } - if (!m_targetWidget) { - return QObject::eventFilter(object, event); - } - if (!object->isWidgetType()) { - return QObject::eventFilter(object, event); - } - const auto widget = qobject_cast(object); - if (widget != m_targetWidget) { - return QObject::eventFilter(object, event); - } - switch (event->type()) { - //case QEvent::WindowActivate: - //case QEvent::WindowDeactivate: - case QEvent::ActivationChange: - //case QEvent::ApplicationStateChange: - m_targetWidget->update(); - break; - case QEvent::Paint: { -#if FRAMELESSHELPER_CONFIG(mica_material) - repaintMica(); -#endif -#if FRAMELESSHELPER_CONFIG(border_painter) - repaintBorder(); -#endif - } break; - case QEvent::WindowStateChange: - if (event->type() == QEvent::WindowStateChange) { - updateContentsMargins(); - emitCustomWindowStateSignals(); - } - break; - case QEvent::Move: - case QEvent::Resize: -#if FRAMELESSHELPER_CONFIG(mica_material) - if (m_micaEnabled) { - m_targetWidget->update(); - } -#endif - break; - default: - break; - } - return QObject::eventFilter(object, event); -} - -#if FRAMELESSHELPER_CONFIG(mica_material) -void WidgetsSharedHelper::repaintMica() -{ - if (!m_micaEnabled) { - return; - } - QPainter painter(m_targetWidget); - const QRect rect = { m_targetWidget->mapToGlobal(QPoint(0, 0)), m_targetWidget->size() }; - m_micaMaterial->paint(&painter, rect, m_targetWidget->isActiveWindow()); -} -#endif - -#if FRAMELESSHELPER_CONFIG(border_painter) -void WidgetsSharedHelper::repaintBorder() -{ - if (Utils::windowStatesToWindowState(m_targetWidget->windowState()) != Qt::WindowNoState) { - return; - } - QPainter painter(m_targetWidget); - m_borderPainter->paint(&painter, m_targetWidget->size(), m_targetWidget->isActiveWindow()); -} -#endif - -void WidgetsSharedHelper::emitCustomWindowStateSignals() -{ - const QMetaObject * const mo = m_targetWidget->metaObject(); - if (!mo) { - return; - } - if (const int idx = mo->indexOfSignal(QMetaObject::normalizedSignature("hiddenChanged()").constData()); idx >= 0) { - QMetaObject::invokeMethod(m_targetWidget, "hiddenChanged"); - } - if (const int idx = mo->indexOfSignal(QMetaObject::normalizedSignature("normalChanged()").constData()); idx >= 0) { - QMetaObject::invokeMethod(m_targetWidget, "normalChanged"); - } - if (const int idx = mo->indexOfSignal(QMetaObject::normalizedSignature("zoomedChanged()").constData()); idx >= 0) { - QMetaObject::invokeMethod(m_targetWidget, "zoomedChanged"); - } -} - -void WidgetsSharedHelper::handleScreenChanged(QScreen *screen) -{ - Q_ASSERT(m_targetWidget); - if (!m_targetWidget) { - return; - } - // The QScreen handle can be null if a window was moved out of a screen. - if (!screen) { - return; - } - if (m_screen == screen) { - return; - } - m_screen = screen; - m_screenDpr = m_screen->devicePixelRatio(); - if (m_screenDpiChangeConnection) { - disconnect(m_screenDpiChangeConnection); - m_screenDpiChangeConnection = {}; - } - m_screenDpiChangeConnection = connect(m_screen, &QScreen::physicalDotsPerInchChanged, - this, [this](const qreal dpi){ - Q_UNUSED(dpi); - const qreal currentDpr = m_screen->devicePixelRatio(); - if (qFuzzyCompare(m_screenDpr, currentDpr)) { - return; - } - m_screenDpr = currentDpr; -#if FRAMELESSHELPER_CONFIG(mica_material) - if (m_micaEnabled) { - MicaMaterialPrivate::get(m_micaMaterial)->maybeGenerateBlurredWallpaper(true); - } -#endif - }); -} - -void WidgetsSharedHelper::updateContentsMargins() -{ -#ifdef Q_OS_WINDOWS - const auto margins = [this]() -> QMargins { - if (!Utils::isWindowFrameBorderVisible() || WindowsVersionHelper::isWin11OrGreater()) { - return {}; - } - if (Utils::windowStatesToWindowState(m_targetWidget->windowState()) != Qt::WindowNoState) { - return {}; - } - return {0, kDefaultWindowFrameBorderThickness, 0, 0}; - }(); - m_targetWidget->setContentsMargins(margins); -#endif -} - -FRAMELESSHELPER_END_NAMESPACE diff --git a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/widgetssharedhelper_p.h b/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/widgetssharedhelper_p.h deleted file mode 100644 index 8b5fbc50..00000000 --- a/src/SARibbonBar/3rdparty/framelesshelper/src/widgets/widgetssharedhelper_p.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../include/FramelessHelper/Widgets/private/widgetssharedhelper_p.h" diff --git a/src/SARibbonBar/3rdparty/qwindowkit b/src/SARibbonBar/3rdparty/qwindowkit new file mode 160000 index 00000000..1fb3ec7e --- /dev/null +++ b/src/SARibbonBar/3rdparty/qwindowkit @@ -0,0 +1 @@ +Subproject commit 1fb3ec7ef46d80cc536048d1c35905dcbfe24f0f diff --git a/src/SARibbonBar/CMakeLists.txt b/src/SARibbonBar/CMakeLists.txt index 68c7f57e..384a588a 100644 --- a/src/SARibbonBar/CMakeLists.txt +++ b/src/SARibbonBar/CMakeLists.txt @@ -4,167 +4,6 @@ set(SARIBBON_LIB_NAME SARibbonBar) set(CMAKE_INCLUDE_CURRENT_DIR ON) -################################################# -# frameless库https://github.com/wangwenx190/framelesshelper -################################################# -function(setup_custom_moc_macros) - cmake_parse_arguments(arg "" "" "TARGETS" ${ARGN}) - if(arg_UNPARSED_ARGUMENTS) - message(AUTHOR_WARNING "setup_custom_moc_macros: Unrecognized arguments: ${arg_UNPARSED_ARGUMENTS}") - endif() - foreach(__target ${arg_TARGETS}) - if(NOT TARGET ${__target}) - message(AUTHOR_WARNING "${__target} is not a valid CMake target!") - continue() - endif() - set_property(TARGET ${__target} APPEND PROPERTY AUTOMOC_MACRO_NAMES "FRAMELESSHELPER_QT_CLASS;FRAMELESSHELPER_PUBLIC_QT_CLASS;FRAMELESSHELPER_PRIVATE_QT_CLASS") - endforeach() -endfunction() - -if(SARIBBON_USE_FRAMELESS_LIB) - if(UNIX AND NOT APPLE) - # Qt X11Extras is only available in Qt5. - if(QT_VERSION_MAJOR LESS 6) - find_package(Qt5 QUIET COMPONENTS X11Extras) - endif() - find_package(X11 QUIET COMPONENTS xcb) - if(TARGET X11::xcb) - message("Found system XCB. The XCB wrapper will be disabled.") - else() - message("System XCB not found. The XCB wrapper will be used instead.") - endif() - find_package(PkgConfig QUIET) - if(PkgConfig_FOUND) - pkg_check_modules(GTK3 QUIET IMPORTED_TARGET gtk+-3.0) - endif() - if(TARGET PkgConfig::GTK3) - message("Found system GTK. The GTK wrapper will be disabled.") - else() - message("System GTK not found. The GTK wrapper will be used instead.") - endif() - endif() - - # frameless core 相关路径设置 - SET(FRAMELESS_HEADER_BASE ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/framelesshelper/include) - SET(FRAMELESS_HEADER_DIR ${FRAMELESS_HEADER_BASE}/FramelessHelper) - SET(FRAMELESS_HEADER_DIR_CORE ${FRAMELESS_HEADER_DIR}/Core) - SET(FRAMELESS_HEADER_DIR_CORE_PRIVATE ${FRAMELESS_HEADER_DIR_CORE}/private) - SET(FRAMELESS_HEADER_DIR_STATIC_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/framelesshelper/qmake/inc/core) - - SET(FRAMELESS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/framelesshelper/src) - SET(FRAMELESS_SOURCE_DIR_CORE ${FRAMELESS_SOURCE_DIR}/core) - - # frameless core config file / cn:配置h文件 - SET(FRAMELESS_CORE_CONFIG_HEADER_FILES - ${FRAMELESS_HEADER_DIR_STATIC_CONFIG}/framelesshelper.version - ${FRAMELESS_HEADER_DIR_STATIC_CONFIG}/framelesshelper.config - ) - # frameless core header files / cn:core对应h文件 - SET(FRAMELESS_CORE_HEADER_FILES - ${FRAMELESS_HEADER_DIR_CORE}/chromepalette.h - ${FRAMELESS_HEADER_DIR_CORE}/framelesshelper_qt.h - ${FRAMELESS_HEADER_DIR_CORE}/framelesshelpercore_global.h - ${FRAMELESS_HEADER_DIR_CORE}/framelessmanager.h - ${FRAMELESS_HEADER_DIR_CORE}/micamaterial.h - ${FRAMELESS_HEADER_DIR_CORE}/utils.h - ${FRAMELESS_HEADER_DIR_CORE}/windowborderpainter.h - ${FRAMELESS_HEADER_DIR_CORE_PRIVATE}/chromepalette_p.h - ${FRAMELESS_HEADER_DIR_CORE_PRIVATE}/framelessconfig_p.h - ${FRAMELESS_HEADER_DIR_CORE_PRIVATE}/framelesshelpercore_global_p.h - ${FRAMELESS_HEADER_DIR_CORE_PRIVATE}/framelessmanager_p.h - ${FRAMELESS_HEADER_DIR_CORE_PRIVATE}/micamaterial_p.h - ${FRAMELESS_HEADER_DIR_CORE_PRIVATE}/scopeguard_p.h - ${FRAMELESS_HEADER_DIR_CORE_PRIVATE}/sysapiloader_p.h - ${FRAMELESS_HEADER_DIR_CORE_PRIVATE}/versionnumber_p.h - ${FRAMELESS_HEADER_DIR_CORE_PRIVATE}/windowborderpainter_p.h - ) - # frameless core cpp files / cn:core对应cpp文件 - SET(FRAMELESS_CORE_SOURCE_FILES - ${FRAMELESS_SOURCE_DIR_CORE}/chromepalette.cpp - ${FRAMELESS_SOURCE_DIR_CORE}/framelessconfig.cpp - ${FRAMELESS_SOURCE_DIR_CORE}/framelesshelper_qt.cpp - ${FRAMELESS_SOURCE_DIR_CORE}/framelesshelpercore_global.cpp - ${FRAMELESS_SOURCE_DIR_CORE}/framelessmanager.cpp - ${FRAMELESS_SOURCE_DIR_CORE}/micamaterial.cpp - ${FRAMELESS_SOURCE_DIR_CORE}/sysapiloader.cpp - ${FRAMELESS_SOURCE_DIR_CORE}/utils.cpp - ${FRAMELESS_SOURCE_DIR_CORE}/windowborderpainter.cpp - ) - if(WIN32) - list(APPEND FRAMELESS_CORE_HEADER_FILES - ${FRAMELESS_HEADER_DIR_CORE}/framelesshelper_windows.h - ${FRAMELESS_HEADER_DIR_CORE}/framelesshelper_win.h - ) - list(APPEND FRAMELESS_CORE_HEADER_FILES - ${FRAMELESS_HEADER_DIR_CORE_PRIVATE}/registrykey_p.h - ${FRAMELESS_HEADER_DIR_CORE_PRIVATE}/winverhelper_p.h - ) - list(APPEND FRAMELESS_CORE_SOURCE_FILES - ${FRAMELESS_SOURCE_DIR_CORE}/registrykey.cpp - ${FRAMELESS_SOURCE_DIR_CORE}/utils_win.cpp - ${FRAMELESS_SOURCE_DIR_CORE}/framelesshelper_win.cpp - ${FRAMELESS_SOURCE_DIR_CORE}/winverhelper.cpp - ${FRAMELESS_SOURCE_DIR_CORE}/platformsupport_win.cpp - ) - elseif(APPLE) - list(APPEND FRAMELESS_CORE_SOURCE_FILES - ${FRAMELESS_SOURCE_DIR_CORE}/utils_mac.mm) - elseif(UNIX) - list(APPEND FRAMELESS_CORE_HEADER_FILES - ${FRAMELESS_HEADER_DIR_CORE}/framelesshelper_linux.h - ) - list(APPEND FRAMELESS_CORE_SOURCE_FILES - ${FRAMELESS_SOURCE_DIR_CORE}/utils_linux.cpp - ${FRAMELESS_SOURCE_DIR_CORE}/platformsupport_linux.cpp - ) - endif() - # resource files - # cn:资源文件 - SET(FRAMELESS_CORE_RESOURCES_FILES - ${FRAMELESS_SOURCE_DIR_CORE}/framelesshelpercore.qrc - ) - - # frameless widget 相关路径设置 - - SET(FRAMELESS_HEADER_DIR_WIDGETS ${FRAMELESS_HEADER_DIR}/Widgets) - SET(FRAMELESS_HEADER_DIR_WIDGETS_PRIVATE ${FRAMELESS_HEADER_DIR_WIDGETS}/private) - SET(FRAMELESS_SOURCE_DIR_WIDGETS ${FRAMELESS_SOURCE_DIR}/widgets) - # frameless widgets header files / cn:widgets对应h文件 - SET(FRAMELESS_WIDGETS_HEADER_FILES - ${FRAMELESS_HEADER_DIR_WIDGETS}/framelesshelperwidgets_global.h - ${FRAMELESS_HEADER_DIR_WIDGETS}/framelesswidget.h - ${FRAMELESS_HEADER_DIR_WIDGETS}/framelessmainwindow.h - ${FRAMELESS_HEADER_DIR_WIDGETS}/standardsystembutton.h - ${FRAMELESS_HEADER_DIR_WIDGETS}/framelesswidgetshelper.h - ${FRAMELESS_HEADER_DIR_WIDGETS}/standardtitlebar.h - ${FRAMELESS_HEADER_DIR_WIDGETS}/framelessdialog.h - ${FRAMELESS_HEADER_DIR_WIDGETS_PRIVATE}/framelesswidgetshelper_p.h - ${FRAMELESS_HEADER_DIR_WIDGETS_PRIVATE}/standardsystembutton_p.h - ${FRAMELESS_HEADER_DIR_WIDGETS_PRIVATE}/standardtitlebar_p.h - ${FRAMELESS_HEADER_DIR_WIDGETS_PRIVATE}/framelesswidget_p.h - ${FRAMELESS_HEADER_DIR_WIDGETS_PRIVATE}/framelessmainwindow_p.h - ${FRAMELESS_HEADER_DIR_WIDGETS_PRIVATE}/widgetssharedhelper_p.h - ${FRAMELESS_HEADER_DIR_WIDGETS_PRIVATE}/framelessdialog_p.h - ) - # frameless widgets cpp files / cn:widgets对应cpp文件 - SET(FRAMELESS_WIDGETS_SOURCE_FILES - ${FRAMELESS_SOURCE_DIR_WIDGETS}/framelessmainwindow.cpp - ${FRAMELESS_SOURCE_DIR_WIDGETS}/framelesswidgetshelper.cpp - ${FRAMELESS_SOURCE_DIR_WIDGETS}/framelesswidget.cpp - ${FRAMELESS_SOURCE_DIR_WIDGETS}/standardsystembutton.cpp - ${FRAMELESS_SOURCE_DIR_WIDGETS}/standardtitlebar.cpp - ${FRAMELESS_SOURCE_DIR_WIDGETS}/widgetssharedhelper.cpp - ${FRAMELESS_SOURCE_DIR_WIDGETS}/framelesshelperwidgets_global.cpp - ${FRAMELESS_SOURCE_DIR_WIDGETS}/framelessdialog.cpp - ) - # 把所有FRAMELESS相关的库合并到一起 - SET(FRAMELESS_HEADER_FILES ${FRAMELESS_CORE_CONFIG_HEADER_FILES}) - list(APPEND FRAMELESS_HEADER_FILES ${FRAMELESS_CORE_HEADER_FILES}) - list(APPEND FRAMELESS_HEADER_FILES ${FRAMELESS_WIDGETS_HEADER_FILES}) - SET(FRAMELESS_SOURCE_FILES ${FRAMELESS_CORE_SOURCE_FILES}) - list(APPEND FRAMELESS_SOURCE_FILES ${FRAMELESS_WIDGETS_SOURCE_FILES}) - SET(FRAMELESS_RESOURCE_FILES ${FRAMELESS_CORE_RESOURCES_FILES}) -endif() ################################################# # SAColorWidgets相关 # https://github.com/czyt1988/SAColorWidgets @@ -277,28 +116,15 @@ SET(SARIBBON_RESOURCE_FILES ) ################################################################ -if(SARIBBON_USE_FRAMELESS_LIB) - add_library(${SARIBBON_LIB_NAME} SHARED - ${SARIBBON_HEADER_FILES} - ${SARIBBON_SOURCE_FILES} - ${SARIBBON_RESOURCE_FILES} - ${SACOLOR_HEADER_FILES} - ${SACOLOR_SOURCE_FILES} - ${FRAMELESS_HEADER_FILES} - ${FRAMELESS_SOURCE_FILES} - ${FRAMELESS_RESOURCE_FILES} - ) - setup_custom_moc_macros(TARGETS ${SARIBBON_LIB_NAME}) -else() - add_library(${SARIBBON_LIB_NAME} SHARED - ${SARIBBON_HEADER_FILES} - ${SARIBBON_SOURCE_FILES} - ${SARIBBON_RESOURCE_FILES} - ${SACOLOR_HEADER_FILES} - ${SACOLOR_SOURCE_FILES} - ) -endif() -add_library(SARibbon ALIAS ${SARIBBON_LIB_NAME}) + +add_library(${SARIBBON_LIB_NAME} SHARED + ${SARIBBON_HEADER_FILES} + ${SARIBBON_SOURCE_FILES} + ${SARIBBON_RESOURCE_FILES} + ${SACOLOR_HEADER_FILES} + ${SACOLOR_SOURCE_FILES} +) +add_library(SA::${SARIBBON_LIB_NAME} ALIAS ${SARIBBON_LIB_NAME}) ################################################# # Qt相关的依赖 ################################################# @@ -310,43 +136,13 @@ target_link_libraries(${SARIBBON_LIB_NAME} PUBLIC ################################################# # frameless相关的依赖 +# qwindowkit库 https://github.com/stdware/qwindowkit ################################################# # Qt X11Extras was first introduced in 5.1 and got removed in 6.0 # But it was again brought back as a private feature of QtGui in 6.2 if(SARIBBON_USE_FRAMELESS_LIB) - if(TARGET Qt5::X11Extras) - target_link_libraries(${SARIBBON_LIB_NAME} PRIVATE - Qt5::X11Extras - ) - endif() - - # frameless 依赖了qt-private相关的库 - target_link_libraries(${SARIBBON_LIB_NAME} PRIVATE - Qt${QT_VERSION_MAJOR}::CorePrivate - Qt${QT_VERSION_MAJOR}::GuiPrivate - ) - - if(APPLE) - target_link_libraries(${SARIBBON_LIB_NAME} PRIVATE - "-framework Foundation" - "-framework Cocoa" - "-framework AppKit" - ) - elseif(UNIX) - if(TARGET X11::xcb) - target_link_libraries(${SARIBBON_LIB_NAME} PRIVATE - X11::xcb - ) - endif() - if(TARGET PkgConfig::GTK3) - target_link_libraries(${SARIBBON_LIB_NAME} PRIVATE - PkgConfig::GTK3 - ) - target_compile_definitions(${SARIBBON_LIB_NAME} PRIVATE - GDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_6 - ) - endif() - endif() + find_package(QWindowKit REQUIRED) + target_link_libraries(${SARIBBON_LIB_NAME} PRIVATE QWindowKit::Widgets) endif() ################################################# @@ -367,11 +163,6 @@ target_compile_definitions(${SARIBBON_LIB_NAME} PRIVATE SA_RIBBON_BAR_MAKE_LIB) # 使用SAColorWidgets但不作为库使用定义的宏,此宏必须为PRIVATE target_compile_definitions(${SARIBBON_LIB_NAME} PRIVATE SA_COLOR_WIDGETS_MAKE_LIB) if(SARIBBON_USE_FRAMELESS_LIB) - # 显示定义FRAMELESSHELPER_FEATURE_static_build为-1,此宏必须为PUBLIC - target_compile_definitions(${SARIBBON_LIB_NAME} PUBLIC FRAMELESSHELPER_FEATURE_static_build=-1) - # 使用frameless,但也要导出符号,因此要定义导出宏,下面两个宏必须为PRIVATE - target_compile_definitions(${SARIBBON_LIB_NAME} PRIVATE FRAMELESSHELPER_CORE_LIBRARY) - target_compile_definitions(${SARIBBON_LIB_NAME} PRIVATE FRAMELESSHELPER_WIDGETS_LIBRARY) #使用frameless必须设置SARIBBON_USE_3RDPARTY_FRAMELESSHELPER宏为1,此宏必须为PUBLIC target_compile_definitions(${SARIBBON_LIB_NAME} PUBLIC SARIBBON_USE_3RDPARTY_FRAMELESSHELPER=1) else() @@ -379,27 +170,11 @@ else() target_compile_definitions(${SARIBBON_LIB_NAME} PUBLIC SARIBBON_USE_3RDPARTY_FRAMELESSHELPER=0) endif() -# INSTALL_INTERFACE的路径替换,不要出现引号 -if(SARIBBON_USE_FRAMELESS_LIB) - target_include_directories(${SARIBBON_LIB_NAME} PUBLIC - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - ) -else() - target_include_directories(${SARIBBON_LIB_NAME} PUBLIC - $ - $ - ) -endif() +target_include_directories(${SARIBBON_LIB_NAME} PUBLIC + $ + $ +) + # ------------------------------- install script ------------------------------- message(STATUS "install dir ${CMAKE_INSTALL_PREFIX}") @@ -443,22 +218,7 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty DESTINATION ${SARIBBON_LIB_NAME}_amalgamate/SARibbonBar ) -# 如果开启了frameless,要把frameless的文件也拷贝过去 -if(SARIBBON_USE_FRAMELESS_LIB) - #复制目录src/SARibbonBar/3rdparty/framelesshelper/include/ - install(DIRECTORY - ${FRAMELESS_HEADER_DIR} - DESTINATION include/${SARIBBON_LIB_NAME}/3rdparty/framelesshelper/include - COMPONENT headers - ) - #复制目录src/SARibbonBar/3rdparty/framelesshelper/qmake/ - SET(FRAMELESS_QMAKE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/framelesshelper/qmake) - install(DIRECTORY - ${FRAMELESS_QMAKE_DIR} - DESTINATION include/${SARIBBON_LIB_NAME}/3rdparty/framelesshelper/ - COMPONENT headers - ) -endif() + include(CMakePackageConfigHelpers) # SARibbonBarConfig.cmake.in中,会让此变量和“${PACKAGE_PREFIX_DIR}/”进行拼接,也就是${PACKAGE_PREFIX_DIR}/@SARIBBON_LIB_INCLUDE_INSTALL_DIR@ @@ -477,7 +237,7 @@ configure_package_config_file( INSTALL_DESTINATION lib/cmake/${SARIBBON_LIB_NAME} PATH_VARS SARIBBON_LIB_INCLUDE_INSTALL_DIR ) -message("CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}") + install(TARGETS ${SARIBBON_LIB_NAME} EXPORT ${SARIBBON_LIB_NAME}Targets RUNTIME DESTINATION bin diff --git a/src/SARibbonBar/SARibbonMainWindow.cpp b/src/SARibbonBar/SARibbonMainWindow.cpp index 1a45af8e..bf548624 100644 --- a/src/SARibbonBar/SARibbonMainWindow.cpp +++ b/src/SARibbonBar/SARibbonMainWindow.cpp @@ -7,16 +7,12 @@ #include #include #include - #include "SAWindowButtonGroup.h" #if SARIBBON_USE_3RDPARTY_FRAMELESSHELPER -#include "FramelessHelper/Widgets/standardsystembutton.h" -#include "FramelessHelper/Widgets/framelesswidgetshelper.h" +#include #include "SARibbonButtonGroupWidget.h" #include "SARibbonQuickAccessBar.h" #include "SARibbonStackedWidget.h" -FRAMELESSHELPER_USE_NAMESPACE -using namespace Global; #else #include "SAFramelessHelper.h" #include "SAWindowButtonGroup.h" @@ -30,14 +26,13 @@ class SARibbonMainWindow::PrivateData SA_RIBBON_DECLARE_PUBLIC(SARibbonMainWindow) public: PrivateData(SARibbonMainWindow* p); - void init(); public: SARibbonMainWindow::RibbonTheme mCurrentRibbonTheme { SARibbonMainWindow::RibbonThemeOffice2013 }; SARibbonBar* mRibbonBar { nullptr }; SAWindowButtonGroup* mWindowButtonGroup { nullptr }; #if SARIBBON_USE_3RDPARTY_FRAMELESSHELPER - FRAMELESSHELPER_PREPEND_NAMESPACE(StandardTitleBar) * mTitleBar = nullptr; + QWK::WidgetWindowAgent* mFramelessHelper { nullptr }; #else SAFramelessHelper* mFramelessHelper { nullptr }; #endif @@ -45,26 +40,21 @@ class SARibbonMainWindow::PrivateData SARibbonMainWindow::PrivateData::PrivateData(SARibbonMainWindow* p) : q_ptr(p) { -} - -void SARibbonMainWindow::PrivateData::init() -{ +#if SARIBBON_USE_3RDPARTY_FRAMELESSHELPER + mFramelessHelper = new QWK::WidgetWindowAgent(p); + mFramelessHelper->setup(p); +#else +#endif } //=================================================== // SARibbonMainWindow //=================================================== SARibbonMainWindow::SARibbonMainWindow(QWidget* parent, bool useRibbon, const Qt::WindowFlags flags) -#if SARIBBON_USE_3RDPARTY_FRAMELESSHELPER - : FramelessMainWindow(parent, flags) -#else - : QMainWindow(parent, flags) -#endif - , d_ptr(new SARibbonMainWindow::PrivateData(this)) + : QMainWindow(parent, flags), d_ptr(new SARibbonMainWindow::PrivateData(this)) { - d_ptr->init(); if (useRibbon) { - installRibbonBar(createRibbonBar()); + setRibbonBar(createRibbonBar()); setRibbonTheme(ribbonTheme()); } else { setupNormalWindow(); @@ -84,10 +74,57 @@ SARibbonBar* SARibbonMainWindow::ribbonBar() const return qobject_cast< SARibbonBar* >(menuWidget()); } +void SARibbonMainWindow::setRibbonBar(SARibbonBar* bar) +{ + QWidget* old = QMainWindow::menuWidget(); + if (old) { + // 如果之前已经设置了menubar,要把之前的删除 + old->deleteLater(); + } #if SARIBBON_USE_3RDPARTY_FRAMELESSHELPER -FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessWidgetsHelper*) SARibbonMainWindow::framelessHelper() + auto helper = d_ptr->mFramelessHelper; + QMainWindow::setMenuWidget(bar); + helper->setTitleBar(bar); + + // 设置window按钮 + if (nullptr == d_ptr->mWindowButtonGroup) { + d_ptr->mWindowButtonGroup = new SAWindowButtonGroup(this); + } + d_ptr->mWindowButtonGroup->setWindowStates(windowState()); + d_ptr->mWindowButtonGroup->show(); + helper->setHitTestVisible(bar->ribbonTabBar()); // IMPORTANT! + helper->setHitTestVisible(bar->rightButtonGroup()); // IMPORTANT! + helper->setHitTestVisible(bar->applicationButton()); // IMPORTANT! + helper->setHitTestVisible(bar->quickAccessBar()); // IMPORTANT! + helper->setHitTestVisible(bar->ribbonStackedWidget()); // IMPORTANT! + helper->setHitTestVisible(d_ptr->mWindowButtonGroup); // IMPORTANT! +#else + + QMainWindow::setMenuWidget(bar); + bar->installEventFilter(this); + // 设置窗体的标题栏高度 + if (nullptr == d_ptr->mFramelessHelper) { + d_ptr->mFramelessHelper = new SAFramelessHelper(this); + } + d_ptr->mFramelessHelper->setTitleHeight(bar->titleBarHeight()); + // 设置window按钮 + if (nullptr == d_ptr->mWindowButtonGroup) { + d_ptr->mWindowButtonGroup = new SAWindowButtonGroup(this); + } + QSize s = d_ptr->mWindowButtonGroup->sizeHint(); + s.setHeight(bar->titleBarHeight()); + d_ptr->mWindowButtonGroup->setFixedSize(s); + d_ptr->mWindowButtonGroup->setWindowStates(windowState()); + d_ptr->mWindowButtonGroup->show(); + +#endif +} + +#if SARIBBON_USE_3RDPARTY_FRAMELESSHELPER +void SARibbonMainWindow::setFramelessHitTestVisible(const QWidget* w, bool visible) { - return FramelessWidgetsHelper::get(this); + auto helper = d_ptr->mFramelessHelper; + helper->setHitTestVisible(w, visible); } #else @@ -260,60 +297,14 @@ bool SARibbonMainWindow::event(QEvent* e) return (QMainWindow::event(e)); } -void SARibbonMainWindow::installRibbonBar(SARibbonBar* bar) -{ - QWidget* old = QMainWindow::menuWidget(); - if (old) { - // 如果之前已经设置了menubar,要把之前的删除 - old->deleteLater(); - } -#if SARIBBON_USE_3RDPARTY_FRAMELESSHELPER - auto helper = FramelessWidgetsHelper::get(this); - QMainWindow::setMenuWidget(bar); - helper->setTitleBarWidget(bar); - - // 设置window按钮 - if (nullptr == d_ptr->mWindowButtonGroup) { - d_ptr->mWindowButtonGroup = new SAWindowButtonGroup(this); - } - d_ptr->mWindowButtonGroup->setWindowStates(windowState()); - d_ptr->mWindowButtonGroup->show(); - helper->setHitTestVisible(d_ptr->mWindowButtonGroup); // IMPORTANT! - helper->setHitTestVisible(bar->ribbonTabBar()); // IMPORTANT! - helper->setHitTestVisible(bar->rightButtonGroup()); // IMPORTANT! - helper->setHitTestVisible(bar->applicationButton()); // IMPORTANT! - helper->setHitTestVisible(bar->quickAccessBar()); // IMPORTANT! - helper->setHitTestVisible(bar->ribbonStackedWidget()); // IMPORTANT! -#else - - QMainWindow::setMenuWidget(bar); - bar->installEventFilter(this); - // 设置窗体的标题栏高度 - if (nullptr == d_ptr->mFramelessHelper) { - d_ptr->mFramelessHelper = new SAFramelessHelper(this); - } - d_ptr->mFramelessHelper->setTitleHeight(bar->titleBarHeight()); - // 设置window按钮 - if (nullptr == d_ptr->mWindowButtonGroup) { - d_ptr->mWindowButtonGroup = new SAWindowButtonGroup(this); - } - QSize s = d_ptr->mWindowButtonGroup->sizeHint(); - s.setHeight(bar->titleBarHeight()); - d_ptr->mWindowButtonGroup->setFixedSize(s); - d_ptr->mWindowButtonGroup->setWindowStates(windowState()); - d_ptr->mWindowButtonGroup->show(); - -#endif -} - /** @brief 构建为普通窗口 */ void SARibbonMainWindow::setupNormalWindow() { #if SARIBBON_USE_3RDPARTY_FRAMELESSHELPER - auto helper = FramelessWidgetsHelper::get(this); - // 设置window按钮 + // auto helper = FramelessWidgetsHelper::get(this); + // 设置window按钮 if (nullptr == d_ptr->mWindowButtonGroup) { d_ptr->mWindowButtonGroup = new SAWindowButtonGroup(this); } diff --git a/src/SARibbonBar/SARibbonMainWindow.h b/src/SARibbonBar/SARibbonMainWindow.h index 6a01acf9..a7f46f54 100644 --- a/src/SARibbonBar/SARibbonMainWindow.h +++ b/src/SARibbonBar/SARibbonMainWindow.h @@ -3,13 +3,7 @@ #include "SARibbonGlobal.h" #include -#if SARIBBON_USE_3RDPARTY_FRAMELESSHELPER -#include "FramelessHelper/Widgets/framelessmainwindow.h" -FRAMELESSHELPER_BEGIN_NAMESPACE -class StandardTitleBar; -class FramelessWidgetsHelper; -FRAMELESSHELPER_END_NAMESPACE -#else +#if !SARIBBON_USE_3RDPARTY_FRAMELESSHELPER class SAFramelessHelper; #endif @@ -38,11 +32,7 @@ class SAWindowButtonGroup; * 通过@ref setRibbonTheme 可改变ribbon的样式,用户也可通过qss自己定义自己的样式 * */ -#if SARIBBON_USE_3RDPARTY_FRAMELESSHELPER -class SA_RIBBON_EXPORT SARibbonMainWindow : public FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessMainWindow) -#else class SA_RIBBON_EXPORT SARibbonMainWindow : public QMainWindow -#endif { Q_OBJECT SA_RIBBON_DECLARE_PRIVATE(SARibbonMainWindow) @@ -70,13 +60,15 @@ class SA_RIBBON_EXPORT SARibbonMainWindow : public QMainWindow ~SARibbonMainWindow() Q_DECL_OVERRIDE; // 返回SARibbonBar SARibbonBar* ribbonBar() const; + // 安装ribbon + void setRibbonBar(SARibbonBar* bar); #if !SARIBBON_USE_3RDPARTY_FRAMELESSHELPER // 返回SAFramelessHelper SAFramelessHelper* framelessHelper(); // 把ribbonbar的事件传递到frameless virtual bool eventFilter(QObject* obj, QEvent* e) Q_DECL_OVERRIDE; #else - FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessWidgetsHelper*) framelessHelper(); + void setFramelessHitTestVisible(const QWidget* w, bool visible = true); #endif // 此函数仅用于控制最小最大化和关闭按钮的显示 void updateWindowFlag(Qt::WindowFlags flags); @@ -99,8 +91,6 @@ class SA_RIBBON_EXPORT SARibbonMainWindow : public QMainWindow virtual bool event(QEvent* e) Q_DECL_OVERRIDE; private: - // 安装ribbon - void installRibbonBar(SARibbonBar* bar); // 构建为普通窗口 void setupNormalWindow(); }; diff --git a/src/example/NormalMenuBarExample/MainWindow.cpp b/src/example/NormalMenuBarExample/MainWindow.cpp index 410404a6..b93350d3 100644 --- a/src/example/NormalMenuBarExample/MainWindow.cpp +++ b/src/example/NormalMenuBarExample/MainWindow.cpp @@ -1,23 +1,12 @@ #include "MainWindow.h" #include "ui_MainWindow.h" -#if SARIBBON_USE_3RDPARTY_FRAMELESSHELPER -#include "FramelessHelper/Widgets/standardsystembutton.h" -#include "FramelessHelper/Widgets/framelesswidgetshelper.h" -FRAMELESSHELPER_USE_NAMESPACE -using namespace Global; -#endif + MainWindow::MainWindow(QWidget* parent) : SARibbonMainWindow(parent, false) { if (!isUseRibbon()) { ui = new Ui::MainWindow; ui->setupUi(this); } -#if SARIBBON_USE_3RDPARTY_FRAMELESSHELPER - if (QWidget* w = menuWidget()) { - auto fh = framelessHelper(); - fh->setHitTestVisible(w); - } -#endif } MainWindow::~MainWindow()