Compare commits
126 Commits
Author | SHA1 | Date |
---|---|---|
|
3102b4ea3b | |
|
6b6b54d5b5 | |
|
585a82fbe8 | |
|
1764a8a918 | |
|
2765d18634 | |
|
096d30b8cf | |
|
529b9d3f93 | |
|
5670a28559 | |
|
a1b0568630 | |
|
7fdea56785 | |
|
bb3f8e0d40 | |
|
8ab8822448 | |
|
85a3fe1b2f | |
|
a6c7b44b5d | |
|
79a9327c01 | |
|
33a6f0df91 | |
|
14dfa52d0b | |
|
bbfea2c29b | |
|
46ac2f684d | |
|
c4a7bc80d0 | |
|
415fb55222 | |
|
78fc5057ab | |
|
c7f48684ec | |
|
4821e8982f | |
|
2cb8ec0aeb | |
|
aa489b25d0 | |
|
3ed04dedeb | |
|
ff4b9f3879 | |
|
b13f13a41f | |
|
12d580cc06 | |
|
77c3eb57e9 | |
|
b98f1e7a6d | |
|
a9642dccfc | |
|
e169c219a0 | |
|
c8511bacf6 | |
|
ad595c59e4 | |
|
7a84744dc3 | |
|
d86f55832f | |
|
b946809927 | |
|
10a9ba0a62 | |
|
d10b8e024c | |
|
e62885fefc | |
|
ba7aab0276 | |
|
786926e7ab | |
|
8f98ab865c | |
|
27a9e0857c | |
|
79d5087df5 | |
|
8c37fa628a | |
|
d48b84ea53 | |
|
26b9996ec6 | |
|
322c448bc1 | |
|
7b41f9aa31 | |
|
66206aa420 | |
|
4df552d526 | |
|
97112f853f | |
|
64a4362580 | |
|
c175d16d3d | |
|
040027a6e3 | |
|
9279500c18 | |
|
0ce47469a9 | |
|
7d09a6b9c9 | |
|
f584bd3a34 | |
|
6abb636a19 | |
|
2db829884d | |
|
102bf93b84 | |
|
2d639071cc | |
|
6ff0bc9300 | |
|
bdb1b5d68f | |
|
f7368d0a08 | |
|
e6a4849f81 | |
|
e0abdb04ce | |
|
e8977c7486 | |
|
95e5791288 | |
|
5c8ac2736f | |
|
15212abd85 | |
|
3bc44c267d | |
|
01f3750efd | |
|
4a1f5fb1f4 | |
|
a130fef677 | |
|
644266923b | |
|
469c686ade | |
|
2202fbf1c2 | |
|
58afa6aa95 | |
|
54e3f6232e | |
|
8ac3d747a1 | |
|
ca968b7ba6 | |
|
2c8bd8ce8c | |
|
44eeb537a2 | |
|
9265735ac7 | |
|
c85c6d6fc5 | |
|
4f7919ef5e | |
|
861b94d8ac | |
|
fc643613c3 | |
|
a29f30efc3 | |
|
013f2e845f | |
|
2035fed510 | |
|
95e0062264 | |
|
e1e38acd6c | |
|
177e377bb4 | |
|
8d3ef93885 | |
|
cb3827210c | |
|
11ad8cce00 | |
|
2289c4be73 | |
|
90b2fe42c6 | |
|
60a691eb61 | |
|
5500e50075 | |
|
3342a28895 | |
|
f2758aba25 | |
|
563a3cfb2d | |
|
cb21815934 | |
|
86bc1c0142 | |
|
20ab4f7d4b | |
|
5b0d06307a | |
|
8cc6a15535 | |
|
ad90846797 | |
|
1b4b5b620f | |
|
2f7a104ebd | |
|
c6ca6cc794 | |
|
4ed21585b4 | |
|
d9ce1c4302 | |
|
03832ac86f | |
|
e84d3a8bd5 | |
|
1ed7b7521c | |
|
b57da216e9 | |
|
8e73e3eac8 | |
|
2cd4d133f3 |
|
@ -18,14 +18,14 @@ jobs:
|
|||
name: Build
|
||||
strategy:
|
||||
matrix:
|
||||
qt-version: [5.15.2, 6.5.1]
|
||||
qt-version: [5.15.2, 6.5.3]
|
||||
library-type: [shared, static]
|
||||
platform: [windows-latest, ubuntu-latest, macos-latest]
|
||||
include:
|
||||
- platform: windows-latest
|
||||
CC: cl
|
||||
CXX: cl
|
||||
LD: link
|
||||
CC: cl.exe
|
||||
CXX: cl.exe
|
||||
LD: link.exe
|
||||
EXTRA_FLAGS: -DFRAMELESSHELPER_ENABLE_SPECTRE=ON -DFRAMELESSHELPER_ENABLE_EHCONTGUARD=ON -DFRAMELESSHELPER_ENABLE_INTELCET=ON -DFRAMELESSHELPER_ENABLE_CFGUARD=ON
|
||||
- platform: ubuntu-latest
|
||||
CC: gcc
|
||||
|
@ -73,6 +73,8 @@ jobs:
|
|||
- name: Install macOS dependencies
|
||||
if: ${{ matrix.platform == 'macos-latest' }}
|
||||
run: |
|
||||
brew update
|
||||
brew upgrade
|
||||
brew install llvm
|
||||
export PATH="/usr/local/opt/llvm/bin:$PATH"
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ target_wrapper.*
|
|||
# QtCreator CMake
|
||||
CMakeLists.txt.user*
|
||||
|
||||
# QtCreator 4.8< compilation database
|
||||
# QtCreator 4.8< compilation database
|
||||
compile_commands.json
|
||||
|
||||
# QtCreator local machine specific files for imported projects
|
||||
|
@ -54,6 +54,8 @@ compile_commands.json
|
|||
# My
|
||||
[Bb]in/
|
||||
[Bb]in64/
|
||||
[Ll]ib/
|
||||
[Ll]ib64/
|
||||
[Bb]uild*/
|
||||
*.7z
|
||||
*.zip
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[submodule "cmake"]
|
||||
path = cmake
|
||||
url = https://github.com/wangwenx190/cmake-utils.git
|
||||
url = ../../wangwenx190/cmake-utils.git
|
||||
|
|
187
CMakeLists.txt
187
CMakeLists.txt
|
@ -25,12 +25,13 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
project(FramelessHelper
|
||||
VERSION "2.4.2"
|
||||
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)
|
||||
|
@ -49,12 +50,19 @@ 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)
|
||||
#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)
|
||||
#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)
|
||||
|
@ -62,10 +70,18 @@ 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)
|
||||
|
||||
include(cmake/utils.cmake)
|
||||
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(NOT APPLE AND FRAMELESSHELPER_ENABLE_UNIVERSAL_BUILD)
|
||||
message(WARNING "Current OS is not macOS, universal build will be disabled.")
|
||||
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.")
|
||||
|
@ -78,15 +94,63 @@ 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()
|
||||
|
||||
set(__extra_flags)
|
||||
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
|
||||
|
@ -95,42 +159,33 @@ setup_project(
|
|||
)
|
||||
unset(__extra_flags)
|
||||
|
||||
set(PROJECT_VERSION_COMMIT "UNKNOWN")
|
||||
set(PROJECT_COMPILE_DATETIME "UNKNOWN")
|
||||
if(NOT FRAMELESSHELPER_REPRODUCIBLE_OUTPUT)
|
||||
get_commit_hash(RESULT PROJECT_VERSION_COMMIT)
|
||||
string(TIMESTAMP PROJECT_COMPILE_DATETIME UTC)
|
||||
endif()
|
||||
|
||||
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_INTELJCC OFF)
|
||||
set(FRAMELESSHELPER_ENABLE_CFGUARD OFF)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
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$<$<CONFIG:Debug>: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)
|
||||
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$<$<CONFIG:Debug>: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)
|
||||
set(__extra_flags "")
|
||||
if(FRAMELESSHELPER_NO_INSTALL)
|
||||
list(APPEND __extra_flags NO_INSTALL)
|
||||
endif()
|
||||
|
@ -141,25 +196,57 @@ prepare_package_export(
|
|||
)
|
||||
unset(__extra_flags)
|
||||
|
||||
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_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
|
||||
)
|
||||
|
||||
if(TARGET Qt${QT_VERSION_MAJOR}::Core AND TARGET Qt${QT_VERSION_MAJOR}::Gui)
|
||||
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)
|
||||
else()
|
||||
message(WARNING "Can't find the QtCore and QtGui module. Nothing will be built.")
|
||||
set(FRAMELESSHELPER_BUILD_WIDGETS OFF)
|
||||
set(FRAMELESSHELPER_BUILD_EXAMPLES OFF)
|
||||
endif()
|
||||
|
||||
if(FRAMELESSHELPER_BUILD_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
|
||||
if(NOT FRAMELESSHELPER_NO_INSTALL)
|
||||
install(FILES "msbuild/FramelessHelper.props" DESTINATION ".")
|
||||
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)
|
||||
|
@ -211,8 +298,6 @@ if(NOT FRAMELESSHELPER_NO_SUMMARY)
|
|||
endif()
|
||||
message("------------------------ FramelessHelper ------------------------")
|
||||
message("FramelessHelper version: ${PROJECT_VERSION}")
|
||||
message("FramelessHelper commit hash: ${PROJECT_VERSION_COMMIT}")
|
||||
message("FramelessHelper configure date and time: ${PROJECT_COMPILE_DATETIME} (UTC)")
|
||||
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}")
|
||||
|
@ -228,11 +313,17 @@ if(NOT FRAMELESSHELPER_NO_SUMMARY)
|
|||
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 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("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()
|
||||
|
|
|
@ -24,21 +24,33 @@
|
|||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
set(_@PROJECT_NAME@_supported_components Core Widgets Quick)
|
||||
include(CMakeFindDependencyMacro)
|
||||
|
||||
foreach(_comp ${@PROJECT_NAME@_FIND_COMPONENTS})
|
||||
if(_comp IN_LIST _@PROJECT_NAME@_supported_components)
|
||||
set(__targets_file "${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@${_comp}Targets.cmake")
|
||||
if(EXISTS "${__targets_file}")
|
||||
include("${__targets_file}")
|
||||
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(@PROJECT_NAME@_FOUND FALSE)
|
||||
set(@PROJECT_NAME@_NOT_FOUND_MESSAGE "Can't find necessary configuration file for @PROJECT_NAME@::${_comp}, please make sure this component is successfully built and installed.")
|
||||
break()
|
||||
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: @PROJECT_NAME@::${_comp}.")
|
||||
set(@PROJECT_NAME@_NOT_FOUND_MESSAGE "Unknown component: ${__target}.")
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
|
@ -59,4 +71,10 @@ 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()
|
||||
|
|
37
README.md
37
README.md
|
@ -1,3 +1,7 @@
|
|||
# ATTENTION! THIS REPO HAS BEEN DEPRECATED!
|
||||
# PLEASE USE THE BRAND NEW [QWINDOWKIT](https://github.com/stdware/qwindowkit) INSTEAD!
|
||||
# THIS REPO IS NO LONGER MAINTAINED.
|
||||
|
||||
# FramelessHelper 2.x
|
||||
|
||||
[](https://github.com/wangwenx190/framelesshelper/actions/workflows/ci.yml)
|
||||
|
@ -8,15 +12,25 @@ Cross-platform window customization framework for Qt Widgets and Qt Quick. Suppo
|
|||
|
||||
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!
|
||||
|
||||
## Roadmap
|
||||
## 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 the main window is not resizable.
|
||||
- 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!
|
||||
|
@ -375,12 +389,7 @@ Please refer to the demo projects to see more detailed usages: [examples](./exam
|
|||
- 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.**
|
||||
- Make sure there are two public invokable functions (slot functions are always invokable): `void setHovered(bool)` and `void setPressed(bool)`. These two functions will be invoked by FramelessHelper when the button is being hovered or pressed. You should change the button's visual state inside these functions. If you need to show tooltips, you'll have to do it manually in these functions.
|
||||
- Make sure there's a public signal: `void clicked()`. When the button is being clicked, that signal will be triggered by FramelessHelper. You should connect your event handler to that signal.
|
||||
- For Qt Quick applications, for the C++ side, you need to inherit your button from the `QQuickAbstractButton` class, for the QML side, you need to inherit your button from the `Button` type (from the `QtQuick.Controls.Basic` module). They have all the invokable functions and signals we need, so no more extra work is needed.
|
||||
- Don't forget to call `setSystemButton()` for each button to let FramelessHelper know which is the minimize/maximize/close button.
|
||||
- System buttons will not be able to receive any actual mouse and keyboard events so there's no need to handle these events inside these buttons. That's also why we need to set the button's visual state manually.
|
||||
- I know this is making everything complicated but unfortunately we can't avoid this mess if we need to support the snap layout feature. Snap layout is really only designed for the original standard window frame, so if we want to forcely support it without a standard window frame, many black magic will be needed.
|
||||
- Call `setSystemButton()` for each button (it can be any *QWidget* or *QQuickItem*) to let FramelessHelper know which is the minimize/maximize/close button.
|
||||
|
||||
### Linux
|
||||
|
||||
|
@ -409,6 +418,18 @@ First of all, it's a Qt issue, not caused by FramelessHelper. And it should not
|
|||
|
||||
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
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
@echo off
|
||||
title Building FramelessHelper ...
|
||||
setlocal
|
||||
cls
|
||||
set __vs_bat=%ProgramFiles%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat
|
||||
if not exist "%__vs_bat%" set __vs_bat=%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat
|
||||
if not exist "%__vs_bat%" set __vs_bat=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat
|
||||
if not exist "%__vs_bat%" set __vs_bat=%ProgramFiles(x86)%\Microsoft Visual Studio\2015\Community\VC\Auxiliary\Build\vcvars64.bat
|
||||
if not exist "%__vs_bat%" (
|
||||
echo Cannot find a valid Visual Studio toolchain!
|
||||
echo Please install at least Visual Studio 2015 to the default location
|
||||
echo and install the English language pack at the same time.
|
||||
echo If you want to use clang-cl or MinGW to build this project, please
|
||||
echo make sure you have added their directory to your PATH environment
|
||||
echo variable.
|
||||
echo Press the ENTER key to continue, or close this window directly.
|
||||
pause
|
||||
) else (
|
||||
call "%__vs_bat%"
|
||||
)
|
||||
cmake --version
|
||||
echo ninja build
|
||||
ninja --version
|
||||
cd /d "%~dp0"
|
||||
if exist build.user.bat call build.user.bat
|
||||
if not defined CC set CC=cl.exe
|
||||
if not defined CXX set CXX=cl.exe
|
||||
if not defined QTDIR set QTDIR=%SystemDrive%\Qt\6.6.0\msvc2019_64
|
||||
echo CC=%CC%
|
||||
echo CXX=%CXX%
|
||||
echo QTDIR=%QTDIR%
|
||||
if exist build rd /s /q build
|
||||
md build
|
||||
cd build
|
||||
md cmake
|
||||
cd cmake
|
||||
cmake -DCMAKE_C_COMPILER="%CC%" -DCMAKE_CXX_COMPILER="%CXX%" -DCMAKE_PREFIX_PATH="%QTDIR%" -DCMAKE_INSTALL_PREFIX="%~dp0build\install" -DCMAKE_CONFIGURATION_TYPES=Release;Debug -G"Ninja Multi-Config" -DFRAMELESSHELPER_ENABLE_VCLTL=ON -DFRAMELESSHELPER_ENABLE_YYTHUNKS=ON -DFRAMELESSHELPER_ENABLE_SPECTRE=ON -DFRAMELESSHELPER_ENABLE_EHCONTGUARD=ON -DFRAMELESSHELPER_ENABLE_INTELCET=ON -DFRAMELESSHELPER_ENABLE_INTELJCC=ON -DFRAMELESSHELPER_ENABLE_CFGUARD=ON -DFRAMELESSHELPER_FORCE_LTO=ON "%~dp0"
|
||||
cmake --build . --target all --config Release --parallel
|
||||
cmake --build . --target all --config Debug --parallel
|
||||
cmake --install . --config Release --strip
|
||||
cmake --install . --config Debug
|
||||
goto fin
|
||||
:fin
|
||||
endlocal
|
||||
cd /d "%~dp0"
|
||||
pause
|
||||
exit /b 0
|
2
cmake
2
cmake
|
@ -1 +1 @@
|
|||
Subproject commit 743c5a0ed048a964973d052798b46932ff0a32b1
|
||||
Subproject commit aa2a9bcf09e4f28e3b351b4f8353a30e3e71bfad
|
|
@ -74,6 +74,7 @@ if(WIN32)
|
|||
PATH "${__manifest_path}"
|
||||
ID "org.wangwenx190.demo.Dialog"
|
||||
VERSION "${PROJECT_VERSION}"
|
||||
DESCRIPTION "FramelessHelper Demo Application: Dialog"
|
||||
VISTA_COMPAT
|
||||
WIN7_COMPAT
|
||||
WIN8_COMPAT
|
||||
|
@ -103,6 +104,31 @@ setup_gui_app(
|
|||
BUNDLE_VERSION_SHORT "1.0"
|
||||
)
|
||||
|
||||
setup_target_rpaths(TARGETS ${DEMO_NAME})
|
||||
|
||||
setup_qt_stuff(TARGETS ${DEMO_NAME})
|
||||
|
||||
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 ${DEMO_NAME} ${__extra_flags})
|
||||
|
||||
if(FRAMELESSHELPER_EXAMPLES_DEPLOYQT)
|
||||
set(__extra_flags)
|
||||
if(FRAMELESSHELPER_NO_INSTALL)
|
||||
|
|
|
@ -57,11 +57,13 @@ void Dialog::setupUi()
|
|||
setWindowTitle(windowTitle() + FRAMELESSHELPER_STRING_LITERAL(" [%1]").arg(name));
|
||||
});
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(titlebar)
|
||||
titleBar = new StandardTitleBar(this);
|
||||
titleBar->setWindowIconVisible(true);
|
||||
#ifndef Q_OS_MACOS
|
||||
# if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button))
|
||||
titleBar->maximizeButton()->hide();
|
||||
#endif // Q_OS_MACOS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
label = new QLabel(tr("Find &what:"));
|
||||
lineEdit = new QLineEdit;
|
||||
|
@ -98,12 +100,11 @@ void Dialog::setupUi()
|
|||
|
||||
connect(moreButton, &QPushButton::toggled, extension, &QWidget::setVisible);
|
||||
|
||||
QVBoxLayout *extensionLayout = new QVBoxLayout;
|
||||
QVBoxLayout *extensionLayout = new QVBoxLayout(extension);
|
||||
extensionLayout->setContentsMargins(0, 0, 0, 0);
|
||||
extensionLayout->addWidget(wholeWordsCheckBox);
|
||||
extensionLayout->addWidget(backwardCheckBox);
|
||||
extensionLayout->addWidget(searchSelectionCheckBox);
|
||||
extension->setLayout(extensionLayout);
|
||||
|
||||
QHBoxLayout *topLeftLayout = new QHBoxLayout;
|
||||
topLeftLayout->addWidget(label);
|
||||
|
@ -121,28 +122,33 @@ void Dialog::setupUi()
|
|||
controlsLayout->addWidget(extension, 1, 0, 1, 2);
|
||||
controlsLayout->setRowStretch(2, 1);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||
#if FRAMELESSHELPER_CONFIG(titlebar)
|
||||
mainLayout->addWidget(titleBar);
|
||||
#endif
|
||||
mainLayout->addLayout(controlsLayout);
|
||||
|
||||
setLayout(mainLayout);
|
||||
|
||||
extension->hide();
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(titlebar)
|
||||
FramelessWidgetsHelper *helper = FramelessWidgetsHelper::get(this);
|
||||
helper->setTitleBarWidget(titleBar);
|
||||
#ifndef Q_OS_MACOS
|
||||
# ifdef Q_OS_WINDOWS
|
||||
FramelessWidgetsHelperPrivate *helperPriv = FramelessWidgetsHelperPrivate::get(helper);
|
||||
helperPriv->setProperty(kSysMenuRemoveRestoreVar, true);
|
||||
helperPriv->setProperty(kSysMenuRemoveSizeVar, true);
|
||||
helperPriv->setProperty(kSysMenuRemoveMinimizeVar, true);
|
||||
helperPriv->setProperty(kSysMenuRemoveMaximizeVar, true);
|
||||
helperPriv->setProperty(kSysMenuRemoveSeparatorVar, true);
|
||||
# endif
|
||||
# if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button))
|
||||
helper->setSystemButton(titleBar->minimizeButton(), SystemButtonType::Minimize);
|
||||
helper->setSystemButton(titleBar->maximizeButton(), SystemButtonType::Maximize);
|
||||
helper->setSystemButton(titleBar->closeButton(), SystemButtonType::Close);
|
||||
#endif // Q_OS_MACOS
|
||||
// Special hack to disable the overriding of the mouse cursor, it's totally different
|
||||
// with making the window un-resizable: we still want the window be able to resize
|
||||
// programatically, but we also want the user not able to resize the window manually.
|
||||
// So apparently we can't use QWidget::setFixedWidth/Height/Size() here.
|
||||
FramelessWidgetsHelperPrivate::get(helper)->setProperty(kDontOverrideCursorVar, true);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void Dialog::waitReady()
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include <FramelessHelper/Widgets/framelessdialog.h>
|
||||
|
||||
FRAMELESSHELPER_REQUIRE_CONFIG(window)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QCheckBox;
|
||||
class QDialogButtonBox;
|
||||
|
@ -14,14 +16,16 @@ class QLineEdit;
|
|||
class QPushButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(titlebar)
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
class StandardTitleBar;
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
#endif
|
||||
|
||||
class Dialog : public FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessDialog)
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(Dialog)
|
||||
Q_DISABLE_COPY(Dialog)
|
||||
|
||||
public:
|
||||
explicit Dialog(QWidget *parent = nullptr);
|
||||
|
@ -36,7 +40,9 @@ private:
|
|||
void setupUi();
|
||||
|
||||
private:
|
||||
#if FRAMELESSHELPER_CONFIG(titlebar)
|
||||
FRAMELESSHELPER_PREPEND_NAMESPACE(StandardTitleBar) *titleBar = nullptr;
|
||||
#endif
|
||||
QLabel *label = nullptr;
|
||||
QLineEdit *lineEdit = nullptr;
|
||||
QCheckBox *caseCheckBox = nullptr;
|
||||
|
|
|
@ -41,7 +41,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
// Not necessary, but better call this function, before the construction
|
||||
// of any Q(Core|Gui)Application instances.
|
||||
FramelessHelper::Widgets::initialize();
|
||||
FramelessHelperWidgetsInitialize();
|
||||
|
||||
#if 0
|
||||
if (!qEnvironmentVariableIsSet("QT_WIDGETS_RHI")) {
|
||||
|
@ -54,7 +54,7 @@ int main(int argc, char *argv[])
|
|||
// Must be called after QGuiApplication has been constructed, we are using
|
||||
// some private functions from QPA which won't be available until there's
|
||||
// a QGuiApplication instance.
|
||||
FramelessHelper::Core::setApplicationOSThemeAware();
|
||||
FramelessHelperEnableThemeAware();
|
||||
|
||||
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||||
//FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
||||
|
|
|
@ -79,6 +79,7 @@ if(WIN32)
|
|||
PATH "${__manifest_path}"
|
||||
ID "org.wangwenx190.demo.MainWindow"
|
||||
VERSION "${PROJECT_VERSION}"
|
||||
DESCRIPTION "FramelessHelper Demo Application: MainWindow"
|
||||
VISTA_COMPAT
|
||||
WIN7_COMPAT
|
||||
WIN8_COMPAT
|
||||
|
@ -108,6 +109,31 @@ setup_gui_app(
|
|||
BUNDLE_VERSION_SHORT "1.0"
|
||||
)
|
||||
|
||||
setup_target_rpaths(TARGETS ${DEMO_NAME})
|
||||
|
||||
setup_qt_stuff(TARGETS ${DEMO_NAME})
|
||||
|
||||
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 ${DEMO_NAME} ${__extra_flags})
|
||||
|
||||
if(FRAMELESSHELPER_EXAMPLES_DEPLOYQT)
|
||||
set(__extra_flags)
|
||||
if(FRAMELESSHELPER_NO_INSTALL)
|
||||
|
|
|
@ -41,7 +41,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
// Not necessary, but better call this function, before the construction
|
||||
// of any Q(Core|Gui)Application instances.
|
||||
FramelessHelper::Widgets::initialize();
|
||||
FramelessHelperWidgetsInitialize();
|
||||
|
||||
#if 0
|
||||
if (!qEnvironmentVariableIsSet("QT_WIDGETS_RHI")) {
|
||||
|
@ -54,7 +54,7 @@ int main(int argc, char *argv[])
|
|||
// Must be called after QGuiApplication has been constructed, we are using
|
||||
// some private functions from QPA which won't be available until there's
|
||||
// a QGuiApplication instance.
|
||||
FramelessHelper::Core::setApplicationOSThemeAware();
|
||||
FramelessHelperEnableThemeAware();
|
||||
|
||||
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||||
//FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
||||
|
|
|
@ -70,8 +70,10 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||
|
||||
void MainWindow::initialize()
|
||||
{
|
||||
#if FRAMELESSHELPER_CONFIG(titlebar)
|
||||
m_titleBar = new StandardTitleBar(this);
|
||||
m_titleBar->setTitleLabelAlignment(Qt::AlignCenter);
|
||||
#endif
|
||||
m_mainWindow = new Ui::MainWindow;
|
||||
m_mainWindow->setupUi(this);
|
||||
|
||||
|
@ -94,19 +96,23 @@ QMenuBar::item:pressed {
|
|||
background: #888888;
|
||||
}
|
||||
)"));
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(titlebar)
|
||||
const auto titleBarLayout = static_cast<QHBoxLayout *>(m_titleBar->layout());
|
||||
titleBarLayout->insertWidget(0, mb);
|
||||
|
||||
// setMenuWidget(): make the menu widget become the first row of the window.
|
||||
setMenuWidget(m_titleBar);
|
||||
#endif
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(titlebar)
|
||||
FramelessWidgetsHelper *helper = FramelessWidgetsHelper::get(this);
|
||||
helper->setTitleBarWidget(m_titleBar);
|
||||
#ifndef Q_OS_MACOS
|
||||
# if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button))
|
||||
helper->setSystemButton(m_titleBar->minimizeButton(), SystemButtonType::Minimize);
|
||||
helper->setSystemButton(m_titleBar->maximizeButton(), SystemButtonType::Maximize);
|
||||
helper->setSystemButton(m_titleBar->closeButton(), SystemButtonType::Close);
|
||||
#endif // Q_OS_MACOS
|
||||
# endif
|
||||
#endif
|
||||
helper->setHitTestVisible(mb); // IMPORTANT!
|
||||
|
||||
setWindowTitle(tr("FramelessHelper demo application - QMainWindow"));
|
||||
|
|
|
@ -26,9 +26,13 @@
|
|||
|
||||
#include <FramelessHelper/Widgets/framelessmainwindow.h>
|
||||
|
||||
FRAMELESSHELPER_REQUIRE_CONFIG(window)
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(titlebar)
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
class StandardTitleBar;
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
#endif
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
|
@ -38,7 +42,7 @@ class MainWindow;
|
|||
class MainWindow : public FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessMainWindow)
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(MainWindow)
|
||||
Q_DISABLE_COPY(MainWindow)
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr, const Qt::WindowFlags flags = {});
|
||||
|
@ -53,6 +57,8 @@ private:
|
|||
void initialize();
|
||||
|
||||
private:
|
||||
#if FRAMELESSHELPER_CONFIG(titlebar)
|
||||
FRAMELESSHELPER_PREPEND_NAMESPACE(StandardTitleBar) *m_titleBar = nullptr;
|
||||
#endif
|
||||
Ui::MainWindow *m_mainWindow = nullptr;
|
||||
};
|
||||
|
|
|
@ -73,7 +73,6 @@ void MainWindow::initialize()
|
|||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
mainLayout->addWidget(m_titleBar);
|
||||
mainLayout->addWidget(m_glWidget);
|
||||
setLayout(mainLayout);
|
||||
|
||||
FramelessWidgetsHelper *helper = FramelessWidgetsHelper::get(this);
|
||||
helper->setTitleBarWidget(m_titleBar);
|
||||
|
|
|
@ -35,7 +35,7 @@ class GLWidget;
|
|||
class MainWindow : public FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessWidget)
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(MainWindow)
|
||||
Q_DISABLE_COPY(MainWindow)
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
|
|
|
@ -74,6 +74,7 @@ if(WIN32)
|
|||
PATH "${__manifest_path}"
|
||||
ID "org.wangwenx190.demo.Quick"
|
||||
VERSION "${PROJECT_VERSION}"
|
||||
DESCRIPTION "FramelessHelper Demo Application: Quick"
|
||||
VISTA_COMPAT
|
||||
WIN7_COMPAT
|
||||
WIN8_COMPAT
|
||||
|
@ -135,6 +136,31 @@ setup_gui_app(
|
|||
BUNDLE_VERSION_SHORT "1.0"
|
||||
)
|
||||
|
||||
setup_target_rpaths(TARGETS ${DEMO_NAME})
|
||||
|
||||
setup_qt_stuff(TARGETS ${DEMO_NAME})
|
||||
|
||||
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 ${DEMO_NAME} ${__extra_flags})
|
||||
|
||||
if(FRAMELESSHELPER_EXAMPLES_DEPLOYQT)
|
||||
set(__extra_flags)
|
||||
if(FRAMELESSHELPER_NO_INSTALL)
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
#endif
|
||||
#include "../shared/log.h"
|
||||
|
||||
FRAMELESSHELPER_REQUIRE_CONFIG(window)
|
||||
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
|
||||
static constexpr const bool IS_MACOS_HOST =
|
||||
|
@ -54,14 +56,14 @@ int main(int argc, char *argv[])
|
|||
|
||||
// Not necessary, but better call this function, before the construction
|
||||
// of any Q(Core|Gui)Application instances.
|
||||
FramelessHelper::Quick::initialize();
|
||||
FramelessHelperQuickInitialize();
|
||||
|
||||
const auto application = std::make_unique<QGuiApplication>(argc, argv);
|
||||
|
||||
// Must be called after QGuiApplication has been constructed, we are using
|
||||
// some private functions from QPA which won't be available until there's
|
||||
// a QGuiApplication instance.
|
||||
FramelessHelper::Core::setApplicationOSThemeAware();
|
||||
FramelessHelperEnableThemeAware();
|
||||
|
||||
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||||
//FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
||||
|
@ -114,7 +116,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
#if (((QT_VERSION < QT_VERSION_CHECK(6, 2, 0)) || defined(QUICK_USE_QMAKE)) && !QMLTC_ENABLED)
|
||||
// Don't forget to register our own custom QML types!
|
||||
FramelessHelper::Quick::registerTypes(engine.get());
|
||||
FramelessHelperQuickRegisterTypes(engine.get());
|
||||
|
||||
qmlRegisterSingletonType<QuickSettings>("Demo", 1, 0, "Settings",
|
||||
[](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * {
|
||||
|
|
|
@ -35,7 +35,7 @@ FramelessApplicationWindow {
|
|||
height: 600
|
||||
title: qsTr("FramelessHelper demo application - Qt Quick [") + objectName + ']'
|
||||
color: {
|
||||
if (FramelessHelper.blurBehindWindowEnabled) {
|
||||
if (FramelessHelper.blurBehindWindowEnabled && FramelessUtils.blurBehindWindowSupported) {
|
||||
return "transparent";
|
||||
}
|
||||
if (FramelessUtils.systemTheme === FramelessHelperConstants.Dark) {
|
||||
|
@ -81,7 +81,7 @@ FramelessApplicationWindow {
|
|||
}
|
||||
|
||||
Timer {
|
||||
interval: 500
|
||||
interval: 100
|
||||
running: true
|
||||
repeat: true
|
||||
onTriggered: timeLabel.text = Qt.formatTime(new Date(), "hh:mm:ss")
|
||||
|
|
|
@ -35,7 +35,7 @@ FramelessWindow {
|
|||
height: 600
|
||||
title: qsTr("FramelessHelper demo application - Qt Quick [") + objectName +']'
|
||||
color: {
|
||||
if (FramelessHelper.blurBehindWindowEnabled) {
|
||||
if (FramelessHelper.blurBehindWindowEnabled && FramelessUtils.blurBehindWindowSupported) {
|
||||
return "transparent";
|
||||
}
|
||||
if (FramelessUtils.systemTheme === FramelessHelperConstants.Dark) {
|
||||
|
@ -81,7 +81,7 @@ FramelessWindow {
|
|||
}
|
||||
|
||||
Timer {
|
||||
interval: 500
|
||||
interval: 100
|
||||
running: true
|
||||
repeat: true
|
||||
onTriggered: timeLabel.text = Qt.formatTime(new Date(), "hh:mm:ss")
|
||||
|
|
|
@ -36,7 +36,7 @@ class QuickSettings : public QObject
|
|||
#ifdef QML_SINGLETON
|
||||
QML_SINGLETON
|
||||
#endif
|
||||
Q_DISABLE_COPY_MOVE(QuickSettings)
|
||||
Q_DISABLE_COPY(QuickSettings)
|
||||
|
||||
public:
|
||||
explicit QuickSettings(QObject *parent = nullptr);
|
||||
|
|
|
@ -74,6 +74,7 @@ if(WIN32)
|
|||
PATH "${__manifest_path}"
|
||||
ID "org.wangwenx190.demo.Widget"
|
||||
VERSION "${PROJECT_VERSION}"
|
||||
DESCRIPTION "FramelessHelper Demo Application: Widget"
|
||||
VISTA_COMPAT
|
||||
WIN7_COMPAT
|
||||
WIN8_COMPAT
|
||||
|
@ -103,6 +104,31 @@ setup_gui_app(
|
|||
BUNDLE_VERSION_SHORT "1.0"
|
||||
)
|
||||
|
||||
setup_target_rpaths(TARGETS ${DEMO_NAME})
|
||||
|
||||
setup_qt_stuff(TARGETS ${DEMO_NAME})
|
||||
|
||||
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 ${DEMO_NAME} ${__extra_flags})
|
||||
|
||||
if(FRAMELESSHELPER_EXAMPLES_DEPLOYQT)
|
||||
set(__extra_flags)
|
||||
if(FRAMELESSHELPER_NO_INSTALL)
|
||||
|
|
|
@ -41,7 +41,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
// Not necessary, but better call this function, before the construction
|
||||
// of any Q(Core|Gui)Application instances.
|
||||
FramelessHelper::Widgets::initialize();
|
||||
FramelessHelperWidgetsInitialize();
|
||||
|
||||
#if 0
|
||||
if (!qEnvironmentVariableIsSet("QT_WIDGETS_RHI")) {
|
||||
|
@ -54,7 +54,7 @@ int main(int argc, char *argv[])
|
|||
// Must be called after QGuiApplication has been constructed, we are using
|
||||
// some private functions from QPA which won't be available until there's
|
||||
// a QGuiApplication instance.
|
||||
FramelessHelper::Core::setApplicationOSThemeAware();
|
||||
FramelessHelperEnableThemeAware();
|
||||
|
||||
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||||
//FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "widget.h"
|
||||
#include <QtCore/qdatetime.h>
|
||||
#include <QtCore/qcoreevent.h>
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
# include <QtGui/qshortcut.h>
|
||||
#else
|
||||
|
@ -33,6 +34,7 @@
|
|||
#include <QtWidgets/qboxlayout.h>
|
||||
#include <QtWidgets/qfileiconprovider.h>
|
||||
#include <FramelessHelper/Core/framelessmanager.h>
|
||||
#include <FramelessHelper/Core/utils.h>
|
||||
#include <FramelessHelper/Widgets/framelesswidgetshelper.h>
|
||||
#include <FramelessHelper/Widgets/standardtitlebar.h>
|
||||
#include <FramelessHelper/Widgets/standardsystembutton.h>
|
||||
|
@ -54,7 +56,7 @@ FRAMELESSHELPER_STRING_CONSTANT(DevicePixelRatio)
|
|||
Widget::Widget(QWidget *parent) : FramelessWidget(parent)
|
||||
{
|
||||
initialize();
|
||||
startTimer(500);
|
||||
m_timerId = startTimer(100);
|
||||
connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged, this, &Widget::updateStyleSheet);
|
||||
}
|
||||
|
||||
|
@ -63,7 +65,7 @@ Widget::~Widget() = default;
|
|||
void Widget::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
FramelessWidget::timerEvent(event);
|
||||
if (m_clockLabel) {
|
||||
if ((event->timerId() == m_timerId) && m_clockLabel) {
|
||||
m_clockLabel->setText(QTime::currentTime().toString(FRAMELESSHELPER_STRING_LITERAL("hh:mm:ss")));
|
||||
}
|
||||
}
|
||||
|
@ -83,26 +85,61 @@ void Widget::initialize()
|
|||
setWindowTitle(tr("FramelessHelper demo application - QWidget"));
|
||||
setWindowIcon(QFileIconProvider().icon(QFileIconProvider::Computer));
|
||||
resize(800, 600);
|
||||
#if FRAMELESSHELPER_CONFIG(titlebar)
|
||||
m_titleBar = new StandardTitleBar(this);
|
||||
m_titleBar->setWindowIconVisible(true);
|
||||
#endif
|
||||
m_clockLabel = new QLabel(this);
|
||||
m_clockLabel->setFrameShape(QFrame::NoFrame);
|
||||
m_clockLabel->setAlignment(Qt::AlignCenter);
|
||||
QFont clockFont = font();
|
||||
clockFont.setBold(true);
|
||||
clockFont.setPointSize(70);
|
||||
m_clockLabel->setFont(clockFont);
|
||||
const auto contentLayout = new QHBoxLayout;
|
||||
contentLayout->setContentsMargins(0, 0, 0, 0);
|
||||
contentLayout->setSpacing(0);
|
||||
contentLayout->addStretch();
|
||||
contentLayout->addWidget(m_clockLabel);
|
||||
contentLayout->addStretch();
|
||||
m_compilerInfoLabel = new QLabel(this);
|
||||
m_compilerInfoLabel->setFrameShape(QFrame::NoFrame);
|
||||
m_compilerInfoLabel->setAlignment(Qt::AlignCenter);
|
||||
static const VersionInfo versionInfo = FramelessHelperVersion();
|
||||
m_compilerInfoLabel->setText(
|
||||
FRAMELESSHELPER_STRING_LITERAL("Compiler: %1 %2")
|
||||
.arg(QString::fromUtf8(versionInfo.compiler.name),
|
||||
QString::fromUtf8(versionInfo.compiler.version)));
|
||||
m_commitInfoLabel = new QLabel(this);
|
||||
m_commitInfoLabel->setFrameShape(QFrame::NoFrame);
|
||||
m_commitInfoLabel->setAlignment(Qt::AlignCenter);
|
||||
m_commitInfoLabel->setText(
|
||||
FRAMELESSHELPER_STRING_LITERAL("Commit: %1 (%2)")
|
||||
.arg(QString::fromUtf8(versionInfo.commit.hash),
|
||||
QString::fromUtf8(versionInfo.commit.author)));
|
||||
const auto clockLabelLayout = new QHBoxLayout;
|
||||
clockLabelLayout->setContentsMargins(0, 0, 0, 0);
|
||||
clockLabelLayout->setSpacing(0);
|
||||
clockLabelLayout->addStretch();
|
||||
clockLabelLayout->addWidget(m_clockLabel);
|
||||
clockLabelLayout->addStretch();
|
||||
const auto compilerInfoLabelLayout = new QHBoxLayout;
|
||||
compilerInfoLabelLayout->setContentsMargins(0, 0, 0, 0);
|
||||
compilerInfoLabelLayout->setSpacing(0);
|
||||
compilerInfoLabelLayout->addStretch();
|
||||
compilerInfoLabelLayout->addWidget(m_compilerInfoLabel);
|
||||
compilerInfoLabelLayout->addStretch();
|
||||
const auto commitInfoLabelLayout = new QHBoxLayout;
|
||||
commitInfoLabelLayout->setContentsMargins(0, 0, 0, 0);
|
||||
commitInfoLabelLayout->setSpacing(0);
|
||||
commitInfoLabelLayout->addStretch();
|
||||
commitInfoLabelLayout->addWidget(m_commitInfoLabel);
|
||||
commitInfoLabelLayout->addStretch();
|
||||
const auto mainLayout = new QVBoxLayout(this);
|
||||
mainLayout->setSpacing(0);
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
#if FRAMELESSHELPER_CONFIG(titlebar)
|
||||
mainLayout->addWidget(m_titleBar);
|
||||
mainLayout->addLayout(contentLayout);
|
||||
setLayout(mainLayout);
|
||||
#endif
|
||||
mainLayout->addStretch();
|
||||
mainLayout->addLayout(clockLabelLayout);
|
||||
mainLayout->addStretch();
|
||||
mainLayout->addLayout(compilerInfoLabelLayout);
|
||||
mainLayout->addLayout(commitInfoLabelLayout);
|
||||
updateStyleSheet();
|
||||
|
||||
m_cancelShortcut = new QShortcut(this);
|
||||
|
@ -132,22 +169,26 @@ void Widget::initialize()
|
|||
setWindowTitle(windowTitle() + FRAMELESSHELPER_STRING_LITERAL(" [%1]").arg(name));
|
||||
});
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(titlebar)
|
||||
FramelessWidgetsHelper *helper = FramelessWidgetsHelper::get(this);
|
||||
helper->setTitleBarWidget(m_titleBar);
|
||||
#ifndef Q_OS_MACOS
|
||||
# if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button))
|
||||
helper->setSystemButton(m_titleBar->minimizeButton(), SystemButtonType::Minimize);
|
||||
helper->setSystemButton(m_titleBar->maximizeButton(), SystemButtonType::Maximize);
|
||||
helper->setSystemButton(m_titleBar->closeButton(), SystemButtonType::Close);
|
||||
#endif // Q_OS_MACOS
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void Widget::updateStyleSheet()
|
||||
{
|
||||
const bool dark = (FramelessManager::instance()->systemTheme() == SystemTheme::Dark);
|
||||
const QColor clockLabelTextColor = (dark ? kDefaultWhiteColor : kDefaultBlackColor);
|
||||
m_clockLabel->setStyleSheet(FRAMELESSHELPER_STRING_LITERAL("background-color: transparent; color: %1;")
|
||||
.arg(clockLabelTextColor.name()));
|
||||
if (FramelessWidgetsHelper::get(this)->isBlurBehindWindowEnabled()) {
|
||||
const QColor labelTextColor = (dark ? kDefaultWhiteColor : kDefaultBlackColor);
|
||||
const QString labelStyleSheet = FRAMELESSHELPER_STRING_LITERAL("background-color: transparent; color: %1;").arg(labelTextColor.name());
|
||||
m_clockLabel->setStyleSheet(labelStyleSheet);
|
||||
m_compilerInfoLabel->setStyleSheet(labelStyleSheet);
|
||||
m_commitInfoLabel->setStyleSheet(labelStyleSheet);
|
||||
if (FramelessWidgetsHelper::get(this)->isBlurBehindWindowEnabled() && Utils::isBlurBehindWindowSupported()) {
|
||||
setStyleSheet(FRAMELESSHELPER_STRING_LITERAL("background-color: transparent;"));
|
||||
} else {
|
||||
const QColor windowBackgroundColor = (dark ? kDefaultSystemDarkColor : kDefaultSystemLightColor);
|
||||
|
|
|
@ -26,19 +26,23 @@
|
|||
|
||||
#include <FramelessHelper/Widgets/framelesswidget.h>
|
||||
|
||||
FRAMELESSHELPER_REQUIRE_CONFIG(window)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QLabel;
|
||||
class QShortcut;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(titlebar)
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
class StandardTitleBar;
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
#endif
|
||||
|
||||
class Widget : public FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessWidget)
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(Widget)
|
||||
Q_DISABLE_COPY(Widget)
|
||||
|
||||
public:
|
||||
explicit Widget(QWidget *parent = nullptr);
|
||||
|
@ -57,8 +61,13 @@ private Q_SLOTS:
|
|||
void updateStyleSheet();
|
||||
|
||||
private:
|
||||
QLabel *m_clockLabel = nullptr;
|
||||
#if FRAMELESSHELPER_CONFIG(titlebar)
|
||||
FRAMELESSHELPER_PREPEND_NAMESPACE(StandardTitleBar) *m_titleBar = nullptr;
|
||||
#endif
|
||||
QLabel *m_clockLabel = nullptr;
|
||||
QLabel *m_compilerInfoLabel = nullptr;
|
||||
QLabel *m_commitInfoLabel = nullptr;
|
||||
QShortcut *m_fullScreenShortcut = nullptr;
|
||||
QShortcut *m_cancelShortcut = nullptr;
|
||||
int m_timerId = -1;
|
||||
};
|
||||
|
|
|
@ -25,16 +25,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||
#include <memory>
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(titlebar)
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class ChromePalettePrivate;
|
||||
|
||||
class FRAMELESSHELPER_CORE_API ChromePalette : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(ChromePalette)
|
||||
Q_DISABLE_COPY_MOVE(ChromePalette)
|
||||
FRAMELESSHELPER_PUBLIC_QT_CLASS(ChromePalette)
|
||||
|
||||
Q_PROPERTY(QColor titleBarActiveBackgroundColor READ titleBarActiveBackgroundColor
|
||||
WRITE setTitleBarActiveBackgroundColor RESET resetTitleBarActiveBackgroundColor
|
||||
|
@ -117,9 +117,8 @@ Q_SIGNALS:
|
|||
void closeButtonPressColorChanged();
|
||||
void titleBarColorChanged();
|
||||
void chromeButtonColorChanged();
|
||||
|
||||
private:
|
||||
QScopedPointer<ChromePalettePrivate> d_ptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,25 +25,28 @@
|
|||
#pragma once
|
||||
|
||||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||
#include <memory>
|
||||
|
||||
#if !FRAMELESSHELPER_CONFIG(native_impl)
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
struct SystemParameters;
|
||||
|
||||
class FramelessHelperQtPrivate;
|
||||
class FRAMELESSHELPER_CORE_API FramelessHelperQt : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(FramelessHelperQt)
|
||||
FRAMELESSHELPER_PUBLIC_QT_CLASS(FramelessHelperQt)
|
||||
|
||||
public:
|
||||
explicit FramelessHelperQt(QObject *parent = nullptr);
|
||||
~FramelessHelperQt() override;
|
||||
|
||||
static void addWindow(const SystemParameters *params);
|
||||
static void removeWindow(const WId windowId);
|
||||
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
|
||||
|
|
|
@ -27,22 +27,28 @@
|
|||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||
#include <QtCore/qabstractnativeeventfilter.h>
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
#ifdef Q_OS_WINDOWS
|
||||
|
||||
struct SystemParameters;
|
||||
#if FRAMELESSHELPER_CONFIG(native_impl)
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FRAMELESSHELPER_CORE_API FramelessHelperWin : public QAbstractNativeEventFilter
|
||||
{
|
||||
Q_DISABLE_COPY_MOVE(FramelessHelperWin)
|
||||
FRAMELESSHELPER_CLASS(FramelessHelperWin)
|
||||
|
||||
public:
|
||||
explicit FramelessHelperWin();
|
||||
~FramelessHelperWin() override;
|
||||
|
||||
static void addWindow(const SystemParameters *params);
|
||||
static void removeWindow(const WId windowId);
|
||||
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
|
||||
|
|
|
@ -59,10 +59,242 @@
|
|||
# include <sdkddkver.h>
|
||||
#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
|
||||
|
@ -79,6 +311,16 @@
|
|||
# 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 <windows.h>
|
||||
#include <uxtheme.h>
|
||||
#include <shellapi.h>
|
||||
|
@ -86,6 +328,170 @@
|
|||
|
||||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||
|
||||
#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
|
||||
|
@ -94,6 +500,206 @@
|
|||
# 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
|
||||
|
@ -122,6 +728,30 @@
|
|||
# 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<int>(static_cast<short>(LOWORD(lp))))
|
||||
#endif
|
||||
|
@ -130,12 +760,48 @@
|
|||
# define GET_Y_LPARAM(lp) (static_cast<int>(static_cast<short>(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<short>(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<LONG>(static_cast<SHORT>(LOWORD(*(LONG*)&pts))); \
|
||||
(pt).y = static_cast<LONG>(static_cast<SHORT>(HIWORD(*(LONG*)&pts))); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef POINTTOPOINTS
|
||||
# define POINTTOPOINTS(pt) (MAKELONG(static_cast<short>((pt).x), static_cast<short>((pt).y)))
|
||||
#endif
|
||||
|
||||
#ifndef MAKEWPARAM
|
||||
# define MAKEWPARAM(l, h) (static_cast<WPARAM>(static_cast<DWORD>(MAKELONG(l, h))))
|
||||
#endif
|
||||
|
||||
#ifndef MAKELPARAM
|
||||
# define MAKELPARAM(l, h) (static_cast<LPARAM>(static_cast<DWORD>(MAKELONG(l, h))))
|
||||
#endif
|
||||
|
||||
#ifndef MAKELRESULT
|
||||
# define MAKELRESULT(l, h) (static_cast<LRESULT>(static_cast<DWORD>(MAKELONG(l, h))))
|
||||
#endif
|
||||
|
||||
#ifndef IsMinimized
|
||||
# define IsMinimized(hwnd) (IsIconic(hwnd) != FALSE)
|
||||
# define IsMinimized(hwnd) (::IsIconic(hwnd) != FALSE)
|
||||
#endif
|
||||
|
||||
#ifndef IsMaximized
|
||||
# define IsMaximized(hwnd) (IsZoomed(hwnd) != FALSE)
|
||||
# define IsMaximized(hwnd) (::IsZoomed(hwnd) != FALSE)
|
||||
#endif
|
||||
|
||||
#ifndef RECT_WIDTH
|
||||
|
@ -395,19 +1061,14 @@ using ACCENT_STATE = enum ACCENT_STATE
|
|||
using ACCENT_FLAG = enum ACCENT_FLAG
|
||||
{
|
||||
ACCENT_NONE = 0,
|
||||
ACCENT_ENABLE_LUMINOSITY = 1 << 1,
|
||||
ACCENT_ENABLE_BORDER_LEFT = 1 << 5,
|
||||
ACCENT_ENABLE_BORDER_TOP = 1 << 6,
|
||||
ACCENT_ENABLE_BORDER_RIGHT = 1 << 7,
|
||||
ACCENT_ENABLE_BORDER_BOTTOM = 1 << 8,
|
||||
ACCENT_ENABLE_BORDER = ACCENT_ENABLE_BORDER_LEFT | ACCENT_ENABLE_BORDER_TOP | ACCENT_ENABLE_BORDER_RIGHT | ACCENT_ENABLE_BORDER_BOTTOM,
|
||||
ACCENT_ENABLE_ALL = ACCENT_ENABLE_BORDER
|
||||
ACCENT_ENABLE_ACRYLIC = 1,
|
||||
ACCENT_ENABLE_ACRYLIC_WITH_LUMINOSITY = 482
|
||||
};
|
||||
|
||||
using ACCENT_POLICY = struct ACCENT_POLICY
|
||||
{
|
||||
ACCENT_STATE AccentState;
|
||||
ACCENT_FLAG AccentFlags;
|
||||
DWORD dwAccentState;
|
||||
DWORD dwAccentFlags;
|
||||
DWORD dwGradientColor; // #AABBGGRR
|
||||
DWORD dwAnimationId;
|
||||
};
|
||||
|
@ -723,7 +1384,7 @@ _AdjustWindowRectExForDpi2(
|
|||
|
||||
EXTERN_C_END
|
||||
|
||||
[[maybe_unused]] inline constexpr const int kAutoHideTaskBarThickness = 2; // The thickness of an auto-hide taskbar in pixels.
|
||||
[[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";
|
||||
|
@ -732,3 +1393,95 @@ EXTERN_C_END
|
|||
[[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<WId>(hwnd));
|
||||
}
|
||||
|
|
|
@ -24,25 +24,35 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "framelesshelper.config"
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <QtCore/qmath.h>
|
||||
#include <QtCore/qpoint.h>
|
||||
#include <QtCore/qsize.h>
|
||||
#include <QtCore/qrect.h>
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qpointer.h>
|
||||
#include <QtGui/qcolor.h>
|
||||
#include <QtGui/qwindowdefs.h>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <memory>
|
||||
|
||||
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
|
||||
# ifdef FRAMELESSHELPER_CORE_STATIC
|
||||
# if FRAMELESSHELPER_CONFIG(static_build)
|
||||
# define FRAMELESSHELPER_CORE_API
|
||||
# else // !FRAMELESSHELPER_CORE_STATIC
|
||||
# ifdef FRAMELESSHELPER_CORE_LIBRARY
|
||||
|
@ -57,11 +67,16 @@ QT_END_NAMESPACE
|
|||
# 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) \
|
||||
Class(Class &&) = delete; \
|
||||
Class &operator=(Class &&) = delete;
|
||||
Q_DISABLE_MOVE(Class)
|
||||
#endif
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0))
|
||||
|
@ -100,6 +115,13 @@ QT_END_NAMESPACE
|
|||
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
|
||||
|
@ -132,6 +154,26 @@ QT_END_NAMESPACE
|
|||
# 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 { \
|
||||
|
@ -140,14 +182,38 @@ QT_END_NAMESPACE
|
|||
} 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 const auto k##name = FRAMELESSHELPER_BYTEARRAY_LITERAL(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 const auto k##name = FRAMELESSHELPER_STRING_LITERAL(str);
|
||||
[[maybe_unused]] static Q_STRING_CONSTEXPR const auto k##name = FRAMELESSHELPER_STRING(str);
|
||||
#endif
|
||||
|
||||
#ifndef FRAMELESSHELPER_BYTEARRAY_CONSTANT
|
||||
|
@ -192,22 +258,99 @@ QT_END_NAMESPACE
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifndef FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
#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<Class##Private> 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: \
|
||||
Q_OBJECT \
|
||||
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 framelesshelpercore_initResource();
|
||||
FRAMELESSHELPER_CORE_API void FramelessHelperCoreInitResource();
|
||||
inline void framelesshelpercore_initResource() { FramelessHelperCoreInitResource(); }
|
||||
#endif // FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
#include "framelesshelper.version"
|
||||
|
||||
[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION =
|
||||
FRAMELESSHELPER_MAKE_VERSION(
|
||||
FRAMELESSHELPER_VERSION_MAJOR,
|
||||
FRAMELESSHELPER_VERSION_MINOR,
|
||||
FRAMELESSHELPER_VERSION_PATCH);
|
||||
#ifndef __FRAMELESSHELPER__
|
||||
# define __FRAMELESSHELPER__ __FRAMELESSHELPER_VERSION__
|
||||
#endif // __FRAMELESSHELPER__
|
||||
|
||||
namespace Global
|
||||
{
|
||||
|
@ -229,35 +372,43 @@ Q_NAMESPACE_EXPORT(FRAMELESSHELPER_CORE_API)
|
|||
[[maybe_unused]] inline constexpr const QSize kDefaultWindowSize = {160, 160}; // Value taken from Windows QPA.
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
# define kDefaultBlackColor QColorConstants::Black
|
||||
# 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 kDefaultBlackColor = {0, 0, 0}; // #000000
|
||||
[[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 kDefaultFrameBorderActiveColor = {77, 77, 77}; // #4D4D4D
|
||||
[[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultFrameBorderInactiveColorDark = {87, 89, 89}; // #575959
|
||||
[[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultFrameBorderInactiveColorLight = {166, 166, 166}; // #A6A6A6
|
||||
[[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 const QByteArray kDontOverrideCursorVar
|
||||
= FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_DONT_OVERRIDE_CURSOR");
|
||||
[[maybe_unused]] inline const QByteArray kDontToggleMaximizeVar
|
||||
= FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_DONT_TOGGLE_MAXIMIZE");
|
||||
[[maybe_unused]] inline const QByteArray kSysMenuDisableMinimizeVar
|
||||
= FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_SYSTEM_MENU_DISABLE_MINIMIZE");
|
||||
[[maybe_unused]] inline const QByteArray kSysMenuDisableMaximizeVar
|
||||
= FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_SYSTEM_MENU_DISABLE_MAXIMIZE");
|
||||
[[maybe_unused]] inline const QByteArray kSysMenuDisableRestoreVar
|
||||
= FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_SYSTEM_MENU_DISABLE_RESTORE");
|
||||
[[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
|
||||
{
|
||||
|
@ -270,7 +421,9 @@ enum class Option : quint8
|
|||
EnableBlurBehindWindow,
|
||||
ForceNonNativeBackgroundBlur,
|
||||
DisableLazyInitializationForMicaMaterial,
|
||||
ForceNativeBackgroundBlur
|
||||
ForceNativeBackgroundBlur,
|
||||
WindowUseSquareCorners,
|
||||
Last = WindowUseSquareCorners
|
||||
};
|
||||
Q_ENUM_NS(Option)
|
||||
|
||||
|
@ -291,7 +444,8 @@ enum class SystemButtonType : quint8
|
|||
Minimize,
|
||||
Maximize,
|
||||
Restore,
|
||||
Close
|
||||
Close,
|
||||
Last = Close
|
||||
};
|
||||
Q_ENUM_NS(SystemButtonType)
|
||||
|
||||
|
@ -429,13 +583,30 @@ Q_ENUM_NS(WindowCornerStyle)
|
|||
|
||||
struct VersionInfo
|
||||
{
|
||||
int version = 0;
|
||||
const char *version_str = nullptr;
|
||||
const char *commit = nullptr;
|
||||
const char *compileDateTime = nullptr;
|
||||
const char *compiler = nullptr;
|
||||
bool isDebug = false;
|
||||
bool isStatic = false;
|
||||
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
|
||||
|
@ -452,17 +623,43 @@ struct Dpi
|
|||
{
|
||||
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
|
||||
{
|
||||
FRAMELESSHELPER_CORE_API void initialize();
|
||||
FRAMELESSHELPER_CORE_API void uninitialize();
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API Global::VersionInfo version();
|
||||
FRAMELESSHELPER_CORE_API void setApplicationOSThemeAware();
|
||||
FRAMELESSHELPER_CORE_API void outputLogo();
|
||||
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
|
||||
|
|
|
@ -25,26 +25,20 @@
|
|||
#pragma once
|
||||
|
||||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||
#include <memory>
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
struct SystemParameters;
|
||||
class FramelessManagerPrivate;
|
||||
|
||||
class FRAMELESSHELPER_CORE_API FramelessManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(FramelessManager)
|
||||
Q_DISABLE_COPY_MOVE(FramelessManager)
|
||||
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:
|
||||
explicit FramelessManager(QObject *parent = nullptr);
|
||||
~FramelessManager() override;
|
||||
|
||||
Q_NODISCARD static FramelessManager *instance();
|
||||
|
||||
Q_NODISCARD Global::SystemTheme systemTheme() const;
|
||||
|
@ -53,8 +47,8 @@ public:
|
|||
Q_NODISCARD Global::WallpaperAspectStyle wallpaperAspectStyle() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void addWindow(const SystemParameters *params);
|
||||
void removeWindow(const WId windowId);
|
||||
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:
|
||||
|
@ -62,7 +56,8 @@ Q_SIGNALS:
|
|||
void wallpaperChanged();
|
||||
|
||||
private:
|
||||
QScopedPointer<FramelessManagerPrivate> d_ptr;
|
||||
explicit FramelessManager(QObject *parent = nullptr);
|
||||
~FramelessManager() override;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
|
|
@ -25,17 +25,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||
#include <QtCore/qrect.h>
|
||||
#include <memory>
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(mica_material)
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class MicaMaterialPrivate;
|
||||
|
||||
class FRAMELESSHELPER_CORE_API MicaMaterial : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(MicaMaterial)
|
||||
Q_DECLARE_PRIVATE(MicaMaterial)
|
||||
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)
|
||||
|
@ -78,9 +77,8 @@ Q_SIGNALS:
|
|||
void noiseOpacityChanged();
|
||||
void fallbackEnabledChanged();
|
||||
void shouldRedraw();
|
||||
|
||||
private:
|
||||
QScopedPointer<MicaMaterialPrivate> d_ptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,29 +25,23 @@
|
|||
#pragma once
|
||||
|
||||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||
#include <optional>
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(titlebar)
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class ChromePalette;
|
||||
|
||||
class FRAMELESSHELPER_CORE_API ChromePalettePrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(ChromePalette)
|
||||
Q_DISABLE_COPY_MOVE(ChromePalettePrivate)
|
||||
FRAMELESSHELPER_PRIVATE_QT_CLASS(ChromePalette)
|
||||
|
||||
public:
|
||||
explicit ChromePalettePrivate(ChromePalette *q);
|
||||
~ChromePalettePrivate() override;
|
||||
|
||||
Q_NODISCARD static ChromePalettePrivate *get(ChromePalette *q);
|
||||
Q_NODISCARD static const ChromePalettePrivate *get(const ChromePalette *q);
|
||||
Q_SLOT void refresh();
|
||||
|
||||
public Q_SLOTS:
|
||||
void refresh();
|
||||
|
||||
private:
|
||||
ChromePalette *q_ptr = nullptr;
|
||||
// System-defined ones:
|
||||
QColor titleBarActiveBackgroundColor_sys = {};
|
||||
QColor titleBarInactiveBackgroundColor_sys = {};
|
||||
|
@ -73,3 +67,5 @@ private:
|
|||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,13 +30,9 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
|
|||
|
||||
class FRAMELESSHELPER_CORE_API FramelessConfig : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(FramelessConfig)
|
||||
FRAMELESSHELPER_QT_CLASS(FramelessConfig)
|
||||
|
||||
public:
|
||||
explicit FramelessConfig(QObject *parent = nullptr);
|
||||
~FramelessConfig() override;
|
||||
|
||||
Q_NODISCARD static FramelessConfig *instance();
|
||||
|
||||
void reload(const bool force = false);
|
||||
|
@ -46,6 +42,10 @@ public:
|
|||
|
||||
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
|
||||
|
|
|
@ -25,6 +25,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||
#include <QtCore/qhash.h>
|
||||
#include <QtGui/qwindowdefs.h>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QScreen;
|
||||
|
@ -32,9 +36,6 @@ QT_END_NAMESPACE
|
|||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
using InitializeHookCallback = std::function<void()>;
|
||||
using UninitializeHookCallback = std::function<void()>;
|
||||
|
||||
using GetWindowFlagsCallback = std::function<Qt::WindowFlags()>;
|
||||
using SetWindowFlagsCallback = std::function<void(const Qt::WindowFlags)>;
|
||||
using GetWindowSizeCallback = std::function<QSize()>;
|
||||
|
@ -56,14 +57,15 @@ using SetSystemButtonStateCallback = std::function<void(const Global::SystemButt
|
|||
using GetWindowIdCallback = std::function<WId()>;
|
||||
using ShouldIgnoreMouseEventsCallback = std::function<bool(const QPoint &)>;
|
||||
using ShowSystemMenuCallback = std::function<void(const QPoint &)>;
|
||||
using SetPropertyCallback = std::function<void(const QByteArray &, const QVariant &)>;
|
||||
using GetPropertyCallback = std::function<QVariant(const QByteArray &, const QVariant &)>;
|
||||
using SetPropertyCallback = std::function<void(const char *, const QVariant &)>;
|
||||
using GetPropertyCallback = std::function<QVariant(const char *, const QVariant &)>;
|
||||
using SetCursorCallback = std::function<void(const QCursor &)>;
|
||||
using UnsetCursorCallback = std::function<void()>;
|
||||
using GetWidgetHandleCallback = std::function<QObject *()>;
|
||||
using ForceChildrenRepaintCallback = std::function<void(const int)>;
|
||||
using ForceChildrenRepaintCallback = std::function<void()>;
|
||||
using ResetQtGrabbedControlCallback = std::function<bool()>;
|
||||
|
||||
struct SystemParameters
|
||||
struct FRAMELESSHELPER_CORE_API FramelessCallbacks
|
||||
{
|
||||
GetWindowFlagsCallback getWindowFlags = nullptr;
|
||||
SetWindowFlagsCallback setWindowFlags = nullptr;
|
||||
|
@ -92,32 +94,91 @@ struct SystemParameters
|
|||
UnsetCursorCallback unsetCursor = nullptr;
|
||||
GetWidgetHandleCallback getWidgetHandle = nullptr;
|
||||
ForceChildrenRepaintCallback forceChildrenRepaint = nullptr;
|
||||
ResetQtGrabbedControlCallback resetQtGrabbedControl = nullptr;
|
||||
|
||||
FramelessCallbacks();
|
||||
virtual ~FramelessCallbacks();
|
||||
|
||||
using PtrType = std::shared_ptr<FramelessCallbacks>;
|
||||
[[nodiscard]] static PtrType create();
|
||||
|
||||
private:
|
||||
FRAMELESSHELPER_CLASS(FramelessCallbacks)
|
||||
};
|
||||
using FramelessCallbacksPtr = FramelessCallbacks::PtrType;
|
||||
|
||||
enum class ExtraDataType : quint8
|
||||
{
|
||||
WindowsUtilities,
|
||||
LinuxUtilities,
|
||||
MacOSUtilities,
|
||||
FramelessWidgetsHelper,
|
||||
FramelessQuickHelper
|
||||
};
|
||||
|
||||
using FramelessParams = SystemParameters *;
|
||||
using FramelessParamsConst = const SystemParameters *;
|
||||
using FramelessParamsRef = SystemParameters &;
|
||||
using FramelessParamsConstRef = const SystemParameters &;
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
inline uint qHash(const ExtraDataType key, const uint seed = 0) noexcept {
|
||||
return ::qHash(static_cast<quint8>(key), seed);
|
||||
}
|
||||
#endif
|
||||
|
||||
FRAMELESSHELPER_CORE_API void registerInitializeHook(const InitializeHookCallback &cb);
|
||||
FRAMELESSHELPER_CORE_API void registerUninitializeHook(const UninitializeHookCallback &cb);
|
||||
struct FRAMELESSHELPER_CORE_API FramelessExtraData
|
||||
{
|
||||
FramelessExtraData();
|
||||
virtual ~FramelessExtraData();
|
||||
|
||||
using PtrType = std::shared_ptr<FramelessExtraData>;
|
||||
|
||||
private:
|
||||
FRAMELESSHELPER_CLASS(FramelessExtraData)
|
||||
};
|
||||
using FramelessExtraDataPtr = FramelessExtraData::PtrType;
|
||||
using FramelessExtraDataPtrs = QList<FramelessExtraDataPtr>;
|
||||
using FramelessExtraDataHash = QHash<ExtraDataType, FramelessExtraDataPtr>;
|
||||
|
||||
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<FramelessData>;
|
||||
[[nodiscard]] static PtrType create();
|
||||
|
||||
private:
|
||||
FRAMELESSHELPER_CLASS(FramelessData)
|
||||
};
|
||||
using FramelessDataPtr = FramelessData::PtrType;
|
||||
using FramelessDataPtrs = QList<FramelessDataPtr>;
|
||||
using FramelessDataHash = QHash<QObject *, FramelessDataPtr>;
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#define DECLARE_SIZE_COMPARE_OPERATORS(Type1, Type2) \
|
||||
[[maybe_unused]] [[nodiscard]] static inline constexpr bool operator>(const Type1 &lhs, const Type2 &rhs) noexcept \
|
||||
[[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]] static inline constexpr bool operator>=(const Type1 &lhs, const Type2 &rhs) noexcept \
|
||||
[[maybe_unused]] [[nodiscard]] inline constexpr bool operator>=(const Type1 &lhs, const Type2 &rhs) noexcept \
|
||||
{ \
|
||||
return (operator>(lhs, rhs) || operator==(lhs, rhs)); \
|
||||
} \
|
||||
[[maybe_unused]] [[nodiscard]] static inline constexpr bool operator<(const Type1 &lhs, const Type2 &rhs) noexcept \
|
||||
[[maybe_unused]] [[nodiscard]] inline constexpr bool operator<(const Type1 &lhs, const Type2 &rhs) noexcept \
|
||||
{ \
|
||||
return (operator!=(lhs, rhs) && !operator>(lhs, rhs)); \
|
||||
} \
|
||||
[[maybe_unused]] [[nodiscard]] static inline constexpr bool operator<=(const Type1 &lhs, const Type2 &rhs) noexcept \
|
||||
[[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)
|
||||
|
|
|
@ -25,57 +25,67 @@
|
|||
#pragma once
|
||||
|
||||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||
#include <QtCore/qtimer.h>
|
||||
#include <optional>
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
struct SystemParameters;
|
||||
class FramelessManager;
|
||||
struct FramelessData;
|
||||
using FramelessDataPtr = std::shared_ptr<FramelessData>;
|
||||
|
||||
class FramelessManager;
|
||||
class FRAMELESSHELPER_CORE_API FramelessManagerPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(FramelessManager)
|
||||
Q_DISABLE_COPY_MOVE(FramelessManagerPrivate)
|
||||
FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessManager)
|
||||
|
||||
public:
|
||||
explicit FramelessManagerPrivate(FramelessManager *q);
|
||||
~FramelessManagerPrivate() override;
|
||||
|
||||
Q_NODISCARD static FramelessManagerPrivate *get(FramelessManager *pub);
|
||||
Q_NODISCARD static const FramelessManagerPrivate *get(const FramelessManager *pub);
|
||||
|
||||
static void initializeIconFont();
|
||||
Q_NODISCARD static QFont getIconFont();
|
||||
|
||||
Q_NODISCARD Global::SystemTheme systemTheme() const;
|
||||
Q_NODISCARD QColor systemAccentColor() const;
|
||||
Q_NODISCARD QString wallpaper() const;
|
||||
Q_NODISCARD Global::WallpaperAspectStyle wallpaperAspectStyle() const;
|
||||
Q_SLOT void notifySystemThemeHasChangedOrNot();
|
||||
Q_SLOT void notifyWallpaperHasChangedOrNot();
|
||||
|
||||
static void addWindow(const SystemParameters *params);
|
||||
static void removeWindow(const WId windowId);
|
||||
|
||||
Q_INVOKABLE void notifySystemThemeHasChangedOrNot();
|
||||
Q_INVOKABLE void notifyWallpaperHasChangedOrNot();
|
||||
|
||||
Q_NODISCARD static bool usePureQtImplementation();
|
||||
|
||||
void setOverrideTheme(const Global::SystemTheme theme);
|
||||
Q_NODISCARD bool isThemeOverrided() const;
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
FramelessManager *q_ptr = nullptr;
|
||||
Global::SystemTheme m_systemTheme = Global::SystemTheme::Unknown;
|
||||
std::optional<Global::SystemTheme> m_overrideTheme = std::nullopt;
|
||||
QColor m_accentColor = {};
|
||||
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<Global::SystemTheme> overrideTheme = std::nullopt;
|
||||
QColor accentColor = {};
|
||||
#ifdef Q_OS_WINDOWS
|
||||
Global::DwmColorizationArea m_colorizationArea = Global::DwmColorizationArea::None;
|
||||
Global::DwmColorizationArea colorizationArea = Global::DwmColorizationArea::None;
|
||||
#endif
|
||||
QString m_wallpaper = {};
|
||||
Global::WallpaperAspectStyle m_wallpaperAspectStyle = Global::WallpaperAspectStyle::Fill;
|
||||
QString wallpaper = {};
|
||||
Global::WallpaperAspectStyle wallpaperAspectStyle = Global::WallpaperAspectStyle::Fill;
|
||||
QTimer themeTimer{};
|
||||
QTimer wallpaperTimer{};
|
||||
};
|
||||
|
||||
class InternalEventFilter : public QObject
|
||||
{
|
||||
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
|
||||
|
|
|
@ -26,59 +26,78 @@
|
|||
|
||||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||
#include <QtGui/qbrush.h>
|
||||
#ifdef FRAMELESSHELPER_HAS_THREAD
|
||||
# undef FRAMELESSHELPER_HAS_THREAD
|
||||
#endif
|
||||
#if QT_CONFIG(thread)
|
||||
# define FRAMELESSHELPER_HAS_THREAD 1
|
||||
# include <QtCore/qthread.h>
|
||||
#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;
|
||||
|
||||
using Transform = struct Transform
|
||||
{
|
||||
qreal Horizontal = 0;
|
||||
qreal Vertical = 0;
|
||||
};
|
||||
|
||||
class FRAMELESSHELPER_CORE_API MicaMaterialPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(MicaMaterialPrivate)
|
||||
Q_DECLARE_PUBLIC(MicaMaterial)
|
||||
FRAMELESSHELPER_PRIVATE_QT_CLASS(MicaMaterial)
|
||||
|
||||
public:
|
||||
explicit MicaMaterialPrivate(MicaMaterial *q);
|
||||
~MicaMaterialPrivate() override;
|
||||
|
||||
Q_NODISCARD static MicaMaterialPrivate *get(MicaMaterial *q);
|
||||
Q_NODISCARD static const MicaMaterialPrivate *get(const MicaMaterial *q);
|
||||
|
||||
Q_NODISCARD static QColor systemFallbackColor();
|
||||
|
||||
Q_NODISCARD static QSize monitorSize();
|
||||
Q_NODISCARD static QSize wallpaperSize();
|
||||
|
||||
Q_NODISCARD QPoint mapToWallpaper(const QPoint &pos) const;
|
||||
Q_NODISCARD QSize mapToWallpaper(const QSize &size) const;
|
||||
Q_NODISCARD QRect mapToWallpaper(const QRect &rect) const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void maybeGenerateBlurredWallpaper(const bool force = false);
|
||||
void updateMaterialBrush();
|
||||
void paint(QPainter *painter, const QRect &rect, const bool active = true);
|
||||
void forceRebuildWallpaper();
|
||||
Q_SLOT void maybeGenerateBlurredWallpaper(const bool force = false);
|
||||
Q_SLOT void updateMaterialBrush();
|
||||
Q_SLOT void forceRebuildWallpaper();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
void prepareGraphicsResources();
|
||||
|
||||
private:
|
||||
MicaMaterial *q_ptr = nullptr;
|
||||
QColor tintColor = {};
|
||||
qreal tintOpacity = 0.0;
|
||||
qreal tintOpacity = qreal(0);
|
||||
QColor fallbackColor = {};
|
||||
qreal noiseOpacity = 0.0;
|
||||
qreal noiseOpacity = qreal(0);
|
||||
bool fallbackEnabled = true;
|
||||
QBrush micaBrush = {};
|
||||
bool initialized = false;
|
||||
Transform transform = {};
|
||||
QSize wallpaperSize = {};
|
||||
};
|
||||
|
||||
class WallpaperThread : public FramelessHelperThreadClass
|
||||
{
|
||||
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
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
|
||||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||
#include <QtCore/qvariant.h>
|
||||
#include <optional>
|
||||
#include <memory>
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
|
||||
#ifndef REGISTRYKEY_FORCE_QSETTINGS
|
||||
# define REGISTRYKEY_FORCE_QSETTINGS (0)
|
||||
|
@ -56,8 +60,7 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
|
|||
|
||||
class FRAMELESSHELPER_CORE_API RegistryKey : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(RegistryKey)
|
||||
FRAMELESSHELPER_QT_CLASS(RegistryKey)
|
||||
|
||||
public:
|
||||
explicit RegistryKey(const Global::RegistryRootKey root, const QString &key, QObject *parent = nullptr);
|
||||
|
@ -73,7 +76,7 @@ public:
|
|||
Q_NODISCARD std::optional<T> value(const QString &name) const
|
||||
{
|
||||
const QVariant var = value(name);
|
||||
if (var.isValid()) {
|
||||
if (var.isValid() && !var.isNull()) {
|
||||
return qvariant_cast<T>(var);
|
||||
}
|
||||
return std::nullopt;
|
||||
|
@ -83,10 +86,12 @@ private:
|
|||
Global::RegistryRootKey m_rootKey = Global::RegistryRootKey::CurrentUser;
|
||||
QString m_subKey = {};
|
||||
#if REGISTRYKEY_QWINREGISTRYKEY
|
||||
QScopedPointer<QWinRegistryKey> m_registryKey;
|
||||
std::unique_ptr<QWinRegistryKey> m_registryKey;
|
||||
#else
|
||||
QScopedPointer<QSettings> m_settings;
|
||||
std::unique_ptr<QSettings> m_settings;
|
||||
#endif
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif // Q_OS_WINDOWS
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||
#include <functional>
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||
# include <QtCore/qscopeguard.h>
|
||||
|
@ -36,7 +37,7 @@ using ScopeGuardCallback = std::function<void()>;
|
|||
|
||||
class [[nodiscard]] ScopeGuard
|
||||
{
|
||||
Q_DISABLE_COPY(ScopeGuard)
|
||||
FRAMELESSHELPER_CLASS(ScopeGuard)
|
||||
|
||||
public:
|
||||
ScopeGuard()
|
||||
|
|
|
@ -30,13 +30,9 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
|
|||
|
||||
class FRAMELESSHELPER_CORE_API SysApiLoader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(SysApiLoader)
|
||||
FRAMELESSHELPER_QT_CLASS(SysApiLoader)
|
||||
|
||||
public:
|
||||
explicit SysApiLoader(QObject *parent = nullptr);
|
||||
~SysApiLoader() override;
|
||||
|
||||
Q_NODISCARD static SysApiLoader *instance();
|
||||
|
||||
Q_NODISCARD static QString platformSharedLibrarySuffixName();
|
||||
|
@ -44,7 +40,6 @@ public:
|
|||
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 QByteArray &function);
|
||||
Q_NODISCARD static QFunctionPointer resolve(const QString &library, const QString &function);
|
||||
|
||||
Q_NODISCARD bool isAvailable(const QString &library, const QString &function);
|
||||
|
@ -56,6 +51,10 @@ public:
|
|||
{
|
||||
return reinterpret_cast<T>(get(library, function));
|
||||
}
|
||||
|
||||
private:
|
||||
explicit SysApiLoader(QObject *parent = nullptr);
|
||||
~SysApiLoader() override;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
@ -86,7 +85,7 @@ FRAMELESSHELPER_END_NAMESPACE
|
|||
# define API_NT_AVAILABLE(func) API_AVAILABLE(ntdll, func)
|
||||
#endif // Q_OS_WINDOWS
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#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)
|
||||
|
|
|
@ -25,15 +25,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||
#include <array>
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
struct VersionNumber
|
||||
{
|
||||
int Major = 0;
|
||||
int Minor = 0;
|
||||
int Patch = 0;
|
||||
int Tweak = 0;
|
||||
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
|
||||
{
|
||||
|
@ -88,35 +89,35 @@ struct VersionNumber
|
|||
};
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
[[maybe_unused]] inline constexpr const VersionNumber WindowsVersions[] =
|
||||
[[maybe_unused]] inline constexpr const std::array<VersionNumber, static_cast<int>(Global::WindowsVersion::Latest) + 1> WindowsVersions =
|
||||
{
|
||||
{ 5, 0, 2195}, // Windows 2000
|
||||
{ 5, 1, 2600}, // Windows XP
|
||||
{ 5, 2, 3790}, // Windows XP x64 Edition or Windows Server 2003
|
||||
{ 6, 0, 6000}, // Windows Vista
|
||||
{ 6, 0, 6001}, // Windows Vista with Service Pack 1 or Windows Server 2008
|
||||
{ 6, 0, 6002}, // Windows Vista with Service Pack 2
|
||||
{ 6, 1, 7600}, // Windows 7 or Windows Server 2008 R2
|
||||
{ 6, 1, 7601}, // Windows 7 with Service Pack 1 or Windows Server 2008 R2 with Service Pack 1
|
||||
{ 6, 2, 9200}, // Windows 8 or Windows Server 2012
|
||||
{ 6, 3, 9200}, // Windows 8.1 or Windows Server 2012 R2
|
||||
{ 6, 3, 9600}, // Windows 8.1 with Update 1
|
||||
{10, 0, 10240}, // Windows 10 Version 1507 (TH1)
|
||||
{10, 0, 10586}, // Windows 10 Version 1511 (November Update) (TH2)
|
||||
{10, 0, 14393}, // Windows 10 Version 1607 (Anniversary Update) (RS1) or Windows Server 2016
|
||||
{10, 0, 15063}, // Windows 10 Version 1703 (Creators Update) (RS2)
|
||||
{10, 0, 16299}, // Windows 10 Version 1709 (Fall Creators Update) (RS3)
|
||||
{10, 0, 17134}, // Windows 10 Version 1803 (April 2018 Update) (RS4)
|
||||
{10, 0, 17763}, // Windows 10 Version 1809 (October 2018 Update) (RS5) or Windows Server 2019
|
||||
{10, 0, 18362}, // Windows 10 Version 1903 (May 2019 Update) (19H1)
|
||||
{10, 0, 18363}, // Windows 10 Version 1909 (November 2019 Update) (19H2)
|
||||
{10, 0, 19041}, // Windows 10 Version 2004 (May 2020 Update) (20H1)
|
||||
{10, 0, 19042}, // Windows 10 Version 20H2 (October 2020 Update) (20H2)
|
||||
{10, 0, 19043}, // Windows 10 Version 21H1 (May 2021 Update) (21H1)
|
||||
{10, 0, 19044}, // Windows 10 Version 21H2 (November 2021 Update) (21H2)
|
||||
{10, 0, 19045}, // Windows 10 Version 22H2 (October 2022 Update) (22H2)
|
||||
{10, 0, 22000}, // Windows 11 Version 21H2 (21H2)
|
||||
{10, 0, 22621} // Windows 11 Version 22H2 (October 2022 Update) (22H2)
|
||||
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
|
||||
|
||||
|
|
|
@ -25,40 +25,27 @@
|
|||
#pragma once
|
||||
|
||||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||
#include <optional>
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(border_painter)
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class WindowBorderPainter;
|
||||
|
||||
class FRAMELESSHELPER_CORE_API WindowBorderPainterPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(WindowBorderPainter)
|
||||
Q_DISABLE_COPY_MOVE(WindowBorderPainterPrivate)
|
||||
FRAMELESSHELPER_PRIVATE_QT_CLASS(WindowBorderPainter)
|
||||
|
||||
public:
|
||||
explicit WindowBorderPainterPrivate(WindowBorderPainter *q);
|
||||
~WindowBorderPainterPrivate() override;
|
||||
|
||||
Q_NODISCARD static WindowBorderPainterPrivate *get(WindowBorderPainter *q);
|
||||
Q_NODISCARD static const WindowBorderPainterPrivate *get(const WindowBorderPainter *q);
|
||||
|
||||
Q_NODISCARD static int getNativeBorderThickness();
|
||||
Q_NODISCARD static QColor getNativeBorderColor(const bool active);
|
||||
Q_NODISCARD static Global::WindowEdges getNativeBorderEdges();
|
||||
|
||||
public Q_SLOTS:
|
||||
void paint(QPainter *painter, const QSize &size, const bool active) const;
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
WindowBorderPainter *q_ptr = nullptr;
|
||||
std::optional<int> m_thickness = std::nullopt;
|
||||
std::optional<Global::WindowEdges> m_edges = std::nullopt;
|
||||
std::optional<QColor> m_activeColor = std::nullopt;
|
||||
std::optional<QColor> m_inactiveColor = std::nullopt;
|
||||
std::optional<int> thickness = std::nullopt;
|
||||
std::optional<Global::WindowEdges> edges = std::nullopt;
|
||||
std::optional<QColor> activeColor = std::nullopt;
|
||||
std::optional<QColor> inactiveColor = std::nullopt;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
namespace WindowsVersionHelper
|
||||
|
@ -68,3 +70,5 @@ DECL(1122H2)
|
|||
} // namespace WindowsVersionHelper
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif // Q_OS_WINDOWS
|
||||
|
|
|
@ -25,11 +25,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||
#ifdef Q_OS_LINUX
|
||||
#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
||||
# include <FramelessHelper/Core/framelesshelper_linux.h>
|
||||
#endif // Q_OS_LINUX
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QScreen;
|
||||
QT_END_NAMESPACE
|
||||
|
@ -37,34 +37,26 @@ QT_END_NAMESPACE
|
|||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
struct SystemParameters;
|
||||
|
||||
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);
|
||||
FRAMELESSHELPER_CORE_API void startSystemMove(QWindow *window, const QPoint &globalPos);
|
||||
FRAMELESSHELPER_CORE_API void startSystemResize(QWindow *window, const Qt::Edges edges, const QPoint &globalPos);
|
||||
[[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);
|
||||
FRAMELESSHELPER_CORE_API void moveWindowToDesktopCenter(
|
||||
const SystemParameters *params, const bool considerTaskBar);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API Qt::WindowState windowStatesToWindowState(
|
||||
const Qt::WindowStates states);
|
||||
[[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 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 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();
|
||||
FRAMELESSHELPER_CORE_API void registerThemeChangeNotification();
|
||||
[[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);
|
||||
|
@ -87,69 +79,67 @@ FRAMELESSHELPER_CORE_API void registerThemeChangeNotification();
|
|||
[[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();
|
||||
FRAMELESSHELPER_CORE_API void triggerFrameChange(const WId windowId);
|
||||
FRAMELESSHELPER_CORE_API void updateWindowFrameMargins(const WId windowId, const bool reset);
|
||||
FRAMELESSHELPER_CORE_API void updateInternalWindowFrameMargins(QWindow *window, const bool enable);
|
||||
[[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);
|
||||
FRAMELESSHELPER_CORE_API void syncWmPaintWithDwm();
|
||||
FRAMELESSHELPER_CORE_API void showSystemMenu(
|
||||
const WId windowId, const QPoint &pos,
|
||||
const bool selectFirstEntry, const SystemParameters *params);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getDwmColorizationColor();
|
||||
[[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 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);
|
||||
FRAMELESSHELPER_CORE_API void maybeFixupQtInternals(const WId windowId);
|
||||
[[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();
|
||||
FRAMELESSHELPER_CORE_API void installSystemMenuHook(
|
||||
const WId windowId, const SystemParameters *params);
|
||||
FRAMELESSHELPER_CORE_API void uninstallSystemMenuHook(const WId windowId);
|
||||
FRAMELESSHELPER_CORE_API void setAeroSnappingEnabled(const WId windowId, const bool enable);
|
||||
FRAMELESSHELPER_CORE_API void tryToEnableHighestDpiAwarenessLevel();
|
||||
FRAMELESSHELPER_CORE_API void updateGlobalWin32ControlsTheme(const WId windowId, const bool dark);
|
||||
[[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();
|
||||
FRAMELESSHELPER_CORE_API void setCornerStyleForWindow(const WId windowId, const Global::WindowCornerStyle style);
|
||||
FRAMELESSHELPER_CORE_API void hideOriginalTitleBarElements
|
||||
(const WId windowId, const bool disable = true);
|
||||
FRAMELESSHELPER_CORE_API void setQtDarkModeAwareEnabled(const bool enable);
|
||||
FRAMELESSHELPER_CORE_API void refreshWin32ThemeResources(const WId windowId, const bool dark);
|
||||
FRAMELESSHELPER_CORE_API void enableNonClientAreaDpiScalingForWindow(const WId windowId);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API
|
||||
Global::DpiAwareness getDpiAwarenessForCurrentProcess(bool *highest = nullptr);
|
||||
FRAMELESSHELPER_CORE_API void fixupChildWindowsDpiMessage(const WId windowId);
|
||||
FRAMELESSHELPER_CORE_API void fixupDialogsDpiScaling();
|
||||
FRAMELESSHELPER_CORE_API void setDarkModeAllowedForApp(const bool allow = true);
|
||||
FRAMELESSHELPER_CORE_API void bringWindowToFront(const WId windowId);
|
||||
[[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);
|
||||
FRAMELESSHELPER_CORE_API void removeMicaWindow(const WId windowId);
|
||||
FRAMELESSHELPER_CORE_API void removeSysMenuHook(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
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QScreen *x11_findScreenForVirtualDesktop
|
||||
(const int virtualDesktopNumber);
|
||||
#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();
|
||||
|
@ -158,11 +148,8 @@ FRAMELESSHELPER_CORE_API void removeSysMenuHook(const WId windowId);
|
|||
[[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);
|
||||
[[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();
|
||||
|
@ -172,11 +159,9 @@ FRAMELESSHELPER_CORE_API void clearWindowProperty(const WId windowId, const xcb_
|
|||
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);
|
||||
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);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool setPlatformPropertiesForWindow(QWindow *window, const QVariantHash &props);
|
||||
#endif // Q_OS_LINUX
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
|
|
|
@ -25,16 +25,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||
#include <memory>
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(border_painter)
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class WindowBorderPainterPrivate;
|
||||
|
||||
class FRAMELESSHELPER_CORE_API WindowBorderPainter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(WindowBorderPainter)
|
||||
Q_DECLARE_PRIVATE(WindowBorderPainter)
|
||||
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)
|
||||
|
@ -61,7 +61,7 @@ public:
|
|||
Q_NODISCARD QColor nativeInactiveColor() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void paint(QPainter *painter, const QSize &size, const bool active) const;
|
||||
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);
|
||||
|
@ -74,9 +74,8 @@ Q_SIGNALS:
|
|||
void inactiveColorChanged();
|
||||
void nativeBorderChanged();
|
||||
void shouldRepaint();
|
||||
|
||||
private:
|
||||
QScopedPointer<WindowBorderPainterPrivate> d_ptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
#include "quickimageitem.h"
|
|
@ -31,7 +31,7 @@
|
|||
#endif
|
||||
|
||||
#ifndef FRAMELESSHELPER_QUICK_API
|
||||
# ifdef FRAMELESSHELPER_QUICK_STATIC
|
||||
# if FRAMELESSHELPER_CONFIG(static_build)
|
||||
# define FRAMELESSHELPER_QUICK_API
|
||||
# else // FRAMELESSHELPER_QUICK_STATIC
|
||||
# ifdef FRAMELESSHELPER_QUICK_LIBRARY
|
||||
|
@ -71,14 +71,23 @@
|
|||
}
|
||||
#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
|
||||
Q_DISABLE_COPY_MOVE(QuickGlobal)
|
||||
FRAMELESSHELPER_QT_CLASS(QuickGlobal)
|
||||
#ifdef QML_NAMED_ELEMENT
|
||||
QML_NAMED_ELEMENT(FramelessHelperConstants)
|
||||
#endif
|
||||
|
@ -146,8 +155,8 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QuickGlobal::WindowEdges)
|
|||
|
||||
namespace FramelessHelper::Quick
|
||||
{
|
||||
FRAMELESSHELPER_QUICK_API void initialize();
|
||||
FRAMELESSHELPER_QUICK_API void uninitialize();
|
||||
inline void initialize() { FramelessHelperQuickInitialize(); }
|
||||
inline void uninitialize() { FramelessHelperQuickUninitialize(); }
|
||||
} // namespace FramelessHelper::Quick
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
|
|
@ -27,24 +27,27 @@
|
|||
#include <FramelessHelper/Quick/framelesshelperquick_global.h>
|
||||
#include <QtQuick/qquickitem.h>
|
||||
#include <QtQuick/qquickwindow.h>
|
||||
#include <memory>
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FramelessQuickHelperPrivate;
|
||||
#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_DECLARE_PRIVATE(FramelessQuickHelper)
|
||||
Q_DISABLE_COPY_MOVE(FramelessQuickHelper)
|
||||
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)
|
||||
|
@ -63,8 +66,12 @@ public:
|
|||
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();
|
||||
|
@ -100,9 +107,6 @@ Q_SIGNALS:
|
|||
void blurBehindWindowEnabledChanged();
|
||||
void windowChanged2();
|
||||
void ready();
|
||||
|
||||
private:
|
||||
QScopedPointer<FramelessQuickHelperPrivate> d_ptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
|
|
@ -34,7 +34,7 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
|
|||
|
||||
namespace FramelessHelper::Quick
|
||||
{
|
||||
FRAMELESSHELPER_QUICK_API void registerTypes(QQmlEngine *engine);
|
||||
inline void registerTypes(QQmlEngine *engine) { FramelessHelperQuickRegisterTypes(engine); }
|
||||
} // namespace FramelessHelper::Quick
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
|
|
@ -35,8 +35,7 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
|
|||
|
||||
class FRAMELESSHELPER_QUICK_API FramelessQuickUtils : public QObject, public QQmlParserStatus
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(FramelessQuickUtils)
|
||||
FRAMELESSHELPER_QT_CLASS(FramelessQuickUtils)
|
||||
Q_INTERFACES(QQmlParserStatus)
|
||||
#ifdef QML_NAMED_ELEMENT
|
||||
QML_NAMED_ELEMENT(FramelessUtils)
|
||||
|
@ -56,6 +55,7 @@ class FRAMELESSHELPER_QUICK_API FramelessQuickUtils : public QObject, public QQm
|
|||
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);
|
||||
|
@ -74,8 +74,9 @@ public:
|
|||
Q_NODISCARD QSizeF defaultSystemButtonIconSize() const;
|
||||
Q_NODISCARD QColor defaultSystemButtonBackgroundColor() const;
|
||||
Q_NODISCARD QColor defaultSystemCloseButtonBackgroundColor() const;
|
||||
Q_NODISCARD bool blurBehindWindowSupported() const;
|
||||
|
||||
Q_NODISCARD Q_INVOKABLE QColor getSystemButtonBackgroundColor(
|
||||
Q_NODISCARD Q_SLOT QColor getSystemButtonBackgroundColor(
|
||||
const QuickGlobal::SystemButtonType button, const QuickGlobal::ButtonState state);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -24,23 +24,22 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifndef FRAMELESSHELPER_QUICK_NO_PRIVATE
|
||||
|
||||
#include <FramelessHelper/Quick/framelesshelperquick_global.h>
|
||||
#include <memory>
|
||||
|
||||
#if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(window) && (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)))
|
||||
|
||||
#include <QtQuickTemplates2/private/qquickapplicationwindow_p.h>
|
||||
|
||||
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_DECLARE_PRIVATE(FramelessQuickApplicationWindow)
|
||||
Q_DISABLE_COPY_MOVE(FramelessQuickApplicationWindow)
|
||||
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)
|
||||
|
@ -75,11 +74,8 @@ Q_SIGNALS:
|
|||
void maximizedChanged();
|
||||
void zoomedChanged();
|
||||
void fullScreenChanged();
|
||||
|
||||
private:
|
||||
QScopedPointer<FramelessQuickApplicationWindowPrivate> d_ptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif // FRAMELESSHELPER_QUICK_NO_PRIVATE
|
||||
#endif
|
||||
|
|
|
@ -24,50 +24,33 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifndef FRAMELESSHELPER_QUICK_NO_PRIVATE
|
||||
|
||||
#include <FramelessHelper/Quick/framelesshelperquick_global.h>
|
||||
|
||||
#if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(window) && (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)))
|
||||
|
||||
#include <QtQuick/qquickwindow.h>
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FramelessQuickApplicationWindow;
|
||||
#if FRAMELESSHELPER_CONFIG(border_painter)
|
||||
class QuickWindowBorder;
|
||||
#endif
|
||||
|
||||
class FramelessQuickApplicationWindow;
|
||||
class FRAMELESSHELPER_QUICK_API FramelessQuickApplicationWindowPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(FramelessQuickApplicationWindow)
|
||||
Q_DISABLE_COPY_MOVE(FramelessQuickApplicationWindowPrivate)
|
||||
FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessQuickApplicationWindow)
|
||||
|
||||
public:
|
||||
explicit FramelessQuickApplicationWindowPrivate(FramelessQuickApplicationWindow *q);
|
||||
~FramelessQuickApplicationWindowPrivate() override;
|
||||
|
||||
Q_NODISCARD static FramelessQuickApplicationWindowPrivate *get(FramelessQuickApplicationWindow *pub);
|
||||
Q_NODISCARD static const FramelessQuickApplicationWindowPrivate *get(const FramelessQuickApplicationWindow *pub);
|
||||
|
||||
Q_INVOKABLE Q_NODISCARD bool isHidden() const;
|
||||
Q_INVOKABLE Q_NODISCARD bool isNormal() const;
|
||||
Q_INVOKABLE Q_NODISCARD bool isMinimized() const;
|
||||
Q_INVOKABLE Q_NODISCARD bool isMaximized() const;
|
||||
Q_INVOKABLE Q_NODISCARD bool isZoomed() const;
|
||||
Q_INVOKABLE Q_NODISCARD bool isFullScreen() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void showMinimized2();
|
||||
void toggleMaximized();
|
||||
void toggleFullScreen();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
FramelessQuickApplicationWindow *q_ptr = nullptr;
|
||||
QuickWindowBorder *m_windowBorder = nullptr;
|
||||
QQuickWindow::Visibility m_savedVisibility = QQuickWindow::Windowed;
|
||||
QQuickWindow::Visibility savedVisibility = QQuickWindow::Windowed;
|
||||
#if FRAMELESSHELPER_CONFIG(border_painter)
|
||||
QuickWindowBorder *windowBorder = nullptr;
|
||||
#endif
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif // FRAMELESSHELPER_QUICK_NO_PRIVATE
|
||||
#endif
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <FramelessHelper/Quick/framelesshelperquick_global.h>
|
||||
#include <QtCore/qtimer.h>
|
||||
#include <optional>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QQuickItem;
|
||||
|
@ -32,81 +34,58 @@ QT_END_NAMESPACE
|
|||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FramelessQuickHelper;
|
||||
#if FRAMELESSHELPER_CONFIG(mica_material)
|
||||
class QuickMicaMaterial;
|
||||
#endif
|
||||
#if FRAMELESSHELPER_CONFIG(border_painter)
|
||||
class QuickWindowBorder;
|
||||
struct QuickHelperData;
|
||||
#endif
|
||||
|
||||
class FramelessQuickHelper;
|
||||
class FRAMELESSHELPER_QUICK_API FramelessQuickHelperPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(FramelessQuickHelper)
|
||||
Q_DISABLE_COPY_MOVE(FramelessQuickHelperPrivate)
|
||||
FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessQuickHelper)
|
||||
|
||||
public:
|
||||
explicit FramelessQuickHelperPrivate(FramelessQuickHelper *q);
|
||||
~FramelessQuickHelperPrivate() override;
|
||||
|
||||
Q_NODISCARD static FramelessQuickHelperPrivate *get(FramelessQuickHelper *pub);
|
||||
Q_NODISCARD static const FramelessQuickHelperPrivate *get(const FramelessQuickHelper *pub);
|
||||
|
||||
Q_NODISCARD bool isContentExtendedIntoTitleBar() const;
|
||||
void extendsContentIntoTitleBar(const bool value);
|
||||
|
||||
Q_NODISCARD QQuickItem *getTitleBarItem() const;
|
||||
void setTitleBarItem(QQuickItem *value);
|
||||
|
||||
void attach();
|
||||
void detach();
|
||||
void setSystemButton(QQuickItem *item, const QuickGlobal::SystemButtonType buttonType);
|
||||
void setHitTestVisible(QQuickItem *item, 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 emitSignalForAllInstances(const char *signal);
|
||||
|
||||
Q_NODISCARD bool isWindowFixedSize() const;
|
||||
void setWindowFixedSize(const bool value);
|
||||
|
||||
void emitSignalForAllInstances(const QByteArray &signal);
|
||||
|
||||
Q_NODISCARD bool isBlurBehindWindowEnabled() const;
|
||||
void setBlurBehindWindowEnabled(const bool value, const QColor &color);
|
||||
|
||||
void setProperty(const QByteArray &name, const QVariant &value);
|
||||
Q_NODISCARD QVariant getProperty(const QByteArray &name, const QVariant &defaultValue = {});
|
||||
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);
|
||||
|
||||
Q_NODISCARD bool isReady() const;
|
||||
void waitForReady();
|
||||
void repaintAllChildren();
|
||||
Q_INVOKABLE void doRepaintAllChildren();
|
||||
|
||||
void repaintAllChildren(const int delay = 0) const;
|
||||
Q_NODISCARD quint32 readyWaitTime() const;
|
||||
void setReadyWaitTime(const quint32 time);
|
||||
|
||||
private:
|
||||
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);
|
||||
Q_NODISCARD QuickHelperData getWindowData() const;
|
||||
Q_NODISCARD QuickHelperData *getWindowDataMutable() const;
|
||||
void rebindWindow();
|
||||
|
||||
private:
|
||||
FramelessQuickHelper *q_ptr = nullptr;
|
||||
QColor m_savedWindowBackgroundColor = {};
|
||||
bool m_blurBehindWindowEnabled = false;
|
||||
std::optional<bool> m_extendIntoTitleBar = std::nullopt;
|
||||
bool m_destroying = false;
|
||||
bool m_qpaReady = false;
|
||||
QColor savedWindowBackgroundColor = {};
|
||||
bool blurBehindWindowEnabled = false;
|
||||
std::optional<bool> extendIntoTitleBar = std::nullopt;
|
||||
bool qpaReady = false;
|
||||
quint32 qpaWaitTime = 0;
|
||||
QTimer repaintTimer{};
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
|
|
@ -24,23 +24,22 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifndef FRAMELESSHELPER_QUICK_NO_PRIVATE
|
||||
|
||||
#include <FramelessHelper/Quick/framelesshelperquick_global.h>
|
||||
#include <memory>
|
||||
|
||||
#if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(window))
|
||||
|
||||
#include <QtQuick/private/qquickwindowmodule_p.h>
|
||||
|
||||
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_DECLARE_PRIVATE(FramelessQuickWindow)
|
||||
Q_DISABLE_COPY_MOVE(FramelessQuickWindow)
|
||||
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)
|
||||
|
@ -75,11 +74,8 @@ Q_SIGNALS:
|
|||
void maximizedChanged();
|
||||
void zoomedChanged();
|
||||
void fullScreenChanged();
|
||||
|
||||
private:
|
||||
QScopedPointer<FramelessQuickWindowPrivate> d_ptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif // FRAMELESSHELPER_QUICK_NO_PRIVATE
|
||||
#endif
|
||||
|
|
|
@ -24,50 +24,33 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifndef FRAMELESSHELPER_QUICK_NO_PRIVATE
|
||||
|
||||
#include <FramelessHelper/Quick/framelesshelperquick_global.h>
|
||||
|
||||
#if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(window))
|
||||
|
||||
#include <QtQuick/qquickwindow.h>
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FramelessQuickWindow;
|
||||
#if FRAMELESSHELPER_CONFIG(border_painter)
|
||||
class QuickWindowBorder;
|
||||
#endif
|
||||
|
||||
class FramelessQuickWindow;
|
||||
class FRAMELESSHELPER_QUICK_API FramelessQuickWindowPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(FramelessQuickWindow)
|
||||
Q_DISABLE_COPY_MOVE(FramelessQuickWindowPrivate)
|
||||
FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessQuickWindow)
|
||||
|
||||
public:
|
||||
explicit FramelessQuickWindowPrivate(FramelessQuickWindow *q);
|
||||
~FramelessQuickWindowPrivate() override;
|
||||
|
||||
Q_NODISCARD static FramelessQuickWindowPrivate *get(FramelessQuickWindow *pub);
|
||||
Q_NODISCARD static const FramelessQuickWindowPrivate *get(const FramelessQuickWindow *pub);
|
||||
|
||||
Q_INVOKABLE Q_NODISCARD bool isHidden() const;
|
||||
Q_INVOKABLE Q_NODISCARD bool isNormal() const;
|
||||
Q_INVOKABLE Q_NODISCARD bool isMinimized() const;
|
||||
Q_INVOKABLE Q_NODISCARD bool isMaximized() const;
|
||||
Q_INVOKABLE Q_NODISCARD bool isZoomed() const;
|
||||
Q_INVOKABLE Q_NODISCARD bool isFullScreen() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void showMinimized2();
|
||||
void toggleMaximized();
|
||||
void toggleFullScreen();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
FramelessQuickWindow *q_ptr = nullptr;
|
||||
QuickWindowBorder *m_windowBorder = nullptr;
|
||||
QQuickWindow::Visibility m_savedVisibility = QQuickWindow::Windowed;
|
||||
QQuickWindow::Visibility savedVisibility = QQuickWindow::Windowed;
|
||||
#if FRAMELESSHELPER_CONFIG(border_painter)
|
||||
QuickWindowBorder *windowBorder = nullptr;
|
||||
#endif
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif // FRAMELESSHELPER_QUICK_NO_PRIVATE
|
||||
#endif
|
||||
|
|
|
@ -26,31 +26,36 @@
|
|||
|
||||
#include <FramelessHelper/Quick/framelesshelperquick_global.h>
|
||||
#include <QtCore/qvariant.h>
|
||||
#include <QtQuick/qquickpainteditem.h>
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class QuickImageItem;
|
||||
|
||||
class FRAMELESSHELPER_QUICK_API QuickImageItemPrivate : public QObject
|
||||
class FRAMELESSHELPER_QUICK_API QuickImageItem : public QQuickPaintedItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(QuickImageItemPrivate)
|
||||
Q_DECLARE_PUBLIC(QuickImageItem)
|
||||
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 QuickImageItemPrivate(QuickImageItem *q);
|
||||
~QuickImageItemPrivate() override;
|
||||
explicit QuickImageItem(QQuickItem *parent = nullptr);
|
||||
~QuickImageItem() override;
|
||||
|
||||
Q_NODISCARD static QuickImageItemPrivate *get(QuickImageItem *q);
|
||||
Q_NODISCARD static const QuickImageItemPrivate *get(const QuickImageItem *q);
|
||||
|
||||
void paint(QPainter *painter) const;
|
||||
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 initialize();
|
||||
void fromUrl(const QUrl &value, QPainter *painter) const;
|
||||
void fromString(const QString &value, QPainter *painter) const;
|
||||
void fromImage(const QImage &value, QPainter *painter) const;
|
||||
|
@ -59,7 +64,6 @@ private:
|
|||
Q_NODISCARD QRectF paintArea() const;
|
||||
|
||||
private:
|
||||
QuickImageItem *q_ptr = nullptr;
|
||||
QVariant m_source = {};
|
||||
};
|
||||
|
||||
|
|
|
@ -26,49 +26,31 @@
|
|||
|
||||
#include <FramelessHelper/Quick/framelesshelperquick_global.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QQuickRectangle;
|
||||
QT_END_NAMESPACE
|
||||
#if FRAMELESSHELPER_CONFIG(mica_material)
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class MicaMaterial;
|
||||
class QuickMicaMaterial;
|
||||
class WallpaperImageNode;
|
||||
|
||||
class QuickMicaMaterial;
|
||||
class FRAMELESSHELPER_QUICK_API QuickMicaMaterialPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(QuickMicaMaterialPrivate)
|
||||
Q_DECLARE_PUBLIC(QuickMicaMaterial)
|
||||
FRAMELESSHELPER_PRIVATE_QT_CLASS(QuickMicaMaterial)
|
||||
|
||||
public:
|
||||
explicit QuickMicaMaterialPrivate(QuickMicaMaterial *q);
|
||||
~QuickMicaMaterialPrivate() override;
|
||||
|
||||
Q_NODISCARD static QuickMicaMaterialPrivate *get(QuickMicaMaterial *q);
|
||||
Q_NODISCARD static const QuickMicaMaterialPrivate *get(const QuickMicaMaterial *q);
|
||||
Q_SLOT void rebindWindow();
|
||||
|
||||
public Q_SLOTS:
|
||||
void rebindWindow();
|
||||
void forceRegenerateWallpaperImageCache();
|
||||
void appendNode(WallpaperImageNode *node);
|
||||
void removeNode(WallpaperImageNode *node);
|
||||
void updateFallbackColor();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
friend class WallpaperImageNode;
|
||||
|
||||
QuickMicaMaterial *q_ptr = nullptr;
|
||||
QMetaObject::Connection m_rootWindowXChangedConnection = {};
|
||||
QMetaObject::Connection m_rootWindowYChangedConnection = {};
|
||||
QMetaObject::Connection m_rootWindowActiveChangedConnection = {};
|
||||
QList<QPointer<WallpaperImageNode>> m_nodes = {};
|
||||
QQuickRectangle *m_fallbackColorItem = nullptr;
|
||||
MicaMaterial *m_micaMaterial = nullptr;
|
||||
QMetaObject::Connection rootWindowXChangedConnection = {};
|
||||
QMetaObject::Connection rootWindowYChangedConnection = {};
|
||||
QMetaObject::Connection rootWindowActiveChangedConnection = {};
|
||||
MicaMaterial *micaMaterial = nullptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,10 +24,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifndef FRAMELESSHELPER_QUICK_NO_PRIVATE
|
||||
|
||||
#include <FramelessHelper/Quick/framelesshelperquick_global.h>
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
|
||||
#if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(system_button) && (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)))
|
||||
|
||||
#include <QtQuickTemplates2/private/qquickbutton_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
@ -39,11 +39,10 @@ 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_DISABLE_COPY_MOVE(QuickStandardSystemButton)
|
||||
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)
|
||||
|
@ -51,7 +50,7 @@ class FRAMELESSHELPER_QUICK_API QuickStandardSystemButton : public QQuickButton
|
|||
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 iconSize READ iconSize WRITE setIconSize NOTIFY iconSizeChanged FINAL)
|
||||
Q_PROPERTY(qreal glyphSize READ glyphSize WRITE setGlyphSize NOTIFY glyphChanged FINAL)
|
||||
|
||||
public:
|
||||
explicit QuickStandardSystemButton(QQuickItem *parent = nullptr);
|
||||
|
@ -65,7 +64,7 @@ public:
|
|||
Q_NODISCARD QColor pressColor() const;
|
||||
Q_NODISCARD QColor activeForegroundColor() const;
|
||||
Q_NODISCARD QColor inactiveForegroundColor() const;
|
||||
Q_NODISCARD qreal iconSize() const;
|
||||
Q_NODISCARD qreal glyphSize() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void updateColor();
|
||||
|
@ -76,7 +75,7 @@ public Q_SLOTS:
|
|||
void setPressColor(const QColor &value);
|
||||
void setActiveForegroundColor(const QColor &value);
|
||||
void setInactiveForegroundColor(const QColor &value);
|
||||
void setIconSize(const qreal value);
|
||||
void setGlyphSize(const qreal value);
|
||||
|
||||
protected:
|
||||
void classBegin() override;
|
||||
|
@ -93,7 +92,7 @@ Q_SIGNALS:
|
|||
void pressColorChanged();
|
||||
void activeForegroundColorChanged();
|
||||
void inactiveForegroundColorChanged();
|
||||
void iconSizeChanged();
|
||||
void glyphSizeChanged();
|
||||
|
||||
private:
|
||||
QQuickText *m_contentItem = nullptr;
|
||||
|
@ -108,6 +107,5 @@ private:
|
|||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
|
||||
#endif // FRAMELESSHELPER_QUICK_NO_PRIVATE
|
||||
#endif
|
||||
|
|
|
@ -24,12 +24,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifndef FRAMELESSHELPER_QUICK_NO_PRIVATE
|
||||
|
||||
#include <FramelessHelper/Quick/framelesshelperquick_global.h>
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
|
||||
#if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(titlebar) && (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)))
|
||||
|
||||
#include <FramelessHelper/Quick/quickchromepalette.h>
|
||||
#include <FramelessHelper/Quick/private/quickstandardsystembutton_p.h>
|
||||
#if FRAMELESSHELPER_CONFIG(system_button)
|
||||
# include <FramelessHelper/Quick/private/quickstandardsystembutton_p.h>
|
||||
#endif
|
||||
#include <QtQuick/private/qquickrectangle_p.h>
|
||||
#include <QtQuickTemplates2/private/qquicklabel_p.h>
|
||||
|
||||
|
@ -43,14 +45,13 @@ 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_DISABLE_COPY_MOVE(QuickStandardTitleBar)
|
||||
Q_PROPERTY(Qt::Alignment titleLabelAlignment READ titleLabelAlignment WRITE setTitleLabelAlignment NOTIFY titleLabelAlignmentChanged FINAL)
|
||||
Q_PROPERTY(QQuickLabel* titleLabel READ titleLabel CONSTANT FINAL)
|
||||
#ifndef Q_OS_MACOS
|
||||
#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)
|
||||
|
@ -70,7 +71,7 @@ public:
|
|||
void setTitleLabelAlignment(const Qt::Alignment value);
|
||||
|
||||
Q_NODISCARD QQuickLabel *titleLabel() const;
|
||||
#ifndef Q_OS_MACOS
|
||||
#if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button))
|
||||
Q_NODISCARD QuickStandardSystemButton *minimizeButton() const;
|
||||
Q_NODISCARD QuickStandardSystemButton *maximizeButton() const;
|
||||
Q_NODISCARD QuickStandardSystemButton *closeButton() const;
|
||||
|
@ -130,7 +131,7 @@ private:
|
|||
Qt::Alignment m_labelAlignment = {};
|
||||
QuickImageItem *m_windowIcon = nullptr;
|
||||
QQuickLabel *m_windowTitleLabel = nullptr;
|
||||
#ifndef Q_OS_MACOS
|
||||
#if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button))
|
||||
QQuickRow *m_systemButtonsRow = nullptr;
|
||||
QuickStandardSystemButton *m_minimizeButton = nullptr;
|
||||
QuickStandardSystemButton *m_maximizeButton = nullptr;
|
||||
|
@ -146,6 +147,5 @@ private:
|
|||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
|
||||
#endif // FRAMELESSHELPER_QUICK_NO_PRIVATE
|
||||
#endif
|
||||
|
|
|
@ -26,38 +26,31 @@
|
|||
|
||||
#include <FramelessHelper/Quick/framelesshelperquick_global.h>
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(border_painter)
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class QuickWindowBorder;
|
||||
class WindowBorderPainter;
|
||||
|
||||
class QuickWindowBorder;
|
||||
class FRAMELESSHELPER_QUICK_API QuickWindowBorderPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(QuickWindowBorderPrivate)
|
||||
Q_DECLARE_PUBLIC(QuickWindowBorder)
|
||||
FRAMELESSHELPER_PRIVATE_QT_CLASS(QuickWindowBorder)
|
||||
|
||||
public:
|
||||
explicit QuickWindowBorderPrivate(QuickWindowBorder *q);
|
||||
~QuickWindowBorderPrivate() override;
|
||||
|
||||
Q_NODISCARD static QuickWindowBorderPrivate *get(QuickWindowBorder *q);
|
||||
Q_NODISCARD static const QuickWindowBorderPrivate *get(const QuickWindowBorder *q);
|
||||
Q_SLOT void update();
|
||||
|
||||
void paint(QPainter *painter) const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void update();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
void rebindWindow();
|
||||
|
||||
private:
|
||||
QuickWindowBorder *q_ptr = nullptr;
|
||||
WindowBorderPainter *m_borderPainter = nullptr;
|
||||
QMetaObject::Connection m_activeChangeConnection = {};
|
||||
QMetaObject::Connection m_visibilityChangeConnection = {};
|
||||
WindowBorderPainter *borderPainter = nullptr;
|
||||
QMetaObject::Connection activeChangeConnection = {};
|
||||
QMetaObject::Connection visibilityChangeConnection = {};
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -28,16 +28,17 @@
|
|||
#include <FramelessHelper/Core/chromepalette.h>
|
||||
#include <QtQml/qqmlparserstatus.h>
|
||||
|
||||
#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
|
||||
Q_DISABLE_COPY_MOVE(QuickChromePalette)
|
||||
Q_INTERFACES(QQmlParserStatus)
|
||||
|
||||
public:
|
||||
explicit QuickChromePalette(QObject *parent = nullptr);
|
||||
|
@ -49,3 +50,5 @@ protected:
|
|||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,20 +25,20 @@
|
|||
#pragma once
|
||||
|
||||
#include <FramelessHelper/Quick/framelesshelperquick_global.h>
|
||||
#include <QtQuick/qquickitem.h>
|
||||
#include <QtQuick/qquickpainteditem.h>
|
||||
#include <memory>
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(mica_material)
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class QuickMicaMaterialPrivate;
|
||||
|
||||
class FRAMELESSHELPER_QUICK_API QuickMicaMaterial : public QQuickItem
|
||||
class FRAMELESSHELPER_QUICK_API QuickMicaMaterial : public QQuickPaintedItem
|
||||
{
|
||||
Q_OBJECT
|
||||
FRAMELESSHELPER_PUBLIC_QT_CLASS(QuickMicaMaterial)
|
||||
#ifdef QML_NAMED_ELEMENT
|
||||
QML_NAMED_ELEMENT(MicaMaterial)
|
||||
#endif
|
||||
Q_DISABLE_COPY_MOVE(QuickMicaMaterial)
|
||||
Q_DECLARE_PRIVATE(QuickMicaMaterial)
|
||||
|
||||
Q_PROPERTY(QColor tintColor READ tintColor WRITE setTintColor NOTIFY tintColorChanged FINAL)
|
||||
Q_PROPERTY(qreal tintOpacity READ tintOpacity WRITE setTintOpacity NOTIFY tintOpacityChanged FINAL)
|
||||
|
@ -50,6 +50,8 @@ public:
|
|||
explicit QuickMicaMaterial(QQuickItem *parent = nullptr);
|
||||
~QuickMicaMaterial() override;
|
||||
|
||||
void paint(QPainter *painter) override;
|
||||
|
||||
Q_NODISCARD QColor tintColor() const;
|
||||
void setTintColor(const QColor &value);
|
||||
|
||||
|
@ -74,12 +76,10 @@ Q_SIGNALS:
|
|||
|
||||
protected:
|
||||
void itemChange(const ItemChange change, const ItemChangeData &value) override;
|
||||
[[nodiscard]] QSGNode *updatePaintNode(QSGNode *old, UpdatePaintNodeData *data) override;
|
||||
void classBegin() override;
|
||||
void componentComplete() override;
|
||||
|
||||
private:
|
||||
QScopedPointer<QuickMicaMaterialPrivate> d_ptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,19 +26,19 @@
|
|||
|
||||
#include <FramelessHelper/Quick/framelesshelperquick_global.h>
|
||||
#include <QtQuick/qquickpainteditem.h>
|
||||
#include <memory>
|
||||
|
||||
#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_DISABLE_COPY_MOVE(QuickWindowBorder)
|
||||
Q_DECLARE_PRIVATE(QuickWindowBorder)
|
||||
|
||||
Q_PROPERTY(qreal thickness READ thickness WRITE setThickness NOTIFY thicknessChanged FINAL)
|
||||
Q_PROPERTY(QuickGlobal::WindowEdges edges READ edges WRITE setEdges NOTIFY edgesChanged FINAL)
|
||||
|
@ -83,9 +83,8 @@ Q_SIGNALS:
|
|||
void activeColorChanged();
|
||||
void inactiveColorChanged();
|
||||
void nativeBorderChanged();
|
||||
|
||||
private:
|
||||
QScopedPointer<QuickWindowBorderPrivate> d_ptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,23 +26,22 @@
|
|||
|
||||
#include <FramelessHelper/Widgets/framelesshelperwidgets_global.h>
|
||||
#include <QtWidgets/qdialog.h>
|
||||
#include <memory>
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(window)
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FramelessDialogPrivate;
|
||||
|
||||
class FRAMELESSHELPER_WIDGETS_API FramelessDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(FramelessDialog)
|
||||
Q_DISABLE_COPY_MOVE(FramelessDialog)
|
||||
FRAMELESSHELPER_PUBLIC_QT_CLASS(FramelessDialog)
|
||||
|
||||
public:
|
||||
explicit FramelessDialog(QWidget *parent = nullptr);
|
||||
~FramelessDialog() override;
|
||||
|
||||
private:
|
||||
QScopedPointer<FramelessDialogPrivate> d_ptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||
|
||||
#ifndef FRAMELESSHELPER_WIDGETS_API
|
||||
# ifdef FRAMELESSHELPER_WIDGETS_STATIC
|
||||
# if FRAMELESSHELPER_CONFIG(static_build)
|
||||
# define FRAMELESSHELPER_WIDGETS_API
|
||||
# else
|
||||
# ifdef FRAMELESSHELPER_WIDGETS_LIBRARY
|
||||
|
@ -40,10 +40,13 @@
|
|||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
FRAMELESSHELPER_WIDGETS_API void FramelessHelperWidgetsInitialize();
|
||||
FRAMELESSHELPER_WIDGETS_API void FramelessHelperWidgetsUninitialize();
|
||||
|
||||
namespace FramelessHelper::Widgets
|
||||
{
|
||||
FRAMELESSHELPER_WIDGETS_API void initialize();
|
||||
FRAMELESSHELPER_WIDGETS_API void uninitialize();
|
||||
inline void initialize() { FramelessHelperWidgetsInitialize(); }
|
||||
inline void uninitialize() { FramelessHelperWidgetsUninitialize(); }
|
||||
} // namespace FramelessHelper::Widgets
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
|
|
@ -26,16 +26,16 @@
|
|||
|
||||
#include <FramelessHelper/Widgets/framelesshelperwidgets_global.h>
|
||||
#include <QtWidgets/qmainwindow.h>
|
||||
#include <memory>
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(window)
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FramelessMainWindowPrivate;
|
||||
|
||||
class FRAMELESSHELPER_WIDGETS_API FramelessMainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(FramelessMainWindow)
|
||||
Q_DISABLE_COPY_MOVE(FramelessMainWindow)
|
||||
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)
|
||||
|
@ -55,9 +55,8 @@ Q_SIGNALS:
|
|||
void hiddenChanged();
|
||||
void normalChanged();
|
||||
void zoomedChanged();
|
||||
|
||||
private:
|
||||
QScopedPointer<FramelessMainWindowPrivate> d_ptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,16 +26,16 @@
|
|||
|
||||
#include <FramelessHelper/Widgets/framelesshelperwidgets_global.h>
|
||||
#include <QtWidgets/qwidget.h>
|
||||
#include <memory>
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(window)
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FramelessWidgetPrivate;
|
||||
|
||||
class FRAMELESSHELPER_WIDGETS_API FramelessWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(FramelessWidget)
|
||||
Q_DISABLE_COPY_MOVE(FramelessWidget)
|
||||
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)
|
||||
|
@ -55,9 +55,8 @@ Q_SIGNALS:
|
|||
void hiddenChanged();
|
||||
void normalChanged();
|
||||
void zoomedChanged();
|
||||
|
||||
private:
|
||||
QScopedPointer<FramelessWidgetPrivate> d_ptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,18 +26,21 @@
|
|||
|
||||
#include <FramelessHelper/Widgets/framelesshelperwidgets_global.h>
|
||||
#include <QtWidgets/qwidget.h>
|
||||
#include <memory>
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FramelessWidgetsHelperPrivate;
|
||||
#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
|
||||
Q_DECLARE_PRIVATE(FramelessWidgetsHelper)
|
||||
Q_DISABLE_COPY_MOVE(FramelessWidgetsHelper)
|
||||
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)
|
||||
|
@ -56,8 +59,12 @@ public:
|
|||
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();
|
||||
|
@ -87,9 +94,6 @@ Q_SIGNALS:
|
|||
void blurBehindWindowEnabledChanged();
|
||||
void windowChanged();
|
||||
void ready();
|
||||
|
||||
private:
|
||||
QScopedPointer<FramelessWidgetsHelperPrivate> d_ptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
|
|
@ -26,32 +26,24 @@
|
|||
|
||||
#include <FramelessHelper/Widgets/framelesshelperwidgets_global.h>
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(window)
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FramelessDialog;
|
||||
class WidgetsSharedHelper;
|
||||
|
||||
class FramelessDialog;
|
||||
class FRAMELESSHELPER_WIDGETS_API FramelessDialogPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(FramelessDialog)
|
||||
Q_DISABLE_COPY_MOVE(FramelessDialogPrivate)
|
||||
FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessDialog)
|
||||
|
||||
public:
|
||||
explicit FramelessDialogPrivate(FramelessDialog *q);
|
||||
~FramelessDialogPrivate() override;
|
||||
|
||||
Q_NODISCARD static FramelessDialogPrivate *get(FramelessDialog *pub);
|
||||
Q_NODISCARD static const FramelessDialogPrivate *get(const FramelessDialog *pub);
|
||||
|
||||
Q_NODISCARD WidgetsSharedHelper *widgetsSharedHelper() const;
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
FramelessDialog *q_ptr = nullptr;
|
||||
WidgetsSharedHelper *m_sharedHelper = nullptr;
|
||||
WidgetsSharedHelper *sharedHelper = nullptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,39 +26,25 @@
|
|||
|
||||
#include <FramelessHelper/Widgets/framelesshelperwidgets_global.h>
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(window)
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FramelessMainWindow;
|
||||
class WidgetsSharedHelper;
|
||||
|
||||
class FramelessMainWindow;
|
||||
class FRAMELESSHELPER_WIDGETS_API FramelessMainWindowPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(FramelessMainWindow)
|
||||
Q_DISABLE_COPY_MOVE(FramelessMainWindowPrivate)
|
||||
FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessMainWindow)
|
||||
|
||||
public:
|
||||
explicit FramelessMainWindowPrivate(FramelessMainWindow *q);
|
||||
~FramelessMainWindowPrivate() override;
|
||||
|
||||
Q_NODISCARD static FramelessMainWindowPrivate *get(FramelessMainWindow *pub);
|
||||
Q_NODISCARD static const FramelessMainWindowPrivate *get(const FramelessMainWindow *pub);
|
||||
|
||||
Q_NODISCARD bool isNormal() const;
|
||||
Q_NODISCARD bool isZoomed() const;
|
||||
|
||||
void toggleMaximized();
|
||||
void toggleFullScreen();
|
||||
|
||||
Q_NODISCARD WidgetsSharedHelper *widgetsSharedHelper() const;
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
FramelessMainWindow *q_ptr = nullptr;
|
||||
Qt::WindowState m_savedWindowState = Qt::WindowNoState;
|
||||
WidgetsSharedHelper *m_sharedHelper = nullptr;
|
||||
Qt::WindowState savedWindowState = Qt::WindowNoState;
|
||||
WidgetsSharedHelper *sharedHelper = nullptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,39 +26,25 @@
|
|||
|
||||
#include <FramelessHelper/Widgets/framelesshelperwidgets_global.h>
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(window)
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FramelessWidget;
|
||||
class WidgetsSharedHelper;
|
||||
|
||||
class FramelessWidget;
|
||||
class FRAMELESSHELPER_WIDGETS_API FramelessWidgetPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(FramelessWidget)
|
||||
Q_DISABLE_COPY_MOVE(FramelessWidgetPrivate)
|
||||
FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessWidget)
|
||||
|
||||
public:
|
||||
explicit FramelessWidgetPrivate(FramelessWidget *q);
|
||||
~FramelessWidgetPrivate() override;
|
||||
|
||||
Q_NODISCARD static FramelessWidgetPrivate *get(FramelessWidget *pub);
|
||||
Q_NODISCARD static const FramelessWidgetPrivate *get(const FramelessWidget *pub);
|
||||
|
||||
Q_NODISCARD bool isNormal() const;
|
||||
Q_NODISCARD bool isZoomed() const;
|
||||
|
||||
void toggleMaximized();
|
||||
void toggleFullScreen();
|
||||
|
||||
Q_NODISCARD WidgetsSharedHelper *widgetsSharedHelper() const;
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
FramelessWidget *q_ptr = nullptr;
|
||||
Qt::WindowState m_savedWindowState = Qt::WindowNoState;
|
||||
WidgetsSharedHelper *m_sharedHelper = nullptr;
|
||||
Qt::WindowState savedWindowState = Qt::WindowNoState;
|
||||
WidgetsSharedHelper *sharedHelper = nullptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,90 +26,66 @@
|
|||
|
||||
#include <FramelessHelper/Widgets/framelesshelperwidgets_global.h>
|
||||
#include <QtCore/qvariant.h>
|
||||
#include <QtCore/qtimer.h>
|
||||
#include <QtWidgets/qsizepolicy.h>
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class FramelessWidgetsHelper;
|
||||
struct WidgetsHelperData;
|
||||
class WidgetsSharedHelper;
|
||||
#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
|
||||
Q_DECLARE_PUBLIC(FramelessWidgetsHelper)
|
||||
Q_DISABLE_COPY_MOVE(FramelessWidgetsHelperPrivate)
|
||||
FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessWidgetsHelper)
|
||||
|
||||
public:
|
||||
explicit FramelessWidgetsHelperPrivate(FramelessWidgetsHelper *q);
|
||||
~FramelessWidgetsHelperPrivate() override;
|
||||
|
||||
Q_NODISCARD static FramelessWidgetsHelperPrivate *get(FramelessWidgetsHelper *pub);
|
||||
Q_NODISCARD static const FramelessWidgetsHelperPrivate *get(const FramelessWidgetsHelper *pub);
|
||||
|
||||
Q_NODISCARD bool isContentExtendedIntoTitleBar() const;
|
||||
void extendsContentIntoTitleBar(const bool value);
|
||||
|
||||
Q_NODISCARD QWidget *getTitleBarWidget() const;
|
||||
void setTitleBarWidget(QWidget *widget);
|
||||
|
||||
void attach();
|
||||
void detach();
|
||||
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 emitSignalForAllInstances(const char *signal);
|
||||
|
||||
Q_NODISCARD bool isWindowFixedSize() const;
|
||||
void setWindowFixedSize(const bool value);
|
||||
|
||||
void emitSignalForAllInstances(const QByteArray &signal);
|
||||
|
||||
Q_NODISCARD bool isBlurBehindWindowEnabled() const;
|
||||
void setBlurBehindWindowEnabled(const bool enable, const QColor &color);
|
||||
|
||||
void setProperty(const QByteArray &name, const QVariant &value);
|
||||
Q_NODISCARD QVariant getProperty(const QByteArray &name, const QVariant &defaultValue = {});
|
||||
|
||||
Q_NODISCARD QWidget *window() const;
|
||||
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);
|
||||
|
||||
Q_NODISCARD bool isReady() const;
|
||||
void waitForReady();
|
||||
void repaintAllChildren();
|
||||
Q_INVOKABLE void doRepaintAllChildren();
|
||||
|
||||
void repaintAllChildren(const int delay = 0) const;
|
||||
Q_NODISCARD quint32 readyWaitTime() const;
|
||||
void setReadyWaitTime(const quint32 time);
|
||||
|
||||
private:
|
||||
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;
|
||||
Q_NODISCARD WidgetsHelperData getWindowData() const;
|
||||
Q_NODISCARD WidgetsHelperData *getWindowDataMutable() const;
|
||||
|
||||
private:
|
||||
FramelessWidgetsHelper *q_ptr = nullptr;
|
||||
QColor m_savedWindowBackgroundColor = {};
|
||||
bool m_blurBehindWindowEnabled = false;
|
||||
QPointer<QWidget> m_window = nullptr;
|
||||
bool m_destroying = false;
|
||||
bool m_qpaReady = false;
|
||||
QSizePolicy m_savedSizePolicy = {};
|
||||
QColor savedWindowBackgroundColor = {};
|
||||
bool blurBehindWindowEnabled = false;
|
||||
QPointer<QWidget> 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
|
||||
|
|
|
@ -25,77 +25,34 @@
|
|||
#pragma once
|
||||
|
||||
#include <FramelessHelper/Widgets/framelesshelperwidgets_global.h>
|
||||
#include <optional>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QEnterEvent;
|
||||
class QPaintEvent;
|
||||
QT_END_NAMESPACE
|
||||
#if FRAMELESSHELPER_CONFIG(system_button)
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class StandardSystemButton;
|
||||
|
||||
class FRAMELESSHELPER_WIDGETS_API StandardSystemButtonPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(StandardSystemButton)
|
||||
Q_DISABLE_COPY_MOVE(StandardSystemButtonPrivate)
|
||||
FRAMELESSHELPER_PRIVATE_QT_CLASS(StandardSystemButton)
|
||||
|
||||
public:
|
||||
explicit StandardSystemButtonPrivate(StandardSystemButton *q);
|
||||
~StandardSystemButtonPrivate() override;
|
||||
|
||||
Q_NODISCARD static StandardSystemButtonPrivate *get(StandardSystemButton *pub);
|
||||
Q_NODISCARD static const StandardSystemButtonPrivate *get(const StandardSystemButton *pub);
|
||||
Q_NODISCARD static QSize getRecommendedButtonSize();
|
||||
|
||||
Q_NODISCARD QString getGlyph() const;
|
||||
void setGlyph(const QString &value);
|
||||
|
||||
Q_NODISCARD Global::SystemButtonType getButtonType() const;
|
||||
void setButtonType(const Global::SystemButtonType type);
|
||||
|
||||
Q_NODISCARD QSize getRecommendedButtonSize() const;
|
||||
|
||||
Q_NODISCARD bool isHovered() const;
|
||||
Q_NODISCARD bool isPressed() const;
|
||||
Q_NODISCARD QColor getHoverColor() const;
|
||||
Q_NODISCARD QColor getPressColor() const;
|
||||
Q_NODISCARD QColor getNormalColor() const;
|
||||
Q_NODISCARD QColor getActiveForegroundColor() const;
|
||||
Q_NODISCARD QColor getInactiveForegroundColor() const;
|
||||
Q_NODISCARD bool isActive() const;
|
||||
Q_NODISCARD int iconSize2() const;
|
||||
|
||||
void setHovered(const bool value);
|
||||
void setPressed(const bool value);
|
||||
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 setIconSize2(const int value);
|
||||
|
||||
void enterEventHandler(QT_ENTER_EVENT_TYPE *event);
|
||||
void leaveEventHandler(QEvent *event);
|
||||
void paintEventHandler(QPaintEvent *event);
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
StandardSystemButton *q_ptr = nullptr;
|
||||
Global::SystemButtonType m_buttonType = Global::SystemButtonType::Unknown;
|
||||
QString m_glyph = {};
|
||||
QColor m_hoverColor = {};
|
||||
QColor m_pressColor = {};
|
||||
QColor m_normalColor = {};
|
||||
QColor m_activeForegroundColor = {};
|
||||
QColor m_inactiveForegroundColor = {};
|
||||
bool m_hovered = false;
|
||||
bool m_pressed = false;
|
||||
bool m_active = false;
|
||||
std::optional<int> m_iconSize2 = std::nullopt;
|
||||
Global::SystemButtonType buttonType = Global::SystemButtonType::Unknown;
|
||||
QString glyph = {};
|
||||
QColor hoverColor = {};
|
||||
QColor pressColor = {};
|
||||
QColor normalColor = {};
|
||||
QColor activeForegroundColor = {};
|
||||
QColor inactiveForegroundColor = {};
|
||||
bool active = false;
|
||||
std::optional<int> glyphSize = std::nullopt;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,23 +26,25 @@
|
|||
|
||||
#include <FramelessHelper/Widgets/framelesshelperwidgets_global.h>
|
||||
#include <QtGui/qfont.h>
|
||||
#include <optional>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QPaintEvent;
|
||||
class QMouseEvent;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(titlebar)
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class StandardTitleBar;
|
||||
#if FRAMELESSHELPER_CONFIG(system_button)
|
||||
class StandardSystemButton;
|
||||
#endif
|
||||
class ChromePalette;
|
||||
|
||||
class StandardTitleBar;
|
||||
class FRAMELESSHELPER_WIDGETS_API StandardTitleBarPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PUBLIC(StandardTitleBar)
|
||||
Q_DISABLE_COPY_MOVE(StandardTitleBarPrivate)
|
||||
FRAMELESSHELPER_PRIVATE_QT_CLASS(StandardTitleBar)
|
||||
|
||||
public:
|
||||
struct FontMetrics
|
||||
|
@ -55,72 +57,43 @@ public:
|
|||
explicit StandardTitleBarPrivate(StandardTitleBar *q);
|
||||
~StandardTitleBarPrivate() override;
|
||||
|
||||
Q_NODISCARD static StandardTitleBarPrivate *get(StandardTitleBar *pub);
|
||||
Q_NODISCARD static const StandardTitleBarPrivate *get(const StandardTitleBar *pub);
|
||||
|
||||
Q_NODISCARD Qt::Alignment titleLabelAlignment() const;
|
||||
void setTitleLabelAlignment(const Qt::Alignment value);
|
||||
|
||||
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;
|
||||
|
||||
void paintTitleBar(QPaintEvent *event);
|
||||
|
||||
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);
|
||||
|
||||
Q_NODISCARD bool mouseEventHandler(QMouseEvent *event);
|
||||
|
||||
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;
|
||||
|
||||
public Q_SLOTS:
|
||||
void updateMaximizeButton();
|
||||
void updateTitleBarColor();
|
||||
void updateChromeButtonColor();
|
||||
void retranslateUi();
|
||||
Q_SLOT void updateMaximizeButton();
|
||||
Q_SLOT void updateTitleBarColor();
|
||||
Q_SLOT void updateChromeButtonColor();
|
||||
Q_SLOT void retranslateUi();
|
||||
|
||||
protected:
|
||||
Q_NODISCARD bool eventFilter(QObject *object, QEvent *event) override;
|
||||
Q_NODISCARD bool mouseEventHandler(QMouseEvent *event);
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
StandardTitleBar *q_ptr = nullptr;
|
||||
#ifndef Q_OS_MACOS
|
||||
StandardSystemButton *m_minimizeButton = nullptr;
|
||||
StandardSystemButton *m_maximizeButton = nullptr;
|
||||
StandardSystemButton *m_closeButton = nullptr;
|
||||
#endif // Q_OS_MACOS
|
||||
QPointer<QWidget> m_window = nullptr;
|
||||
bool m_extended = false;
|
||||
Qt::Alignment m_labelAlignment = {};
|
||||
bool m_hideWhenClose = false;
|
||||
ChromePalette *m_chromePalette = nullptr;
|
||||
bool m_titleLabelVisible = true;
|
||||
std::optional<QSize> m_windowIconSize = std::nullopt;
|
||||
bool m_windowIconVisible = false;
|
||||
std::optional<QFont> m_titleFont = std::nullopt;
|
||||
bool m_closeTriggered = false;
|
||||
#if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button))
|
||||
StandardSystemButton *minimizeButton = nullptr;
|
||||
StandardSystemButton *maximizeButton = nullptr;
|
||||
StandardSystemButton *closeButton = nullptr;
|
||||
#endif
|
||||
QPointer<QWidget> 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<QSize> windowIconSize = std::nullopt;
|
||||
bool windowIconVisible = false;
|
||||
std::optional<QFont> titleFont = std::nullopt;
|
||||
bool closeTriggered = false;
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *object, QEvent *event) override;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -29,14 +29,19 @@
|
|||
|
||||
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
|
||||
Q_DISABLE_COPY_MOVE(WidgetsSharedHelper)
|
||||
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);
|
||||
|
@ -44,11 +49,14 @@ public:
|
|||
|
||||
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;
|
||||
|
@ -58,24 +66,34 @@ private Q_SLOTS:
|
|||
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<QWidget> m_targetWidget;
|
||||
QPointer<QScreen> 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 = {};
|
||||
qreal m_screenDpr = 0.0;
|
||||
QMetaObject::Connection m_screenDpiChangeConnection = {};
|
||||
#endif
|
||||
#if FRAMELESSHELPER_CONFIG(border_painter)
|
||||
WindowBorderPainter *m_borderPainter = nullptr;
|
||||
QMetaObject::Connection m_borderRepaintConnection = {};
|
||||
QMetaObject::Connection m_screenChangeConnection = {};
|
||||
#endif
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
|
|
@ -25,28 +25,26 @@
|
|||
#pragma once
|
||||
|
||||
#include <FramelessHelper/Widgets/framelesshelperwidgets_global.h>
|
||||
#include <QtWidgets/qabstractbutton.h>
|
||||
#include <QtWidgets/qpushbutton.h>
|
||||
#include <memory>
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(system_button)
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class StandardSystemButtonPrivate;
|
||||
|
||||
class FRAMELESSHELPER_WIDGETS_API StandardSystemButton : public QAbstractButton
|
||||
class FRAMELESSHELPER_WIDGETS_API StandardSystemButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(StandardSystemButton)
|
||||
Q_DISABLE_COPY_MOVE(StandardSystemButton)
|
||||
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(bool hovered READ isHovered WRITE setHovered NOTIFY hoveredChanged FINAL)
|
||||
Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged 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 iconSize2 READ iconSize2 WRITE setIconSize2 NOTIFY iconSize2Changed FINAL)
|
||||
Q_PROPERTY(int glyphSize READ glyphSize WRITE setGlyphSize NOTIFY glyphSizeChanged FINAL)
|
||||
|
||||
public:
|
||||
explicit StandardSystemButton(QWidget *parent = nullptr);
|
||||
|
@ -54,51 +52,42 @@ public:
|
|||
~StandardSystemButton() override;
|
||||
|
||||
Q_NODISCARD QSize sizeHint() const override;
|
||||
Q_NODISCARD Global::SystemButtonType buttonType();
|
||||
Q_NODISCARD Global::SystemButtonType buttonType() const;
|
||||
Q_NODISCARD QString glyph() const;
|
||||
Q_NODISCARD bool isHovered() const;
|
||||
Q_NODISCARD bool isPressed() 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 iconSize2() const;
|
||||
Q_NODISCARD int glyphSize() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setButtonType(const Global::SystemButtonType value);
|
||||
void setGlyph(const QString &glyph);
|
||||
void setHovered(const bool value);
|
||||
void setPressed(const bool value);
|
||||
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 setIconSize2(const int value);
|
||||
void setGlyphSize(const int value);
|
||||
|
||||
protected:
|
||||
void enterEvent(QT_ENTER_EVENT_TYPE *event) override;
|
||||
void leaveEvent(QEvent *event) override;
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void buttonTypeChanged();
|
||||
void glyphChanged();
|
||||
void hoveredChanged();
|
||||
void pressedChanged();
|
||||
void hoverColorChanged();
|
||||
void pressColorChanged();
|
||||
void normalColorChanged();
|
||||
void activeForegroundColorChanged();
|
||||
void inactiveForegroundColorChanged();
|
||||
void activeChanged();
|
||||
void iconSize2Changed();
|
||||
|
||||
private:
|
||||
QScopedPointer<StandardSystemButtonPrivate> d_ptr;
|
||||
void glyphSizeChanged();
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,25 +25,28 @@
|
|||
#pragma once
|
||||
|
||||
#include <FramelessHelper/Widgets/framelesshelperwidgets_global.h>
|
||||
#include <FramelessHelper/Widgets/standardsystembutton.h>
|
||||
#include <memory>
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(titlebar)
|
||||
|
||||
#include <FramelessHelper/Core/chromepalette.h>
|
||||
#if FRAMELESSHELPER_CONFIG(system_button)
|
||||
# include <FramelessHelper/Widgets/standardsystembutton.h>
|
||||
#endif
|
||||
#include <QtWidgets/qwidget.h>
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class StandardTitleBarPrivate;
|
||||
|
||||
class FRAMELESSHELPER_WIDGETS_API StandardTitleBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(StandardTitleBar)
|
||||
Q_DISABLE_COPY_MOVE(StandardTitleBar)
|
||||
FRAMELESSHELPER_PUBLIC_QT_CLASS(StandardTitleBar)
|
||||
Q_PROPERTY(Qt::Alignment titleLabelAlignment READ titleLabelAlignment WRITE setTitleLabelAlignment NOTIFY titleLabelAlignmentChanged FINAL)
|
||||
#ifndef Q_OS_MACOS
|
||||
#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_OS_MACOS
|
||||
#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)
|
||||
|
@ -59,7 +62,7 @@ public:
|
|||
Q_NODISCARD Qt::Alignment titleLabelAlignment() const;
|
||||
void setTitleLabelAlignment(const Qt::Alignment value);
|
||||
|
||||
#ifndef Q_OS_MACOS
|
||||
#if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button))
|
||||
Q_NODISCARD StandardSystemButton *minimizeButton() const;
|
||||
Q_NODISCARD StandardSystemButton *maximizeButton() const;
|
||||
Q_NODISCARD StandardSystemButton *closeButton() const;
|
||||
|
@ -98,9 +101,8 @@ Q_SIGNALS:
|
|||
void windowIconSizeChanged();
|
||||
void windowIconVisibleChanged();
|
||||
void titleFontChanged();
|
||||
|
||||
private:
|
||||
QScopedPointer<StandardTitleBarPrivate> d_ptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<LibraryPath>$(MSBuildThisFileDirectory)lib64;$(MSBuildThisFileDirectory)lib64\debug;$(MSBuildThisFileDirectory)lib64\release;$(LibraryPath)</LibraryPath>
|
||||
<LibraryPath>$(MSBuildThisFileDirectory)..\lib;$(MSBuildThisFileDirectory)..\lib\debug;$(MSBuildThisFileDirectory)..\lib\release;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings">
|
||||
<QtHeaderSearchPath>$(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)</QtHeaderSearchPath>
|
||||
<QtHeaderSearchPath>$(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)</QtHeaderSearchPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>FRAMELESSHELPER_CORE_STATIC;FRAMELESSHELPER_WIDGETS_STATIC;FRAMELESSHELPER_QUICK_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies Condition="'$(Configuration)'=='Debug'">FramelessHelperCored.lib;FramelessHelperWidgetsd.lib;FramelessHelperQuickd.lib;%(AdditionalDependencies);</AdditionalDependencies>
|
||||
<AdditionalDependencies Condition="'$(Configuration)'=='Release'">FramelessHelperCore.lib;FramelessHelperWidgets.lib;FramelessHelperQuick.lib;%(AdditionalDependencies);</AdditionalDependencies>
|
||||
<AdditionalDependencies Condition="'$(Configuration)'=='Debug'">FramelessHelperCore64d.lib;FramelessHelperWidgets64d.lib;FramelessHelperQuick64d.lib;%(AdditionalDependencies);</AdditionalDependencies>
|
||||
<AdditionalDependencies Condition="'$(Configuration)'=='Release'">FramelessHelperCore64.lib;FramelessHelperWidgets64.lib;FramelessHelperQuick64.lib;%(AdditionalDependencies);</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
</Project>
|
||||
|
|
|
@ -7,9 +7,6 @@ CORE_PRIV_INC_DIR = $$CORE_PUB_INC_DIR/private
|
|||
CORE_EXTRA_INC_DIR = $$PWD/inc/core
|
||||
CORE_SRC_DIR = $$PWD/../src/core
|
||||
|
||||
DEFINES += \
|
||||
FRAMELESSHELPER_CORE_STATIC
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$BASE_INC_DIR \
|
||||
$$COMMON_INC_DIR \
|
||||
|
@ -26,6 +23,7 @@ DEPENDPATH += \
|
|||
|
||||
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 \
|
||||
|
|
|
@ -22,44 +22,31 @@
|
|||
* 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
|
||||
|
||||
#include <FramelessHelper/Quick/framelesshelperquick_global.h>
|
||||
#include <QtQuick/qquickpainteditem.h>
|
||||
#ifndef _FRAMELESSHELPER_CONFIG_INCLUDE_GUARD_
|
||||
#define _FRAMELESSHELPER_CONFIG_INCLUDE_GUARD_
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
class QuickImageItemPrivate;
|
||||
|
||||
class FRAMELESSHELPER_QUICK_API QuickImageItem : public QQuickPaintedItem
|
||||
{
|
||||
Q_OBJECT
|
||||
#ifdef QML_NAMED_ELEMENT
|
||||
QML_NAMED_ELEMENT(ImageItem)
|
||||
#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
|
||||
Q_DISABLE_COPY_MOVE(QuickImageItem)
|
||||
Q_DECLARE_PRIVATE(QuickImageItem)
|
||||
|
||||
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);
|
||||
|
||||
protected:
|
||||
void classBegin() override;
|
||||
void componentComplete() override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void sourceChanged();
|
||||
|
||||
private:
|
||||
QScopedPointer<QuickImageItemPrivate> d_ptr;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
#endif // _FRAMELESSHELPER_CONFIG_INCLUDE_GUARD_
|
|
@ -22,23 +22,38 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
// Generated automatically by QMake.
|
||||
// WARNING! DO NOT EDIT THIS FILE MANUALLY!
|
||||
// ALL CHANGES WILL BE LOST AFTER RE-CONFIGURING!
|
||||
// Also please do not include this file directly,
|
||||
// it's designed to be included by FramelessHelper's own headers.
|
||||
// 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_DEFINED_
|
||||
#define _FRAMELESSHELPER_VERSION_DEFINED_
|
||||
#ifndef _FRAMELESSHELPER_VERSION_INCLUDE_GUARD_
|
||||
#define _FRAMELESSHELPER_VERSION_INCLUDE_GUARD_
|
||||
|
||||
[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_MAJOR = 2;
|
||||
[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_MINOR = 4;
|
||||
[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_PATCH = 2;
|
||||
//[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_TWEAK = 0;
|
||||
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_VERSION_STR[] = "2.4.2";
|
||||
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_STR[] = "UNKNOWN";
|
||||
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMPILE_DATETIME_STR[] = "UNKNOWN";
|
||||
#define __FRAMELESSHELPER_VERSION_MAJOR__ 2
|
||||
#define __FRAMELESSHELPER_VERSION_MINOR__ 5
|
||||
#define __FRAMELESSHELPER_VERSION_PATCH__ 0
|
||||
#define __FRAMELESSHELPER_VERSION_TWEAK__ 0
|
||||
#define __FRAMELESSHELPER_VERSION__ 0x02050000
|
||||
|
||||
#endif // _FRAMELESSHELPER_VERSION_DEFINED_
|
||||
[[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_
|
||||
|
|
|
@ -9,9 +9,6 @@ QUICK_PUB_INC_DIR = $$COMMON_INC_DIR/Quick
|
|||
QUICK_PRIV_INC_DIR = $$QUICK_PUB_INC_DIR/private
|
||||
QUICK_SRC_DIR = $$PWD/../src/quick
|
||||
|
||||
DEFINES += \
|
||||
FRAMELESSHELPER_QUICK_STATIC
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$BASE_INC_DIR \
|
||||
$$COMMON_INC_DIR \
|
||||
|
|
|
@ -6,9 +6,6 @@ WIDGETS_PUB_INC_DIR = $$COMMON_INC_DIR/Widgets
|
|||
WIDGETS_PRIV_INC_DIR = $$WIDGETS_PUB_INC_DIR/private
|
||||
WIDGETS_SRC_DIR = $$PWD/../src/widgets
|
||||
|
||||
DEFINES += \
|
||||
FRAMELESSHELPER_WIDGETS_STATIC
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$BASE_INC_DIR \
|
||||
$$COMMON_INC_DIR \
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
SOFTWARE.
|
||||
]]
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
if(FRAMELESSHELPER_ENABLE_UNIVERSAL_BUILD)
|
||||
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
|
||||
endif()
|
||||
|
@ -37,58 +35,46 @@ if(UNIX AND NOT APPLE)
|
|||
endif()
|
||||
find_package(X11 QUIET COMPONENTS xcb)
|
||||
if(TARGET X11::xcb)
|
||||
message("Found system XCB. The XCB wrapper will be disabled.")
|
||||
message(STATUS "--- Found system XCB. The XCB wrapper will be disabled.")
|
||||
else()
|
||||
message("System XCB not found. The XCB wrapper will be used instead.")
|
||||
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("Found system GTK. The GTK wrapper will be disabled.")
|
||||
message(STATUS "--- Found system GTK. The GTK wrapper will be disabled.")
|
||||
else()
|
||||
message("System GTK not found. The GTK wrapper will be used instead.")
|
||||
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})
|
||||
|
||||
configure_file(framelesshelper.version.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/framelesshelper.version @ONLY)
|
||||
|
||||
set(PUBLIC_HEADERS
|
||||
${CMAKE_CURRENT_BINARY_DIR}/framelesshelper.version
|
||||
${FRAMELESSHELPER_VERSION_FILE}
|
||||
${FRAMELESSHELPER_CONFIG_FILE}
|
||||
${INCLUDE_PREFIX}/framelesshelpercore_global.h
|
||||
${INCLUDE_PREFIX}/framelesshelper_qt.h
|
||||
${INCLUDE_PREFIX}/framelessmanager.h
|
||||
${INCLUDE_PREFIX}/utils.h
|
||||
${INCLUDE_PREFIX}/chromepalette.h
|
||||
${INCLUDE_PREFIX}/micamaterial.h
|
||||
${INCLUDE_PREFIX}/windowborderpainter.h
|
||||
)
|
||||
|
||||
set(PUBLIC_HEADERS_ALIAS
|
||||
${INCLUDE_PREFIX}/Global
|
||||
${INCLUDE_PREFIX}/FramelessHelper_Qt
|
||||
${INCLUDE_PREFIX}/FramelessManager
|
||||
${INCLUDE_PREFIX}/Utils
|
||||
${INCLUDE_PREFIX}/ChromePalette
|
||||
${INCLUDE_PREFIX}/MicaMaterial
|
||||
${INCLUDE_PREFIX}/WindowBorderPainter
|
||||
)
|
||||
|
||||
set(PRIVATE_HEADERS
|
||||
${INCLUDE_PREFIX}/private/framelessmanager_p.h
|
||||
${INCLUDE_PREFIX}/private/framelessconfig_p.h
|
||||
${INCLUDE_PREFIX}/private/sysapiloader_p.h
|
||||
${INCLUDE_PREFIX}/private/chromepalette_p.h
|
||||
${INCLUDE_PREFIX}/private/micamaterial_p.h
|
||||
${INCLUDE_PREFIX}/private/windowborderpainter_p.h
|
||||
${INCLUDE_PREFIX}/private/framelesshelpercore_global_p.h
|
||||
${INCLUDE_PREFIX}/private/versionnumber_p.h
|
||||
${INCLUDE_PREFIX}/private/scopeguard_p.h
|
||||
|
@ -96,25 +82,15 @@ set(PRIVATE_HEADERS
|
|||
|
||||
set(SOURCES
|
||||
utils.cpp
|
||||
framelesshelper_qt.cpp
|
||||
framelessmanager.cpp
|
||||
framelessconfig.cpp
|
||||
sysapiloader.cpp
|
||||
chromepalette.cpp
|
||||
framelesshelpercore_global.cpp
|
||||
micamaterial.cpp
|
||||
windowborderpainter.cpp
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND PUBLIC_HEADERS
|
||||
${INCLUDE_PREFIX}/framelesshelper_windows.h
|
||||
${INCLUDE_PREFIX}/framelesshelper_win.h
|
||||
)
|
||||
list(APPEND PUBLIC_HEADERS_ALIAS
|
||||
${INCLUDE_PREFIX}/FramelessHelper_Windows
|
||||
${INCLUDE_PREFIX}/FramelessHelper_Win
|
||||
)
|
||||
list(APPEND 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
|
||||
|
@ -122,25 +98,56 @@ if(WIN32)
|
|||
list(APPEND SOURCES
|
||||
registrykey.cpp
|
||||
utils_win.cpp
|
||||
framelesshelper_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 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}")
|
||||
|
@ -150,9 +157,9 @@ if(WIN32 AND NOT FRAMELESSHELPER_BUILD_STATIC)
|
|||
COMPANY "wangwenx190"
|
||||
DESCRIPTION "${PROJECT_NAME} ${SUB_MODULE} Module"
|
||||
COPYRIGHT "MIT License"
|
||||
ORIGINAL_FILENAME "${PROJECT_NAME}${SUB_MODULE}.dll"
|
||||
ORIGINAL_FILENAME "${SUB_MODULE_FULL_NAME}.dll"
|
||||
PRODUCT "${PROJECT_NAME}"
|
||||
COMMENTS "Built from commit ${PROJECT_VERSION_COMMIT} on ${PROJECT_COMPILE_DATETIME} (UTC)."
|
||||
COMMENTS "Who don't love Raiden Shogun ?"
|
||||
LIBRARY
|
||||
)
|
||||
endif()
|
||||
|
@ -166,22 +173,21 @@ if(FRAMELESSHELPER_BUILD_STATIC)
|
|||
else()
|
||||
set(SUB_MOD_LIB_TYPE "SHARED")
|
||||
endif()
|
||||
add_library(${SUB_MODULE} ${SUB_MOD_LIB_TYPE} ${ALL_SOURCES})
|
||||
add_library(${SUB_MODULE_FULL_NAME} ALIAS ${SUB_MODULE})
|
||||
add_library(${PROJECT_NAME}::${SUB_MODULE} ALIAS ${SUB_MODULE})
|
||||
add_library(${PROJECT_NAME}::${SUB_MODULE_FULL_NAME} ALIAS ${SUB_MODULE})
|
||||
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} PROPERTIES
|
||||
set_target_properties(${SUB_MODULE_TARGET} PROPERTIES
|
||||
VERSION "${PROJECT_VERSION}"
|
||||
SOVERSION "${PROJECT_VERSION_MAJOR}"
|
||||
OUTPUT_NAME "${SUB_MODULE_FULL_NAME}"
|
||||
OUTPUT_NAME "${SUB_MODULE_TARGET}${FRAMELESSHELPER_64BIT_POSTFIX}"
|
||||
)
|
||||
|
||||
set(__export_targets ${SUB_MODULE})
|
||||
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} framelesshelpercore
|
||||
qt_add_resources(${SUB_MODULE_TARGET} framelesshelpercore
|
||||
PREFIX
|
||||
"/org.wangwenx190.${PROJECT_NAME}"
|
||||
FILES
|
||||
|
@ -193,101 +199,91 @@ if(NOT FRAMELESSHELPER_NO_BUNDLE_RESOURCE)
|
|||
list(APPEND __export_targets ${__qrc_targets})
|
||||
if(FRAMELESSHELPER_BUILD_STATIC)
|
||||
foreach(__target ${__qrc_targets})
|
||||
target_sources(${SUB_MODULE} PRIVATE
|
||||
target_sources(${SUB_MODULE_TARGET} PRIVATE
|
||||
$<TARGET_OBJECTS:${__target}>
|
||||
)
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
target_sources(${SUB_MODULE} PRIVATE
|
||||
target_sources(${SUB_MODULE_TARGET} PRIVATE
|
||||
framelesshelpercore.qrc
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(FRAMELESSHELPER_BUILD_STATIC)
|
||||
target_compile_definitions(${SUB_MODULE} PUBLIC FRAMELESSHELPER_CORE_STATIC)
|
||||
endif()
|
||||
|
||||
if(FRAMELESSHELPER_NO_DEBUG_OUTPUT)
|
||||
target_compile_definitions(${SUB_MODULE} PRIVATE
|
||||
FRAMELESSHELPER_CORE_NO_DEBUG_OUTPUT
|
||||
)
|
||||
endif()
|
||||
|
||||
if(FRAMELESSHELPER_NO_BUNDLE_RESOURCE)
|
||||
target_compile_definitions(${SUB_MODULE} PUBLIC FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE)
|
||||
endif()
|
||||
|
||||
if(FRAMELESSHELPER_NO_PRIVATE)
|
||||
target_compile_definitions(${SUB_MODULE} PUBLIC FRAMELESSHELPER_CORE_NO_PRIVATE)
|
||||
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} PUBLIC FRAMELESSHELPER_NAMESPACE=${FRAMELESSHELPER_NAMESPACE})
|
||||
target_compile_definitions(${SUB_MODULE_TARGET} PUBLIC FRAMELESSHELPER_NAMESPACE=${FRAMELESSHELPER_NAMESPACE})
|
||||
endif()
|
||||
|
||||
target_compile_definitions(${SUB_MODULE} PRIVATE
|
||||
target_compile_definitions(${SUB_MODULE_TARGET} PRIVATE
|
||||
FRAMELESSHELPER_CORE_LIBRARY
|
||||
)
|
||||
|
||||
if(APPLE)
|
||||
target_link_libraries(${SUB_MODULE} PRIVATE
|
||||
target_link_libraries(${SUB_MODULE_TARGET} PRIVATE
|
||||
"-framework Foundation"
|
||||
"-framework Cocoa"
|
||||
"-framework AppKit"
|
||||
)
|
||||
elseif(UNIX)
|
||||
if(TARGET X11::xcb)
|
||||
target_link_libraries(${SUB_MODULE} PRIVATE
|
||||
target_link_libraries(${SUB_MODULE_TARGET} PRIVATE
|
||||
X11::xcb
|
||||
)
|
||||
endif()
|
||||
if(TARGET PkgConfig::GTK3)
|
||||
target_link_libraries(${SUB_MODULE} PRIVATE
|
||||
target_link_libraries(${SUB_MODULE_TARGET} PRIVATE
|
||||
PkgConfig::GTK3
|
||||
)
|
||||
target_compile_definitions(${SUB_MODULE} PRIVATE
|
||||
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} 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} PRIVATE
|
||||
target_link_libraries(${SUB_MODULE_TARGET} PRIVATE
|
||||
Qt5::X11Extras
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
target_link_libraries(${SUB_MODULE} PRIVATE
|
||||
target_link_libraries(${SUB_MODULE_TARGET} PRIVATE
|
||||
Qt${QT_VERSION_MAJOR}::CorePrivate
|
||||
Qt${QT_VERSION_MAJOR}::GuiPrivate
|
||||
)
|
||||
endif()
|
||||
|
||||
target_include_directories(${SUB_MODULE} PUBLIC
|
||||
include(GNUInstallDirs)
|
||||
target_include_directories(${SUB_MODULE_TARGET} PUBLIC
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${INCLUDE_PREFIX}/../..>"
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${INCLUDE_PREFIX}>"
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${INCLUDE_PREFIX}/private>"
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
|
||||
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>"
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${SUB_MODULE_PATH}>"
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${SUB_MODULE_PATH}/private>"
|
||||
)
|
||||
|
||||
setup_qt_stuff(TARGETS ${SUB_MODULE})
|
||||
set(__extra_flags)
|
||||
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()
|
||||
|
@ -300,16 +296,14 @@ endif()
|
|||
if(FRAMELESSHELPER_ENABLE_INTELCET)
|
||||
list(APPEND __extra_flags INTELCET)
|
||||
endif()
|
||||
if(FRAMELESSHELPER_ENABLE_INTELJCC)
|
||||
list(APPEND __extra_flags INTELJCC)
|
||||
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} ${__extra_flags})
|
||||
setup_compile_params(TARGETS ${SUB_MODULE_TARGET} ${__extra_flags})
|
||||
|
||||
if(NOT FRAMELESSHELPER_NO_INSTALL)
|
||||
setup_package_export(
|
||||
TARGETS ${__export_targets}
|
||||
|
@ -323,5 +317,5 @@ if(NOT FRAMELESSHELPER_NO_INSTALL)
|
|||
endif()
|
||||
|
||||
if(NOT FRAMELESSHELPER_NO_SUMMARY)
|
||||
dump_target_info(TARGETS ${SUB_MODULE})
|
||||
dump_target_info(TARGETS ${SUB_MODULE_TARGET})
|
||||
endif()
|
||||
|
|
|
@ -24,24 +24,26 @@
|
|||
|
||||
#include "chromepalette.h"
|
||||
#include "chromepalette_p.h"
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(titlebar)
|
||||
|
||||
#include "framelessmanager.h"
|
||||
#include "utils.h"
|
||||
#include <QtCore/qloggingcategory.h>
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(debug_output)
|
||||
[[maybe_unused]] static Q_LOGGING_CATEGORY(lcChromePalette, "wangwenx190.framelesshelper.core.chromepalette")
|
||||
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_DEBUG_OUTPUT
|
||||
# define INFO QT_NO_QDEBUG_MACRO()
|
||||
# define DEBUG QT_NO_QDEBUG_MACRO()
|
||||
# define WARNING QT_NO_QDEBUG_MACRO()
|
||||
# define CRITICAL QT_NO_QDEBUG_MACRO()
|
||||
#else
|
||||
# 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;
|
||||
|
@ -53,8 +55,7 @@ ChromePalettePrivate::ChromePalettePrivate(ChromePalette *q) : QObject(q)
|
|||
return;
|
||||
}
|
||||
q_ptr = q;
|
||||
connect(FramelessManager::instance(),
|
||||
&FramelessManager::systemThemeChanged, this, &ChromePalettePrivate::refresh);
|
||||
connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged, this, &ChromePalettePrivate::refresh);
|
||||
refresh();
|
||||
}
|
||||
|
||||
|
@ -92,15 +93,7 @@ void ChromePalettePrivate::refresh()
|
|||
titleBarInactiveBackgroundColor_sys = (dark ? kDefaultSystemDarkColor : kDefaultWhiteColor);
|
||||
titleBarActiveForegroundColor_sys = [this, dark, colorized]() -> QColor {
|
||||
if (dark || colorized) {
|
||||
// Calculate the most appropriate foreground color, based on the
|
||||
// current background color.
|
||||
const qreal grayF = (
|
||||
(0.299 * titleBarActiveBackgroundColor_sys.redF()) +
|
||||
(0.587 * titleBarActiveBackgroundColor_sys.greenF()) +
|
||||
(0.114 * titleBarActiveBackgroundColor_sys.blueF()));
|
||||
if (grayF <= 0.5) {
|
||||
return kDefaultWhiteColor;
|
||||
}
|
||||
return Utils::calculateForegroundColor(titleBarActiveBackgroundColor_sys);
|
||||
}
|
||||
return kDefaultBlackColor;
|
||||
}();
|
||||
|
@ -131,7 +124,7 @@ void ChromePalettePrivate::refresh()
|
|||
}
|
||||
|
||||
ChromePalette::ChromePalette(QObject *parent) :
|
||||
QObject(parent), d_ptr(new ChromePalettePrivate(this))
|
||||
QObject(parent), d_ptr(std::make_unique<ChromePalettePrivate>(this))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -428,3 +421,5 @@ void ChromePalette::resetCloseButtonPressColor()
|
|||
}
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
*/
|
||||
|
||||
#include "framelessconfig_p.h"
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <QtCore/qdir.h>
|
||||
#include <QtCore/qsettings.h>
|
||||
#include <QtCore/qcoreapplication.h>
|
||||
|
@ -31,72 +33,66 @@
|
|||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
static Q_LOGGING_CATEGORY(lcFramelessConfig, "wangwenx190.framelesshelper.core.framelessconfig")
|
||||
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_DEBUG_OUTPUT
|
||||
# define INFO QT_NO_QDEBUG_MACRO()
|
||||
# define DEBUG QT_NO_QDEBUG_MACRO()
|
||||
# define WARNING QT_NO_QDEBUG_MACRO()
|
||||
# define CRITICAL QT_NO_QDEBUG_MACRO()
|
||||
#else
|
||||
#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;
|
||||
|
||||
FRAMELESSHELPER_STRING_CONSTANT2(ConfigFileName, ".framelesshelper.ini")
|
||||
|
||||
static const struct
|
||||
struct FramelessConfigEntry
|
||||
{
|
||||
const QByteArray env = {};
|
||||
const QByteArray cfg = {};
|
||||
} OptionsTable[] = {
|
||||
{FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_USE_CROSS_PLATFORM_QT_IMPLEMENTATION"),
|
||||
FRAMELESSHELPER_BYTEARRAY_LITERAL("Options/UseCrossPlatformQtImplementation")},
|
||||
{FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_FORCE_HIDE_WINDOW_FRAME_BORDER"),
|
||||
FRAMELESSHELPER_BYTEARRAY_LITERAL("Options/ForceHideWindowFrameBorder")},
|
||||
{FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_FORCE_SHOW_WINDOW_FRAME_BORDER"),
|
||||
FRAMELESSHELPER_BYTEARRAY_LITERAL("Options/ForceShowWindowFrameBorder")},
|
||||
{FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_DISABLE_WINDOWS_SNAP_LAYOUT"),
|
||||
FRAMELESSHELPER_BYTEARRAY_LITERAL("Options/DisableWindowsSnapLayout")},
|
||||
{FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_WINDOW_USE_ROUND_CORNERS"),
|
||||
FRAMELESSHELPER_BYTEARRAY_LITERAL("Options/WindowUseRoundCorners")},
|
||||
{FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_CENTER_WINDOW_BEFORE_SHOW"),
|
||||
FRAMELESSHELPER_BYTEARRAY_LITERAL("Options/CenterWindowBeforeShow")},
|
||||
{FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_ENABLE_BLUR_BEHIND_WINDOW"),
|
||||
FRAMELESSHELPER_BYTEARRAY_LITERAL("Options/EnableBlurBehindWindow")},
|
||||
{FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_FORCE_NON_NATIVE_BACKGROUND_BLUR"),
|
||||
FRAMELESSHELPER_BYTEARRAY_LITERAL("Options/ForceNonNativeBackgroundBlur")},
|
||||
{FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_DISABLE_LAZY_INITIALIZATION_FOR_MICA_MATERIAL"),
|
||||
FRAMELESSHELPER_BYTEARRAY_LITERAL("Options/DisableLazyInitializationForMicaMaterial")},
|
||||
{FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_FORCE_NATIVE_BACKGROUND_BLUR"),
|
||||
FRAMELESSHELPER_BYTEARRAY_LITERAL("Options/ForceNativeBackgroundBlur")}
|
||||
const char *env = nullptr;
|
||||
const char *cfg = nullptr;
|
||||
};
|
||||
|
||||
static constexpr const auto OptionCount = std::size(OptionsTable);
|
||||
static constexpr const std::array<FramelessConfigEntry, static_cast<int>(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" }
|
||||
};
|
||||
|
||||
struct ConfigData
|
||||
static constexpr const auto OptionCount = std::size(FramelessOptionsTable);
|
||||
|
||||
struct FramelessConfigData
|
||||
{
|
||||
bool loaded = false;
|
||||
bool options[OptionCount] = {};
|
||||
std::array<bool, OptionCount> options = {};
|
||||
bool disableEnvVar = false;
|
||||
bool disableCfgFile = false;
|
||||
};
|
||||
|
||||
Q_GLOBAL_STATIC(ConfigData, g_data)
|
||||
|
||||
Q_GLOBAL_STATIC(FramelessConfig, g_config)
|
||||
Q_GLOBAL_STATIC(FramelessConfigData, g_framelessConfigData)
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(debug_output)
|
||||
static inline void warnInappropriateOptions()
|
||||
{
|
||||
const FramelessConfig * const cfg = FramelessConfig::instance();
|
||||
#ifndef Q_OS_WINDOWS
|
||||
if (cfg->isSet(Option::UseCrossPlatformQtImplementation)) {
|
||||
WARNING << "Option::UseCrossPlatformQtImplementation is default on non-Windows platforms.";
|
||||
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.";
|
||||
}
|
||||
|
@ -117,6 +113,7 @@ static inline void warnInappropriateOptions()
|
|||
WARNING << "Option::WindowUseRoundCorners has not been implemented yet.";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
FramelessConfig::FramelessConfig(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
@ -127,12 +124,13 @@ FramelessConfig::~FramelessConfig() = default;
|
|||
|
||||
FramelessConfig *FramelessConfig::instance()
|
||||
{
|
||||
return g_config();
|
||||
static FramelessConfig config;
|
||||
return &config;
|
||||
}
|
||||
|
||||
void FramelessConfig::reload(const bool force)
|
||||
{
|
||||
if (g_data()->loaded && !force) {
|
||||
if (g_framelessConfigData()->loaded && !force) {
|
||||
return;
|
||||
}
|
||||
const auto configFile = []() -> std::unique_ptr<QSettings> {
|
||||
|
@ -140,39 +138,40 @@ void FramelessConfig::reload(const bool force)
|
|||
return nullptr;
|
||||
}
|
||||
const QDir appDir(QCoreApplication::applicationDirPath());
|
||||
return std::make_unique<QSettings>(appDir.filePath(kConfigFileName), QSettings::IniFormat);
|
||||
return std::make_unique<QSettings>(appDir.filePath(FRAMELESSHELPER_STRING_LITERAL(".framelesshelper.ini")), QSettings::IniFormat);
|
||||
}();
|
||||
for (int i = 0; i != OptionCount; ++i) {
|
||||
const bool envVar = (!g_data()->disableEnvVar
|
||||
&& qEnvironmentVariableIsSet(OptionsTable[i].env.constData())
|
||||
&& (qEnvironmentVariableIntValue(OptionsTable[i].env.constData()) > 0));
|
||||
const bool cfgFile = (!g_data()->disableCfgFile && configFile
|
||||
&& configFile->value(QUtf8String(OptionsTable[i].cfg), false).toBool());
|
||||
g_data()->options[i] = (envVar || cfgFile);
|
||||
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_data()->loaded = true;
|
||||
|
||||
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_data()->options[static_cast<int>(option)] = on;
|
||||
g_framelessConfigData()->options.at(static_cast<int>(option)) = on;
|
||||
}
|
||||
|
||||
bool FramelessConfig::isSet(const Option option) const
|
||||
{
|
||||
return g_data()->options[static_cast<int>(option)];
|
||||
return g_framelessConfigData()->options.at(static_cast<int>(option));
|
||||
}
|
||||
|
||||
void FramelessConfig::setLoadFromEnvironmentVariablesDisabled(const bool on)
|
||||
{
|
||||
g_data()->disableEnvVar = on;
|
||||
g_framelessConfigData()->disableEnvVar = on;
|
||||
}
|
||||
|
||||
void FramelessConfig::setLoadFromConfigurationFileDisabled(const bool on)
|
||||
{
|
||||
g_data()->disableCfgFile = on;
|
||||
g_framelessConfigData()->disableCfgFile = on;
|
||||
}
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
|
|
@ -1,44 +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.
|
||||
*/
|
||||
|
||||
// Generated automatically by CMake.
|
||||
// WARNING! DO NOT EDIT THIS FILE MANUALLY!
|
||||
// ALL CHANGES WILL BE LOST AFTER RE-CONFIGURING!
|
||||
// Also please do not include this file directly,
|
||||
// it's designed to be included by FramelessHelper's own headers.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _FRAMELESSHELPER_VERSION_DEFINED_
|
||||
#define _FRAMELESSHELPER_VERSION_DEFINED_
|
||||
|
||||
[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_MAJOR = @PROJECT_VERSION_MAJOR@;
|
||||
[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_MINOR = @PROJECT_VERSION_MINOR@;
|
||||
[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_PATCH = @PROJECT_VERSION_PATCH@;
|
||||
//[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_TWEAK = @PROJECT_VERSION_TWEAK@;
|
||||
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_VERSION_STR[] = "@PROJECT_VERSION@";
|
||||
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_STR[] = "@PROJECT_VERSION_COMMIT@";
|
||||
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMPILE_DATETIME_STR[] = "@PROJECT_COMPILE_DATETIME@";
|
||||
|
||||
#endif // _FRAMELESSHELPER_VERSION_DEFINED_
|
|
@ -23,6 +23,9 @@
|
|||
*/
|
||||
|
||||
#include "framelesshelper_qt.h"
|
||||
|
||||
#if !FRAMELESSHELPER_CONFIG(native_impl)
|
||||
|
||||
#include "framelessmanager.h"
|
||||
#include "framelessmanager_p.h"
|
||||
#include "framelessconfig_p.h"
|
||||
|
@ -34,95 +37,145 @@
|
|||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(debug_output)
|
||||
[[maybe_unused]] static Q_LOGGING_CATEGORY(lcFramelessHelperQt, "wangwenx190.framelesshelper.core.impl.qt")
|
||||
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_DEBUG_OUTPUT
|
||||
# define INFO QT_NO_QDEBUG_MACRO()
|
||||
# define DEBUG QT_NO_QDEBUG_MACRO()
|
||||
# define WARNING QT_NO_QDEBUG_MACRO()
|
||||
# define CRITICAL QT_NO_QDEBUG_MACRO()
|
||||
#else
|
||||
# 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 QtHelperData
|
||||
struct FramelessDataQt : public FramelessData
|
||||
{
|
||||
SystemParameters params = {};
|
||||
FramelessHelperQt *eventFilter = nullptr;
|
||||
FramelessHelperQt *framelessHelperImpl = nullptr;
|
||||
bool cursorShapeChanged = false;
|
||||
bool leftButtonPressed = false;
|
||||
};
|
||||
|
||||
struct QtHelper
|
||||
FramelessDataQt();
|
||||
~FramelessDataQt() override;
|
||||
};
|
||||
using FramelessDataQtPtr = std::shared_ptr<FramelessDataQt>;
|
||||
|
||||
[[nodiscard]] static inline FramelessDataQtPtr tryGetData(const QObject *window)
|
||||
{
|
||||
QHash<WId, QtHelperData> data = {};
|
||||
Q_ASSERT(window);
|
||||
if (!window) {
|
||||
return nullptr;
|
||||
}
|
||||
const FramelessDataPtr data = FramelessManagerPrivate::getData(window);
|
||||
if (!data) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::dynamic_pointer_cast<FramelessDataQt>(data);
|
||||
}
|
||||
|
||||
class FramelessHelperQtPrivate
|
||||
{
|
||||
FRAMELESSHELPER_PRIVATE_CLASS(FramelessHelperQt)
|
||||
|
||||
public:
|
||||
explicit FramelessHelperQtPrivate(FramelessHelperQt *q);
|
||||
~FramelessHelperQtPrivate();
|
||||
|
||||
const QObject *window = nullptr;
|
||||
};
|
||||
|
||||
Q_GLOBAL_STATIC(QtHelper, g_qtHelper)
|
||||
FramelessDataQt::FramelessDataQt() = default;
|
||||
|
||||
FramelessHelperQt::FramelessHelperQt(QObject *parent) : QObject(parent) {}
|
||||
FramelessDataQt::~FramelessDataQt() = default;
|
||||
|
||||
[[nodiscard]] FramelessDataPtr FramelessData::create()
|
||||
{
|
||||
return std::make_shared<FramelessDataQt>();
|
||||
}
|
||||
|
||||
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<FramelessHelperQtPrivate>(this))
|
||||
{
|
||||
}
|
||||
|
||||
FramelessHelperQt::~FramelessHelperQt() = default;
|
||||
|
||||
void FramelessHelperQt::addWindow(FramelessParamsConst params)
|
||||
void FramelessHelperQt::addWindow(const QObject *window)
|
||||
{
|
||||
Q_ASSERT(params);
|
||||
if (!params) {
|
||||
Q_ASSERT(window);
|
||||
if (!window) {
|
||||
return;
|
||||
}
|
||||
const WId windowId = params->getWindowId();
|
||||
if (g_qtHelper()->data.contains(windowId)) {
|
||||
const FramelessDataQtPtr data = tryGetData(window);
|
||||
if (!data || data->frameless || !data->callbacks) {
|
||||
return;
|
||||
}
|
||||
QtHelperData data = {};
|
||||
data.params = *params;
|
||||
QWindow *window = params->getWindowHandle();
|
||||
// Give it a parent so that it can be automatically deleted by Qt.
|
||||
data.eventFilter = new FramelessHelperQt(window);
|
||||
g_qtHelper()->data.insert(windowId, data);
|
||||
const auto shouldApplyFramelessFlag = []() -> bool {
|
||||
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)
|
||||
#elif (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
||||
return !Utils::isCustomDecorationSupported();
|
||||
#else // Windows
|
||||
#elif defined(Q_OS_WINDOWS)
|
||||
return true;
|
||||
#endif // Q_OS_MACOS
|
||||
}();
|
||||
#if (defined(Q_OS_MACOS) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)))
|
||||
window->setProperty("_q_mac_wantsLayer", 1);
|
||||
qWindow->setProperty("_q_mac_wantsLayer", 1);
|
||||
#endif // (defined(Q_OS_MACOS) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)))
|
||||
if (shouldApplyFramelessFlag) {
|
||||
params->setWindowFlags(params->getWindowFlags() | Qt::FramelessWindowHint);
|
||||
data->callbacks->setWindowFlags(data->callbacks->getWindowFlags() | Qt::FramelessWindowHint);
|
||||
} else {
|
||||
#ifdef Q_OS_LINUX
|
||||
Q_UNUSED(Utils::tryHideSystemTitleBar(windowId, true));
|
||||
#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
||||
std::ignore = Utils::tryHideSystemTitleBar(data->callbacks->getWindowId(), true);
|
||||
#elif defined(Q_OS_MACOS)
|
||||
Utils::setSystemTitleBarVisible(windowId, false);
|
||||
Utils::setSystemTitleBarVisible(data->callbacks->getWindowId(), false);
|
||||
#endif // Q_OS_LINUX
|
||||
}
|
||||
window->installEventFilter(data.eventFilter);
|
||||
FramelessHelper::Core::setApplicationOSThemeAware();
|
||||
if (!data->framelessHelperImpl) {
|
||||
data->framelessHelperImpl = new FramelessHelperQt(qWindow);
|
||||
data->framelessHelperImpl->d_func()->window = window;
|
||||
qWindow->installEventFilter(data->framelessHelperImpl);
|
||||
}
|
||||
FramelessHelperEnableThemeAware();
|
||||
}
|
||||
|
||||
void FramelessHelperQt::removeWindow(const WId windowId)
|
||||
void FramelessHelperQt::removeWindow(const QObject *window)
|
||||
{
|
||||
Q_ASSERT(windowId);
|
||||
if (!windowId) {
|
||||
Q_ASSERT(window);
|
||||
if (!window) {
|
||||
return;
|
||||
}
|
||||
if (!g_qtHelper()->data.contains(windowId)) {
|
||||
const FramelessDataQtPtr data = tryGetData(window);
|
||||
if (!data || !data->frameless || !data->callbacks) {
|
||||
return;
|
||||
}
|
||||
g_qtHelper()->data.remove(windowId);
|
||||
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(windowId);
|
||||
#endif
|
||||
Utils::removeWindowProxy(data->callbacks->getWindowId());
|
||||
#endif // Q_OS_MACOS
|
||||
}
|
||||
|
||||
bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event)
|
||||
|
@ -133,24 +186,22 @@ bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event)
|
|||
return false;
|
||||
}
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 5, 0))
|
||||
// First detect whether we got a theme change event or not, if so,
|
||||
// inform the user the system theme has changed.
|
||||
if (Utils::isThemeChangeEvent(event)) {
|
||||
// Sometimes the FramelessManager instance may be destroyed already.
|
||||
if (FramelessManager * const manager = FramelessManager::instance()) {
|
||||
if (FramelessManagerPrivate * const managerPriv = FramelessManagerPrivate::get(manager)) {
|
||||
if (FramelessManager *manager = FramelessManager::instance()) {
|
||||
if (FramelessManagerPrivate *managerPriv = FramelessManagerPrivate::get(manager)) {
|
||||
managerPriv->notifySystemThemeHasChangedOrNot();
|
||||
}
|
||||
}
|
||||
return QObject::eventFilter(object, event);
|
||||
return false;
|
||||
}
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 5, 0))
|
||||
// We are only interested in events that are dispatched to top level windows.
|
||||
if (!object->isWindowType()) {
|
||||
return QObject::eventFilter(object, event);
|
||||
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 DPR change event).
|
||||
// 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))
|
||||
|
@ -159,23 +210,22 @@ bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event)
|
|||
&& (type != QEvent::ScreenChangeInternal) // Qt's internal event to notify screen change and DPR change.
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0))
|
||||
) {
|
||||
return QObject::eventFilter(object, event);
|
||||
return false;
|
||||
}
|
||||
const auto window = qobject_cast<QWindow *>(object);
|
||||
const WId windowId = window->winId();
|
||||
if (!g_qtHelper()->data.contains(windowId)) {
|
||||
return QObject::eventFilter(object, event);
|
||||
const FramelessDataQtPtr data = tryGetData(d->window);
|
||||
if (!data || !data->frameless || !data->callbacks) {
|
||||
return false;
|
||||
}
|
||||
const QtHelperData data = g_qtHelper()->data.value(windowId);
|
||||
#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.params.forceChildrenRepaint(500);
|
||||
return QObject::eventFilter(object, event);
|
||||
data->callbacks->forceChildrenRepaint();
|
||||
return false;
|
||||
}
|
||||
const auto qWindow = qobject_cast<QWindow *>(object);
|
||||
const auto mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
const Qt::MouseButton button = mouseEvent->button();
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
|
@ -185,64 +235,63 @@ bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event)
|
|||
const QPoint scenePos = mouseEvent->windowPos().toPoint();
|
||||
const QPoint globalPos = mouseEvent->screenPos().toPoint();
|
||||
#endif
|
||||
const bool windowFixedSize = data.params.isWindowFixedSize();
|
||||
const bool ignoreThisEvent = data.params.shouldIgnoreMouseEvents(scenePos);
|
||||
const bool insideTitleBar = data.params.isInsideTitleBarDraggableArea(scenePos);
|
||||
const bool dontOverrideCursor = data.params.getProperty(kDontOverrideCursorVar, false).toBool();
|
||||
const bool dontToggleMaximize = data.params.getProperty(kDontToggleMaximizeVar, false).toBool();
|
||||
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: {
|
||||
case QEvent::MouseButtonPress:
|
||||
if (button == Qt::LeftButton) {
|
||||
g_qtHelper()->data[windowId].leftButtonPressed = true;
|
||||
data->leftButtonPressed = true;
|
||||
if (!windowFixedSize) {
|
||||
const Qt::Edges edges = Utils::calculateWindowEdges(window, scenePos);
|
||||
const Qt::Edges edges = Utils::calculateWindowEdges(qWindow, scenePos);
|
||||
if (edges != Qt::Edges{}) {
|
||||
Utils::startSystemResize(window, edges, globalPos);
|
||||
std::ignore = Utils::startSystemResize(qWindow, edges, globalPos);
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case QEvent::MouseButtonRelease: {
|
||||
break;
|
||||
case QEvent::MouseButtonRelease:
|
||||
if (button == Qt::LeftButton) {
|
||||
g_qtHelper()->data[windowId].leftButtonPressed = false;
|
||||
}
|
||||
if (button == Qt::RightButton) {
|
||||
data->leftButtonPressed = false;
|
||||
} else if (button == Qt::RightButton) {
|
||||
if (!ignoreThisEvent && insideTitleBar) {
|
||||
data.params.showSystemMenu(globalPos);
|
||||
data->callbacks->showSystemMenu(globalPos);
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case QEvent::MouseButtonDblClick: {
|
||||
break;
|
||||
case QEvent::MouseButtonDblClick:
|
||||
if (!dontToggleMaximize && (button == Qt::LeftButton) && !windowFixedSize && !ignoreThisEvent && insideTitleBar) {
|
||||
Qt::WindowState newWindowState = Qt::WindowNoState;
|
||||
if (data.params.getWindowState() != Qt::WindowMaximized) {
|
||||
if (data->callbacks->getWindowState() != Qt::WindowMaximized) {
|
||||
newWindowState = Qt::WindowMaximized;
|
||||
}
|
||||
data.params.setWindowState(newWindowState);
|
||||
data->callbacks->setWindowState(newWindowState);
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
} break;
|
||||
break;
|
||||
case QEvent::MouseMove: {
|
||||
if (!dontOverrideCursor && !windowFixedSize) {
|
||||
const Qt::CursorShape cs = Utils::calculateCursorShape(window, scenePos);
|
||||
const Qt::CursorShape cs = Utils::calculateCursorShape(qWindow, scenePos);
|
||||
if (cs == Qt::ArrowCursor) {
|
||||
if (data.cursorShapeChanged) {
|
||||
data.params.unsetCursor();
|
||||
g_qtHelper()->data[windowId].cursorShapeChanged = false;
|
||||
if (data->cursorShapeChanged) {
|
||||
data->callbacks->unsetCursor();
|
||||
data->cursorShapeChanged = false;
|
||||
}
|
||||
} else {
|
||||
data.params.setCursor(cs);
|
||||
g_qtHelper()->data[windowId].cursorShapeChanged = true;
|
||||
data->callbacks->setCursor(cs);
|
||||
data->cursorShapeChanged = true;
|
||||
}
|
||||
}
|
||||
if (data.leftButtonPressed) {
|
||||
if (data->leftButtonPressed) {
|
||||
if (!ignoreThisEvent && insideTitleBar) {
|
||||
Utils::startSystemMove(window, globalPos);
|
||||
std::ignore = Utils::startSystemMove(qWindow, globalPos);
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
|
@ -251,7 +300,9 @@ bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
return QObject::eventFilter(object, event);
|
||||
return false;
|
||||
}
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif // !native_impl
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -30,30 +30,6 @@
|
|||
#include <QtCore/qcoreapplication.h>
|
||||
#include <QtCore/qloggingcategory.h>
|
||||
|
||||
#ifndef COMPILER_STRING
|
||||
# ifdef Q_CC_CLANG // Must be before GNU, because Clang claims to be GNU too.
|
||||
# define COMPILER_STRING __VERSION__ // Already includes the compiler's name.
|
||||
# elif defined(Q_CC_GHS)
|
||||
# define COMPILER_STRING "GHS " QT_STRINGIFY(__GHS_VERSION_NUMBER)
|
||||
# elif defined(Q_CC_GNU)
|
||||
# define COMPILER_STRING "GCC " __VERSION__
|
||||
# elif defined(Q_CC_MSVC)
|
||||
# if (_MSC_VER < 1910)
|
||||
# define COMPILER_STRING "MSVC 2015"
|
||||
# elif (_MSC_VER < 1917)
|
||||
# define COMPILER_STRING "MSVC 2017"
|
||||
# elif (_MSC_VER < 1930)
|
||||
# define COMPILER_STRING "MSVC 2019"
|
||||
# elif (_MSC_VER < 2000)
|
||||
# define COMPILER_STRING "MSVC 2022"
|
||||
# else
|
||||
# define COMPILER_STRING "MSVC version " QT_STRINGIFY(_MSC_VER)
|
||||
# endif
|
||||
# else
|
||||
# define COMPILER_STRING "UNKNOWN"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QT_BEGIN_NAMESPACE
|
||||
QDebug operator<<(QDebug d, const FRAMELESSHELPER_PREPEND_NAMESPACE(VersionNumber) &ver)
|
||||
|
@ -70,16 +46,26 @@ QDebug operator<<(QDebug d, const FRAMELESSHELPER_PREPEND_NAMESPACE(VersionNumbe
|
|||
QDebug operator<<(QDebug d, const FRAMELESSHELPER_PREPEND_NAMESPACE(Global)::VersionInfo &ver)
|
||||
{
|
||||
const QDebugStateSaver saver(d);
|
||||
int major = 0, minor = 0, patch = 0;
|
||||
FRAMELESSHELPER_EXTRACT_VERSION(ver.version, major, minor, patch)
|
||||
const auto ver_num = FRAMELESSHELPER_PREPEND_NAMESPACE(VersionNumber){major, minor, patch};
|
||||
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 << ", "
|
||||
<< "compiler: " << ver.compiler << ", "
|
||||
<< "debug build: " << ver.isDebug << ", "
|
||||
<< "static build: " << ver.isStatic << ')';
|
||||
<< "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;
|
||||
}
|
||||
|
||||
|
@ -96,31 +82,30 @@ QDebug operator<<(QDebug d, const FRAMELESSHELPER_PREPEND_NAMESPACE(Global)::Dpi
|
|||
QT_END_NAMESPACE
|
||||
#endif // QT_NO_DEBUG_STREAM
|
||||
|
||||
#ifndef FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
#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 framelesshelpercore_initResource()
|
||||
void FramelessHelperCoreInitResource()
|
||||
{
|
||||
Q_INIT_RESOURCE(framelesshelpercore);
|
||||
}
|
||||
#endif // FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
#endif // FRAMELESSHELPER_CONFIG(bundle_resource)
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
static Q_LOGGING_CATEGORY(lcCoreGlobal, "wangwenx190.framelesshelper.core.global")
|
||||
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_DEBUG_OUTPUT
|
||||
# define INFO QT_NO_QDEBUG_MACRO()
|
||||
# define DEBUG QT_NO_QDEBUG_MACRO()
|
||||
# define WARNING QT_NO_QDEBUG_MACRO()
|
||||
# define CRITICAL QT_NO_QDEBUG_MACRO()
|
||||
#else
|
||||
#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;
|
||||
|
@ -129,33 +114,24 @@ using namespace Global;
|
|||
static_assert(std::size(WindowsVersions) == (static_cast<int>(WindowsVersion::Latest) + 1));
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
[[maybe_unused]] static constexpr const char QT_QPA_ENV_VAR[] = "QT_QPA_PLATFORM";
|
||||
FRAMELESSHELPER_BYTEARRAY_CONSTANT(xcb)
|
||||
#endif
|
||||
FramelessCallbacks::FramelessCallbacks() = default;
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
[[maybe_unused]] static constexpr const char MAC_LAYER_ENV_VAR[] = "QT_MAC_WANTS_LAYER";
|
||||
#endif
|
||||
FramelessCallbacks::~FramelessCallbacks() = default;
|
||||
|
||||
[[maybe_unused]] static constexpr const char kNoLogoEnvVar[] = "FRAMELESSHELPER_NO_LOGO";
|
||||
|
||||
void registerInitializeHook(const InitializeHookCallback &cb)
|
||||
FramelessCallbacksPtr FramelessCallbacks::create()
|
||||
{
|
||||
Q_UNUSED(cb);
|
||||
WARNING << "registerInitializeHook: This function is deprecated and will be removed in a future version. Please consider using Qt's official Q_COREAPP_STARTUP_FUNCTION() macro instead.";
|
||||
return std::make_shared<FramelessCallbacks>();
|
||||
}
|
||||
|
||||
void registerUninitializeHook(const UninitializeHookCallback &cb)
|
||||
{
|
||||
Q_UNUSED(cb);
|
||||
WARNING << "registerUninitializeHook: This function is deprecated and will be removed in a future version. Please consider using Qt's official qAddPostRoutine() function instead.";
|
||||
}
|
||||
FramelessExtraData::FramelessExtraData() = default;
|
||||
|
||||
namespace FramelessHelper::Core
|
||||
{
|
||||
FramelessExtraData::~FramelessExtraData() = default;
|
||||
|
||||
void initialize()
|
||||
FramelessData::FramelessData() = default;
|
||||
|
||||
FramelessData::~FramelessData() = default;
|
||||
|
||||
void FramelessHelperCoreInitialize()
|
||||
{
|
||||
static bool inited = false;
|
||||
if (inited) {
|
||||
|
@ -163,22 +139,22 @@ void initialize()
|
|||
}
|
||||
inited = true;
|
||||
|
||||
outputLogo();
|
||||
FramelessHelperPrintLogo();
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#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_ENV_VAR, kxcb);
|
||||
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(MAC_LAYER_ENV_VAR, FRAMELESSHELPER_BYTEARRAY_LITERAL("1"));
|
||||
qputenv("QT_MAC_WANTS_LAYER", "1");
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
|
@ -189,12 +165,12 @@ void initialize()
|
|||
// 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.
|
||||
Utils::tryToEnableHighestDpiAwarenessLevel();
|
||||
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.
|
||||
Utils::fixupDialogsDpiScaling();
|
||||
std::ignore = Utils::fixupDialogsDpiScaling();
|
||||
#endif
|
||||
|
||||
// We need this flag to enable nested frameless windows, however,
|
||||
|
@ -210,7 +186,7 @@ void initialize()
|
|||
#endif
|
||||
}
|
||||
|
||||
void uninitialize()
|
||||
void FramelessHelperCoreUninitialize()
|
||||
{
|
||||
static bool uninited = false;
|
||||
if (uninited) {
|
||||
|
@ -219,38 +195,44 @@ void uninitialize()
|
|||
uninited = true;
|
||||
}
|
||||
|
||||
VersionInfo version()
|
||||
VersionInfo FramelessHelperVersion()
|
||||
{
|
||||
static const auto result = []() -> VersionInfo {
|
||||
const auto _compiler = []() -> const char * { return COMPILER_STRING; }();
|
||||
const auto _debug = []() -> bool {
|
||||
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
|
||||
}();
|
||||
const auto _static = []() -> bool {
|
||||
#ifdef FRAMELESSHELPER_CORE_STATIC
|
||||
vi.build.is_static = []() -> bool {
|
||||
#if FRAMELESSHELPER_CONFIG(static_build)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}();
|
||||
return VersionInfo{
|
||||
/* .version */ FRAMELESSHELPER_VERSION,
|
||||
/* .version_str */ FRAMELESSHELPER_VERSION_STR,
|
||||
/* .commit */ FRAMELESSHELPER_COMMIT_STR,
|
||||
/* .compileDateTime */ FRAMELESSHELPER_COMPILE_DATETIME_STR,
|
||||
/* .compiler */ _compiler,
|
||||
/* .isDebug */ _debug,
|
||||
/* .isStatic */ _static
|
||||
};
|
||||
return vi;
|
||||
}();
|
||||
return result;
|
||||
}
|
||||
|
||||
void setApplicationOSThemeAware()
|
||||
void FramelessHelperEnableThemeAware()
|
||||
{
|
||||
static bool set = false;
|
||||
if (set) {
|
||||
|
@ -260,38 +242,39 @@ void setApplicationOSThemeAware()
|
|||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
// This hack is needed to let AllowDarkModeForWindow() work.
|
||||
Utils::setDarkModeAllowedForApp(true);
|
||||
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.
|
||||
Utils::setQtDarkModeAwareEnabled(true);
|
||||
std::ignore = Utils::setQtDarkModeAwareEnabled(true);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if ((defined(Q_OS_LINUX) && (QT_VERSION < QT_VERSION_CHECK(6, 4, 0))) || \
|
||||
#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.
|
||||
Utils::registerThemeChangeNotification();
|
||||
std::ignore = Utils::registerThemeChangeNotification();
|
||||
#endif
|
||||
}
|
||||
|
||||
void outputLogo()
|
||||
void FramelessHelperPrintLogo()
|
||||
{
|
||||
if (qEnvironmentVariableIntValue(kNoLogoEnvVar)) {
|
||||
static const bool noLogo = (qEnvironmentVariableIntValue("FRAMELESSHELPER_NO_LOGO") != 0);
|
||||
if (noLogo) {
|
||||
return;
|
||||
}
|
||||
const VersionInfo &ver = version();
|
||||
const VersionInfo ver = FramelessHelperVersion();
|
||||
QString message = {};
|
||||
QTextStream stream(&message, QIODevice::WriteOnly);
|
||||
stream << "FramelessHelper (" << (ver.isStatic ? "static" : "shared")
|
||||
<< ", " << (ver.isDebug ? "debug" : "release") << ") version "
|
||||
<< ver.version_str << ", author wangwenx190 (Yuhang Zhao)."
|
||||
<< " Built by " << ver.compiler << " from " << ver.commit
|
||||
<< " on " << ver.compileDateTime << " (UTC).";
|
||||
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
|
||||
|
|
|
@ -24,12 +24,20 @@
|
|||
|
||||
#include "framelessmanager.h"
|
||||
#include "framelessmanager_p.h"
|
||||
#include "framelesshelper_qt.h"
|
||||
#include "framelessconfig_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 "framelesshelper_win.h"
|
||||
# include "winverhelper_p.h"
|
||||
#endif
|
||||
#include <QtCore/qvariant.h>
|
||||
|
@ -44,62 +52,88 @@
|
|||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
static Q_LOGGING_CATEGORY(lcFramelessManager, "wangwenx190.framelesshelper.core.framelessmanager")
|
||||
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_DEBUG_OUTPUT
|
||||
# define INFO QT_NO_QDEBUG_MACRO()
|
||||
# define DEBUG QT_NO_QDEBUG_MACRO()
|
||||
# define WARNING QT_NO_QDEBUG_MACRO()
|
||||
# define CRITICAL QT_NO_QDEBUG_MACRO()
|
||||
#else
|
||||
#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;
|
||||
|
||||
struct FramelessManagerHelper
|
||||
static constexpr const int kEventDelayInterval = 1000;
|
||||
|
||||
struct InternalData
|
||||
{
|
||||
QList<WId> windowIds = {};
|
||||
FramelessDataHash dataMap = {};
|
||||
QHash<WId, QObject *> windowMap = {};
|
||||
|
||||
InternalData();
|
||||
~InternalData();
|
||||
|
||||
private:
|
||||
FRAMELESSHELPER_CLASS(InternalData)
|
||||
};
|
||||
|
||||
Q_GLOBAL_STATIC(FramelessManagerHelper, g_helper)
|
||||
InternalData::InternalData() = default;
|
||||
|
||||
Q_GLOBAL_STATIC(FramelessManager, g_manager)
|
||||
InternalData::~InternalData() = default;
|
||||
|
||||
[[maybe_unused]] static constexpr const char kGlobalFlagVarName[] = "__FRAMELESSHELPER__";
|
||||
Q_GLOBAL_STATIC(InternalData, g_internalData)
|
||||
|
||||
#ifndef FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
FRAMELESSHELPER_STRING_CONSTANT2(IconFontFilePath, ":/org.wangwenx190.FramelessHelper/resources/fonts/iconfont.ttf")
|
||||
FRAMELESSHELPER_STRING_CONSTANT2(IconFontFamilyName_win11, "Segoe Fluent Icons")
|
||||
FRAMELESSHELPER_STRING_CONSTANT2(IconFontFamilyName_win10, "Segoe MDL2 Assets")
|
||||
FRAMELESSHELPER_STRING_CONSTANT2(IconFontFamilyName_fallback, "iconfont")
|
||||
# ifdef Q_OS_MACOS
|
||||
[[maybe_unused]] static constexpr const int kIconFontPointSize = 10;
|
||||
# else // !Q_OS_MACOS
|
||||
[[maybe_unused]] static constexpr const int kIconFontPointSize = 8;
|
||||
# endif // Q_OS_MACOS
|
||||
#endif // FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
|
||||
#ifndef FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
#if FRAMELESSHELPER_CONFIG(bundle_resource)
|
||||
[[nodiscard]] static inline QString iconFontFamilyName()
|
||||
{
|
||||
static const auto result = []() -> QString {
|
||||
#ifdef Q_OS_WINDOWS
|
||||
if (WindowsVersionHelper::isWin11OrGreater()) {
|
||||
return kIconFontFamilyName_win11;
|
||||
return FRAMELESSHELPER_STRING_LITERAL("Segoe Fluent Icons");
|
||||
}
|
||||
if (WindowsVersionHelper::isWin10OrGreater()) {
|
||||
return kIconFontFamilyName_win10;
|
||||
return FRAMELESSHELPER_STRING_LITERAL("Segoe MDL2 Assets");
|
||||
}
|
||||
#endif // Q_OS_WINDOWS
|
||||
return kIconFontFamilyName_fallback;
|
||||
return FRAMELESSHELPER_STRING_LITERAL("iconfont");
|
||||
}();
|
||||
return result;
|
||||
}
|
||||
#endif // FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
#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)
|
||||
{
|
||||
|
@ -133,110 +167,53 @@ const FramelessManagerPrivate *FramelessManagerPrivate::get(const FramelessManag
|
|||
|
||||
void FramelessManagerPrivate::initializeIconFont()
|
||||
{
|
||||
#ifndef FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
#if FRAMELESSHELPER_CONFIG(bundle_resource)
|
||||
static bool inited = false;
|
||||
if (inited) {
|
||||
return;
|
||||
}
|
||||
inited = true;
|
||||
framelesshelpercore_initResource();
|
||||
FramelessHelperCoreInitResource();
|
||||
// We always register this font because it's our only fallback.
|
||||
const int id = QFontDatabase::addApplicationFont(kIconFontFilePath);
|
||||
const int id = QFontDatabase::addApplicationFont(FRAMELESSHELPER_STRING_LITERAL(":/org.wangwenx190.FramelessHelper/resources/fonts/iconfont.ttf"));
|
||||
if (id < 0) {
|
||||
WARNING << "Failed to load icon font:" << kIconFontFilePath;
|
||||
WARNING << "Failed to load icon font.";
|
||||
} else {
|
||||
DEBUG << "Successfully registered icon font:" << QFontDatabase::applicationFontFamilies(id);
|
||||
DEBUG << "Successfully registered icon font.";
|
||||
}
|
||||
#endif // FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
}
|
||||
|
||||
QFont FramelessManagerPrivate::getIconFont()
|
||||
{
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
return {};
|
||||
#else // !FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
#if FRAMELESSHELPER_CONFIG(bundle_resource)
|
||||
static const auto font = []() -> QFont {
|
||||
QFont f = {};
|
||||
f.setFamily(iconFontFamilyName());
|
||||
f.setPointSize(kIconFontPointSize);
|
||||
# ifdef Q_OS_MACOS
|
||||
f.setPointSize(10);
|
||||
# else // !Q_OS_MACOS
|
||||
f.setPointSize(8);
|
||||
# endif // Q_OS_MACOS
|
||||
return f;
|
||||
}();
|
||||
return font;
|
||||
#endif // FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
}
|
||||
|
||||
SystemTheme FramelessManagerPrivate::systemTheme() const
|
||||
{
|
||||
// The user's choice has top priority.
|
||||
if (isThemeOverrided()) {
|
||||
return m_overrideTheme.value();
|
||||
}
|
||||
return m_systemTheme;
|
||||
}
|
||||
|
||||
QColor FramelessManagerPrivate::systemAccentColor() const
|
||||
{
|
||||
return m_accentColor;
|
||||
}
|
||||
|
||||
QString FramelessManagerPrivate::wallpaper() const
|
||||
{
|
||||
return m_wallpaper;
|
||||
}
|
||||
|
||||
WallpaperAspectStyle FramelessManagerPrivate::wallpaperAspectStyle() const
|
||||
{
|
||||
return m_wallpaperAspectStyle;
|
||||
}
|
||||
|
||||
void FramelessManagerPrivate::addWindow(FramelessParamsConst params)
|
||||
{
|
||||
Q_ASSERT(params);
|
||||
if (!params) {
|
||||
return;
|
||||
}
|
||||
const WId windowId = params->getWindowId();
|
||||
if (g_helper()->windowIds.contains(windowId)) {
|
||||
return;
|
||||
}
|
||||
g_helper()->windowIds.append(windowId);
|
||||
static const bool pureQt = usePureQtImplementation();
|
||||
if (pureQt) {
|
||||
FramelessHelperQt::addWindow(params);
|
||||
}
|
||||
#ifdef Q_OS_WINDOWS
|
||||
if (!pureQt) {
|
||||
FramelessHelperWin::addWindow(params);
|
||||
}
|
||||
Utils::installSystemMenuHook(windowId, params);
|
||||
#endif
|
||||
connect(params->getWindowHandle(), &QWindow::destroyed, FramelessManager::instance(), [windowId](){ removeWindow(windowId); });
|
||||
}
|
||||
|
||||
void FramelessManagerPrivate::removeWindow(const WId windowId)
|
||||
{
|
||||
Q_ASSERT(windowId);
|
||||
if (!windowId) {
|
||||
return;
|
||||
}
|
||||
if (!g_helper()->windowIds.contains(windowId)) {
|
||||
return;
|
||||
}
|
||||
g_helper()->windowIds.removeAll(windowId);
|
||||
static const bool pureQt = usePureQtImplementation();
|
||||
if (pureQt) {
|
||||
FramelessHelperQt::removeWindow(windowId);
|
||||
}
|
||||
#ifdef Q_OS_WINDOWS
|
||||
if (!pureQt) {
|
||||
FramelessHelperWin::removeWindow(windowId);
|
||||
}
|
||||
Utils::removeSysMenuHook(windowId);
|
||||
Utils::removeMicaWindow(windowId);
|
||||
#endif
|
||||
#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();
|
||||
|
@ -244,17 +221,17 @@ void FramelessManagerPrivate::notifySystemThemeHasChangedOrNot()
|
|||
const DwmColorizationArea currentColorizationArea = Utils::getDwmColorizationArea();
|
||||
#endif
|
||||
bool notify = false;
|
||||
if (m_systemTheme != currentSystemTheme) {
|
||||
m_systemTheme = currentSystemTheme;
|
||||
if (systemTheme != currentSystemTheme) {
|
||||
systemTheme = currentSystemTheme;
|
||||
notify = true;
|
||||
}
|
||||
if (m_accentColor != currentAccentColor) {
|
||||
m_accentColor = currentAccentColor;
|
||||
if (accentColor != currentAccentColor) {
|
||||
accentColor = currentAccentColor;
|
||||
notify = true;
|
||||
}
|
||||
#ifdef Q_OS_WINDOWS
|
||||
if (m_colorizationArea != currentColorizationArea) {
|
||||
m_colorizationArea = currentColorizationArea;
|
||||
if (colorizationArea != currentColorizationArea) {
|
||||
colorizationArea = currentColorizationArea;
|
||||
notify = true;
|
||||
}
|
||||
#endif
|
||||
|
@ -262,87 +239,147 @@ void FramelessManagerPrivate::notifySystemThemeHasChangedOrNot()
|
|||
if (notify && !isThemeOverrided()) {
|
||||
Q_Q(FramelessManager);
|
||||
Q_EMIT q->systemThemeChanged();
|
||||
DEBUG.nospace() << "System theme changed. Current theme: " << m_systemTheme
|
||||
<< ", accent color: " << m_accentColor.name(QColor::HexArgb).toUpper()
|
||||
DEBUG.nospace() << "System theme changed. Current theme: " << systemTheme
|
||||
<< ", accent color: " << accentColor.name(QColor::HexArgb).toUpper()
|
||||
#ifdef Q_OS_WINDOWS
|
||||
<< ", colorization area: " << m_colorizationArea
|
||||
<< ", colorization area: " << colorizationArea
|
||||
#endif
|
||||
<< '.';
|
||||
}
|
||||
}
|
||||
|
||||
void FramelessManagerPrivate::notifyWallpaperHasChangedOrNot()
|
||||
void FramelessManagerPrivate::doNotifyWallpaperHasChangedOrNot()
|
||||
{
|
||||
const QString currentWallpaper = Utils::getWallpaperFilePath();
|
||||
const WallpaperAspectStyle currentWallpaperAspectStyle = Utils::getWallpaperAspectStyle();
|
||||
bool notify = false;
|
||||
if (m_wallpaper != currentWallpaper) {
|
||||
m_wallpaper = currentWallpaper;
|
||||
if (wallpaper != currentWallpaper) {
|
||||
wallpaper = currentWallpaper;
|
||||
notify = true;
|
||||
}
|
||||
if (m_wallpaperAspectStyle != currentWallpaperAspectStyle) {
|
||||
m_wallpaperAspectStyle = currentWallpaperAspectStyle;
|
||||
if (wallpaperAspectStyle != currentWallpaperAspectStyle) {
|
||||
wallpaperAspectStyle = currentWallpaperAspectStyle;
|
||||
notify = true;
|
||||
}
|
||||
if (notify) {
|
||||
Q_Q(FramelessManager);
|
||||
Q_EMIT q->wallpaperChanged();
|
||||
DEBUG.nospace() << "Wallpaper changed. Current wallpaper: " << m_wallpaper
|
||||
<< ", aspect style: " << m_wallpaperAspectStyle << '.';
|
||||
DEBUG.nospace() << "Wallpaper changed. Current wallpaper: " << wallpaper
|
||||
<< ", aspect style: " << wallpaperAspectStyle << '.';
|
||||
}
|
||||
}
|
||||
|
||||
bool FramelessManagerPrivate::usePureQtImplementation()
|
||||
FramelessDataPtr FramelessManagerPrivate::getData(const QObject *window)
|
||||
{
|
||||
static const auto result = []() -> bool {
|
||||
#ifdef Q_OS_WINDOWS
|
||||
return FramelessConfig::instance()->isSet(Option::UseCrossPlatformQtImplementation);
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}();
|
||||
return result;
|
||||
Q_ASSERT(window);
|
||||
Q_ASSERT(window->isWidgetType() || window->isWindowType());
|
||||
if (!window || !(window->isWidgetType() || window->isWindowType())) {
|
||||
return nullptr;
|
||||
}
|
||||
return g_internalData()->dataMap.value(const_cast<QObject *>(window));
|
||||
}
|
||||
|
||||
void FramelessManagerPrivate::setOverrideTheme(const SystemTheme theme)
|
||||
FramelessDataPtr FramelessManagerPrivate::createData(const QObject *window, const WId windowId)
|
||||
{
|
||||
if ((!m_overrideTheme.has_value() && (theme == SystemTheme::Unknown))
|
||||
|| (m_overrideTheme.has_value() && (m_overrideTheme.value() == theme))) {
|
||||
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<QObject *>(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;
|
||||
}
|
||||
if (theme == SystemTheme::Unknown) {
|
||||
m_overrideTheme = std::nullopt;
|
||||
} else {
|
||||
m_overrideTheme = theme;
|
||||
const auto win = const_cast<QObject *>(window);
|
||||
const FramelessDataPtr data = g_internalData()->dataMap.value(win);
|
||||
Q_ASSERT(data);
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
Q_Q(FramelessManager);
|
||||
Q_EMIT q->systemThemeChanged();
|
||||
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 (m_overrideTheme.value_or(SystemTheme::Unknown) != SystemTheme::Unknown);
|
||||
return (overrideTheme.value_or(SystemTheme::Unknown) != SystemTheme::Unknown);
|
||||
}
|
||||
|
||||
void FramelessManagerPrivate::initialize()
|
||||
{
|
||||
m_systemTheme = (Utils::shouldAppsUseDarkMode() ? SystemTheme::Dark : SystemTheme::Light);
|
||||
m_accentColor = Utils::getAccentColor();
|
||||
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
|
||||
m_colorizationArea = Utils::getDwmColorizationArea();
|
||||
colorizationArea = Utils::getDwmColorizationArea();
|
||||
#endif
|
||||
m_wallpaper = Utils::getWallpaperFilePath();
|
||||
m_wallpaperAspectStyle = Utils::getWallpaperAspectStyle();
|
||||
DEBUG.nospace() << "Current system theme: " << m_systemTheme
|
||||
<< ", accent color: " << m_accentColor.name(QColor::HexArgb).toUpper()
|
||||
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: " << m_colorizationArea
|
||||
<< ", colorization area: " << colorizationArea
|
||||
#endif
|
||||
<< ", wallpaper: " << m_wallpaper
|
||||
<< ", aspect style: " << m_wallpaperAspectStyle
|
||||
<< ", wallpaper: " << wallpaper
|
||||
<< ", aspect style: " << wallpaperAspectStyle
|
||||
<< '.';
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
|
||||
QStyleHints * const styleHints = QGuiApplication::styleHints();
|
||||
// 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){
|
||||
|
@ -350,20 +387,21 @@ void FramelessManagerPrivate::initialize()
|
|||
notifySystemThemeHasChangedOrNot();
|
||||
});
|
||||
}
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
|
||||
#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.
|
||||
const int ver = FramelessHelper::Core::version().version;
|
||||
qputenv(kGlobalFlagVarName, QByteArray::number(ver));
|
||||
qApp->setProperty(kGlobalFlagVarName, ver);
|
||||
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(new FramelessManagerPrivate(this))
|
||||
QObject(parent), d_ptr(std::make_unique<FramelessManagerPrivate>(this))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -371,49 +409,126 @@ FramelessManager::~FramelessManager() = default;
|
|||
|
||||
FramelessManager *FramelessManager::instance()
|
||||
{
|
||||
return g_manager();
|
||||
static FramelessManager manager;
|
||||
return &manager;
|
||||
}
|
||||
|
||||
SystemTheme FramelessManager::systemTheme() const
|
||||
{
|
||||
Q_D(const FramelessManager);
|
||||
return d->systemTheme();
|
||||
// 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->systemAccentColor();
|
||||
return d->accentColor;
|
||||
}
|
||||
|
||||
QString FramelessManager::wallpaper() const
|
||||
{
|
||||
Q_D(const FramelessManager);
|
||||
return d->wallpaper();
|
||||
return d->wallpaper;
|
||||
}
|
||||
|
||||
WallpaperAspectStyle FramelessManager::wallpaperAspectStyle() const
|
||||
{
|
||||
Q_D(const FramelessManager);
|
||||
return d->wallpaperAspectStyle();
|
||||
}
|
||||
|
||||
void FramelessManager::addWindow(FramelessParamsConst params)
|
||||
{
|
||||
Q_D(FramelessManager);
|
||||
d->addWindow(params);
|
||||
}
|
||||
|
||||
void FramelessManager::removeWindow(const WId windowId)
|
||||
{
|
||||
Q_D(FramelessManager);
|
||||
d->removeWindow(windowId);
|
||||
return d->wallpaperAspectStyle;
|
||||
}
|
||||
|
||||
void FramelessManager::setOverrideTheme(const SystemTheme theme)
|
||||
{
|
||||
Q_D(FramelessManager);
|
||||
d->setOverrideTheme(theme);
|
||||
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<QObject *>(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<QObject *>(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
|
||||
|
|
|
@ -24,45 +24,45 @@
|
|||
|
||||
#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 <optional>
|
||||
#include <memory>
|
||||
#include <QtCore/qsysinfo.h>
|
||||
#include <QtCore/qloggingcategory.h>
|
||||
#include <QtCore/qmutex.h>
|
||||
#include <QtCore/qthread.h>
|
||||
#if FRAMELESSHELPER_HAS_THREAD
|
||||
# include <QtCore/qmutex.h>
|
||||
#endif
|
||||
#include <QtGui/qpixmap.h>
|
||||
#include <QtGui/qimage.h>
|
||||
#include <QtGui/qimagereader.h>
|
||||
#include <QtGui/qpainter.h>
|
||||
#include <QtGui/qscreen.h>
|
||||
#include <QtGui/qguiapplication.h>
|
||||
#ifndef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#if FRAMELESSHELPER_CONFIG(private_qt)
|
||||
# include <QtGui/private/qmemrotate_p.h>
|
||||
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#endif
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
static Q_LOGGING_CATEGORY(lcMicaMaterial, "wangwenx190.framelesshelper.core.micamaterial")
|
||||
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_DEBUG_OUTPUT
|
||||
# define INFO QT_NO_QDEBUG_MACRO()
|
||||
# define DEBUG QT_NO_QDEBUG_MACRO()
|
||||
# define WARNING QT_NO_QDEBUG_MACRO()
|
||||
# define CRITICAL QT_NO_QDEBUG_MACRO()
|
||||
#else
|
||||
#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
|
||||
|
||||
DECLARE_SIZE_COMPARE_OPERATORS(QSize, QSize)
|
||||
DECLARE_SIZE_COMPARE_OPERATORS(QSizeF, QSizeF)
|
||||
DECLARE_SIZE_COMPARE_OPERATORS(QSize, QSizeF)
|
||||
DECLARE_SIZE_COMPARE_OPERATORS(QSizeF, QSize)
|
||||
|
||||
using namespace Global;
|
||||
|
||||
[[maybe_unused]] static constexpr const QSize kMaximumPictureSize = { 1920, 1080 };
|
||||
|
@ -77,28 +77,18 @@ using namespace Global;
|
|||
[[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
|
||||
|
||||
#ifndef FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
FRAMELESSHELPER_STRING_CONSTANT2(NoiseImageFilePath, ":/org.wangwenx190.FramelessHelper/resources/images/noise.png")
|
||||
#endif // FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
|
||||
struct ImageData
|
||||
{
|
||||
QPixmap blurredWallpaper = {};
|
||||
bool graphicsResourcesReady = false;
|
||||
#if FRAMELESSHELPER_HAS_THREAD
|
||||
QMutex mutex{};
|
||||
};
|
||||
|
||||
struct MetricsData
|
||||
{
|
||||
std::optional<QSize> monitorSize = std::nullopt;
|
||||
std::optional<QSize> wallpaperSize = std::nullopt;
|
||||
QMutex mutex{};
|
||||
#endif
|
||||
};
|
||||
|
||||
Q_GLOBAL_STATIC(ImageData, g_imageData)
|
||||
Q_GLOBAL_STATIC(MetricsData, g_metricsData)
|
||||
|
||||
#ifndef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#if FRAMELESSHELPER_CONFIG(private_qt)
|
||||
template<const int shift>
|
||||
[[nodiscard]] static inline constexpr int qt_static_shift(const int value)
|
||||
{
|
||||
|
@ -159,16 +149,12 @@ static inline void qt_blurrow(QImage &im, const int line, const int alpha)
|
|||
|
||||
int zR = 0, zG = 0, zB = 0, zA = 0;
|
||||
|
||||
#ifdef Q_CC_MSVC
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4127) // false alarm.
|
||||
#endif // Q_CC_MSVC
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_MSVC(4127) // false alarm.
|
||||
if (alphaOnly && (im.format() != QImage::Format_Indexed8)) {
|
||||
bptr += alphaIndex;
|
||||
}
|
||||
#ifdef Q_CC_MSVC
|
||||
# pragma warning(pop)
|
||||
#endif // Q_CC_MSVC
|
||||
QT_WARNING_POP
|
||||
|
||||
const int stride = (im.depth() >> 3);
|
||||
const int im_width = im.width();
|
||||
|
@ -418,8 +404,10 @@ static inline void expblur(QImage &img, qreal radius, const bool improvedQuality
|
|||
|
||||
if (p) {
|
||||
p->save();
|
||||
p->setRenderHints(QPainter::Antialiasing |
|
||||
QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
|
||||
// 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();
|
||||
|
@ -441,7 +429,7 @@ static inline void expblur(QImage &img, qreal radius, const bool improvedQuality
|
|||
expblur<12, 10, false>(blurImage, radius, quality, transposed);
|
||||
}
|
||||
}
|
||||
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#endif
|
||||
|
||||
/*!
|
||||
Transforms an \a alignment of Qt::AlignLeft or Qt::AlignRight
|
||||
|
@ -494,120 +482,118 @@ static inline void expblur(QImage &img, qreal radius, const bool improvedQuality
|
|||
return {x, y, w, h};
|
||||
}
|
||||
|
||||
class WallpaperThread : public QThread
|
||||
WallpaperThread::WallpaperThread(QObject *parent) : FramelessHelperThreadClass(parent)
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(WallpaperThread)
|
||||
}
|
||||
|
||||
public:
|
||||
explicit WallpaperThread(QObject *parent = nullptr) : QThread(parent) {}
|
||||
~WallpaperThread() override = default;
|
||||
WallpaperThread::~WallpaperThread() = default;
|
||||
|
||||
Q_SIGNALS:
|
||||
void imageUpdated(const Transform &);
|
||||
|
||||
protected:
|
||||
void run() override
|
||||
{
|
||||
Transform transform = {};
|
||||
const QSize monitorSize = MicaMaterialPrivate::monitorSize();
|
||||
const QSize imageSize = MicaMaterialPrivate::wallpaperSize();
|
||||
// If we scaled the image size, record the scale factor and we need it to map our clip rect
|
||||
// to the real (unscaled) rect.
|
||||
if (imageSize != monitorSize) {
|
||||
transform.Horizontal = (qreal(imageSize.width()) / qreal(monitorSize.width()));
|
||||
transform.Vertical = (qreal(imageSize.height()) / qreal(monitorSize.height()));
|
||||
}
|
||||
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();
|
||||
QImage buffer(imageSize, kDefaultImageFormat);
|
||||
#ifdef Q_OS_WINDOWS
|
||||
if (aspectStyle == WallpaperAspectStyle::Center) {
|
||||
buffer.fill(kDefaultBlackColor);
|
||||
}
|
||||
#if FRAMELESSHELPER_HAS_THREAD
|
||||
void WallpaperThread::run()
|
||||
#else
|
||||
void WallpaperThread::start()
|
||||
#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(imageSize, mode);
|
||||
image = image.scaled(newSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
static constexpr const QPoint desktopOriginPoint = {0, 0};
|
||||
const QRect desktopRect = {desktopOriginPoint, imageSize};
|
||||
if (aspectStyle == WallpaperAspectStyle::Tile) {
|
||||
QPainter bufferPainter(&buffer);
|
||||
bufferPainter.setRenderHints(QPainter::Antialiasing |
|
||||
QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
|
||||
bufferPainter.fillRect(desktopRect, QBrush(image));
|
||||
} else {
|
||||
QPainter bufferPainter(&buffer);
|
||||
bufferPainter.setRenderHints(QPainter::Antialiasing |
|
||||
QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
|
||||
const QRect rect = alignedRect(Qt::LeftToRight, Qt::AlignCenter, image.size(), desktopRect);
|
||||
bufferPainter.drawImage(rect.topLeft(), image);
|
||||
}
|
||||
{
|
||||
const QMutexLocker locker(&g_imageData()->mutex);
|
||||
g_imageData()->blurredWallpaper = QPixmap(imageSize);
|
||||
g_imageData()->blurredWallpaper.fill(kDefaultTransparentColor);
|
||||
QPainter painter(&g_imageData()->blurredWallpaper);
|
||||
painter.setRenderHints(QPainter::Antialiasing |
|
||||
QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
painter.drawImage(desktopOriginPoint, buffer);
|
||||
#else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
qt_blurImage(&painter, buffer, kDefaultBlurRadius, true, false);
|
||||
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
}
|
||||
Q_EMIT imageUpdated(transform);
|
||||
{
|
||||
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<WallpaperThread> 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);
|
||||
|
@ -617,6 +603,7 @@ static inline void threadCleaner()
|
|||
g_threadData()->thread->wait();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
MicaMaterialPrivate::MicaMaterialPrivate(MicaMaterial *q) : QObject(q)
|
||||
{
|
||||
|
@ -650,11 +637,16 @@ const MicaMaterialPrivate *MicaMaterialPrivate::get(const MicaMaterial *q)
|
|||
|
||||
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()) {
|
||||
|
@ -663,26 +655,31 @@ void MicaMaterialPrivate::maybeGenerateBlurredWallpaper(const bool force)
|
|||
g_threadData()->thread->wait();
|
||||
}
|
||||
g_threadData()->thread->start(QThread::LowPriority);
|
||||
#else
|
||||
g_threadData()->thread->start();
|
||||
#endif
|
||||
}
|
||||
|
||||
void MicaMaterialPrivate::updateMaterialBrush()
|
||||
{
|
||||
#ifndef FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
framelesshelpercore_initResource();
|
||||
static const QImage noiseTexture = QImage(kNoiseImageFilePath);
|
||||
#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);
|
||||
painter.setRenderHints(QPainter::Antialiasing |
|
||||
QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
|
||||
// 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);
|
||||
#ifndef FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
#if FRAMELESSHELPER_CONFIG(bundle_resource)
|
||||
painter.fillRect(rect, QBrush(noiseTexture));
|
||||
#endif // FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
micaBrush = QBrush(micaTexture);
|
||||
|
@ -692,60 +689,34 @@ void MicaMaterialPrivate::updateMaterialBrush()
|
|||
}
|
||||
}
|
||||
|
||||
void MicaMaterialPrivate::paint(QPainter *painter, const QRect &rect, const bool active)
|
||||
{
|
||||
Q_ASSERT(painter);
|
||||
if (!painter) {
|
||||
return;
|
||||
}
|
||||
prepareGraphicsResources();
|
||||
static constexpr const QPoint originPoint = {0, 0};
|
||||
const QRect mappedRect = mapToWallpaper(rect);
|
||||
painter->save();
|
||||
painter->setRenderHints(QPainter::Antialiasing |
|
||||
QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
|
||||
if (active) {
|
||||
const QMutexLocker locker(&g_imageData()->mutex);
|
||||
painter->drawPixmap(originPoint, g_imageData()->blurredWallpaper, mappedRect);
|
||||
}
|
||||
painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
|
||||
painter->setOpacity(qreal(1));
|
||||
painter->fillRect(QRect{originPoint, mappedRect.size()}, [this, active]() -> QBrush {
|
||||
if (!fallbackEnabled || active) {
|
||||
return micaBrush;
|
||||
}
|
||||
if (fallbackColor.isValid()) {
|
||||
return fallbackColor;
|
||||
}
|
||||
return systemFallbackColor();
|
||||
}());
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void MicaMaterialPrivate::forceRebuildWallpaper()
|
||||
{
|
||||
g_metricsData()->mutex.lock();
|
||||
g_metricsData()->monitorSize = std::nullopt;
|
||||
g_metricsData()->wallpaperSize = std::nullopt;
|
||||
g_metricsData()->mutex.unlock();
|
||||
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<WallpaperThread>();
|
||||
#if FRAMELESSHELPER_HAS_THREAD
|
||||
qAddPostRoutine(threadCleaner);
|
||||
#endif
|
||||
}
|
||||
connect(g_threadData()->thread.get(), &WallpaperThread::imageUpdated, this, [this](const Transform &t){
|
||||
transform = t;
|
||||
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;
|
||||
|
@ -771,13 +742,19 @@ void MicaMaterialPrivate::initialize()
|
|||
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -786,76 +763,24 @@ QColor MicaMaterialPrivate::systemFallbackColor()
|
|||
return ((FramelessManager::instance()->systemTheme() == SystemTheme::Dark) ? kDefaultFallbackColorDark : kDefaultFallbackColorLight);
|
||||
}
|
||||
|
||||
QSize MicaMaterialPrivate::monitorSize()
|
||||
{
|
||||
g_metricsData()->mutex.lock();
|
||||
if (!g_metricsData()->monitorSize.has_value()) {
|
||||
g_metricsData()->mutex.unlock();
|
||||
const QScreen * const monitor = QGuiApplication::primaryScreen();
|
||||
Q_ASSERT(monitor);
|
||||
// We do not use the virtual desktop size here, instead, we only calculate the primary
|
||||
// monitor size to simplify the logic, otherwise we will need a lot more code to take
|
||||
// every case into account.
|
||||
QSize size = (monitor ? monitor->size() : kMaximumPictureSize);
|
||||
if (Q_UNLIKELY(size.isEmpty())) {
|
||||
WARNING << "Failed to retrieve the monitor size. Using default size (1920x1080) instead ...";
|
||||
size = kMaximumPictureSize;
|
||||
}
|
||||
g_metricsData()->mutex.lock();
|
||||
g_metricsData()->monitorSize = size;
|
||||
// Don't unlock the mutex here, we'll unlock it from outside.
|
||||
DEBUG << "Primary monitor size:" << size * (monitor ? monitor->devicePixelRatio() : qreal(1));
|
||||
}
|
||||
const QSize result = g_metricsData()->monitorSize.value();
|
||||
g_metricsData()->mutex.unlock();
|
||||
return result;
|
||||
}
|
||||
|
||||
QSize MicaMaterialPrivate::wallpaperSize()
|
||||
{
|
||||
g_metricsData()->mutex.lock();
|
||||
if (!g_metricsData()->wallpaperSize.has_value()) {
|
||||
g_metricsData()->mutex.unlock();
|
||||
const QSize desktopSize = monitorSize();
|
||||
// It's observed that QImage consumes too much memory if the image resolution is very large.
|
||||
const QSize size = (desktopSize > kMaximumPictureSize ? kMaximumPictureSize : desktopSize);
|
||||
g_metricsData()->mutex.lock();
|
||||
g_metricsData()->wallpaperSize = size;
|
||||
// Don't unlock the mutex here, we'll unlock it from outside.
|
||||
DEBUG << "Wallpaper size:" << size;
|
||||
}
|
||||
const QSize result = g_metricsData()->wallpaperSize.value();
|
||||
g_metricsData()->mutex.unlock();
|
||||
return result;
|
||||
}
|
||||
|
||||
QPoint MicaMaterialPrivate::mapToWallpaper(const QPoint &pos) const
|
||||
{
|
||||
if (pos.isNull()) {
|
||||
return {};
|
||||
}
|
||||
QPointF result = pos;
|
||||
if (!qFuzzyIsNull(transform.Horizontal) && (transform.Horizontal > qreal(0))
|
||||
&& !qFuzzyCompare(transform.Horizontal, qreal(1))) {
|
||||
result.setX(result.x() * transform.Horizontal);
|
||||
}
|
||||
if (!qFuzzyIsNull(transform.Vertical) && (transform.Vertical > qreal(0))
|
||||
&& !qFuzzyCompare(transform.Vertical, qreal(1))) {
|
||||
result.setY(result.y() * transform.Vertical);
|
||||
}
|
||||
const QSizeF imageSize = wallpaperSize();
|
||||
// Make sure the position is always inside the wallpaper rectangle.
|
||||
while (result.x() < qreal(0)) {
|
||||
result.setX(result.x() + imageSize.width());
|
||||
result.setX(result.x() + wallpaperSize.width());
|
||||
}
|
||||
while (result.x() > imageSize.width()) {
|
||||
result.setX(result.x() - imageSize.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() + imageSize.height());
|
||||
result.setY(result.y() + wallpaperSize.height());
|
||||
}
|
||||
while (result.y() > imageSize.height()) {
|
||||
result.setY(result.y() - imageSize.height());
|
||||
while ((result.y() > wallpaperSize.height()) || qFuzzyCompare(result.y(), wallpaperSize.height())) {
|
||||
result.setY(result.y() - wallpaperSize.height());
|
||||
}
|
||||
return result.toPoint();
|
||||
}
|
||||
|
@ -866,45 +791,29 @@ QSize MicaMaterialPrivate::mapToWallpaper(const QSize &size) const
|
|||
return {};
|
||||
}
|
||||
QSizeF result = size;
|
||||
if (!qFuzzyIsNull(transform.Horizontal) && (transform.Horizontal > qreal(0))
|
||||
&& !qFuzzyCompare(transform.Horizontal, qreal(1))) {
|
||||
result.setWidth(result.width() * transform.Horizontal);
|
||||
}
|
||||
if (!qFuzzyIsNull(transform.Vertical) && (transform.Vertical > qreal(0))
|
||||
&& !qFuzzyCompare(transform.Vertical, qreal(1))) {
|
||||
result.setHeight(result.height() * transform.Vertical);
|
||||
}
|
||||
const QSizeF imageSize = wallpaperSize();
|
||||
// Make sure we don't get a size larger than the wallpaper's size.
|
||||
if (result.width() > imageSize.width()) {
|
||||
result.setWidth(imageSize.width());
|
||||
if (result.width() > wallpaperSize.width()) {
|
||||
result.setWidth(wallpaperSize.width());
|
||||
}
|
||||
if (result.height() > imageSize.height()) {
|
||||
result.setHeight(imageSize.height());
|
||||
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 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();
|
||||
}
|
||||
// Make sure we don't get something outside of the wallpaper area.
|
||||
const QRectF intersectedRect = wallpaperRect.intersected(mappedRect);
|
||||
// OK, the two rectangles are not intersected, just draw the whole wallpaper.
|
||||
if (!Utils::isValidGeometry(intersectedRect)) {
|
||||
WARNING << "The mapped rectangle and the wallpaper rectangle are not intersected.";
|
||||
return wallpaperRect.toRect();
|
||||
}
|
||||
return intersectedRect.toRect();
|
||||
return mappedRect.toRect();
|
||||
}
|
||||
|
||||
MicaMaterial::MicaMaterial(QObject *parent)
|
||||
: QObject(parent), d_ptr(new MicaMaterialPrivate(this))
|
||||
: QObject(parent), d_ptr(std::make_unique<MicaMaterialPrivate>(this))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1010,10 +919,81 @@ void MicaMaterial::setFallbackEnabled(const bool value)
|
|||
|
||||
void MicaMaterial::paint(QPainter *painter, const QRect &rect, const bool active)
|
||||
{
|
||||
Q_ASSERT(painter);
|
||||
if (!painter) {
|
||||
return;
|
||||
}
|
||||
Q_D(MicaMaterial);
|
||||
d->paint(painter, rect, active);
|
||||
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
|
||||
|
||||
#include "micamaterial.moc"
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
#include "framelesshelper_linux.h"
|
||||
#include "sysapiloader_p.h"
|
||||
|
||||
|
@ -509,3 +511,5 @@ QString gtkSettings(const gchar *property)
|
|||
return result;
|
||||
}
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif // __linux__
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#if (defined(WIN32) || defined(_WIN32))
|
||||
|
||||
#include "sysapiloader_p.h"
|
||||
#include "winverhelper_p.h"
|
||||
#include "framelesshelper_windows.h"
|
||||
|
@ -48,11 +50,11 @@ _GetWindowCompositionAttribute(const HWND hWnd, PWINDOWCOMPOSITIONATTRIBDATA pvD
|
|||
Q_ASSERT(hWnd);
|
||||
Q_ASSERT(pvData);
|
||||
if (!hWnd || !pvData) {
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
::SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
if (!API_USER_AVAILABLE(GetWindowCompositionAttribute)) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
return API_CALL_FUNCTION4(user32, GetWindowCompositionAttribute, hWnd, pvData);
|
||||
|
@ -64,11 +66,11 @@ _SetWindowCompositionAttribute(const HWND hWnd, PWINDOWCOMPOSITIONATTRIBDATA pvD
|
|||
Q_ASSERT(hWnd);
|
||||
Q_ASSERT(pvData);
|
||||
if (!hWnd || !pvData) {
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
::SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
if (!API_USER_AVAILABLE(SetWindowCompositionAttribute)) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
return API_CALL_FUNCTION4(user32, SetWindowCompositionAttribute, hWnd, pvData);
|
||||
|
@ -109,14 +111,14 @@ _ShouldAppsUseDarkMode(VOID)
|
|||
{
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
static const auto pShouldAppsUseDarkMode
|
||||
= reinterpret_cast<ShouldAppsUseDarkModePtr>(
|
||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(132)));
|
||||
if (!pShouldAppsUseDarkMode) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
return pShouldAppsUseDarkMode();
|
||||
|
@ -127,19 +129,19 @@ _AllowDarkModeForWindow(const HWND hWnd, const BOOL bAllow)
|
|||
{
|
||||
Q_ASSERT(hWnd);
|
||||
if (!hWnd) {
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
::SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
static const auto pAllowDarkModeForWindow
|
||||
= reinterpret_cast<AllowDarkModeForWindowPtr>(
|
||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(133)));
|
||||
if (!pAllowDarkModeForWindow) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
return pAllowDarkModeForWindow(hWnd, bAllow);
|
||||
|
@ -150,14 +152,14 @@ _AllowDarkModeForApp(const BOOL bAllow)
|
|||
{
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
static const auto pAllowDarkModeForApp
|
||||
= reinterpret_cast<AllowDarkModeForAppPtr>(
|
||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(135)));
|
||||
if (!pAllowDarkModeForApp) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
return pAllowDarkModeForApp(bAllow);
|
||||
|
@ -168,14 +170,14 @@ _FlushMenuThemes(VOID)
|
|||
{
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return;
|
||||
}
|
||||
static const auto pFlushMenuThemes
|
||||
= reinterpret_cast<FlushMenuThemesPtr>(
|
||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(136)));
|
||||
if (!pFlushMenuThemes) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return;
|
||||
}
|
||||
pFlushMenuThemes();
|
||||
|
@ -186,14 +188,14 @@ _RefreshImmersiveColorPolicyState(VOID)
|
|||
{
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return;
|
||||
}
|
||||
static const auto pRefreshImmersiveColorPolicyState
|
||||
= reinterpret_cast<RefreshImmersiveColorPolicyStatePtr>(
|
||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(104)));
|
||||
if (!pRefreshImmersiveColorPolicyState) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return;
|
||||
}
|
||||
pRefreshImmersiveColorPolicyState();
|
||||
|
@ -204,19 +206,19 @@ _IsDarkModeAllowedForWindow(const HWND hWnd)
|
|||
{
|
||||
Q_ASSERT(hWnd);
|
||||
if (!hWnd) {
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
::SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
static const auto pIsDarkModeAllowedForWindow
|
||||
= reinterpret_cast<IsDarkModeAllowedForWindowPtr>(
|
||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(137)));
|
||||
if (!pIsDarkModeAllowedForWindow) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
return pIsDarkModeAllowedForWindow(hWnd);
|
||||
|
@ -227,14 +229,14 @@ _GetIsImmersiveColorUsingHighContrast(const IMMERSIVE_HC_CACHE_MODE mode)
|
|||
{
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
static const auto pGetIsImmersiveColorUsingHighContrast
|
||||
= reinterpret_cast<GetIsImmersiveColorUsingHighContrastPtr>(
|
||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(106)));
|
||||
if (!pGetIsImmersiveColorUsingHighContrast) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
return pGetIsImmersiveColorUsingHighContrast(mode);
|
||||
|
@ -246,19 +248,19 @@ _OpenNcThemeData(const HWND hWnd, LPCWSTR pszClassList)
|
|||
Q_ASSERT(hWnd);
|
||||
Q_ASSERT(pszClassList);
|
||||
if (!hWnd || !pszClassList) {
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
::SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return nullptr;
|
||||
}
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return nullptr;
|
||||
}
|
||||
static const auto pOpenNcThemeData
|
||||
= reinterpret_cast<OpenNcThemeDataPtr>(
|
||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(49)));
|
||||
if (!pOpenNcThemeData) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return nullptr;
|
||||
}
|
||||
return pOpenNcThemeData(hWnd, pszClassList);
|
||||
|
@ -269,14 +271,14 @@ _ShouldSystemUseDarkMode(VOID)
|
|||
{
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
static const auto pShouldSystemUseDarkMode
|
||||
= reinterpret_cast<ShouldSystemUseDarkModePtr>(
|
||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(138)));
|
||||
if (!pShouldSystemUseDarkMode) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
return pShouldSystemUseDarkMode();
|
||||
|
@ -287,14 +289,14 @@ _SetPreferredAppMode(const PREFERRED_APP_MODE mode)
|
|||
{
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return PAM_MAX;
|
||||
}
|
||||
static const auto pSetPreferredAppMode
|
||||
= reinterpret_cast<SetPreferredAppModePtr>(
|
||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(135)));
|
||||
if (!pSetPreferredAppMode) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return PAM_MAX;
|
||||
}
|
||||
return pSetPreferredAppMode(mode);
|
||||
|
@ -305,14 +307,14 @@ _IsDarkModeAllowedForApp(VOID)
|
|||
{
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
static const auto pIsDarkModeAllowedForApp
|
||||
= reinterpret_cast<IsDarkModeAllowedForAppPtr>(
|
||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(139)));
|
||||
if (!pIsDarkModeAllowedForApp) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
return pIsDarkModeAllowedForApp();
|
||||
|
@ -323,12 +325,12 @@ _EnableChildWindowDpiMessage2(const HWND hWnd, const BOOL fEnable)
|
|||
{
|
||||
Q_ASSERT(hWnd);
|
||||
if (!hWnd) {
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
::SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
using EnableChildWindowDpiMessagePtr = decltype(&::_EnableChildWindowDpiMessage);
|
||||
|
@ -353,7 +355,7 @@ _EnableChildWindowDpiMessage2(const HWND hWnd, const BOOL fEnable)
|
|||
return nullptr;
|
||||
}();
|
||||
if (!pEnableChildWindowDpiMessage) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
return pEnableChildWindowDpiMessage(hWnd, fEnable);
|
||||
|
@ -364,7 +366,7 @@ _EnablePerMonitorDialogScaling2(VOID)
|
|||
{
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
using EnablePerMonitorDialogScalingPtr = decltype(&::_EnablePerMonitorDialogScaling);
|
||||
|
@ -383,7 +385,7 @@ _EnablePerMonitorDialogScaling2(VOID)
|
|||
return nullptr;
|
||||
}();
|
||||
if (!pEnablePerMonitorDialogScaling) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
return pEnablePerMonitorDialogScaling();
|
||||
|
@ -394,12 +396,12 @@ _GetDpiForWindow2(const HWND hWnd)
|
|||
{
|
||||
Q_ASSERT(hWnd);
|
||||
if (!hWnd) {
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
::SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
using GetDpiForWindowPtr = decltype(&::_GetDpiForWindow);
|
||||
|
@ -422,7 +424,7 @@ _GetDpiForWindow2(const HWND hWnd)
|
|||
return nullptr;
|
||||
}();
|
||||
if (!pGetDpiForWindow) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
return pGetDpiForWindow(hWnd);
|
||||
|
@ -434,12 +436,12 @@ _GetSystemMetricsForDpi2(const int nIndex, const UINT dpi)
|
|||
Q_ASSERT(nIndex >= 0);
|
||||
Q_ASSERT(dpi != 0);
|
||||
if ((nIndex < 0) || (dpi == 0)) {
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
::SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
using GetSystemMetricsForDpiPtr = decltype(&::_GetSystemMetricsForDpi);
|
||||
|
@ -458,7 +460,7 @@ _GetSystemMetricsForDpi2(const int nIndex, const UINT dpi)
|
|||
return nullptr;
|
||||
}();
|
||||
if (!pGetSystemMetricsForDpi) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
return pGetSystemMetricsForDpi(nIndex, dpi);
|
||||
|
@ -471,12 +473,12 @@ _AdjustWindowRectExForDpi2(LPRECT lpRect, const DWORD dwStyle,
|
|||
Q_ASSERT(lpRect);
|
||||
Q_ASSERT(dpi != 0);
|
||||
if (!lpRect || (dpi == 0)) {
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
::SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
using AdjustWindowRectExForDpiPtr = decltype(&::_AdjustWindowRectExForDpi);
|
||||
|
@ -494,8 +496,10 @@ _AdjustWindowRectExForDpi2(LPRECT lpRect, const DWORD dwStyle,
|
|||
return nullptr;
|
||||
}();
|
||||
if (!pAdjustWindowRectExForDpi) {
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
return pAdjustWindowRectExForDpi(lpRect, dwStyle, bMenu, dwExStyle, dpi);
|
||||
}
|
||||
|
||||
#endif // Q_OS_WINDOWS
|
||||
|
|
|
@ -23,7 +23,11 @@
|
|||
*/
|
||||
|
||||
#include "registrykey_p.h"
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
|
||||
#include "framelesshelper_windows.h"
|
||||
#include <array>
|
||||
#include <QtCore/qloggingcategory.h>
|
||||
#if REGISTRYKEY_QWINREGISTRYKEY
|
||||
# include <QtCore/private/qwinregistry_p.h>
|
||||
|
@ -33,49 +37,50 @@
|
|||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(debug_output)
|
||||
[[maybe_unused]] static Q_LOGGING_CATEGORY(lcCoreRegistryKey, "wangwenx190.framelesshelper.core.registrykey")
|
||||
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_DEBUG_OUTPUT
|
||||
# define INFO QT_NO_QDEBUG_MACRO()
|
||||
# define DEBUG QT_NO_QDEBUG_MACRO()
|
||||
# define WARNING QT_NO_QDEBUG_MACRO()
|
||||
# define CRITICAL QT_NO_QDEBUG_MACRO()
|
||||
#else
|
||||
# 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 const HKEY g_keyMap[] = {
|
||||
HKEY_CLASSES_ROOT,
|
||||
HKEY_CURRENT_USER,
|
||||
HKEY_LOCAL_MACHINE,
|
||||
HKEY_USERS,
|
||||
HKEY_PERFORMANCE_DATA,
|
||||
HKEY_CURRENT_CONFIG,
|
||||
HKEY_DYN_DATA,
|
||||
HKEY_CURRENT_USER_LOCAL_SETTINGS,
|
||||
HKEY_PERFORMANCE_TEXT,
|
||||
HKEY_PERFORMANCE_NLSTEXT
|
||||
static constexpr const std::array<ULONG_PTR, 10> 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_assert(std::size(g_keyMap) == (static_cast<int>(RegistryRootKey::PerformanceNlsText) + 1));
|
||||
static constexpr const auto registryKeyCount = std::size(g_registryKeyMap);
|
||||
static_assert(registryKeyCount == (static_cast<quint8>(RegistryRootKey::PerformanceNlsText) + 1));
|
||||
|
||||
static const QString g_strMap[] = {
|
||||
FRAMELESSHELPER_STRING_LITERAL("HKEY_CLASSES_ROOT"),
|
||||
FRAMELESSHELPER_STRING_LITERAL("HKEY_CURRENT_USER"),
|
||||
FRAMELESSHELPER_STRING_LITERAL("HKEY_LOCAL_MACHINE"),
|
||||
FRAMELESSHELPER_STRING_LITERAL("HKEY_USERS"),
|
||||
FRAMELESSHELPER_STRING_LITERAL("HKEY_PERFORMANCE_DATA"),
|
||||
FRAMELESSHELPER_STRING_LITERAL("HKEY_CURRENT_CONFIG"),
|
||||
FRAMELESSHELPER_STRING_LITERAL("HKEY_DYN_DATA"),
|
||||
FRAMELESSHELPER_STRING_LITERAL("HKEY_CURRENT_USER_LOCAL_SETTINGS"),
|
||||
FRAMELESSHELPER_STRING_LITERAL("HKEY_PERFORMANCE_TEXT"),
|
||||
FRAMELESSHELPER_STRING_LITERAL("HKEY_PERFORMANCE_NLSTEXT")
|
||||
[[maybe_unused]] static Q_STRING_CONSTEXPR const std::array<FRAMELESSHELPER_STRING_TYPE, registryKeyCount> 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")
|
||||
};
|
||||
static_assert(std::size(g_strMap) == std::size(g_keyMap));
|
||||
|
||||
RegistryKey::RegistryKey(const RegistryRootKey root, const QString &key, QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
@ -86,14 +91,14 @@ RegistryKey::RegistryKey(const RegistryRootKey root, const QString &key, QObject
|
|||
m_rootKey = root;
|
||||
m_subKey = key;
|
||||
#if REGISTRYKEY_QWINREGISTRYKEY
|
||||
m_registryKey.reset(new QWinRegistryKey(g_keyMap[static_cast<int>(m_rootKey)], m_subKey));
|
||||
m_registryKey = std::make_unique<QWinRegistryKey>(reinterpret_cast<HKEY>(g_registryKeyMap.at(static_cast<quint8>(m_rootKey))), m_subKey);
|
||||
if (!m_registryKey->isValid()) {
|
||||
m_registryKey.reset();
|
||||
}
|
||||
#else
|
||||
const QString rootKey = g_strMap[static_cast<int>(m_rootKey)];
|
||||
const QString rootKey = g_registryStrMap.at(static_cast<quint8>(m_rootKey));
|
||||
const auto lastSlashPos = m_subKey.lastIndexOf(u'\\');
|
||||
m_settings.reset(new QSettings(rootKey + u'\\' + m_subKey.left(lastSlashPos), QSettings::NativeFormat));
|
||||
m_settings = std::make_unique<QSettings>(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 {
|
||||
|
@ -117,9 +122,9 @@ QString RegistryKey::subKey() const
|
|||
bool RegistryKey::isValid() const
|
||||
{
|
||||
#if REGISTRYKEY_QWINREGISTRYKEY
|
||||
return (!m_registryKey.isNull() && m_registryKey->isValid());
|
||||
return (m_registryKey && m_registryKey->isValid());
|
||||
#else
|
||||
return !m_settings.isNull();
|
||||
return m_settings;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -150,3 +155,5 @@ QVariant RegistryKey::value(const QString &name) const
|
|||
}
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif // Q_OS_WINDOWS
|
||||
|
|
|
@ -57,30 +57,30 @@
|
|||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
static Q_LOGGING_CATEGORY(lcSysApiLoader, "wangwenx190.framelesshelper.core.sysapiloader")
|
||||
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_DEBUG_OUTPUT
|
||||
# define INFO QT_NO_QDEBUG_MACRO()
|
||||
# define DEBUG QT_NO_QDEBUG_MACRO()
|
||||
# define WARNING QT_NO_QDEBUG_MACRO()
|
||||
# define CRITICAL QT_NO_QDEBUG_MACRO()
|
||||
#else
|
||||
#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
|
||||
|
||||
struct SysApiLoaderData
|
||||
using SysApiLoaderData = QHash<QString, QFunctionPointer>;
|
||||
|
||||
Q_GLOBAL_STATIC(SysApiLoaderData, g_sysApiLoaderData)
|
||||
|
||||
#if FRAMELESSHELPER_CONFIG(debug_output)
|
||||
[[nodiscard]] static inline bool isDebug()
|
||||
{
|
||||
QHash<QString, QFunctionPointer> functionCache = {};
|
||||
};
|
||||
|
||||
Q_GLOBAL_STATIC(SysApiLoaderData, g_loaderData)
|
||||
|
||||
Q_GLOBAL_STATIC(SysApiLoader, g_sysApiLoader)
|
||||
|
||||
static const bool LoaderDebugFlag = qEnvironmentVariableIntValue("FRAMELESSHELPER_SYSAPILOADER_DEBUG");
|
||||
static const bool flag = (qEnvironmentVariableIntValue("FRAMELESSHELPER_SYSAPILOADER_DEBUG") != 0);
|
||||
return flag;
|
||||
}
|
||||
#endif
|
||||
|
||||
SysApiLoader::SysApiLoader(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
@ -90,7 +90,8 @@ SysApiLoader::~SysApiLoader() = default;
|
|||
|
||||
SysApiLoader *SysApiLoader::instance()
|
||||
{
|
||||
return g_sysApiLoader();
|
||||
static SysApiLoader loader;
|
||||
return &loader;
|
||||
}
|
||||
|
||||
QString SysApiLoader::platformSharedLibrarySuffixName()
|
||||
|
@ -98,12 +99,12 @@ QString SysApiLoader::platformSharedLibrarySuffixName()
|
|||
static const auto result = []() -> QString {
|
||||
#ifdef Q_OS_WINDOWS
|
||||
return FRAMELESSHELPER_STRING_LITERAL(".dll");
|
||||
#elif defined(Q_OS_LINUX)
|
||||
#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!"
|
||||
# error "Unsupported platform!"
|
||||
#endif
|
||||
}();
|
||||
return result;
|
||||
|
@ -114,11 +115,11 @@ QString SysApiLoader::platformSystemLibraryDirectory()
|
|||
static const auto result = []() -> QString {
|
||||
#ifdef Q_OS_WINDOWS
|
||||
QVarLengthArray<wchar_t, MAX_PATH> buf = {};
|
||||
const UINT len = GetSystemDirectoryW(buf.data(), MAX_PATH);
|
||||
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);
|
||||
::GetSystemDirectoryW(buf.data(), len);
|
||||
}
|
||||
return QString::fromWCharArray(buf.constData(), len);
|
||||
#else
|
||||
|
@ -167,16 +168,6 @@ QFunctionPointer SysApiLoader::resolve(const QString &library, const char *funct
|
|||
#endif // SYSAPILOADER_QLIBRARY
|
||||
}
|
||||
|
||||
QFunctionPointer SysApiLoader::resolve(const QString &library, const QByteArray &function)
|
||||
{
|
||||
Q_ASSERT(!library.isEmpty());
|
||||
Q_ASSERT(!function.isEmpty());
|
||||
if (library.isEmpty() || function.isEmpty()) {
|
||||
return nullptr;
|
||||
}
|
||||
return SysApiLoader::resolve(library, function.constData());
|
||||
}
|
||||
|
||||
QFunctionPointer SysApiLoader::resolve(const QString &library, const QString &function)
|
||||
{
|
||||
Q_ASSERT(!library.isEmpty());
|
||||
|
@ -184,7 +175,7 @@ QFunctionPointer SysApiLoader::resolve(const QString &library, const QString &fu
|
|||
if (library.isEmpty() || function.isEmpty()) {
|
||||
return nullptr;
|
||||
}
|
||||
return SysApiLoader::resolve(library, function.toUtf8());
|
||||
return SysApiLoader::resolve(library, function.toUtf8().constData());
|
||||
}
|
||||
|
||||
bool SysApiLoader::isAvailable(const QString &library, const QString &function)
|
||||
|
@ -195,17 +186,22 @@ bool SysApiLoader::isAvailable(const QString &library, const QString &function)
|
|||
return false;
|
||||
}
|
||||
const QString key = generateUniqueKey(library, function);
|
||||
if (g_loaderData()->functionCache.contains(key)) {
|
||||
if (LoaderDebugFlag) {
|
||||
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;
|
||||
}
|
||||
return (g_loaderData()->functionCache.value(key) != nullptr);
|
||||
#endif
|
||||
return (it.value() != nullptr);
|
||||
} else {
|
||||
const QFunctionPointer symbol = SysApiLoader::resolve(library, function);
|
||||
g_loaderData()->functionCache.insert(key, symbol);
|
||||
if (LoaderDebugFlag) {
|
||||
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;
|
||||
|
@ -224,15 +220,20 @@ QFunctionPointer SysApiLoader::get(const QString &library, const QString &functi
|
|||
return nullptr;
|
||||
}
|
||||
const QString key = generateUniqueKey(library, function);
|
||||
if (g_loaderData()->functionCache.contains(key)) {
|
||||
if (LoaderDebugFlag) {
|
||||
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;
|
||||
}
|
||||
return g_loaderData()->functionCache.value(key);
|
||||
#endif
|
||||
return it.value();
|
||||
} else {
|
||||
if (LoaderDebugFlag) {
|
||||
#if FRAMELESSHELPER_CONFIG(debug_output)
|
||||
if (isDebug()) {
|
||||
DEBUG << Q_FUNC_INFO << "Function cache not found:" << key;
|
||||
}
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,62 +24,68 @@
|
|||
|
||||
#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 <array>
|
||||
#include <QtCore/qloggingcategory.h>
|
||||
#include <QtGui/qwindow.h>
|
||||
#include <QtGui/qscreen.h>
|
||||
#include <QtGui/qguiapplication.h>
|
||||
#include <QtGui/qfontmetrics.h>
|
||||
#include <QtGui/qpalette.h>
|
||||
#ifndef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#include <QtGui/qsurface.h>
|
||||
#include <QtGui/qsurfaceformat.h>
|
||||
#if FRAMELESSHELPER_CONFIG(private_qt)
|
||||
# include <QtGui/private/qhighdpiscaling_p.h>
|
||||
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
# include <QtGui/private/qwindow_p.h>
|
||||
#endif // FRAMELESSHELPER_CONFIG(private_qt)
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
|
||||
# include <QtGui/qstylehints.h>
|
||||
#elif ((QT_VERSION >= QT_VERSION_CHECK(6, 2, 1)) && !defined(FRAMELESSHELPER_CORE_NO_PRIVATE))
|
||||
#elif ((QT_VERSION >= QT_VERSION_CHECK(6, 2, 1)) && FRAMELESSHELPER_CONFIG(private_qt))
|
||||
# include <QtGui/qpa/qplatformtheme.h>
|
||||
# include <QtGui/private/qguiapplication_p.h>
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
|
||||
#endif // ((QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)) && FRAMELESSHELPER_CONFIG(private_qt))
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
static Q_LOGGING_CATEGORY(lcUtilsCommon, "wangwenx190.framelesshelper.core.utils.common")
|
||||
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_DEBUG_OUTPUT
|
||||
# define INFO QT_NO_QDEBUG_MACRO()
|
||||
# define DEBUG QT_NO_QDEBUG_MACRO()
|
||||
# define WARNING QT_NO_QDEBUG_MACRO()
|
||||
# define CRITICAL QT_NO_QDEBUG_MACRO()
|
||||
#else
|
||||
#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;
|
||||
|
||||
#ifndef FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
#if FRAMELESSHELPER_CONFIG(bundle_resource)
|
||||
struct FONT_ICON
|
||||
{
|
||||
quint32 SegoeUI = 0;
|
||||
quint32 Fallback = 0;
|
||||
};
|
||||
|
||||
static const QHash<int, FONT_ICON> g_fontIconsTable = {
|
||||
{static_cast<int>(SystemButtonType::Unknown), {0x0000, 0x0000}},
|
||||
{static_cast<int>(SystemButtonType::WindowIcon), {0xE756, 0x0000}},
|
||||
{static_cast<int>(SystemButtonType::Help), {0xE897, 0x0000}},
|
||||
{static_cast<int>(SystemButtonType::Minimize), {0xE921, 0xE93E}},
|
||||
{static_cast<int>(SystemButtonType::Maximize), {0xE922, 0xE93C}},
|
||||
{static_cast<int>(SystemButtonType::Restore), {0xE923, 0xE93D}},
|
||||
{static_cast<int>(SystemButtonType::Close), {0xE8BB, 0xE93B}}
|
||||
static constexpr const std::array<FONT_ICON, static_cast<int>(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_CORE_NO_BUNDLE_RESOURCE
|
||||
#endif // FRAMELESSHELPER_CONFIG(bundle_resource)
|
||||
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#if !FRAMELESSHELPER_CONFIG(private_qt)
|
||||
[[nodiscard]] static inline QPoint getScaleOrigin(const QWindow *window)
|
||||
{
|
||||
Q_ASSERT(window);
|
||||
|
@ -95,7 +101,7 @@ static const QHash<int, FONT_ICON> g_fontIconsTable = {
|
|||
}
|
||||
return screen->geometry().topLeft();
|
||||
}
|
||||
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#endif // !FRAMELESSHELPER_CONFIG(private_qt)
|
||||
|
||||
Qt::CursorShape Utils::calculateCursorShape(const QWindow *window, const QPoint &pos)
|
||||
{
|
||||
|
@ -168,15 +174,8 @@ Qt::Edges Utils::calculateWindowEdges(const QWindow *window, const QPoint &pos)
|
|||
|
||||
QString Utils::getSystemButtonGlyph(const SystemButtonType button)
|
||||
{
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
return {};
|
||||
#else // !FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
const auto index = static_cast<int>(button);
|
||||
if (!g_fontIconsTable.contains(index)) {
|
||||
WARNING << "FIXME: Add FONT_ICON value for button" << button;
|
||||
return {};
|
||||
}
|
||||
const FONT_ICON icon = g_fontIconsTable.value(index);
|
||||
#if FRAMELESSHELPER_CONFIG(bundle_resource)
|
||||
const FONT_ICON &icon = g_fontIconsTable.at(static_cast<int>(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)
|
||||
|
@ -188,7 +187,9 @@ QString Utils::getSystemButtonGlyph(const SystemButtonType button)
|
|||
// 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);
|
||||
#endif // FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||
#else // !FRAMELESSHELPER_CONFIG(bundle_resource)
|
||||
return {};
|
||||
#endif // FRAMELESSHELPER_CONFIG(bundle_resource)
|
||||
}
|
||||
|
||||
QWindow *Utils::findWindow(const WId windowId)
|
||||
|
@ -211,29 +212,38 @@ QWindow *Utils::findWindow(const WId windowId)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void Utils::moveWindowToDesktopCenter(FramelessParamsConst params, const bool considerTaskBar)
|
||||
bool Utils::moveWindowToDesktopCenter(const WId windowId, const bool considerTaskBar)
|
||||
{
|
||||
Q_ASSERT(params);
|
||||
if (!params) {
|
||||
return;
|
||||
Q_ASSERT(windowId);
|
||||
if (!windowId) {
|
||||
return false;
|
||||
}
|
||||
const QSize windowSize = params->getWindowSize();
|
||||
if (windowSize.isEmpty() || (windowSize == kDefaultWindowSize)) {
|
||||
return;
|
||||
const QObject *window = FramelessManagerPrivate::getWindow(windowId);
|
||||
if (!window) {
|
||||
return false;
|
||||
}
|
||||
const QScreen *screen = params->getWindowScreen();
|
||||
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;
|
||||
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()) / 2.0);
|
||||
const int newY = std::round(qreal(screenSize.height() - windowSize.height()) / 2.0);
|
||||
params->setWindowPosition(QPoint(newX + offset.x(), newY + offset.y()));
|
||||
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)
|
||||
|
@ -269,40 +279,43 @@ QColor Utils::calculateSystemButtonBackgroundColor(const SystemButtonType button
|
|||
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);
|
||||
const auto result = [isClose, isTitleColor]() -> QColor {
|
||||
auto result = [isDark, isClose, isTitleColor]() -> QColor {
|
||||
if (isClose) {
|
||||
return kDefaultSystemCloseButtonBackgroundColor;
|
||||
}
|
||||
if (isTitleColor) {
|
||||
return getAccentColor();
|
||||
return calculateForegroundColor(getAccentColor());
|
||||
}
|
||||
return kDefaultSystemButtonBackgroundColor;
|
||||
return (isDark ? kDefaultWhiteColor : kDefaultBlackColor);
|
||||
}();
|
||||
if (isClose) {
|
||||
return (isHovered ? result.lighter(110) : result.lighter(140));
|
||||
}
|
||||
if (!isTitleColor) {
|
||||
return (isHovered ? result.lighter(110) : result);
|
||||
if (isHovered) {
|
||||
result.setAlpha(12);
|
||||
} else {
|
||||
result.setAlpha(6);
|
||||
}
|
||||
return (isHovered ? result.lighter(150) : result.lighter(120));
|
||||
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)) && !defined(FRAMELESSHELPER_CORE_NO_PRIVATE))
|
||||
#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_CORE_NO_PRIVATE)
|
||||
#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)
|
||||
# elif (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
||||
return shouldAppsUseDarkMode_linux();
|
||||
# elif defined(Q_OS_MACOS)
|
||||
return shouldAppsUseDarkMode_macos();
|
||||
|
@ -315,11 +328,11 @@ bool Utils::shouldAppsUseDarkMode()
|
|||
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 > 1) || qFuzzyCompare(factor, qreal(1)));
|
||||
if (factor < 1) {
|
||||
return 1;
|
||||
Q_ASSERT((factor > qreal(1)) || qFuzzyCompare(factor, qreal(1)));
|
||||
if (factor < qreal(1)) {
|
||||
return qreal(1);
|
||||
}
|
||||
#if (defined(FRAMELESSHELPER_CORE_NO_PRIVATE) || (QT_VERSION < QT_VERSION_CHECK(6, 2, 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) {
|
||||
|
@ -343,9 +356,9 @@ qreal Utils::roundScaleFactor(const qreal factor)
|
|||
# else // (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
|
||||
return std::round(factor);
|
||||
# endif // (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
#else // (!FRAMELESSHELPER_CORE_NO_PRIVATE && (QT_VERSION >= QT_VERSION_CHECK(6, 2, 1)))
|
||||
#else // (FRAMELESSHELPER_CONFIG(private_qt) && (QT_VERSION >= QT_VERSION_CHECK(6, 2, 1)))
|
||||
return QHighDpiScaling::roundScaleFactor(factor);
|
||||
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#endif
|
||||
}
|
||||
|
||||
int Utils::toNativePixels(const QWindow *window, const int value)
|
||||
|
@ -354,11 +367,11 @@ int Utils::toNativePixels(const QWindow *window, const int value)
|
|||
if (!window) {
|
||||
return 0;
|
||||
}
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
return std::round(qreal(value) * window->devicePixelRatio());
|
||||
#else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#if FRAMELESSHELPER_CONFIG(private_qt)
|
||||
return QHighDpi::toNativePixels(value, window);
|
||||
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#else
|
||||
return std::round(qreal(value) * window->devicePixelRatio());
|
||||
#endif
|
||||
}
|
||||
|
||||
QPoint Utils::toNativePixels(const QWindow *window, const QPoint &point)
|
||||
|
@ -367,12 +380,12 @@ QPoint Utils::toNativePixels(const QWindow *window, const QPoint &point)
|
|||
if (!window) {
|
||||
return {};
|
||||
}
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#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;
|
||||
#else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
return QHighDpi::toNativePixels(point, window);
|
||||
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#endif
|
||||
}
|
||||
|
||||
QSize Utils::toNativePixels(const QWindow *window, const QSize &size)
|
||||
|
@ -381,11 +394,11 @@ QSize Utils::toNativePixels(const QWindow *window, const QSize &size)
|
|||
if (!window) {
|
||||
return {};
|
||||
}
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
return QSizeF(QSizeF(size) * window->devicePixelRatio()).toSize();
|
||||
#else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#if FRAMELESSHELPER_CONFIG(private_qt)
|
||||
return QHighDpi::toNativePixels(size, window);
|
||||
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#else
|
||||
return QSizeF(QSizeF(size) * window->devicePixelRatio()).toSize();
|
||||
#endif
|
||||
}
|
||||
|
||||
QRect Utils::toNativePixels(const QWindow *window, const QRect &rect)
|
||||
|
@ -394,11 +407,11 @@ QRect Utils::toNativePixels(const QWindow *window, const QRect &rect)
|
|||
if (!window) {
|
||||
return {};
|
||||
}
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
return QRect(toNativePixels(window, rect.topLeft()), toNativePixels(window, rect.size()));
|
||||
#else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#if FRAMELESSHELPER_CONFIG(private_qt)
|
||||
return QHighDpi::toNativePixels(rect, window);
|
||||
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#else
|
||||
return QRect(toNativePixels(window, rect.topLeft()), toNativePixels(window, rect.size()));
|
||||
#endif
|
||||
}
|
||||
|
||||
int Utils::fromNativePixels(const QWindow *window, const int value)
|
||||
|
@ -407,11 +420,11 @@ int Utils::fromNativePixels(const QWindow *window, const int value)
|
|||
if (!window) {
|
||||
return 0;
|
||||
}
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
return std::round(qreal(value) / window->devicePixelRatio());
|
||||
#else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#if FRAMELESSHELPER_CONFIG(private_qt)
|
||||
return QHighDpi::fromNativePixels(value, window);
|
||||
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#else
|
||||
return std::round(qreal(value) / window->devicePixelRatio());
|
||||
#endif
|
||||
}
|
||||
|
||||
QPoint Utils::fromNativePixels(const QWindow *window, const QPoint &point)
|
||||
|
@ -420,12 +433,12 @@ QPoint Utils::fromNativePixels(const QWindow *window, const QPoint &point)
|
|||
if (!window) {
|
||||
return {};
|
||||
}
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#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;
|
||||
#else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
return QHighDpi::fromNativePixels(point, window);
|
||||
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#endif
|
||||
}
|
||||
|
||||
QSize Utils::fromNativePixels(const QWindow *window, const QSize &size)
|
||||
|
@ -434,11 +447,11 @@ QSize Utils::fromNativePixels(const QWindow *window, const QSize &size)
|
|||
if (!window) {
|
||||
return {};
|
||||
}
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
return QSizeF(QSizeF(size) / window->devicePixelRatio()).toSize();
|
||||
#else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#if FRAMELESSHELPER_CONFIG(private_qt)
|
||||
return QHighDpi::fromNativePixels(size, window);
|
||||
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#else
|
||||
return QSizeF(QSizeF(size) / window->devicePixelRatio()).toSize();
|
||||
#endif
|
||||
}
|
||||
|
||||
QRect Utils::fromNativePixels(const QWindow *window, const QRect &rect)
|
||||
|
@ -447,11 +460,11 @@ QRect Utils::fromNativePixels(const QWindow *window, const QRect &rect)
|
|||
if (!window) {
|
||||
return {};
|
||||
}
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
return QRect(fromNativePixels(window, rect.topLeft()), fromNativePixels(window, rect.size()));
|
||||
#else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#if FRAMELESSHELPER_CONFIG(private_qt)
|
||||
return QHighDpi::fromNativePixels(rect, window);
|
||||
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#else
|
||||
return QRect(fromNativePixels(window, rect.topLeft()), fromNativePixels(window, rect.size()));
|
||||
#endif
|
||||
}
|
||||
|
||||
QPoint Utils::toNativeLocalPosition(const QWindow *window, const QPoint &point)
|
||||
|
@ -460,11 +473,11 @@ QPoint Utils::toNativeLocalPosition(const QWindow *window, const QPoint &point)
|
|||
if (!window) {
|
||||
return {};
|
||||
}
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
return QPointF(QPointF(point) * window->devicePixelRatio()).toPoint();
|
||||
#else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#if FRAMELESSHELPER_CONFIG(private_qt)
|
||||
return QHighDpi::toNativeLocalPosition(point, window);
|
||||
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#else
|
||||
return QPointF(QPointF(point) * window->devicePixelRatio()).toPoint();
|
||||
#endif
|
||||
}
|
||||
|
||||
QPoint Utils::toNativeGlobalPosition(const QWindow *window, const QPoint &point)
|
||||
|
@ -473,11 +486,11 @@ QPoint Utils::toNativeGlobalPosition(const QWindow *window, const QPoint &point)
|
|||
if (!window) {
|
||||
return {};
|
||||
}
|
||||
#if (defined(FRAMELESSHELPER_CORE_NO_PRIVATE) || (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)))
|
||||
#if (!FRAMELESSHELPER_CONFIG(private_qt) || (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)))
|
||||
return toNativePixels(window, point);
|
||||
#else // !FRAMELESSHELPER_CORE_NO_PRIVATE && QT_VERSION >= 6.0.0
|
||||
#else
|
||||
return QHighDpi::toNativeGlobalPosition(point, window);
|
||||
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE || QT_VERSION < 6.0.0
|
||||
#endif
|
||||
}
|
||||
|
||||
QPoint Utils::fromNativeLocalPosition(const QWindow *window, const QPoint &point)
|
||||
|
@ -486,11 +499,11 @@ QPoint Utils::fromNativeLocalPosition(const QWindow *window, const QPoint &point
|
|||
if (!window) {
|
||||
return {};
|
||||
}
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
return QPointF(QPointF(point) / window->devicePixelRatio()).toPoint();
|
||||
#else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#if FRAMELESSHELPER_CONFIG(private_qt)
|
||||
return QHighDpi::fromNativeLocalPosition(point, window);
|
||||
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#else
|
||||
return QPointF(QPointF(point) / window->devicePixelRatio()).toPoint();
|
||||
#endif
|
||||
}
|
||||
|
||||
QPoint Utils::fromNativeGlobalPosition(const QWindow *window, const QPoint &point)
|
||||
|
@ -499,11 +512,11 @@ QPoint Utils::fromNativeGlobalPosition(const QWindow *window, const QPoint &poin
|
|||
if (!window) {
|
||||
return {};
|
||||
}
|
||||
#if (defined(FRAMELESSHELPER_CORE_NO_PRIVATE) || (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)))
|
||||
#if (!FRAMELESSHELPER_CONFIG(private_qt) || (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)))
|
||||
return fromNativePixels(window, point);
|
||||
#else // !FRAMELESSHELPER_CORE_NO_PRIVATE && QT_VERSION >= 6.0.0
|
||||
#else
|
||||
return QHighDpi::fromNativeGlobalPosition(point, window);
|
||||
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE || QT_VERSION < 6.0.0
|
||||
#endif
|
||||
}
|
||||
|
||||
int Utils::horizontalAdvance(const QFontMetrics &fm, const QString &str)
|
||||
|
@ -576,11 +589,11 @@ quint32 Utils::defaultScreenDpi()
|
|||
QColor Utils::getAccentColor()
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0))
|
||||
return QGuiApplication::palette().color(QPalette::AccentColor);
|
||||
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)
|
||||
# elif (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
||||
return getAccentColor_linux();
|
||||
# elif defined(Q_OS_MACOS)
|
||||
return getAccentColor_macos();
|
||||
|
@ -590,4 +603,66 @@ QColor Utils::getAccentColor()
|
|||
#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<QWindow *>(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
|
||||
|
|
|
@ -23,21 +23,20 @@
|
|||
*/
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
||||
|
||||
#include "framelessconfig_p.h"
|
||||
#include "framelessmanager.h"
|
||||
#include "framelessmanager_p.h"
|
||||
#include <cstring> // for std::memcpy
|
||||
#include <QtCore/qloggingcategory.h>
|
||||
#include <QtGui/qevent.h>
|
||||
#include <QtGui/qwindow.h>
|
||||
#include <QtGui/qscreen.h>
|
||||
#include <QtGui/qpalette.h>
|
||||
#include <QtGui/qguiapplication.h>
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
# if __has_include(<QtX11Extras/qx11info_x11.h>)
|
||||
# include <QtX11Extras/qx11info_x11.h>
|
||||
# define FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
# endif // __has_include(<QtX11Extras/qx11info_x11.h>)
|
||||
#else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#if FRAMELESSHELPER_CONFIG(private_qt)
|
||||
# include <QtGui/qpa/qplatformnativeinterface.h>
|
||||
# include <QtGui/qpa/qplatformwindow.h>
|
||||
# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
|
@ -50,22 +49,26 @@
|
|||
# include <QtGui/private/qtx11extras_p.h>
|
||||
# define FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
# endif // (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0))
|
||||
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#else // !FRAMELESSHELPER_CONFIG(private_qt)
|
||||
# if __has_include(<QtX11Extras/qx11info_x11.h>)
|
||||
# include <QtX11Extras/qx11info_x11.h>
|
||||
# define FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
# endif // __has_include(<QtX11Extras/qx11info_x11.h>)
|
||||
#endif // FRAMELESSHELPER_CONFIG(private_qt)
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
static Q_LOGGING_CATEGORY(lcUtilsLinux, "wangwenx190.framelesshelper.core.utils.linux")
|
||||
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_DEBUG_OUTPUT
|
||||
# define INFO QT_NO_QDEBUG_MACRO()
|
||||
# define DEBUG QT_NO_QDEBUG_MACRO()
|
||||
# define WARNING QT_NO_QDEBUG_MACRO()
|
||||
# define CRITICAL QT_NO_QDEBUG_MACRO()
|
||||
#else
|
||||
#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;
|
||||
|
@ -120,12 +123,29 @@ extern QString gtkSettings(const gchar *);
|
|||
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)
|
||||
{
|
||||
#ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
Q_UNUSED(virtualDesktopNumber);
|
||||
return QGuiApplication::primaryScreen();
|
||||
#else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#if FRAMELESSHELPER_CONFIG(private_qt)
|
||||
if (virtualDesktopNumber == -1) {
|
||||
return QGuiApplication::primaryScreen();
|
||||
}
|
||||
|
@ -146,7 +166,10 @@ QScreen *Utils::x11_findScreenForVirtualDesktop(const int virtualDesktopNumber)
|
|||
# endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
}
|
||||
return nullptr;
|
||||
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
#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)
|
||||
|
@ -154,10 +177,7 @@ x11_return_type Utils::x11_appRootWindow(const int screen)
|
|||
#ifdef FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
return QX11Info::appRootWindow(screen);
|
||||
#else // !FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
# ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
Q_UNUSED(screen);
|
||||
return 0;
|
||||
# else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
# if FRAMELESSHELPER_CONFIG(private_qt)
|
||||
if (!qApp) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -170,7 +190,10 @@ x11_return_type Utils::x11_appRootWindow(const int screen)
|
|||
return 0;
|
||||
}
|
||||
return static_cast<xcb_window_t>(reinterpret_cast<quintptr>(native->nativeResourceForScreen(krootwindow, scr)));
|
||||
# endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
# else // !FRAMELESSHELPER_CONFIG(private_qt)
|
||||
Q_UNUSED(screen);
|
||||
return 0;
|
||||
# endif // FRAMELESSHELPER_CONFIG(private_qt)
|
||||
#endif // FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
}
|
||||
|
||||
|
@ -179,9 +202,7 @@ int Utils::x11_appScreen()
|
|||
#ifdef FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
return QX11Info::appScreen();
|
||||
#else // !FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
# ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
return 0;
|
||||
# else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
# if FRAMELESSHELPER_CONFIG(private_qt)
|
||||
if (!qApp) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -190,7 +211,9 @@ int Utils::x11_appScreen()
|
|||
return 0;
|
||||
}
|
||||
return reinterpret_cast<qintptr>(native->nativeResourceForIntegration(kx11screen));
|
||||
# endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
# else // !FRAMELESSHELPER_CONFIG(private_qt)
|
||||
return 0;
|
||||
# endif // FRAMELESSHELPER_CONFIG(private_qt)
|
||||
#endif // FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
}
|
||||
|
||||
|
@ -199,9 +222,7 @@ x11_return_type Utils::x11_appTime()
|
|||
#ifdef FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
return QX11Info::appTime();
|
||||
#else // !FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
# ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
return 0;
|
||||
# else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
# if FRAMELESSHELPER_CONFIG(private_qt)
|
||||
if (!qApp) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -214,7 +235,9 @@ x11_return_type Utils::x11_appTime()
|
|||
return 0;
|
||||
}
|
||||
return static_cast<xcb_timestamp_t>(reinterpret_cast<quintptr>(native->nativeResourceForScreen(kapptime, screen)));
|
||||
# endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
# else // !FRAMELESSHELPER_CONFIG(private_qt)
|
||||
return 0;
|
||||
# endif // FRAMELESSHELPER_CONFIG(private_qt)
|
||||
#endif // FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
}
|
||||
|
||||
|
@ -223,9 +246,7 @@ x11_return_type Utils::x11_appUserTime()
|
|||
#ifdef FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
return QX11Info::appUserTime();
|
||||
#else // !FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
# ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
return 0;
|
||||
# else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
# if FRAMELESSHELPER_CONFIG(private_qt)
|
||||
if (!qApp) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -238,7 +259,9 @@ x11_return_type Utils::x11_appUserTime()
|
|||
return 0;
|
||||
}
|
||||
return static_cast<xcb_timestamp_t>(reinterpret_cast<quintptr>(native->nativeResourceForScreen(kappusertime, screen)));
|
||||
# endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
# else // !FRAMELESSHELPER_CONFIG(private_qt)
|
||||
return 0;
|
||||
# endif // FRAMELESSHELPER_CONFIG(private_qt)
|
||||
#endif // FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
}
|
||||
|
||||
|
@ -247,9 +270,7 @@ x11_return_type Utils::x11_getTimestamp()
|
|||
#ifdef FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
return QX11Info::getTimestamp();
|
||||
#else // !FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
# ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
return 0;
|
||||
# else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
# if FRAMELESSHELPER_CONFIG(private_qt)
|
||||
if (!qApp) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -262,7 +283,9 @@ x11_return_type Utils::x11_getTimestamp()
|
|||
return 0;
|
||||
}
|
||||
return static_cast<xcb_timestamp_t>(reinterpret_cast<quintptr>(native->nativeResourceForScreen(kgettimestamp, screen)));
|
||||
# endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
# else // !FRAMELESSHELPER_CONFIG(private_qt)
|
||||
return 0;
|
||||
# endif // FRAMELESSHELPER_CONFIG(private_qt)
|
||||
#endif // FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
}
|
||||
|
||||
|
@ -271,9 +294,7 @@ QByteArray Utils::x11_nextStartupId()
|
|||
#ifdef FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
return QX11Info::nextStartupId();
|
||||
#else // !FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
# ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
return {};
|
||||
# else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
# if FRAMELESSHELPER_CONFIG(private_qt)
|
||||
if (!qApp) {
|
||||
return {};
|
||||
}
|
||||
|
@ -282,7 +303,9 @@ QByteArray Utils::x11_nextStartupId()
|
|||
return {};
|
||||
}
|
||||
return static_cast<char *>(native->nativeResourceForIntegration(kstartupid));
|
||||
# endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
# else // !FRAMELESSHELPER_CONFIG(private_qt)
|
||||
return {};
|
||||
# endif // FRAMELESSHELPER_CONFIG(private_qt)
|
||||
#endif // FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
}
|
||||
|
||||
|
@ -291,9 +314,7 @@ Display *Utils::x11_display()
|
|||
#ifdef FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
return QX11Info::display();
|
||||
#else // !FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
# ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
return nullptr;
|
||||
# else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
# if FRAMELESSHELPER_CONFIG(private_qt)
|
||||
if (!qApp) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -311,7 +332,9 @@ Display *Utils::x11_display()
|
|||
# else // (QT_VERSION < QT_VERSION_CHECK(6, 2, 0))
|
||||
return reinterpret_cast<Display *>(native->nativeResourceForIntegration(kdisplay));
|
||||
# endif // (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0))
|
||||
# endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
# else // !FRAMELESSHELPER_CONFIG(private_qt)
|
||||
return nullptr;
|
||||
# endif // FRAMELESSHELPER_CONFIG(private_qt)
|
||||
#endif // FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
}
|
||||
|
||||
|
@ -320,9 +343,7 @@ xcb_connection_t *Utils::x11_connection()
|
|||
#ifdef FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
return QX11Info::connection();
|
||||
#else // !FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
# ifdef FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
return nullptr;
|
||||
# else // !FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
# if FRAMELESSHELPER_CONFIG(private_qt)
|
||||
if (!qApp) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -340,41 +361,47 @@ xcb_connection_t *Utils::x11_connection()
|
|||
# else // (QT_VERSION < QT_VERSION_CHECK(6, 2, 0))
|
||||
return reinterpret_cast<xcb_connection_t *>(native->nativeResourceForIntegration(kconnection));
|
||||
# endif // (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0))
|
||||
# endif // FRAMELESSHELPER_CORE_NO_PRIVATE
|
||||
# else // !FRAMELESSHELPER_CONFIG(private_qt)
|
||||
return nullptr;
|
||||
# endif // FRAMELESSHELPER_CONFIG(private_qt)
|
||||
#endif // FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
}
|
||||
|
||||
void Utils::startSystemMove(QWindow *window, const QPoint &globalPos)
|
||||
bool Utils::startSystemMove(QWindow *window, const QPoint &globalPos)
|
||||
{
|
||||
Q_ASSERT(window);
|
||||
if (!window) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||
Q_UNUSED(globalPos);
|
||||
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))
|
||||
}
|
||||
|
||||
void Utils::startSystemResize(QWindow *window, const Qt::Edges edges, const QPoint &globalPos)
|
||||
bool Utils::startSystemResize(QWindow *window, const Qt::Edges edges, const QPoint &globalPos)
|
||||
{
|
||||
Q_ASSERT(window);
|
||||
if (!window) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (edges == Qt::Edges{}) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||
Q_UNUSED(globalPos);
|
||||
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))
|
||||
}
|
||||
|
||||
|
@ -503,13 +530,13 @@ WallpaperAspectStyle Utils::getWallpaperAspectStyle()
|
|||
if (options.isEmpty()) {
|
||||
return defaultAspectStyle;
|
||||
} else {
|
||||
if ((options == u"wallpaper"_s) || (options == u"tiled"_s)) {
|
||||
if ((options == "wallpaper"_L1) || (options == "tiled"_L1)) {
|
||||
return WallpaperAspectStyle::Tile;
|
||||
} else if (options == u"centered"_s) {
|
||||
} else if (options == "centered"_L1) {
|
||||
return WallpaperAspectStyle::Center;
|
||||
} else if (options == u"stretched"_s) {
|
||||
} else if (options == "stretched"_L1) {
|
||||
return WallpaperAspectStyle::Stretch;
|
||||
} else if (options == u"scaled"_s) {
|
||||
} else if (options == "scaled"_L1) {
|
||||
return WallpaperAspectStyle::Fit;
|
||||
} else {
|
||||
return defaultAspectStyle;
|
||||
|
@ -558,15 +585,16 @@ static inline void themeChangeNotificationCallback()
|
|||
}
|
||||
}
|
||||
|
||||
void Utils::registerThemeChangeNotification()
|
||||
bool Utils::registerThemeChangeNotification()
|
||||
{
|
||||
GtkSettings * const settings = gtk_settings_get_default();
|
||||
Q_ASSERT(settings);
|
||||
if (!settings) {
|
||||
return;
|
||||
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)
|
||||
|
@ -967,3 +995,5 @@ bool Utils::setPlatformPropertiesForWindow(QWindow *window, const QVariantHash &
|
|||
}
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
||||
#endif // Q_OS_LINUX
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue