├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── FramelessHelperConfig.cmake.in ├── LICENSE ├── README.md ├── build.bat ├── doc ├── QVogenClient.png ├── linux_dark.png ├── linux_light.png ├── mac_dark.png ├── mac_light.png ├── win_dark.png └── win_light.png ├── examples ├── CMakeLists.txt ├── dialog │ ├── CMakeLists.txt │ ├── dialog.cpp │ ├── dialog.h │ └── main.cpp ├── mainwindow │ ├── CMakeLists.txt │ ├── main.cpp │ ├── mainwindow.cpp │ ├── mainwindow.h │ └── mainwindow.ui ├── openglwidget │ ├── CMakeLists.txt │ ├── glwidget.cpp │ ├── glwidget.h │ ├── images.qrc │ ├── images │ │ └── qtlogo.png │ ├── logo.cpp │ ├── logo.h │ ├── main.cpp │ ├── mainwindow.cpp │ └── mainwindow.h ├── quick │ ├── CMakeLists.txt │ ├── images │ │ ├── microsoft.png │ │ └── microsoft.svg │ ├── main.cpp │ ├── qml │ │ ├── ApplicationWindow.qml │ │ ├── HomePage.qml │ │ └── Window.qml │ ├── quick.pro │ ├── quicksettings.cpp │ ├── quicksettings.h │ ├── resources.qrc │ └── scripts │ │ ├── d3d11.bat │ │ ├── d3d12.bat │ │ ├── opengl.bat │ │ └── vulkan.bat ├── shared │ ├── example.ico │ ├── log.cpp │ ├── log.h │ ├── settings.cpp │ └── settings.h └── widget │ ├── CMakeLists.txt │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.pro ├── include └── FramelessHelper │ ├── Core │ ├── ChromePalette │ ├── FramelessHelper_Linux │ ├── FramelessHelper_Qt │ ├── FramelessHelper_Win │ ├── FramelessHelper_Windows │ ├── FramelessManager │ ├── Global │ ├── MicaMaterial │ ├── Utils │ ├── WindowBorderPainter │ ├── chromepalette.h │ ├── framelesshelper_linux.h │ ├── framelesshelper_qt.h │ ├── framelesshelper_win.h │ ├── framelesshelper_windows.h │ ├── framelesshelpercore_global.h │ ├── framelessmanager.h │ ├── micamaterial.h │ ├── private │ │ ├── chromepalette_p.h │ │ ├── framelessconfig_p.h │ │ ├── framelesshelpercore_global_p.h │ │ ├── framelessmanager_p.h │ │ ├── micamaterial_p.h │ │ ├── registrykey_p.h │ │ ├── scopeguard_p.h │ │ ├── sysapiloader_p.h │ │ ├── versionnumber_p.h │ │ ├── windowborderpainter_p.h │ │ └── winverhelper_p.h │ ├── utils.h │ └── windowborderpainter.h │ ├── Quick │ ├── FramelessQuickHelper │ ├── FramelessQuickModule │ ├── FramelessQuickUtils │ ├── Global │ ├── QuickChromePalette │ ├── QuickMicaMaterial │ ├── QuickWindowBorder │ ├── framelesshelperquick_global.h │ ├── framelessquickhelper.h │ ├── framelessquickmodule.h │ ├── framelessquickutils.h │ ├── private │ │ ├── framelessquickapplicationwindow_p.h │ │ ├── framelessquickapplicationwindow_p_p.h │ │ ├── framelessquickhelper_p.h │ │ ├── framelessquickwindow_p.h │ │ ├── framelessquickwindow_p_p.h │ │ ├── quickimageitem_p.h │ │ ├── quickmicamaterial_p.h │ │ ├── quickstandardsystembutton_p.h │ │ ├── quickstandardtitlebar_p.h │ │ └── quickwindowborder_p.h │ ├── quickchromepalette.h │ ├── quickmicamaterial.h │ └── quickwindowborder.h │ └── Widgets │ ├── FramelessDialog │ ├── FramelessMainWindow │ ├── FramelessWidget │ ├── FramelessWidgetsHelper │ ├── Global │ ├── StandardSystemButton │ ├── StandardTitleBar │ ├── framelessdialog.h │ ├── framelesshelperwidgets_global.h │ ├── framelessmainwindow.h │ ├── framelesswidget.h │ ├── framelesswidgetshelper.h │ ├── private │ ├── framelessdialog_p.h │ ├── framelessmainwindow_p.h │ ├── framelesswidget_p.h │ ├── framelesswidgetshelper_p.h │ ├── standardsystembutton_p.h │ ├── standardtitlebar_p.h │ └── widgetssharedhelper_p.h │ ├── standardsystembutton.h │ └── standardtitlebar.h ├── msbuild └── FramelessHelper.props ├── qmake ├── core.pri ├── inc │ └── core │ │ ├── framelesshelper.config │ │ └── framelesshelper.version ├── quick.pri └── widgets.pri └── src ├── CMakeLists.txt ├── core ├── CMakeLists.txt ├── chromepalette.cpp ├── chromepalette.h ├── chromepalette_p.h ├── framelessconfig.cpp ├── framelessconfig_p.h ├── framelesshelper_linux.h ├── framelesshelper_qt.cpp ├── framelesshelper_qt.h ├── framelesshelper_win.cpp ├── framelesshelper_win.h ├── framelesshelper_windows.h ├── framelesshelpercore.qrc ├── framelesshelpercore_global.cpp ├── framelesshelpercore_global.h ├── framelesshelpercore_global_p.h ├── framelessmanager.cpp ├── framelessmanager.h ├── framelessmanager_p.h ├── micamaterial.cpp ├── micamaterial.h ├── micamaterial_p.h ├── platformsupport_linux.cpp ├── platformsupport_win.cpp ├── registrykey.cpp ├── registrykey_p.h ├── resources │ ├── fonts │ │ └── iconfont.ttf │ └── images │ │ └── noise.png ├── scopeguard_p.h ├── sysapiloader.cpp ├── sysapiloader_p.h ├── utils.cpp ├── utils.h ├── utils_linux.cpp ├── utils_mac.mm ├── utils_win.cpp ├── versionnumber_p.h ├── windowborderpainter.cpp ├── windowborderpainter.h ├── windowborderpainter_p.h ├── winverhelper.cpp └── winverhelper_p.h ├── quick ├── CMakeLists.txt ├── framelesshelperquick_global.cpp ├── framelesshelperquick_global.h ├── framelessquickapplicationwindow.cpp ├── framelessquickapplicationwindow_p.h ├── framelessquickapplicationwindow_p_p.h ├── framelessquickhelper.cpp ├── framelessquickhelper.h ├── framelessquickhelper_p.h ├── framelessquickmodule.h ├── framelessquickutils.cpp ├── framelessquickutils.h ├── framelessquickwindow.cpp ├── framelessquickwindow_p.h ├── framelessquickwindow_p_p.h ├── quickchromepalette.cpp ├── quickchromepalette.h ├── quickimageitem.cpp ├── quickimageitem.h ├── quickimageitem_p.h ├── quickmicamaterial.cpp ├── quickmicamaterial.h ├── quickmicamaterial_p.h ├── quickstandardsystembutton.cpp ├── quickstandardsystembutton_p.h ├── quickstandardtitlebar.cpp ├── quickstandardtitlebar_p.h ├── quickwindowborder.cpp ├── quickwindowborder.h └── quickwindowborder_p.h └── widgets ├── CMakeLists.txt ├── framelessdialog.cpp ├── framelessdialog.h ├── framelessdialog_p.h ├── framelesshelperwidgets_global.cpp ├── framelesshelperwidgets_global.h ├── framelessmainwindow.cpp ├── framelessmainwindow.h ├── framelessmainwindow_p.h ├── framelesswidget.cpp ├── framelesswidget.h ├── framelesswidget_p.h ├── framelesswidgetshelper.cpp ├── framelesswidgetshelper.h ├── framelesswidgetshelper_p.h ├── standardsystembutton.cpp ├── standardsystembutton.h ├── standardsystembutton_p.h ├── standardtitlebar.cpp ├── standardtitlebar.h ├── standardtitlebar_p.h ├── widgetssharedhelper.cpp └── widgetssharedhelper_p.h /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: "CI: Build Test" 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths-ignore: 8 | - "**.md" 9 | - "**.png" 10 | - "**.jpg" 11 | - "**.jpeg" 12 | - ".gitignore" 13 | workflow_dispatch: 14 | pull_request: 15 | 16 | jobs: 17 | build: 18 | name: Build 19 | strategy: 20 | matrix: 21 | qt-version: [5.15.2, 6.5.3] 22 | library-type: [shared, static] 23 | platform: [windows-latest, ubuntu-latest, macos-latest] 24 | include: 25 | - platform: windows-latest 26 | CC: cl.exe 27 | CXX: cl.exe 28 | LD: link.exe 29 | EXTRA_FLAGS: -DFRAMELESSHELPER_ENABLE_SPECTRE=ON -DFRAMELESSHELPER_ENABLE_EHCONTGUARD=ON -DFRAMELESSHELPER_ENABLE_INTELCET=ON -DFRAMELESSHELPER_ENABLE_CFGUARD=ON 30 | - platform: ubuntu-latest 31 | CC: gcc 32 | CXX: g++ 33 | LD: ld 34 | EXTRA_FLAGS: -DFRAMELESSHELPER_ENABLE_SPECTRE=ON -DFRAMELESSHELPER_ENABLE_INTELCET=ON -DFRAMELESSHELPER_ENABLE_CFGUARD=ON 35 | - platform: macos-latest 36 | CC: /usr/local/opt/llvm/bin/clang 37 | CXX: /usr/local/opt/llvm/bin/clang++ 38 | LD: /usr/local/opt/llvm/bin/ld64.lld 39 | EXTRA_FLAGS: -DFRAMELESSHELPER_ENABLE_UNIVERSAL_BUILD=OFF 40 | - library-type: shared 41 | lib_type_flag: -DFRAMELESSHELPER_BUILD_STATIC=OFF 42 | - library-type: static 43 | lib_type_flag: -DFRAMELESSHELPER_BUILD_STATIC=ON 44 | 45 | runs-on: ${{ matrix.platform }} 46 | 47 | steps: 48 | - name: Check out repository 49 | uses: actions/checkout@v3 50 | with: 51 | submodules: recursive 52 | 53 | - name: Install Qt SDK 54 | uses: jurplel/install-qt-action@v3 55 | with: 56 | version: ${{ matrix.qt-version }} 57 | cache: true 58 | 59 | - name: Set up Ninja 60 | uses: seanmiddleditch/gha-setup-ninja@v3 61 | with: 62 | version: 1.11.1 # Current latest version. 63 | 64 | - name: Set up MSVC environment 65 | if: ${{ matrix.platform == 'windows-latest' }} 66 | uses: ilammy/msvc-dev-cmd@v1 67 | 68 | - name: Install Linux dependencies 69 | if: ${{ matrix.platform == 'ubuntu-latest' }} 70 | run: | 71 | sudo apt install -y libgl1-mesa-dev libxcb1-dev libgtk-3-dev 72 | 73 | - name: Install macOS dependencies 74 | if: ${{ matrix.platform == 'macos-latest' }} 75 | run: | 76 | brew update 77 | brew upgrade 78 | brew install llvm 79 | export PATH="/usr/local/opt/llvm/bin:$PATH" 80 | 81 | - name: Build library with CMake 82 | run: | 83 | mkdir ci 84 | cd ci 85 | cmake -DCMAKE_MESSAGE_LOG_LEVEL=STATUS -DCMAKE_C_COMPILER=${{ matrix.CC }} -DCMAKE_CXX_COMPILER=${{ matrix.CXX }} -DCMAKE_LINKER=${{ matrix.LD }} -DCMAKE_INSTALL_PREFIX=../../install -DCMAKE_BUILD_TYPE=Release -DFRAMELESSHELPER_BUILD_EXAMPLES=ON -DFRAMELESSHELPER_NO_SUMMARY=OFF ${{ matrix.lib_type_flag }} ${{ matrix.EXTRA_FLAGS }} -GNinja .. 86 | cmake --build . --target all --config Release --parallel 87 | cmake --install . --config Release --strip 88 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # C++ objects and libs 2 | *.slo 3 | *.lo 4 | *.o 5 | *.a 6 | *.la 7 | *.lai 8 | *.so 9 | *.so.* 10 | *.dll 11 | *.dylib 12 | 13 | # Qt-es 14 | object_script.*.Release 15 | object_script.*.Debug 16 | *_plugin_import.cpp 17 | /.qmake.cache 18 | /.qmake.stash 19 | *.pro.user 20 | *.pro.user.* 21 | *.qbs.user 22 | *.qbs.user.* 23 | *.moc 24 | moc_*.cpp 25 | moc_*.h 26 | qrc_*.cpp 27 | ui_*.h 28 | *.qmlc 29 | *.jsc 30 | Makefile* 31 | *build-* 32 | *.qm 33 | *.prl 34 | 35 | # Qt unit tests 36 | target_wrapper.* 37 | 38 | # QtCreator 39 | *.autosave 40 | 41 | # QtCreator Qml 42 | *.qmlproject.user 43 | *.qmlproject.user.* 44 | 45 | # QtCreator CMake 46 | CMakeLists.txt.user* 47 | 48 | # QtCreator 4.8< compilation database 49 | compile_commands.json 50 | 51 | # QtCreator local machine specific files for imported projects 52 | *creator.user* 53 | 54 | # My 55 | [Bb]in/ 56 | [Bb]in64/ 57 | [Ll]ib/ 58 | [Ll]ib64/ 59 | [Bb]uild*/ 60 | *.7z 61 | *.zip 62 | *.rar 63 | *.tar 64 | *.gz 65 | *.xz 66 | *.exe 67 | *.lib 68 | *.pdb 69 | *.ilk 70 | *.exp 71 | *.obj 72 | build.user.bat 73 | build.user.sh 74 | user.conf 75 | [Dd]oc/ 76 | [Dd]ocs/ 77 | Thumbs.db 78 | *.rc 79 | *.bin 80 | *.run 81 | .qmake.conf 82 | *.res 83 | .DS_Store 84 | .vscode/ 85 | .vs/ 86 | .cmake.conf 87 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "cmake"] 2 | path = cmake 3 | url = ../../wangwenx190/cmake-utils.git 4 | -------------------------------------------------------------------------------- /FramelessHelperConfig.cmake.in: -------------------------------------------------------------------------------- 1 | #[[ 2 | MIT License 3 | 4 | Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | ]] 24 | 25 | @PACKAGE_INIT@ 26 | 27 | include(CMakeFindDependencyMacro) 28 | 29 | set(_@PROJECT_NAME@_supported_components Core Widgets Quick) 30 | set(_@PROJECT_NAME@_available_components Core Gui) 31 | 32 | foreach(_component ${@PROJECT_NAME@_FIND_COMPONENTS}) 33 | if(_component IN_LIST _@PROJECT_NAME@_supported_components) 34 | set(__target @PROJECT_NAME@::${_component}) 35 | if(TARGET ${__target}) 36 | continue() 37 | else() 38 | set(__target_full @PROJECT_NAME@${_component}) 39 | set(__targets_file "${CMAKE_CURRENT_LIST_DIR}/${__target_full}Targets.cmake") 40 | if(EXISTS "${__targets_file}") 41 | include("${__targets_file}") 42 | add_library(${__target} ALIAS @PROJECT_NAME@::${__target_full}) 43 | list(APPEND _@PROJECT_NAME@_available_components ${_component}) 44 | else() 45 | set(@PROJECT_NAME@_FOUND FALSE) 46 | 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.") 47 | break() 48 | endif() 49 | endif() 50 | else() 51 | set(@PROJECT_NAME@_FOUND FALSE) 52 | set(@PROJECT_NAME@_NOT_FOUND_MESSAGE "Unknown component: ${__target}.") 53 | break() 54 | endif() 55 | endforeach() 56 | 57 | if(NOT DEFINED @PROJECT_NAME@_FOUND) 58 | set(@PROJECT_NAME@_FOUND TRUE) 59 | set(@PROJECT_NAME@_VERSION "@PROJECT_VERSION@") 60 | set(@PROJECT_NAME@_VERSION_MAJOR "@PROJECT_VERSION_MAJOR@") 61 | set(@PROJECT_NAME@_VERSION_MINOR "@PROJECT_VERSION_MINOR@") 62 | set(@PROJECT_NAME@_VERSION_PATCH "@PROJECT_VERSION_PATCH@") 63 | #set(@PROJECT_NAME@_VERSION_TWEAK "@PROJECT_VERSION_TWEAK@") 64 | set(@PROJECT_NAME@_DESCRIPTION "@PROJECT_DESCRIPTION@") 65 | set(@PROJECT_NAME@_HOMEPAGE_URL "@PROJECT_HOMEPAGE_URL@") 66 | set(@PROJECT_NAME@_COMMIT "@PROJECT_VERSION_COMMIT@") 67 | set(@PROJECT_NAME@_COMPILE_DATETIME "@PROJECT_COMPILE_DATETIME@") 68 | endif() 69 | 70 | include(FeatureSummary) 71 | set_package_properties(@PROJECT_NAME@ PROPERTIES 72 | DESCRIPTION "@PROJECT_DESCRIPTION@" 73 | URL "@PROJECT_HOMEPAGE_URL@" 74 | ) 75 | 76 | if(${@PROJECT_NAME@_FOUND}) 77 | list(REMOVE_DUPLICATES _@PROJECT_NAME@_available_components) 78 | find_dependency(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS ${_@PROJECT_NAME@_available_components}) 79 | find_dependency(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS ${_@PROJECT_NAME@_available_components}) 80 | endif() 81 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | title Building FramelessHelper ... 3 | setlocal 4 | cls 5 | set __vs_bat=%ProgramFiles%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat 6 | if not exist "%__vs_bat%" set __vs_bat=%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat 7 | if not exist "%__vs_bat%" set __vs_bat=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat 8 | if not exist "%__vs_bat%" set __vs_bat=%ProgramFiles(x86)%\Microsoft Visual Studio\2015\Community\VC\Auxiliary\Build\vcvars64.bat 9 | if not exist "%__vs_bat%" ( 10 | echo Cannot find a valid Visual Studio toolchain! 11 | echo Please install at least Visual Studio 2015 to the default location 12 | echo and install the English language pack at the same time. 13 | echo If you want to use clang-cl or MinGW to build this project, please 14 | echo make sure you have added their directory to your PATH environment 15 | echo variable. 16 | echo Press the ENTER key to continue, or close this window directly. 17 | pause 18 | ) else ( 19 | call "%__vs_bat%" 20 | ) 21 | cmake --version 22 | echo ninja build 23 | ninja --version 24 | cd /d "%~dp0" 25 | if exist build.user.bat call build.user.bat 26 | if not defined CC set CC=cl.exe 27 | if not defined CXX set CXX=cl.exe 28 | if not defined QTDIR set QTDIR=%SystemDrive%\Qt\6.6.0\msvc2019_64 29 | echo CC=%CC% 30 | echo CXX=%CXX% 31 | echo QTDIR=%QTDIR% 32 | if exist build rd /s /q build 33 | md build 34 | cd build 35 | md cmake 36 | cd cmake 37 | 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" 38 | cmake --build . --target all --config Release --parallel 39 | cmake --build . --target all --config Debug --parallel 40 | cmake --install . --config Release --strip 41 | cmake --install . --config Debug 42 | goto fin 43 | :fin 44 | endlocal 45 | cd /d "%~dp0" 46 | pause 47 | exit /b 0 48 | -------------------------------------------------------------------------------- /doc/QVogenClient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangwenx190/framelesshelper/3102b4ea3b0756d92e02ae1656d0cccc9f824a82/doc/QVogenClient.png -------------------------------------------------------------------------------- /doc/linux_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangwenx190/framelesshelper/3102b4ea3b0756d92e02ae1656d0cccc9f824a82/doc/linux_dark.png -------------------------------------------------------------------------------- /doc/linux_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangwenx190/framelesshelper/3102b4ea3b0756d92e02ae1656d0cccc9f824a82/doc/linux_light.png -------------------------------------------------------------------------------- /doc/mac_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangwenx190/framelesshelper/3102b4ea3b0756d92e02ae1656d0cccc9f824a82/doc/mac_dark.png -------------------------------------------------------------------------------- /doc/mac_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangwenx190/framelesshelper/3102b4ea3b0756d92e02ae1656d0cccc9f824a82/doc/mac_light.png -------------------------------------------------------------------------------- /doc/win_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangwenx190/framelesshelper/3102b4ea3b0756d92e02ae1656d0cccc9f824a82/doc/win_dark.png -------------------------------------------------------------------------------- /doc/win_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangwenx190/framelesshelper/3102b4ea3b0756d92e02ae1656d0cccc9f824a82/doc/win_light.png -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #[[ 2 | MIT License 3 | 4 | Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | ]] 24 | 25 | if(FRAMELESSHELPER_BUILD_WIDGETS AND TARGET Qt${QT_VERSION_MAJOR}::Widgets) 26 | add_subdirectory(widget) 27 | add_subdirectory(mainwindow) 28 | #add_subdirectory(openglwidget) # Currently not functional. 29 | add_subdirectory(dialog) 30 | endif() 31 | 32 | if(FRAMELESSHELPER_BUILD_QUICK AND TARGET Qt${QT_VERSION_MAJOR}::Quick AND (QT_VERSION_MAJOR GREATER_EQUAL 6) AND (NOT FRAMELESSHELPER_NO_PRIVATE)) 33 | add_subdirectory(quick) 34 | endif() 35 | -------------------------------------------------------------------------------- /examples/dialog/dialog.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | FRAMELESSHELPER_REQUIRE_CONFIG(window) 9 | 10 | QT_BEGIN_NAMESPACE 11 | class QCheckBox; 12 | class QDialogButtonBox; 13 | class QGroupBox; 14 | class QLabel; 15 | class QLineEdit; 16 | class QPushButton; 17 | QT_END_NAMESPACE 18 | 19 | #if FRAMELESSHELPER_CONFIG(titlebar) 20 | FRAMELESSHELPER_BEGIN_NAMESPACE 21 | class StandardTitleBar; 22 | FRAMELESSHELPER_END_NAMESPACE 23 | #endif 24 | 25 | class Dialog : public FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessDialog) 26 | { 27 | Q_OBJECT 28 | Q_DISABLE_COPY(Dialog) 29 | 30 | public: 31 | explicit Dialog(QWidget *parent = nullptr); 32 | ~Dialog() override; 33 | 34 | void waitReady(); 35 | 36 | protected: 37 | void closeEvent(QCloseEvent *event) override; 38 | 39 | private: 40 | void setupUi(); 41 | 42 | private: 43 | #if FRAMELESSHELPER_CONFIG(titlebar) 44 | FRAMELESSHELPER_PREPEND_NAMESPACE(StandardTitleBar) *titleBar = nullptr; 45 | #endif 46 | QLabel *label = nullptr; 47 | QLineEdit *lineEdit = nullptr; 48 | QCheckBox *caseCheckBox = nullptr; 49 | QCheckBox *fromStartCheckBox = nullptr; 50 | QCheckBox *wholeWordsCheckBox = nullptr; 51 | QCheckBox *searchSelectionCheckBox = nullptr; 52 | QCheckBox *backwardCheckBox = nullptr; 53 | QDialogButtonBox *buttonBox = nullptr; 54 | QPushButton *findButton = nullptr; 55 | QPushButton *moreButton = nullptr; 56 | QWidget *extension = nullptr; 57 | }; 58 | -------------------------------------------------------------------------------- /examples/dialog/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include 26 | #include 27 | #include "dialog.h" 28 | #include "../shared/log.h" 29 | 30 | FRAMELESSHELPER_USE_NAMESPACE 31 | 32 | #define CREATE_WINDOW(Name) \ 33 | const auto Name = std::make_unique(); \ 34 | Name->setObjectName(FRAMELESSHELPER_STRING_LITERAL(#Name)); \ 35 | Name->waitReady(); \ 36 | Name->show(); 37 | 38 | int main(int argc, char *argv[]) 39 | { 40 | Log::setup(FRAMELESSHELPER_STRING_LITERAL("dialog")); 41 | 42 | // Not necessary, but better call this function, before the construction 43 | // of any Q(Core|Gui)Application instances. 44 | FramelessHelperWidgetsInitialize(); 45 | 46 | #if 0 47 | if (!qEnvironmentVariableIsSet("QT_WIDGETS_RHI")) { 48 | qputenv("QT_WIDGETS_RHI", FRAMELESSHELPER_BYTEARRAY_LITERAL("1")); 49 | } 50 | #endif 51 | 52 | const auto application = std::make_unique(argc, argv); 53 | 54 | // Must be called after QGuiApplication has been constructed, we are using 55 | // some private functions from QPA which won't be available until there's 56 | // a QGuiApplication instance. 57 | FramelessHelperEnableThemeAware(); 58 | 59 | FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); 60 | //FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial); 61 | 62 | CREATE_WINDOW(dialog1) 63 | CREATE_WINDOW(dialog2) 64 | CREATE_WINDOW(dialog3) 65 | 66 | return QCoreApplication::exec(); 67 | } 68 | -------------------------------------------------------------------------------- /examples/mainwindow/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include 26 | #include 27 | #include "mainwindow.h" 28 | #include "../shared/log.h" 29 | 30 | FRAMELESSHELPER_USE_NAMESPACE 31 | 32 | #define CREATE_WINDOW(Name) \ 33 | const auto Name = std::make_unique(); \ 34 | Name->setObjectName(FRAMELESSHELPER_STRING_LITERAL(#Name)); \ 35 | Name->waitReady(); \ 36 | Name->show(); 37 | 38 | int main(int argc, char *argv[]) 39 | { 40 | Log::setup(FRAMELESSHELPER_STRING_LITERAL("mainwindow")); 41 | 42 | // Not necessary, but better call this function, before the construction 43 | // of any Q(Core|Gui)Application instances. 44 | FramelessHelperWidgetsInitialize(); 45 | 46 | #if 0 47 | if (!qEnvironmentVariableIsSet("QT_WIDGETS_RHI")) { 48 | qputenv("QT_WIDGETS_RHI", FRAMELESSHELPER_BYTEARRAY_LITERAL("1")); 49 | } 50 | #endif 51 | 52 | const auto application = std::make_unique(argc, argv); 53 | 54 | // Must be called after QGuiApplication has been constructed, we are using 55 | // some private functions from QPA which won't be available until there's 56 | // a QGuiApplication instance. 57 | FramelessHelperEnableThemeAware(); 58 | 59 | FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); 60 | //FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial); 61 | 62 | CREATE_WINDOW(mainWindow1) 63 | CREATE_WINDOW(mainWindow2) 64 | CREATE_WINDOW(mainWindow3) 65 | 66 | return QCoreApplication::exec(); 67 | } 68 | -------------------------------------------------------------------------------- /examples/mainwindow/mainwindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | FRAMELESSHELPER_REQUIRE_CONFIG(window) 30 | 31 | #if FRAMELESSHELPER_CONFIG(titlebar) 32 | FRAMELESSHELPER_BEGIN_NAMESPACE 33 | class StandardTitleBar; 34 | FRAMELESSHELPER_END_NAMESPACE 35 | #endif 36 | 37 | namespace Ui 38 | { 39 | class MainWindow; 40 | } 41 | 42 | class MainWindow : public FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessMainWindow) 43 | { 44 | Q_OBJECT 45 | Q_DISABLE_COPY(MainWindow) 46 | 47 | public: 48 | explicit MainWindow(QWidget *parent = nullptr, const Qt::WindowFlags flags = {}); 49 | ~MainWindow() override; 50 | 51 | void waitReady(); 52 | 53 | protected: 54 | void closeEvent(QCloseEvent *event) override; 55 | 56 | private: 57 | void initialize(); 58 | 59 | private: 60 | #if FRAMELESSHELPER_CONFIG(titlebar) 61 | FRAMELESSHELPER_PREPEND_NAMESPACE(StandardTitleBar) *m_titleBar = nullptr; 62 | #endif 63 | Ui::MainWindow *m_mainWindow = nullptr; 64 | }; 65 | -------------------------------------------------------------------------------- /examples/openglwidget/images.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/qtlogo.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /examples/openglwidget/images/qtlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangwenx190/framelesshelper/3102b4ea3b0756d92e02ae1656d0cccc9f824a82/examples/openglwidget/images/qtlogo.png -------------------------------------------------------------------------------- /examples/openglwidget/logo.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2016 The Qt Company Ltd. 4 | ** Contact: https://www.qt.io/licensing/ 5 | ** 6 | ** This file is part of the examples of the Qt Toolkit. 7 | ** 8 | ** $QT_BEGIN_LICENSE:BSD$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and The Qt Company. For licensing terms 14 | ** and conditions see https://www.qt.io/terms-conditions. For further 15 | ** information use the contact form at https://www.qt.io/contact-us. 16 | ** 17 | ** BSD License Usage 18 | ** Alternatively, you may use this file under the terms of the BSD license 19 | ** as follows: 20 | ** 21 | ** "Redistribution and use in source and binary forms, with or without 22 | ** modification, are permitted provided that the following conditions are 23 | ** met: 24 | ** * Redistributions of source code must retain the above copyright 25 | ** notice, this list of conditions and the following disclaimer. 26 | ** * Redistributions in binary form must reproduce the above copyright 27 | ** notice, this list of conditions and the following disclaimer in 28 | ** the documentation and/or other materials provided with the 29 | ** distribution. 30 | ** * Neither the name of The Qt Company Ltd nor the names of its 31 | ** contributors may be used to endorse or promote products derived 32 | ** from this software without specific prior written permission. 33 | ** 34 | ** 35 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 36 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 37 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 38 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 39 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 40 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 41 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 42 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 43 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 44 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 45 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 46 | ** 47 | ** $QT_END_LICENSE$ 48 | ** 49 | ****************************************************************************/ 50 | 51 | #pragma once 52 | 53 | #include 54 | #include 55 | #include 56 | 57 | class Logo 58 | { 59 | public: 60 | Logo(); 61 | const GLfloat *constData() const { return m_data.constData(); } 62 | int count() const { return m_count; } 63 | int vertexCount() const { return m_count / 6; } 64 | 65 | private: 66 | void quad(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, GLfloat x3, GLfloat y3, GLfloat x4, GLfloat y4); 67 | void extrude(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); 68 | void add(const QVector3D &v, const QVector3D &n); 69 | 70 | QVector m_data; 71 | int m_count = 0; 72 | }; 73 | -------------------------------------------------------------------------------- /examples/openglwidget/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "mainwindow.h" 26 | #include "glwidget.h" 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include "../shared/settings.h" 33 | 34 | extern template void Settings::set(const QString &, const QString &, const QRect &); 35 | extern template void Settings::set(const QString &, const QString &, const qreal &); 36 | 37 | extern template QRect Settings::get(const QString &, const QString &); 38 | extern template qreal Settings::get(const QString &, const QString &); 39 | 40 | FRAMELESSHELPER_USE_NAMESPACE 41 | 42 | using namespace Global; 43 | 44 | FRAMELESSHELPER_STRING_CONSTANT(Geometry) 45 | FRAMELESSHELPER_STRING_CONSTANT(DevicePixelRatio) 46 | 47 | MainWindow::MainWindow(QWidget *parent) : FramelessWidget(parent) 48 | { 49 | initialize(); 50 | } 51 | 52 | MainWindow::~MainWindow() = default; 53 | 54 | void MainWindow::closeEvent(QCloseEvent *event) 55 | { 56 | if (!parent()) { 57 | Settings::set({}, kGeometry, geometry()); 58 | Settings::set({}, kDevicePixelRatio, devicePixelRatioF()); 59 | } 60 | FramelessWidget::closeEvent(event); 61 | } 62 | 63 | void MainWindow::initialize() 64 | { 65 | setWindowTitle(tr("FramelessHelper demo application - QOpenGLWidget")); 66 | setWindowIcon(QFileIconProvider().icon(QFileIconProvider::Computer)); 67 | resize(800, 600); 68 | m_titleBar = new StandardTitleBar(this); 69 | m_titleBar->setWindowIconVisible(true); 70 | m_glWidget = new GLWidget(this); 71 | const auto mainLayout = new QVBoxLayout(this); 72 | mainLayout->setSpacing(0); 73 | mainLayout->setContentsMargins(0, 0, 0, 0); 74 | mainLayout->addWidget(m_titleBar); 75 | mainLayout->addWidget(m_glWidget); 76 | 77 | FramelessWidgetsHelper *helper = FramelessWidgetsHelper::get(this); 78 | helper->setTitleBarWidget(m_titleBar); 79 | #ifndef Q_OS_MACOS 80 | helper->setSystemButton(m_titleBar->minimizeButton(), SystemButtonType::Minimize); 81 | helper->setSystemButton(m_titleBar->maximizeButton(), SystemButtonType::Maximize); 82 | helper->setSystemButton(m_titleBar->closeButton(), SystemButtonType::Close); 83 | #endif // Q_OS_MACOS 84 | } 85 | 86 | void MainWindow::waitReady() 87 | { 88 | FramelessWidgetsHelper *helper = FramelessWidgetsHelper::get(this); 89 | helper->waitForReady(); 90 | const auto savedGeometry = Settings::get({}, kGeometry); 91 | if (savedGeometry.isValid() && !parent()) { 92 | const auto savedDpr = Settings::get({}, kDevicePixelRatio); 93 | // Qt doesn't support dpr < 1. 94 | const qreal oldDpr = std::max(savedDpr, qreal(1)); 95 | const qreal scale = (devicePixelRatioF() / oldDpr); 96 | setGeometry({savedGeometry.topLeft() * scale, savedGeometry.size() * scale}); 97 | } else { 98 | helper->moveWindowToDesktopCenter(); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /examples/openglwidget/mainwindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | FRAMELESSHELPER_BEGIN_NAMESPACE 30 | class StandardTitleBar; 31 | FRAMELESSHELPER_END_NAMESPACE 32 | 33 | class GLWidget; 34 | 35 | class MainWindow : public FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessWidget) 36 | { 37 | Q_OBJECT 38 | Q_DISABLE_COPY(MainWindow) 39 | 40 | public: 41 | explicit MainWindow(QWidget *parent = nullptr); 42 | ~MainWindow() override; 43 | 44 | void waitReady(); 45 | 46 | protected: 47 | void closeEvent(QCloseEvent *event) override; 48 | 49 | private: 50 | void initialize(); 51 | 52 | private: 53 | FRAMELESSHELPER_PREPEND_NAMESPACE(StandardTitleBar) *m_titleBar = nullptr; 54 | GLWidget *m_glWidget = nullptr; 55 | }; 56 | -------------------------------------------------------------------------------- /examples/quick/images/microsoft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangwenx190/framelesshelper/3102b4ea3b0756d92e02ae1656d0cccc9f824a82/examples/quick/images/microsoft.png -------------------------------------------------------------------------------- /examples/quick/images/microsoft.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /examples/quick/qml/HomePage.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | import QtQml 26 | 27 | QtObject { 28 | property Window window: Window{} 29 | property ApplicationWindow applicationWindow: ApplicationWindow{} 30 | 31 | Component.onCompleted: { 32 | window.show(); 33 | applicationWindow.show(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /examples/quick/quick.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | TARGET = FramelessHelperDemo-Quick 3 | QT += qml quick quickcontrols2 4 | DEFINES += QUICK_USE_QMAKE 5 | HEADERS += \ 6 | ../shared/log.h \ 7 | ../shared/settings.h \ 8 | quicksettings.h 9 | SOURCES += \ 10 | ../shared/log.cpp \ 11 | ../shared/settings.cpp \ 12 | quicksettings.cpp \ 13 | main.cpp 14 | RESOURCES += resources.qrc 15 | include(../../qmake/core.pri) 16 | include(../../qmake/quick.pri) 17 | -------------------------------------------------------------------------------- /examples/quick/quicksettings.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "quicksettings.h" 26 | #include "../shared/settings.h" 27 | 28 | FRAMELESSHELPER_STRING_CONSTANT(Geometry) 29 | FRAMELESSHELPER_STRING_CONSTANT(DevicePixelRatio) 30 | 31 | extern template void Settings::set(const QString &, const QString &, const QRect &); 32 | extern template void Settings::set(const QString &, const QString &, const qreal &); 33 | 34 | extern template QRect Settings::get(const QString &, const QString &); 35 | extern template qreal Settings::get(const QString &, const QString &); 36 | 37 | QuickSettings::QuickSettings(QObject *parent) : QObject(parent) 38 | { 39 | } 40 | 41 | QuickSettings::~QuickSettings() = default; 42 | 43 | void QuickSettings::saveGeometry(QWindow *window) 44 | { 45 | Q_ASSERT(window); 46 | if (!window) { 47 | return; 48 | } 49 | const QString objName = window->objectName(); 50 | Settings::set(objName, kGeometry, window->geometry()); 51 | Settings::set(objName, kDevicePixelRatio, window->devicePixelRatio()); 52 | } 53 | 54 | bool QuickSettings::restoreGeometry(QWindow *window) 55 | { 56 | Q_ASSERT(window); 57 | if (!window) { 58 | return false; 59 | } 60 | const QString objName = window->objectName(); 61 | const auto savedGeometry = Settings::get(objName, kGeometry); 62 | if (!savedGeometry.isValid()) { 63 | return false; 64 | } 65 | const auto savedDpr = Settings::get(objName, kDevicePixelRatio); 66 | // Qt doesn't support dpr < 1. 67 | const qreal oldDpr = std::max(savedDpr, qreal(1)); 68 | const qreal scale = (window->devicePixelRatio() / oldDpr); 69 | window->setGeometry({savedGeometry.topLeft() * scale, savedGeometry.size() * scale}); 70 | return true; 71 | } 72 | -------------------------------------------------------------------------------- /examples/quick/quicksettings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | class QuickSettings : public QObject 31 | { 32 | Q_OBJECT 33 | #ifdef QML_NAMED_ELEMENT 34 | QML_NAMED_ELEMENT(Settings) 35 | #endif 36 | #ifdef QML_SINGLETON 37 | QML_SINGLETON 38 | #endif 39 | Q_DISABLE_COPY(QuickSettings) 40 | 41 | public: 42 | explicit QuickSettings(QObject *parent = nullptr); 43 | ~QuickSettings() override; 44 | 45 | public Q_SLOTS: 46 | void saveGeometry(QWindow *window); 47 | Q_NODISCARD bool restoreGeometry(QWindow *window); 48 | }; 49 | -------------------------------------------------------------------------------- /examples/quick/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/microsoft.svg 4 | qml/Window.qml 5 | qml/ApplicationWindow.qml 6 | qml/HomePage.qml 7 | 8 | 9 | -------------------------------------------------------------------------------- /examples/quick/scripts/d3d11.bat: -------------------------------------------------------------------------------- 1 | :: MIT License 2 | :: 3 | :: Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 4 | :: 5 | :: Permission is hereby granted, free of charge, to any person obtaining a copy 6 | :: of this software and associated documentation files (the "Software"), to deal 7 | :: in the Software without restriction, including without limitation the rights 8 | :: to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | :: copies of the Software, and to permit persons to whom the Software is 10 | :: furnished to do so, subject to the following conditions: 11 | :: 12 | :: The above copyright notice and this permission notice shall be included in 13 | :: all copies or substantial portions of the Software. 14 | :: 15 | :: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | :: IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | :: FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | :: AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | :: LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | :: OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | :: SOFTWARE. 22 | 23 | @echo off 24 | setlocal 25 | set QSG_RHI_BACKEND=d3d11 26 | "%~dp0FramelessHelperDemo-Quick.exe" 27 | endlocal 28 | exit /b 0 29 | -------------------------------------------------------------------------------- /examples/quick/scripts/d3d12.bat: -------------------------------------------------------------------------------- 1 | :: MIT License 2 | :: 3 | :: Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 4 | :: 5 | :: Permission is hereby granted, free of charge, to any person obtaining a copy 6 | :: of this software and associated documentation files (the "Software"), to deal 7 | :: in the Software without restriction, including without limitation the rights 8 | :: to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | :: copies of the Software, and to permit persons to whom the Software is 10 | :: furnished to do so, subject to the following conditions: 11 | :: 12 | :: The above copyright notice and this permission notice shall be included in 13 | :: all copies or substantial portions of the Software. 14 | :: 15 | :: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | :: IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | :: FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | :: AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | :: LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | :: OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | :: SOFTWARE. 22 | 23 | @echo off 24 | setlocal 25 | set QSG_RHI_BACKEND=d3d12 26 | "%~dp0FramelessHelperDemo-Quick.exe" 27 | endlocal 28 | exit /b 0 29 | -------------------------------------------------------------------------------- /examples/quick/scripts/opengl.bat: -------------------------------------------------------------------------------- 1 | :: MIT License 2 | :: 3 | :: Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 4 | :: 5 | :: Permission is hereby granted, free of charge, to any person obtaining a copy 6 | :: of this software and associated documentation files (the "Software"), to deal 7 | :: in the Software without restriction, including without limitation the rights 8 | :: to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | :: copies of the Software, and to permit persons to whom the Software is 10 | :: furnished to do so, subject to the following conditions: 11 | :: 12 | :: The above copyright notice and this permission notice shall be included in 13 | :: all copies or substantial portions of the Software. 14 | :: 15 | :: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | :: IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | :: FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | :: AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | :: LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | :: OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | :: SOFTWARE. 22 | 23 | @echo off 24 | setlocal 25 | set QSG_RHI_BACKEND=opengl 26 | "%~dp0FramelessHelperDemo-Quick.exe" 27 | endlocal 28 | exit /b 0 29 | -------------------------------------------------------------------------------- /examples/quick/scripts/vulkan.bat: -------------------------------------------------------------------------------- 1 | :: MIT License 2 | :: 3 | :: Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 4 | :: 5 | :: Permission is hereby granted, free of charge, to any person obtaining a copy 6 | :: of this software and associated documentation files (the "Software"), to deal 7 | :: in the Software without restriction, including without limitation the rights 8 | :: to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | :: copies of the Software, and to permit persons to whom the Software is 10 | :: furnished to do so, subject to the following conditions: 11 | :: 12 | :: The above copyright notice and this permission notice shall be included in 13 | :: all copies or substantial portions of the Software. 14 | :: 15 | :: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | :: IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | :: FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | :: AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | :: LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | :: OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | :: SOFTWARE. 22 | 23 | @echo off 24 | setlocal 25 | set QSG_RHI_BACKEND=vulkan 26 | "%~dp0FramelessHelperDemo-Quick.exe" 27 | endlocal 28 | exit /b 0 29 | -------------------------------------------------------------------------------- /examples/shared/example.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangwenx190/framelesshelper/3102b4ea3b0756d92e02ae1656d0cccc9f824a82/examples/shared/example.ico -------------------------------------------------------------------------------- /examples/shared/log.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "log.h" 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #ifndef QT_ENDL 33 | # if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) 34 | # define QT_ENDL Qt::endl 35 | # else 36 | # define QT_ENDL endl 37 | # endif 38 | #endif 39 | 40 | static QString g_app = {}; 41 | static bool g_logError = false; 42 | 43 | static std::unique_ptr g_logFile = nullptr; 44 | static std::unique_ptr g_logStream = nullptr; 45 | 46 | static inline void myMessageHandler(const QtMsgType type, const QMessageLogContext &context, const QString &message) 47 | { 48 | if (message.isEmpty()) { 49 | return; 50 | } 51 | const QString finalMessage = qFormatLogMessage(type, context, message).trimmed(); 52 | if ((type == QtInfoMsg) || (type == QtDebugMsg)) { 53 | std::cout << qUtf8Printable(finalMessage) << std::endl; 54 | } else { 55 | std::cerr << qUtf8Printable(finalMessage) << std::endl; 56 | } 57 | if (g_logError) { 58 | return; 59 | } 60 | if (!g_logFile) { 61 | g_logFile = std::make_unique(); 62 | g_logFile->setFileName(FRAMELESSHELPER_STRING_LITERAL("debug-%1.log").arg(g_app)); 63 | if (!g_logFile->open(QFile::WriteOnly | QFile::Text | QFile::Append)) { 64 | std::cerr << "Can't open file to write: " << qUtf8Printable(g_logFile->errorString()) << std::endl; 65 | g_logFile.reset(); 66 | g_logError = true; 67 | return; 68 | } 69 | } 70 | if (!g_logStream) { 71 | g_logStream = std::make_unique(); 72 | g_logStream->setDevice(g_logFile.get()); 73 | } 74 | (*g_logStream) << finalMessage << QT_ENDL; 75 | } 76 | 77 | void Log::setup(const QString &app) 78 | { 79 | Q_ASSERT(!app.isEmpty()); 80 | if (app.isEmpty()) { 81 | return; 82 | } 83 | static bool once = false; 84 | if (once) { 85 | return; 86 | } 87 | once = true; 88 | g_app = app; 89 | qSetMessagePattern(FRAMELESSHELPER_STRING_LITERAL( 90 | "[%{time yyyy/MM/dd hh:mm:ss.zzz}] <%{if-info}INFO%{endif}%{if-debug}DEBUG" 91 | "%{endif}%{if-warning}WARNING%{endif}%{if-critical}CRITICAL%{endif}%{if-fatal}" 92 | "FATAL%{endif}> %{if-category}%{category}: %{endif}%{message}")); 93 | qInstallMessageHandler(myMessageHandler); 94 | } 95 | -------------------------------------------------------------------------------- /examples/shared/log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | namespace Log 30 | { 31 | void setup(const QString &app); 32 | } // namespace Log 33 | -------------------------------------------------------------------------------- /examples/shared/settings.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "settings.h" 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | static std::unique_ptr g_settings = nullptr; 33 | 34 | [[nodiscard]] static inline QSettings *appConfigFile() 35 | { 36 | const QFileInfo fileInfo(QCoreApplication::applicationFilePath()); 37 | const QString iniFileName = fileInfo.completeBaseName() + FRAMELESSHELPER_STRING_LITERAL(".ini"); 38 | const QString iniFilePath = fileInfo.canonicalPath() + u'/' + iniFileName; 39 | return new QSettings(iniFilePath, QSettings::IniFormat); 40 | } 41 | 42 | [[nodiscard]] static inline QString appKey(const QString &id, const QString &key) 43 | { 44 | Q_ASSERT(!key.isEmpty()); 45 | if (key.isEmpty()) { 46 | return {}; 47 | } 48 | return (id.isEmpty() ? key : (id + u'/' + key)); 49 | } 50 | 51 | template 52 | void Settings::set(const QString &id, const QString &key, const T &data) 53 | { 54 | Q_ASSERT(!key.isEmpty()); 55 | if (key.isEmpty()) { 56 | return; 57 | } 58 | if (!g_settings) { 59 | g_settings.reset(appConfigFile()); 60 | } 61 | g_settings->setValue(appKey(id, key), data); 62 | } 63 | 64 | template 65 | T Settings::get(const QString &id, const QString &key) 66 | { 67 | Q_ASSERT(!key.isEmpty()); 68 | if (key.isEmpty()) { 69 | return T{}; 70 | } 71 | if (!g_settings) { 72 | g_settings.reset(appConfigFile()); 73 | } 74 | return qvariant_cast(g_settings->value(appKey(id, key))); 75 | } 76 | 77 | template void Settings::set(const QString &, const QString &, const QRect &); 78 | template void Settings::set(const QString &, const QString &, const qreal &); 79 | template void Settings::set(const QString &, const QString &, const QByteArray &); 80 | 81 | template QRect Settings::get(const QString &, const QString &); 82 | template qreal Settings::get(const QString &, const QString &); 83 | template QByteArray Settings::get(const QString &, const QString &); 84 | -------------------------------------------------------------------------------- /examples/shared/settings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | namespace Settings 30 | { 31 | template 32 | void set(const QString &id, const QString &key, const T &data); 33 | 34 | template 35 | [[nodiscard]] T get(const QString &id, const QString &key); 36 | } // namespace Settings 37 | -------------------------------------------------------------------------------- /examples/widget/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include 26 | #include 27 | #include "widget.h" 28 | #include "../shared/log.h" 29 | 30 | FRAMELESSHELPER_USE_NAMESPACE 31 | 32 | #define CREATE_WINDOW(Name) \ 33 | const auto Name = std::make_unique(); \ 34 | Name->setObjectName(FRAMELESSHELPER_STRING_LITERAL(#Name)); \ 35 | Name->waitReady(); \ 36 | Name->show(); 37 | 38 | int main(int argc, char *argv[]) 39 | { 40 | Log::setup(FRAMELESSHELPER_STRING_LITERAL("widget")); 41 | 42 | // Not necessary, but better call this function, before the construction 43 | // of any Q(Core|Gui)Application instances. 44 | FramelessHelperWidgetsInitialize(); 45 | 46 | #if 0 47 | if (!qEnvironmentVariableIsSet("QT_WIDGETS_RHI")) { 48 | qputenv("QT_WIDGETS_RHI", FRAMELESSHELPER_BYTEARRAY_LITERAL("1")); 49 | } 50 | #endif 51 | 52 | const auto application = std::make_unique(argc, argv); 53 | 54 | // Must be called after QGuiApplication has been constructed, we are using 55 | // some private functions from QPA which won't be available until there's 56 | // a QGuiApplication instance. 57 | FramelessHelperEnableThemeAware(); 58 | 59 | FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); 60 | //FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial); 61 | 62 | CREATE_WINDOW(widget1) 63 | CREATE_WINDOW(widget2) 64 | CREATE_WINDOW(widget3) 65 | 66 | return QCoreApplication::exec(); 67 | } 68 | -------------------------------------------------------------------------------- /examples/widget/widget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | FRAMELESSHELPER_REQUIRE_CONFIG(window) 30 | 31 | QT_BEGIN_NAMESPACE 32 | class QLabel; 33 | class QShortcut; 34 | QT_END_NAMESPACE 35 | 36 | #if FRAMELESSHELPER_CONFIG(titlebar) 37 | FRAMELESSHELPER_BEGIN_NAMESPACE 38 | class StandardTitleBar; 39 | FRAMELESSHELPER_END_NAMESPACE 40 | #endif 41 | 42 | class Widget : public FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessWidget) 43 | { 44 | Q_OBJECT 45 | Q_DISABLE_COPY(Widget) 46 | 47 | public: 48 | explicit Widget(QWidget *parent = nullptr); 49 | ~Widget() override; 50 | 51 | void waitReady(); 52 | 53 | protected: 54 | void timerEvent(QTimerEvent *event) override; 55 | void closeEvent(QCloseEvent *event) override; 56 | 57 | private: 58 | void initialize(); 59 | 60 | private Q_SLOTS: 61 | void updateStyleSheet(); 62 | 63 | private: 64 | #if FRAMELESSHELPER_CONFIG(titlebar) 65 | FRAMELESSHELPER_PREPEND_NAMESPACE(StandardTitleBar) *m_titleBar = nullptr; 66 | #endif 67 | QLabel *m_clockLabel = nullptr; 68 | QLabel *m_compilerInfoLabel = nullptr; 69 | QLabel *m_commitInfoLabel = nullptr; 70 | QShortcut *m_fullScreenShortcut = nullptr; 71 | QShortcut *m_cancelShortcut = nullptr; 72 | int m_timerId = -1; 73 | }; 74 | -------------------------------------------------------------------------------- /examples/widget/widget.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | TARGET = FramelessHelperDemo-Widget 3 | QT += widgets 4 | HEADERS += \ 5 | ../shared/log.h \ 6 | ../shared/settings.h \ 7 | widget.h 8 | SOURCES += \ 9 | ../shared/log.cpp \ 10 | ../shared/settings.cpp \ 11 | widget.cpp \ 12 | main.cpp 13 | include(../../qmake/core.pri) 14 | include(../../qmake/widgets.pri) 15 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/ChromePalette: -------------------------------------------------------------------------------- 1 | #include "chromepalette.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/FramelessHelper_Linux: -------------------------------------------------------------------------------- 1 | #include "framelesshelper_linux.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/FramelessHelper_Qt: -------------------------------------------------------------------------------- 1 | #include "framelesshelper_qt.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/FramelessHelper_Win: -------------------------------------------------------------------------------- 1 | #include "framelesshelper_win.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/FramelessHelper_Windows: -------------------------------------------------------------------------------- 1 | #include "framelesshelper_windows.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/FramelessManager: -------------------------------------------------------------------------------- 1 | #include "framelessmanager.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/Global: -------------------------------------------------------------------------------- 1 | #include "framelesshelpercore_global.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/MicaMaterial: -------------------------------------------------------------------------------- 1 | #include "micamaterial.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/Utils: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/WindowBorderPainter: -------------------------------------------------------------------------------- 1 | #include "windowborderpainter.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/framelesshelper_qt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | #if !FRAMELESSHELPER_CONFIG(native_impl) 31 | 32 | FRAMELESSHELPER_BEGIN_NAMESPACE 33 | 34 | class FramelessHelperQtPrivate; 35 | class FRAMELESSHELPER_CORE_API FramelessHelperQt : public QObject 36 | { 37 | FRAMELESSHELPER_PUBLIC_QT_CLASS(FramelessHelperQt) 38 | 39 | public: 40 | explicit FramelessHelperQt(QObject *parent = nullptr); 41 | ~FramelessHelperQt() override; 42 | 43 | static void addWindow(const QObject *window); 44 | static void removeWindow(const QObject *window); 45 | 46 | protected: 47 | Q_NODISCARD bool eventFilter(QObject *object, QEvent *event) override; 48 | }; 49 | 50 | FRAMELESSHELPER_END_NAMESPACE 51 | 52 | #endif // !native_impl 53 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/framelesshelper_win.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | #ifdef Q_OS_WINDOWS 31 | 32 | #if FRAMELESSHELPER_CONFIG(native_impl) 33 | 34 | FRAMELESSHELPER_BEGIN_NAMESPACE 35 | 36 | class FRAMELESSHELPER_CORE_API FramelessHelperWin : public QAbstractNativeEventFilter 37 | { 38 | FRAMELESSHELPER_CLASS(FramelessHelperWin) 39 | 40 | public: 41 | explicit FramelessHelperWin(); 42 | ~FramelessHelperWin() override; 43 | 44 | static void addWindow(const QObject *window); 45 | static void removeWindow(const QObject *window); 46 | 47 | Q_NODISCARD bool nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result) override; 48 | }; 49 | 50 | FRAMELESSHELPER_END_NAMESPACE 51 | 52 | #endif // native_impl 53 | 54 | #endif // Q_OS_WINDOWS 55 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/framelessmanager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | FRAMELESSHELPER_BEGIN_NAMESPACE 31 | 32 | class FramelessManagerPrivate; 33 | class FRAMELESSHELPER_CORE_API FramelessManager : public QObject 34 | { 35 | FRAMELESSHELPER_PUBLIC_QT_CLASS(FramelessManager) 36 | Q_PROPERTY(Global::SystemTheme systemTheme READ systemTheme WRITE setOverrideTheme NOTIFY systemThemeChanged FINAL) 37 | Q_PROPERTY(QColor systemAccentColor READ systemAccentColor NOTIFY systemThemeChanged FINAL) 38 | Q_PROPERTY(QString wallpaper READ wallpaper NOTIFY wallpaperChanged FINAL) 39 | Q_PROPERTY(Global::WallpaperAspectStyle wallpaperAspectStyle READ wallpaperAspectStyle NOTIFY wallpaperChanged FINAL) 40 | 41 | public: 42 | Q_NODISCARD static FramelessManager *instance(); 43 | 44 | Q_NODISCARD Global::SystemTheme systemTheme() const; 45 | Q_NODISCARD QColor systemAccentColor() const; 46 | Q_NODISCARD QString wallpaper() const; 47 | Q_NODISCARD Global::WallpaperAspectStyle wallpaperAspectStyle() const; 48 | 49 | public Q_SLOTS: 50 | Q_NODISCARD bool addWindow(const QObject *window, const WId windowId); 51 | Q_NODISCARD bool removeWindow(const QObject *window); 52 | void setOverrideTheme(const Global::SystemTheme theme); 53 | 54 | Q_SIGNALS: 55 | void systemThemeChanged(); 56 | void wallpaperChanged(); 57 | 58 | private: 59 | explicit FramelessManager(QObject *parent = nullptr); 60 | ~FramelessManager() override; 61 | }; 62 | 63 | FRAMELESSHELPER_END_NAMESPACE 64 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/micamaterial.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | #if FRAMELESSHELPER_CONFIG(mica_material) 31 | 32 | FRAMELESSHELPER_BEGIN_NAMESPACE 33 | 34 | class MicaMaterialPrivate; 35 | class FRAMELESSHELPER_CORE_API MicaMaterial : public QObject 36 | { 37 | FRAMELESSHELPER_PUBLIC_QT_CLASS(MicaMaterial) 38 | 39 | Q_PROPERTY(QColor tintColor READ tintColor WRITE setTintColor NOTIFY tintColorChanged FINAL) 40 | Q_PROPERTY(qreal tintOpacity READ tintOpacity WRITE setTintOpacity NOTIFY tintOpacityChanged FINAL) 41 | Q_PROPERTY(QColor fallbackColor READ fallbackColor WRITE setFallbackColor NOTIFY fallbackColorChanged FINAL) 42 | Q_PROPERTY(qreal noiseOpacity READ noiseOpacity WRITE setNoiseOpacity NOTIFY noiseOpacityChanged FINAL) 43 | Q_PROPERTY(bool fallbackEnabled READ isFallbackEnabled WRITE setFallbackEnabled NOTIFY fallbackEnabledChanged FINAL) 44 | 45 | public: 46 | explicit MicaMaterial(QObject *parent = nullptr); 47 | ~MicaMaterial() override; 48 | 49 | Q_NODISCARD QColor tintColor() const; 50 | void setTintColor(const QColor &value); 51 | 52 | Q_NODISCARD qreal tintOpacity() const; 53 | void setTintOpacity(const qreal value); 54 | 55 | Q_NODISCARD QColor fallbackColor() const; 56 | void setFallbackColor(const QColor &value); 57 | 58 | Q_NODISCARD qreal noiseOpacity() const; 59 | void setNoiseOpacity(const qreal value); 60 | 61 | Q_NODISCARD bool isFallbackEnabled() const; 62 | void setFallbackEnabled(const bool value); 63 | 64 | public Q_SLOTS: 65 | void paint(QPainter *painter, const QRect &rect, const bool active = true); 66 | 67 | [[deprecated("Use another overload instead.")]] 68 | void paint(QPainter *painter, const QSize &size, const QPoint &pos, const bool active = true) 69 | { 70 | paint(painter, QRect{ pos, size }, active); 71 | } 72 | 73 | Q_SIGNALS: 74 | void tintColorChanged(); 75 | void tintOpacityChanged(); 76 | void fallbackColorChanged(); 77 | void noiseOpacityChanged(); 78 | void fallbackEnabledChanged(); 79 | void shouldRedraw(); 80 | }; 81 | 82 | FRAMELESSHELPER_END_NAMESPACE 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/private/chromepalette_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | #if FRAMELESSHELPER_CONFIG(titlebar) 31 | 32 | FRAMELESSHELPER_BEGIN_NAMESPACE 33 | 34 | class ChromePalette; 35 | class FRAMELESSHELPER_CORE_API ChromePalettePrivate : public QObject 36 | { 37 | FRAMELESSHELPER_PRIVATE_QT_CLASS(ChromePalette) 38 | 39 | public: 40 | explicit ChromePalettePrivate(ChromePalette *q); 41 | ~ChromePalettePrivate() override; 42 | 43 | Q_SLOT void refresh(); 44 | 45 | // System-defined ones: 46 | QColor titleBarActiveBackgroundColor_sys = {}; 47 | QColor titleBarInactiveBackgroundColor_sys = {}; 48 | QColor titleBarActiveForegroundColor_sys = {}; 49 | QColor titleBarInactiveForegroundColor_sys = {}; 50 | QColor chromeButtonNormalColor_sys = {}; 51 | QColor chromeButtonHoverColor_sys = {}; 52 | QColor chromeButtonPressColor_sys = {}; 53 | QColor closeButtonNormalColor_sys = {}; 54 | QColor closeButtonHoverColor_sys = {}; 55 | QColor closeButtonPressColor_sys = {}; 56 | // User-defined ones: 57 | std::optional titleBarActiveBackgroundColor = std::nullopt; 58 | std::optional titleBarInactiveBackgroundColor = std::nullopt; 59 | std::optional titleBarActiveForegroundColor = std::nullopt; 60 | std::optional titleBarInactiveForegroundColor = std::nullopt; 61 | std::optional chromeButtonNormalColor = std::nullopt; 62 | std::optional chromeButtonHoverColor = std::nullopt; 63 | std::optional chromeButtonPressColor = std::nullopt; 64 | std::optional closeButtonNormalColor = std::nullopt; 65 | std::optional closeButtonHoverColor = std::nullopt; 66 | std::optional closeButtonPressColor = std::nullopt; 67 | }; 68 | 69 | FRAMELESSHELPER_END_NAMESPACE 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/private/framelessconfig_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | FRAMELESSHELPER_BEGIN_NAMESPACE 30 | 31 | class FRAMELESSHELPER_CORE_API FramelessConfig : public QObject 32 | { 33 | FRAMELESSHELPER_QT_CLASS(FramelessConfig) 34 | 35 | public: 36 | Q_NODISCARD static FramelessConfig *instance(); 37 | 38 | void reload(const bool force = false); 39 | 40 | void set(const Global::Option option, const bool on = true); 41 | Q_NODISCARD bool isSet(const Global::Option option) const; 42 | 43 | static void setLoadFromEnvironmentVariablesDisabled(const bool on = true); 44 | static void setLoadFromConfigurationFileDisabled(const bool on = true); 45 | 46 | private: 47 | explicit FramelessConfig(QObject *parent = nullptr); 48 | ~FramelessConfig() override; 49 | }; 50 | 51 | FRAMELESSHELPER_END_NAMESPACE 52 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/private/framelessmanager_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | FRAMELESSHELPER_BEGIN_NAMESPACE 32 | 33 | struct FramelessData; 34 | using FramelessDataPtr = std::shared_ptr; 35 | 36 | class FramelessManager; 37 | class FRAMELESSHELPER_CORE_API FramelessManagerPrivate : public QObject 38 | { 39 | FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessManager) 40 | 41 | public: 42 | explicit FramelessManagerPrivate(FramelessManager *q); 43 | ~FramelessManagerPrivate() override; 44 | 45 | static void initializeIconFont(); 46 | Q_NODISCARD static QFont getIconFont(); 47 | 48 | Q_SLOT void notifySystemThemeHasChangedOrNot(); 49 | Q_SLOT void notifyWallpaperHasChangedOrNot(); 50 | 51 | Q_NODISCARD bool isThemeOverrided() const; 52 | 53 | void initialize(); 54 | 55 | void doNotifySystemThemeHasChangedOrNot(); 56 | void doNotifyWallpaperHasChangedOrNot(); 57 | 58 | Q_NODISCARD static FramelessDataPtr getData(const QObject *window); 59 | Q_NODISCARD static FramelessDataPtr createData(const QObject *window, const WId windowId); 60 | Q_NODISCARD static WId getWindowId(const QObject *window); 61 | Q_NODISCARD static QObject *getWindow(const WId windowId); 62 | static void updateWindowId(const QObject *window, const WId newWindowId); 63 | 64 | Global::SystemTheme systemTheme = Global::SystemTheme::Unknown; 65 | std::optional overrideTheme = std::nullopt; 66 | QColor accentColor = {}; 67 | #ifdef Q_OS_WINDOWS 68 | Global::DwmColorizationArea colorizationArea = Global::DwmColorizationArea::None; 69 | #endif 70 | QString wallpaper = {}; 71 | Global::WallpaperAspectStyle wallpaperAspectStyle = Global::WallpaperAspectStyle::Fill; 72 | QTimer themeTimer{}; 73 | QTimer wallpaperTimer{}; 74 | }; 75 | 76 | class InternalEventFilter : public QObject 77 | { 78 | FRAMELESSHELPER_QT_CLASS(InternalEventFilter) 79 | 80 | public: 81 | explicit InternalEventFilter(const QObject *window, QObject *parent = nullptr); 82 | ~InternalEventFilter() override; 83 | 84 | protected: 85 | Q_NODISCARD bool eventFilter(QObject *object, QEvent *event) override; 86 | 87 | private: 88 | const QObject *m_window = nullptr; 89 | }; 90 | 91 | FRAMELESSHELPER_END_NAMESPACE 92 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/private/micamaterial_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #ifdef FRAMELESSHELPER_HAS_THREAD 30 | # undef FRAMELESSHELPER_HAS_THREAD 31 | #endif 32 | #if QT_CONFIG(thread) 33 | # define FRAMELESSHELPER_HAS_THREAD 1 34 | # include 35 | #else // !QT_CONFIG(thread) 36 | # define FRAMELESSHELPER_HAS_THREAD 0 37 | #endif // QT_CONFIG(thread) 38 | 39 | #if FRAMELESSHELPER_CONFIG(mica_material) 40 | 41 | FRAMELESSHELPER_BEGIN_NAMESPACE 42 | 43 | #if FRAMELESSHELPER_HAS_THREAD 44 | using FramelessHelperThreadClass = QThread; 45 | #else 46 | using FramelessHelperThreadClass = QObject; 47 | #endif 48 | 49 | class MicaMaterial; 50 | class FRAMELESSHELPER_CORE_API MicaMaterialPrivate : public QObject 51 | { 52 | FRAMELESSHELPER_PRIVATE_QT_CLASS(MicaMaterial) 53 | 54 | public: 55 | explicit MicaMaterialPrivate(MicaMaterial *q); 56 | ~MicaMaterialPrivate() override; 57 | 58 | Q_NODISCARD static QColor systemFallbackColor(); 59 | 60 | Q_NODISCARD QPoint mapToWallpaper(const QPoint &pos) const; 61 | Q_NODISCARD QSize mapToWallpaper(const QSize &size) const; 62 | Q_NODISCARD QRect mapToWallpaper(const QRect &rect) const; 63 | 64 | Q_SLOT void maybeGenerateBlurredWallpaper(const bool force = false); 65 | Q_SLOT void updateMaterialBrush(); 66 | Q_SLOT void forceRebuildWallpaper(); 67 | 68 | void initialize(); 69 | void prepareGraphicsResources(); 70 | 71 | QColor tintColor = {}; 72 | qreal tintOpacity = qreal(0); 73 | QColor fallbackColor = {}; 74 | qreal noiseOpacity = qreal(0); 75 | bool fallbackEnabled = true; 76 | QBrush micaBrush = {}; 77 | bool initialized = false; 78 | QSize wallpaperSize = {}; 79 | }; 80 | 81 | class WallpaperThread : public FramelessHelperThreadClass 82 | { 83 | FRAMELESSHELPER_QT_CLASS(WallpaperThread) 84 | 85 | public: 86 | explicit WallpaperThread(QObject *parent = nullptr); 87 | ~WallpaperThread() override; 88 | 89 | Q_SIGNALS: 90 | void imageUpdated(); 91 | 92 | #if FRAMELESSHELPER_HAS_THREAD 93 | protected: 94 | void run() override; 95 | #else 96 | public: 97 | void start(); 98 | #endif 99 | }; 100 | 101 | FRAMELESSHELPER_END_NAMESPACE 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/private/registrykey_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #ifdef Q_OS_WINDOWS 33 | 34 | #ifndef REGISTRYKEY_FORCE_QSETTINGS 35 | # define REGISTRYKEY_FORCE_QSETTINGS (0) 36 | #endif // REGISTRYKEY_FORCE_QSETTINGS 37 | 38 | #ifndef REGISTRYKEY_IMPL 39 | # if ((QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) && !(REGISTRYKEY_FORCE_QSETTINGS) && !defined(FRAMELESSHELPER_CORE_NO_PRIVATE)) 40 | # define REGISTRYKEY_IMPL (1) 41 | # else // ((QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) || REGISTRYKEY_FORCE_QSETTINGS || defined(FRAMELESSHELPER_CORE_NO_PRIVATE)) 42 | # define REGISTRYKEY_IMPL (2) 43 | # endif // ((QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) && !REGISTRYKEY_FORCE_QSETTINGS && !defined(FRAMELESSHELPER_CORE_NO_PRIVATE)) 44 | #endif // REGISTRYKEY_IMPL 45 | 46 | #ifndef REGISTRYKEY_QWINREGISTRYKEY 47 | # define REGISTRYKEY_QWINREGISTRYKEY ((REGISTRYKEY_IMPL) == 1) 48 | #endif // REGISTRYKEY_QWINREGISTRYKEY 49 | 50 | #ifndef REGISTRYKEY_QSETTINGS 51 | # define REGISTRYKEY_QSETTINGS ((REGISTRYKEY_IMPL) == 2) 52 | #endif // REGISTRYKEY_QSETTINGS 53 | 54 | QT_BEGIN_NAMESPACE 55 | class QWinRegistryKey; 56 | class QSettings; 57 | QT_END_NAMESPACE 58 | 59 | FRAMELESSHELPER_BEGIN_NAMESPACE 60 | 61 | class FRAMELESSHELPER_CORE_API RegistryKey : public QObject 62 | { 63 | FRAMELESSHELPER_QT_CLASS(RegistryKey) 64 | 65 | public: 66 | explicit RegistryKey(const Global::RegistryRootKey root, const QString &key, QObject *parent = nullptr); 67 | ~RegistryKey() override; 68 | 69 | Q_NODISCARD Global::RegistryRootKey rootKey() const; 70 | Q_NODISCARD QString subKey() const; 71 | 72 | Q_NODISCARD bool isValid() const; 73 | 74 | Q_NODISCARD QVariant value(const QString &name) const; 75 | template 76 | Q_NODISCARD std::optional value(const QString &name) const 77 | { 78 | const QVariant var = value(name); 79 | if (var.isValid() && !var.isNull()) { 80 | return qvariant_cast(var); 81 | } 82 | return std::nullopt; 83 | } 84 | 85 | private: 86 | Global::RegistryRootKey m_rootKey = Global::RegistryRootKey::CurrentUser; 87 | QString m_subKey = {}; 88 | #if REGISTRYKEY_QWINREGISTRYKEY 89 | std::unique_ptr m_registryKey; 90 | #else 91 | std::unique_ptr m_settings; 92 | #endif 93 | }; 94 | 95 | FRAMELESSHELPER_END_NAMESPACE 96 | 97 | #endif // Q_OS_WINDOWS 98 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/private/scopeguard_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) 31 | # include 32 | #else // (QT_VERSION < QT_VERSION_CHECK(5, 12, 0)) 33 | 34 | FRAMELESSHELPER_BEGIN_NAMESPACE 35 | 36 | using ScopeGuardCallback = std::function; 37 | 38 | class [[nodiscard]] ScopeGuard 39 | { 40 | FRAMELESSHELPER_CLASS(ScopeGuard) 41 | 42 | public: 43 | ScopeGuard() 44 | { 45 | } 46 | 47 | explicit ScopeGuard(const ScopeGuardCallback &cb) 48 | { 49 | // For the ctor, we require a non-null function. 50 | Q_ASSERT(cb); 51 | if (!cb) { 52 | return; 53 | } 54 | m_callback = cb; 55 | } 56 | 57 | explicit ScopeGuard(ScopeGuardCallback &&cb) 58 | { 59 | // For the ctor, we require a non-null function. 60 | Q_ASSERT(cb); 61 | if (!cb) { 62 | return; 63 | } 64 | m_callback = std::move(cb); 65 | } 66 | 67 | ScopeGuard(ScopeGuard &&other) : m_callback(std::move(other.m_callback)) 68 | { 69 | } 70 | 71 | ~ScopeGuard() 72 | { 73 | if (m_callback) { 74 | m_callback(); 75 | } 76 | } 77 | 78 | [[nodiscard]] ScopeGuardCallback callback() const 79 | { 80 | return m_callback; 81 | } 82 | 83 | void setCallback(const ScopeGuardCallback &cb) 84 | { 85 | // But we allow null functions here. 86 | m_callback = cb; 87 | } 88 | 89 | private: 90 | ScopeGuardCallback m_callback = nullptr; 91 | }; 92 | 93 | [[nodiscard]] inline ScopeGuard make_guard(ScopeGuardCallback &&cb) 94 | { 95 | return ScopeGuard(cb); 96 | } 97 | 98 | #define qScopeGuard make_guard 99 | 100 | FRAMELESSHELPER_END_NAMESPACE 101 | 102 | #endif // (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) 103 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/private/sysapiloader_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | FRAMELESSHELPER_BEGIN_NAMESPACE 30 | 31 | class FRAMELESSHELPER_CORE_API SysApiLoader : public QObject 32 | { 33 | FRAMELESSHELPER_QT_CLASS(SysApiLoader) 34 | 35 | public: 36 | Q_NODISCARD static SysApiLoader *instance(); 37 | 38 | Q_NODISCARD static QString platformSharedLibrarySuffixName(); 39 | Q_NODISCARD static QString platformSystemLibraryDirectory(); 40 | Q_NODISCARD static QString generateUniqueKey(const QString &library, const QString &function); 41 | 42 | Q_NODISCARD static QFunctionPointer resolve(const QString &library, const char *function); 43 | Q_NODISCARD static QFunctionPointer resolve(const QString &library, const QString &function); 44 | 45 | Q_NODISCARD bool isAvailable(const QString &library, const QString &function); 46 | 47 | Q_NODISCARD QFunctionPointer get(const QString &library, const QString &function); 48 | 49 | template 50 | Q_NODISCARD T get(const QString &library, const QString &function) 51 | { 52 | return reinterpret_cast(get(library, function)); 53 | } 54 | 55 | private: 56 | explicit SysApiLoader(QObject *parent = nullptr); 57 | ~SysApiLoader() override; 58 | }; 59 | 60 | FRAMELESSHELPER_END_NAMESPACE 61 | 62 | #define API_AVAILABLE(lib, func) \ 63 | (FRAMELESSHELPER_PREPEND_NAMESPACE(SysApiLoader)::instance()->isAvailable(k##lib, k##func)) 64 | 65 | #define API_CALL_FUNCTION(lib, func, ...) \ 66 | ((FRAMELESSHELPER_PREPEND_NAMESPACE(SysApiLoader)::instance()->get(k##lib, k##func))(__VA_ARGS__)) 67 | 68 | #define API_CALL_FUNCTION2(lib, func, type, ...) \ 69 | ((FRAMELESSHELPER_PREPEND_NAMESPACE(SysApiLoader)::instance()->get(k##lib, k##func))(__VA_ARGS__)) 70 | 71 | #define API_CALL_FUNCTION3(lib, func, name, ...) \ 72 | ((FRAMELESSHELPER_PREPEND_NAMESPACE(SysApiLoader)::instance()->get(k##lib, k##name))(__VA_ARGS__)) 73 | 74 | #define API_CALL_FUNCTION4(lib, func, ...) API_CALL_FUNCTION3(lib, _##func, func, __VA_ARGS__) 75 | 76 | #define API_CALL_FUNCTION5(lib, func, ...) API_CALL_FUNCTION3(lib, func##2, func, __VA_ARGS__) 77 | 78 | #ifdef Q_OS_WINDOWS 79 | # define API_USER_AVAILABLE(func) API_AVAILABLE(user32, func) 80 | # define API_THEME_AVAILABLE(func) API_AVAILABLE(uxtheme, func) 81 | # define API_DWM_AVAILABLE(func) API_AVAILABLE(dwmapi, func) 82 | # define API_SHCORE_AVAILABLE(func) API_AVAILABLE(shcore, func) 83 | # define API_WINMM_AVAILABLE(func) API_AVAILABLE(winmm, func) 84 | # define API_D2D_AVAILABLE(func) API_AVAILABLE(d2d1, func) 85 | # define API_NT_AVAILABLE(func) API_AVAILABLE(ntdll, func) 86 | #endif // Q_OS_WINDOWS 87 | 88 | #if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) 89 | # define API_XLIB_AVAILABLE(func) API_AVAILABLE(libX11, func) 90 | # define API_XCB_AVAILABLE(func) API_AVAILABLE(libxcb, func) 91 | # define API_GTK_AVAILABLE(func) API_AVAILABLE(libgtk, func) 92 | #endif // Q_OS_LINUX 93 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/private/windowborderpainter_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | #if FRAMELESSHELPER_CONFIG(border_painter) 31 | 32 | FRAMELESSHELPER_BEGIN_NAMESPACE 33 | 34 | class WindowBorderPainter; 35 | class FRAMELESSHELPER_CORE_API WindowBorderPainterPrivate : public QObject 36 | { 37 | FRAMELESSHELPER_PRIVATE_QT_CLASS(WindowBorderPainter) 38 | 39 | public: 40 | explicit WindowBorderPainterPrivate(WindowBorderPainter *q); 41 | ~WindowBorderPainterPrivate() override; 42 | 43 | std::optional thickness = std::nullopt; 44 | std::optional edges = std::nullopt; 45 | std::optional activeColor = std::nullopt; 46 | std::optional inactiveColor = std::nullopt; 47 | }; 48 | 49 | FRAMELESSHELPER_END_NAMESPACE 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/private/winverhelper_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #ifdef Q_OS_WINDOWS 30 | 31 | FRAMELESSHELPER_BEGIN_NAMESPACE 32 | 33 | namespace WindowsVersionHelper 34 | { 35 | 36 | #define DECL(Name) [[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin##Name##OrGreater(); 37 | 38 | DECL(2K) 39 | DECL(XP) 40 | DECL(XP64) 41 | DECL(Vista) 42 | DECL(VistaSP1) 43 | DECL(VistaSP2) 44 | DECL(7) 45 | DECL(7SP1) 46 | DECL(8) 47 | DECL(8Point1) 48 | DECL(8Point1Update1) 49 | DECL(10) 50 | DECL(10TH1) 51 | DECL(10TH2) 52 | DECL(10RS1) 53 | DECL(10RS2) 54 | DECL(10RS3) 55 | DECL(10RS4) 56 | DECL(10RS5) 57 | DECL(1019H1) 58 | DECL(1019H2) 59 | DECL(1020H1) 60 | DECL(1020H2) 61 | DECL(1021H1) 62 | DECL(1021H2) 63 | DECL(1022H2) 64 | DECL(11) 65 | DECL(1121H2) 66 | DECL(1122H2) 67 | 68 | #undef DECL 69 | 70 | } // namespace WindowsVersionHelper 71 | 72 | FRAMELESSHELPER_END_NAMESPACE 73 | 74 | #endif // Q_OS_WINDOWS 75 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/windowborderpainter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | #if FRAMELESSHELPER_CONFIG(border_painter) 31 | 32 | FRAMELESSHELPER_BEGIN_NAMESPACE 33 | 34 | class WindowBorderPainterPrivate; 35 | class FRAMELESSHELPER_CORE_API WindowBorderPainter : public QObject 36 | { 37 | FRAMELESSHELPER_PUBLIC_QT_CLASS(WindowBorderPainter) 38 | 39 | Q_PROPERTY(int thickness READ thickness WRITE setThickness NOTIFY thicknessChanged FINAL) 40 | Q_PROPERTY(Global::WindowEdges edges READ edges WRITE setEdges NOTIFY edgesChanged FINAL) 41 | Q_PROPERTY(QColor activeColor READ activeColor WRITE setActiveColor NOTIFY activeColorChanged FINAL) 42 | Q_PROPERTY(QColor inactiveColor READ inactiveColor WRITE setInactiveColor NOTIFY inactiveColorChanged FINAL) 43 | 44 | Q_PROPERTY(int nativeThickness READ nativeThickness NOTIFY nativeBorderChanged FINAL) 45 | Q_PROPERTY(Global::WindowEdges nativeEdges READ nativeEdges NOTIFY nativeBorderChanged FINAL) 46 | Q_PROPERTY(QColor nativeActiveColor READ nativeActiveColor NOTIFY nativeBorderChanged FINAL) 47 | Q_PROPERTY(QColor nativeInactiveColor READ nativeInactiveColor NOTIFY nativeBorderChanged FINAL) 48 | 49 | public: 50 | explicit WindowBorderPainter(QObject *parent = nullptr); 51 | ~WindowBorderPainter() override; 52 | 53 | Q_NODISCARD int thickness() const; 54 | Q_NODISCARD Global::WindowEdges edges() const; 55 | Q_NODISCARD QColor activeColor() const; 56 | Q_NODISCARD QColor inactiveColor() const; 57 | 58 | Q_NODISCARD int nativeThickness() const; 59 | Q_NODISCARD Global::WindowEdges nativeEdges() const; 60 | Q_NODISCARD QColor nativeActiveColor() const; 61 | Q_NODISCARD QColor nativeInactiveColor() const; 62 | 63 | public Q_SLOTS: 64 | void paint(QPainter *painter, const QSize &size, const bool active); 65 | void setThickness(const int value); 66 | void setEdges(const Global::WindowEdges value); 67 | void setActiveColor(const QColor &value); 68 | void setInactiveColor(const QColor &value); 69 | 70 | Q_SIGNALS: 71 | void thicknessChanged(); 72 | void edgesChanged(); 73 | void activeColorChanged(); 74 | void inactiveColorChanged(); 75 | void nativeBorderChanged(); 76 | void shouldRepaint(); 77 | }; 78 | 79 | FRAMELESSHELPER_END_NAMESPACE 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/FramelessQuickHelper: -------------------------------------------------------------------------------- 1 | #include "framelessquickhelper.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/FramelessQuickModule: -------------------------------------------------------------------------------- 1 | #include "framelessquickmodule.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/FramelessQuickUtils: -------------------------------------------------------------------------------- 1 | #include "framelessquickutils.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/Global: -------------------------------------------------------------------------------- 1 | #include "framelesshelperquick_global.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/QuickChromePalette: -------------------------------------------------------------------------------- 1 | #include "quickchromepalette.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/QuickMicaMaterial: -------------------------------------------------------------------------------- 1 | #include "quickmicamaterial.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/QuickWindowBorder: -------------------------------------------------------------------------------- 1 | #include "quickwindowborder.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/framelessquickmodule.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | QT_BEGIN_NAMESPACE 30 | class QQmlEngine; 31 | QT_END_NAMESPACE 32 | 33 | FRAMELESSHELPER_BEGIN_NAMESPACE 34 | 35 | namespace FramelessHelper::Quick 36 | { 37 | inline void registerTypes(QQmlEngine *engine) { FramelessHelperQuickRegisterTypes(engine); } 38 | } // namespace FramelessHelper::Quick 39 | 40 | FRAMELESSHELPER_END_NAMESPACE 41 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | #if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(window) && (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))) 31 | 32 | #include 33 | 34 | FRAMELESSHELPER_BEGIN_NAMESPACE 35 | 36 | class FramelessQuickApplicationWindowPrivate; 37 | class FRAMELESSHELPER_QUICK_API FramelessQuickApplicationWindow : public QQuickApplicationWindow 38 | { 39 | FRAMELESSHELPER_PUBLIC_QT_CLASS(FramelessQuickApplicationWindow) 40 | #ifdef QML_NAMED_ELEMENT 41 | QML_NAMED_ELEMENT(FramelessApplicationWindow) 42 | #endif 43 | Q_PROPERTY(bool hidden READ isHidden NOTIFY hiddenChanged FINAL) 44 | Q_PROPERTY(bool normal READ isNormal NOTIFY normalChanged FINAL) 45 | Q_PROPERTY(bool minimized READ isMinimized NOTIFY minimizedChanged FINAL) 46 | Q_PROPERTY(bool maximized READ isMaximized NOTIFY maximizedChanged FINAL) 47 | Q_PROPERTY(bool zoomed READ isZoomed NOTIFY zoomedChanged FINAL) 48 | Q_PROPERTY(bool fullScreen READ isFullScreen NOTIFY fullScreenChanged FINAL) 49 | 50 | public: 51 | explicit FramelessQuickApplicationWindow(QWindow *parent = nullptr); 52 | ~FramelessQuickApplicationWindow() override; 53 | 54 | Q_NODISCARD bool isHidden() const; 55 | Q_NODISCARD bool isNormal() const; 56 | Q_NODISCARD bool isMinimized() const; 57 | Q_NODISCARD bool isMaximized() const; 58 | Q_NODISCARD bool isZoomed() const; 59 | Q_NODISCARD bool isFullScreen() const; 60 | 61 | public Q_SLOTS: 62 | void showMinimized2(); 63 | void toggleMaximized(); 64 | void toggleFullScreen(); 65 | 66 | protected: 67 | void classBegin() override; 68 | void componentComplete() override; 69 | 70 | Q_SIGNALS: 71 | void hiddenChanged(); 72 | void normalChanged(); 73 | void minimizedChanged(); 74 | void maximizedChanged(); 75 | void zoomedChanged(); 76 | void fullScreenChanged(); 77 | }; 78 | 79 | FRAMELESSHELPER_END_NAMESPACE 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(window) && (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))) 30 | 31 | #include 32 | 33 | FRAMELESSHELPER_BEGIN_NAMESPACE 34 | 35 | #if FRAMELESSHELPER_CONFIG(border_painter) 36 | class QuickWindowBorder; 37 | #endif 38 | 39 | class FramelessQuickApplicationWindow; 40 | class FRAMELESSHELPER_QUICK_API FramelessQuickApplicationWindowPrivate : public QObject 41 | { 42 | FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessQuickApplicationWindow) 43 | 44 | public: 45 | explicit FramelessQuickApplicationWindowPrivate(FramelessQuickApplicationWindow *q); 46 | ~FramelessQuickApplicationWindowPrivate() override; 47 | 48 | QQuickWindow::Visibility savedVisibility = QQuickWindow::Windowed; 49 | #if FRAMELESSHELPER_CONFIG(border_painter) 50 | QuickWindowBorder *windowBorder = nullptr; 51 | #endif 52 | }; 53 | 54 | FRAMELESSHELPER_END_NAMESPACE 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/private/framelessquickhelper_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | QT_BEGIN_NAMESPACE 32 | class QQuickItem; 33 | QT_END_NAMESPACE 34 | 35 | FRAMELESSHELPER_BEGIN_NAMESPACE 36 | 37 | #if FRAMELESSHELPER_CONFIG(mica_material) 38 | class QuickMicaMaterial; 39 | #endif 40 | #if FRAMELESSHELPER_CONFIG(border_painter) 41 | class QuickWindowBorder; 42 | #endif 43 | 44 | class FramelessQuickHelper; 45 | class FRAMELESSHELPER_QUICK_API FramelessQuickHelperPrivate : public QObject 46 | { 47 | FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessQuickHelper) 48 | 49 | public: 50 | explicit FramelessQuickHelperPrivate(FramelessQuickHelper *q); 51 | ~FramelessQuickHelperPrivate() override; 52 | 53 | void attach(); 54 | void detach(); 55 | 56 | void emitSignalForAllInstances(const char *signal); 57 | 58 | void setProperty(const char *name, const QVariant &value); 59 | Q_NODISCARD QVariant getProperty(const char *name, const QVariant &defaultValue = {}); 60 | 61 | #if FRAMELESSHELPER_CONFIG(mica_material) 62 | Q_NODISCARD QuickMicaMaterial *findOrCreateMicaMaterial() const; 63 | #endif 64 | #if FRAMELESSHELPER_CONFIG(border_painter) 65 | Q_NODISCARD QuickWindowBorder *findOrCreateWindowBorder() const; 66 | #endif 67 | 68 | Q_NODISCARD static FramelessQuickHelper *findOrCreateFramelessHelper(QObject *object); 69 | 70 | void repaintAllChildren(); 71 | Q_INVOKABLE void doRepaintAllChildren(); 72 | 73 | Q_NODISCARD quint32 readyWaitTime() const; 74 | void setReadyWaitTime(const quint32 time); 75 | 76 | Q_NODISCARD QRect mapItemGeometryToScene(const QQuickItem * const item) const; 77 | Q_NODISCARD bool isInSystemButtons(const QPoint &pos, QuickGlobal::SystemButtonType *button) const; 78 | Q_NODISCARD bool isInTitleBarDraggableArea(const QPoint &pos) const; 79 | Q_NODISCARD bool shouldIgnoreMouseEvents(const QPoint &pos) const; 80 | void setSystemButtonState(const QuickGlobal::SystemButtonType button, const QuickGlobal::ButtonState state); 81 | void rebindWindow(); 82 | 83 | QColor savedWindowBackgroundColor = {}; 84 | bool blurBehindWindowEnabled = false; 85 | std::optional extendIntoTitleBar = std::nullopt; 86 | bool qpaReady = false; 87 | quint32 qpaWaitTime = 0; 88 | QTimer repaintTimer{}; 89 | }; 90 | 91 | FRAMELESSHELPER_END_NAMESPACE 92 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/private/framelessquickwindow_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | #if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(window)) 31 | 32 | #include 33 | 34 | FRAMELESSHELPER_BEGIN_NAMESPACE 35 | 36 | class FramelessQuickWindowPrivate; 37 | class FRAMELESSHELPER_QUICK_API FramelessQuickWindow : public QQuickWindowQmlImpl 38 | { 39 | FRAMELESSHELPER_PUBLIC_QT_CLASS(FramelessQuickWindow) 40 | #ifdef QML_NAMED_ELEMENT 41 | QML_NAMED_ELEMENT(FramelessWindow) 42 | #endif 43 | Q_PROPERTY(bool hidden READ isHidden NOTIFY hiddenChanged FINAL) 44 | Q_PROPERTY(bool normal READ isNormal NOTIFY normalChanged FINAL) 45 | Q_PROPERTY(bool minimized READ isMinimized NOTIFY minimizedChanged FINAL) 46 | Q_PROPERTY(bool maximized READ isMaximized NOTIFY maximizedChanged FINAL) 47 | Q_PROPERTY(bool zoomed READ isZoomed NOTIFY zoomedChanged FINAL) 48 | Q_PROPERTY(bool fullScreen READ isFullScreen NOTIFY fullScreenChanged FINAL) 49 | 50 | public: 51 | explicit FramelessQuickWindow(QWindow *parent = nullptr); 52 | ~FramelessQuickWindow() override; 53 | 54 | Q_NODISCARD bool isHidden() const; 55 | Q_NODISCARD bool isNormal() const; 56 | Q_NODISCARD bool isMinimized() const; 57 | Q_NODISCARD bool isMaximized() const; 58 | Q_NODISCARD bool isZoomed() const; 59 | Q_NODISCARD bool isFullScreen() const; 60 | 61 | public Q_SLOTS: 62 | void showMinimized2(); 63 | void toggleMaximized(); 64 | void toggleFullScreen(); 65 | 66 | protected: 67 | void classBegin() override; 68 | void componentComplete() override; 69 | 70 | Q_SIGNALS: 71 | void hiddenChanged(); 72 | void normalChanged(); 73 | void minimizedChanged(); 74 | void maximizedChanged(); 75 | void zoomedChanged(); 76 | void fullScreenChanged(); 77 | }; 78 | 79 | FRAMELESSHELPER_END_NAMESPACE 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/private/framelessquickwindow_p_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(window)) 30 | 31 | #include 32 | 33 | FRAMELESSHELPER_BEGIN_NAMESPACE 34 | 35 | #if FRAMELESSHELPER_CONFIG(border_painter) 36 | class QuickWindowBorder; 37 | #endif 38 | 39 | class FramelessQuickWindow; 40 | class FRAMELESSHELPER_QUICK_API FramelessQuickWindowPrivate : public QObject 41 | { 42 | FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessQuickWindow) 43 | 44 | public: 45 | explicit FramelessQuickWindowPrivate(FramelessQuickWindow *q); 46 | ~FramelessQuickWindowPrivate() override; 47 | 48 | QQuickWindow::Visibility savedVisibility = QQuickWindow::Windowed; 49 | #if FRAMELESSHELPER_CONFIG(border_painter) 50 | QuickWindowBorder *windowBorder = nullptr; 51 | #endif 52 | }; 53 | 54 | FRAMELESSHELPER_END_NAMESPACE 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/private/quickimageitem_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | FRAMELESSHELPER_BEGIN_NAMESPACE 32 | 33 | class FRAMELESSHELPER_QUICK_API QuickImageItem : public QQuickPaintedItem 34 | { 35 | FRAMELESSHELPER_QT_CLASS(QuickImageItem) 36 | #ifdef QML_NAMED_ELEMENT 37 | QML_NAMED_ELEMENT(ImageItem) 38 | #endif 39 | 40 | Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged FINAL) 41 | 42 | public: 43 | explicit QuickImageItem(QQuickItem *parent = nullptr); 44 | ~QuickImageItem() override; 45 | 46 | void paint(QPainter *painter) override; 47 | 48 | Q_NODISCARD QVariant source() const; 49 | void setSource(const QVariant &value); 50 | 51 | Q_SIGNALS: 52 | void sourceChanged(); 53 | 54 | protected: 55 | void classBegin() override; 56 | void componentComplete() override; 57 | 58 | private: 59 | void fromUrl(const QUrl &value, QPainter *painter) const; 60 | void fromString(const QString &value, QPainter *painter) const; 61 | void fromImage(const QImage &value, QPainter *painter) const; 62 | void fromPixmap(const QPixmap &value, QPainter *painter) const; 63 | void fromIcon(const QIcon &value, QPainter *painter) const; 64 | Q_NODISCARD QRectF paintArea() const; 65 | 66 | private: 67 | QVariant m_source = {}; 68 | }; 69 | 70 | FRAMELESSHELPER_END_NAMESPACE 71 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/private/quickmicamaterial_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #if FRAMELESSHELPER_CONFIG(mica_material) 30 | 31 | FRAMELESSHELPER_BEGIN_NAMESPACE 32 | 33 | class MicaMaterial; 34 | 35 | class QuickMicaMaterial; 36 | class FRAMELESSHELPER_QUICK_API QuickMicaMaterialPrivate : public QObject 37 | { 38 | FRAMELESSHELPER_PRIVATE_QT_CLASS(QuickMicaMaterial) 39 | 40 | public: 41 | explicit QuickMicaMaterialPrivate(QuickMicaMaterial *q); 42 | ~QuickMicaMaterialPrivate() override; 43 | 44 | Q_SLOT void rebindWindow(); 45 | 46 | void initialize(); 47 | 48 | QMetaObject::Connection rootWindowXChangedConnection = {}; 49 | QMetaObject::Connection rootWindowYChangedConnection = {}; 50 | QMetaObject::Connection rootWindowActiveChangedConnection = {}; 51 | MicaMaterial *micaMaterial = nullptr; 52 | }; 53 | 54 | FRAMELESSHELPER_END_NAMESPACE 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/private/quickwindowborder_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #if FRAMELESSHELPER_CONFIG(border_painter) 30 | 31 | FRAMELESSHELPER_BEGIN_NAMESPACE 32 | 33 | class WindowBorderPainter; 34 | 35 | class QuickWindowBorder; 36 | class FRAMELESSHELPER_QUICK_API QuickWindowBorderPrivate : public QObject 37 | { 38 | FRAMELESSHELPER_PRIVATE_QT_CLASS(QuickWindowBorder) 39 | 40 | public: 41 | explicit QuickWindowBorderPrivate(QuickWindowBorder *q); 42 | ~QuickWindowBorderPrivate() override; 43 | 44 | Q_SLOT void update(); 45 | 46 | void initialize(); 47 | void rebindWindow(); 48 | 49 | WindowBorderPainter *borderPainter = nullptr; 50 | QMetaObject::Connection activeChangeConnection = {}; 51 | QMetaObject::Connection visibilityChangeConnection = {}; 52 | }; 53 | 54 | FRAMELESSHELPER_END_NAMESPACE 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/quickchromepalette.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #if FRAMELESSHELPER_CONFIG(titlebar) 32 | 33 | FRAMELESSHELPER_BEGIN_NAMESPACE 34 | 35 | class FRAMELESSHELPER_QUICK_API QuickChromePalette : public ChromePalette, public QQmlParserStatus 36 | { 37 | FRAMELESSHELPER_QT_CLASS(QuickChromePalette) 38 | Q_INTERFACES(QQmlParserStatus) 39 | #ifdef QML_ANONYMOUS 40 | QML_ANONYMOUS 41 | #endif 42 | 43 | public: 44 | explicit QuickChromePalette(QObject *parent = nullptr); 45 | ~QuickChromePalette() override; 46 | 47 | protected: 48 | void classBegin() override; 49 | void componentComplete() override; 50 | }; 51 | 52 | FRAMELESSHELPER_END_NAMESPACE 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/quickmicamaterial.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #if FRAMELESSHELPER_CONFIG(mica_material) 32 | 33 | FRAMELESSHELPER_BEGIN_NAMESPACE 34 | 35 | class QuickMicaMaterialPrivate; 36 | class FRAMELESSHELPER_QUICK_API QuickMicaMaterial : public QQuickPaintedItem 37 | { 38 | FRAMELESSHELPER_PUBLIC_QT_CLASS(QuickMicaMaterial) 39 | #ifdef QML_NAMED_ELEMENT 40 | QML_NAMED_ELEMENT(MicaMaterial) 41 | #endif 42 | 43 | Q_PROPERTY(QColor tintColor READ tintColor WRITE setTintColor NOTIFY tintColorChanged FINAL) 44 | Q_PROPERTY(qreal tintOpacity READ tintOpacity WRITE setTintOpacity NOTIFY tintOpacityChanged FINAL) 45 | Q_PROPERTY(QColor fallbackColor READ fallbackColor WRITE setFallbackColor NOTIFY fallbackColorChanged FINAL) 46 | Q_PROPERTY(qreal noiseOpacity READ noiseOpacity WRITE setNoiseOpacity NOTIFY noiseOpacityChanged FINAL) 47 | Q_PROPERTY(bool fallbackEnabled READ isFallbackEnabled WRITE setFallbackEnabled NOTIFY fallbackEnabledChanged FINAL) 48 | 49 | public: 50 | explicit QuickMicaMaterial(QQuickItem *parent = nullptr); 51 | ~QuickMicaMaterial() override; 52 | 53 | void paint(QPainter *painter) override; 54 | 55 | Q_NODISCARD QColor tintColor() const; 56 | void setTintColor(const QColor &value); 57 | 58 | Q_NODISCARD qreal tintOpacity() const; 59 | void setTintOpacity(const qreal value); 60 | 61 | Q_NODISCARD QColor fallbackColor() const; 62 | void setFallbackColor(const QColor &value); 63 | 64 | Q_NODISCARD qreal noiseOpacity() const; 65 | void setNoiseOpacity(const qreal value); 66 | 67 | Q_NODISCARD bool isFallbackEnabled() const; 68 | void setFallbackEnabled(const bool value); 69 | 70 | Q_SIGNALS: 71 | void tintColorChanged(); 72 | void tintOpacityChanged(); 73 | void fallbackColorChanged(); 74 | void noiseOpacityChanged(); 75 | void fallbackEnabledChanged(); 76 | 77 | protected: 78 | void itemChange(const ItemChange change, const ItemChangeData &value) override; 79 | void classBegin() override; 80 | void componentComplete() override; 81 | }; 82 | 83 | FRAMELESSHELPER_END_NAMESPACE 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/quickwindowborder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #if FRAMELESSHELPER_CONFIG(border_painter) 32 | 33 | FRAMELESSHELPER_BEGIN_NAMESPACE 34 | 35 | class QuickWindowBorderPrivate; 36 | class FRAMELESSHELPER_QUICK_API QuickWindowBorder : public QQuickPaintedItem 37 | { 38 | FRAMELESSHELPER_PUBLIC_QT_CLASS(QuickWindowBorder) 39 | #ifdef QML_NAMED_ELEMENT 40 | QML_NAMED_ELEMENT(WindowBorder) 41 | #endif 42 | 43 | Q_PROPERTY(qreal thickness READ thickness WRITE setThickness NOTIFY thicknessChanged FINAL) 44 | Q_PROPERTY(QuickGlobal::WindowEdges edges READ edges WRITE setEdges NOTIFY edgesChanged FINAL) 45 | Q_PROPERTY(QColor activeColor READ activeColor WRITE setActiveColor NOTIFY activeColorChanged FINAL) 46 | Q_PROPERTY(QColor inactiveColor READ inactiveColor WRITE setInactiveColor NOTIFY inactiveColorChanged FINAL) 47 | 48 | Q_PROPERTY(qreal nativeThickness READ nativeThickness NOTIFY nativeBorderChanged FINAL) 49 | Q_PROPERTY(QuickGlobal::WindowEdges nativeEdges READ nativeEdges NOTIFY nativeBorderChanged FINAL) 50 | Q_PROPERTY(QColor nativeActiveColor READ nativeActiveColor NOTIFY nativeBorderChanged FINAL) 51 | Q_PROPERTY(QColor nativeInactiveColor READ nativeInactiveColor NOTIFY nativeBorderChanged FINAL) 52 | 53 | public: 54 | explicit QuickWindowBorder(QQuickItem *parent = nullptr); 55 | ~QuickWindowBorder() override; 56 | 57 | void paint(QPainter *painter) override; 58 | 59 | Q_NODISCARD qreal thickness() const; 60 | Q_NODISCARD QuickGlobal::WindowEdges edges() const; 61 | Q_NODISCARD QColor activeColor() const; 62 | Q_NODISCARD QColor inactiveColor() const; 63 | 64 | Q_NODISCARD qreal nativeThickness() const; 65 | Q_NODISCARD QuickGlobal::WindowEdges nativeEdges() const; 66 | Q_NODISCARD QColor nativeActiveColor() const; 67 | Q_NODISCARD QColor nativeInactiveColor() const; 68 | 69 | public Q_SLOTS: 70 | void setThickness(const qreal value); 71 | void setEdges(const QuickGlobal::WindowEdges value); 72 | void setActiveColor(const QColor &value); 73 | void setInactiveColor(const QColor &value); 74 | 75 | protected: 76 | void itemChange(const ItemChange change, const ItemChangeData &value) override; 77 | void classBegin() override; 78 | void componentComplete() override; 79 | 80 | Q_SIGNALS: 81 | void thicknessChanged(); 82 | void edgesChanged(); 83 | void activeColorChanged(); 84 | void inactiveColorChanged(); 85 | void nativeBorderChanged(); 86 | }; 87 | 88 | FRAMELESSHELPER_END_NAMESPACE 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/FramelessDialog: -------------------------------------------------------------------------------- 1 | #include "framelessdialog.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/FramelessMainWindow: -------------------------------------------------------------------------------- 1 | #include "framelessmainwindow.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/FramelessWidget: -------------------------------------------------------------------------------- 1 | #include "framelesswidget.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/FramelessWidgetsHelper: -------------------------------------------------------------------------------- 1 | #include "framelesswidgetshelper.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/Global: -------------------------------------------------------------------------------- 1 | #include "framelesshelperwidgets_global.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/StandardSystemButton: -------------------------------------------------------------------------------- 1 | #include "standardsystembutton.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/StandardTitleBar: -------------------------------------------------------------------------------- 1 | #include "standardtitlebar.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/framelessdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #if FRAMELESSHELPER_CONFIG(window) 32 | 33 | FRAMELESSHELPER_BEGIN_NAMESPACE 34 | 35 | class FramelessDialogPrivate; 36 | class FRAMELESSHELPER_WIDGETS_API FramelessDialog : public QDialog 37 | { 38 | FRAMELESSHELPER_PUBLIC_QT_CLASS(FramelessDialog) 39 | 40 | public: 41 | explicit FramelessDialog(QWidget *parent = nullptr); 42 | ~FramelessDialog() override; 43 | }; 44 | 45 | FRAMELESSHELPER_END_NAMESPACE 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/framelesshelperwidgets_global.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #ifndef FRAMELESSHELPER_WIDGETS_API 30 | # if FRAMELESSHELPER_CONFIG(static_build) 31 | # define FRAMELESSHELPER_WIDGETS_API 32 | # else 33 | # ifdef FRAMELESSHELPER_WIDGETS_LIBRARY 34 | # define FRAMELESSHELPER_WIDGETS_API Q_DECL_EXPORT 35 | # else 36 | # define FRAMELESSHELPER_WIDGETS_API Q_DECL_IMPORT 37 | # endif 38 | # endif 39 | #endif 40 | 41 | FRAMELESSHELPER_BEGIN_NAMESPACE 42 | 43 | FRAMELESSHELPER_WIDGETS_API void FramelessHelperWidgetsInitialize(); 44 | FRAMELESSHELPER_WIDGETS_API void FramelessHelperWidgetsUninitialize(); 45 | 46 | namespace FramelessHelper::Widgets 47 | { 48 | inline void initialize() { FramelessHelperWidgetsInitialize(); } 49 | inline void uninitialize() { FramelessHelperWidgetsUninitialize(); } 50 | } // namespace FramelessHelper::Widgets 51 | 52 | FRAMELESSHELPER_END_NAMESPACE 53 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/framelessmainwindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #if FRAMELESSHELPER_CONFIG(window) 32 | 33 | FRAMELESSHELPER_BEGIN_NAMESPACE 34 | 35 | class FramelessMainWindowPrivate; 36 | class FRAMELESSHELPER_WIDGETS_API FramelessMainWindow : public QMainWindow 37 | { 38 | FRAMELESSHELPER_PUBLIC_QT_CLASS(FramelessMainWindow) 39 | Q_PROPERTY(bool hidden READ isHidden NOTIFY hiddenChanged FINAL) 40 | Q_PROPERTY(bool normal READ isNormal NOTIFY normalChanged FINAL) 41 | Q_PROPERTY(bool zoomed READ isZoomed NOTIFY zoomedChanged FINAL) 42 | 43 | public: 44 | explicit FramelessMainWindow(QWidget *parent = nullptr, const Qt::WindowFlags flags = {}); 45 | ~FramelessMainWindow() override; 46 | 47 | Q_NODISCARD bool isNormal() const; 48 | Q_NODISCARD bool isZoomed() const; 49 | 50 | public Q_SLOTS: 51 | void toggleMaximized(); 52 | void toggleFullScreen(); 53 | 54 | Q_SIGNALS: 55 | void hiddenChanged(); 56 | void normalChanged(); 57 | void zoomedChanged(); 58 | }; 59 | 60 | FRAMELESSHELPER_END_NAMESPACE 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/framelesswidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #if FRAMELESSHELPER_CONFIG(window) 32 | 33 | FRAMELESSHELPER_BEGIN_NAMESPACE 34 | 35 | class FramelessWidgetPrivate; 36 | class FRAMELESSHELPER_WIDGETS_API FramelessWidget : public QWidget 37 | { 38 | FRAMELESSHELPER_PUBLIC_QT_CLASS(FramelessWidget) 39 | Q_PROPERTY(bool hidden READ isHidden NOTIFY hiddenChanged FINAL) 40 | Q_PROPERTY(bool normal READ isNormal NOTIFY normalChanged FINAL) 41 | Q_PROPERTY(bool zoomed READ isZoomed NOTIFY zoomedChanged FINAL) 42 | 43 | public: 44 | explicit FramelessWidget(QWidget *parent = nullptr); 45 | ~FramelessWidget() override; 46 | 47 | Q_NODISCARD bool isNormal() const; 48 | Q_NODISCARD bool isZoomed() const; 49 | 50 | public Q_SLOTS: 51 | void toggleMaximized(); 52 | void toggleFullScreen(); 53 | 54 | Q_SIGNALS: 55 | void hiddenChanged(); 56 | void normalChanged(); 57 | void zoomedChanged(); 58 | }; 59 | 60 | FRAMELESSHELPER_END_NAMESPACE 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/private/framelessdialog_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #if FRAMELESSHELPER_CONFIG(window) 30 | 31 | FRAMELESSHELPER_BEGIN_NAMESPACE 32 | 33 | class WidgetsSharedHelper; 34 | 35 | class FramelessDialog; 36 | class FRAMELESSHELPER_WIDGETS_API FramelessDialogPrivate : public QObject 37 | { 38 | FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessDialog) 39 | 40 | public: 41 | explicit FramelessDialogPrivate(FramelessDialog *q); 42 | ~FramelessDialogPrivate() override; 43 | 44 | WidgetsSharedHelper *sharedHelper = nullptr; 45 | }; 46 | 47 | FRAMELESSHELPER_END_NAMESPACE 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/private/framelessmainwindow_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #if FRAMELESSHELPER_CONFIG(window) 30 | 31 | FRAMELESSHELPER_BEGIN_NAMESPACE 32 | 33 | class WidgetsSharedHelper; 34 | 35 | class FramelessMainWindow; 36 | class FRAMELESSHELPER_WIDGETS_API FramelessMainWindowPrivate : public QObject 37 | { 38 | FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessMainWindow) 39 | 40 | public: 41 | explicit FramelessMainWindowPrivate(FramelessMainWindow *q); 42 | ~FramelessMainWindowPrivate() override; 43 | 44 | Qt::WindowState savedWindowState = Qt::WindowNoState; 45 | WidgetsSharedHelper *sharedHelper = nullptr; 46 | }; 47 | 48 | FRAMELESSHELPER_END_NAMESPACE 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/private/framelesswidget_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #if FRAMELESSHELPER_CONFIG(window) 30 | 31 | FRAMELESSHELPER_BEGIN_NAMESPACE 32 | 33 | class WidgetsSharedHelper; 34 | 35 | class FramelessWidget; 36 | class FRAMELESSHELPER_WIDGETS_API FramelessWidgetPrivate : public QObject 37 | { 38 | FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessWidget) 39 | 40 | public: 41 | explicit FramelessWidgetPrivate(FramelessWidget *q); 42 | ~FramelessWidgetPrivate() override; 43 | 44 | Qt::WindowState savedWindowState = Qt::WindowNoState; 45 | WidgetsSharedHelper *sharedHelper = nullptr; 46 | }; 47 | 48 | FRAMELESSHELPER_END_NAMESPACE 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/private/framelesswidgetshelper_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | FRAMELESSHELPER_BEGIN_NAMESPACE 33 | 34 | #if FRAMELESSHELPER_CONFIG(mica_material) 35 | class MicaMaterial; 36 | #endif 37 | #if FRAMELESSHELPER_CONFIG(border_painter) 38 | class WindowBorderPainter; 39 | #endif 40 | class WidgetsSharedHelper; 41 | 42 | class FramelessWidgetsHelper; 43 | class FRAMELESSHELPER_WIDGETS_API FramelessWidgetsHelperPrivate : public QObject 44 | { 45 | FRAMELESSHELPER_PRIVATE_QT_CLASS(FramelessWidgetsHelper) 46 | 47 | public: 48 | explicit FramelessWidgetsHelperPrivate(FramelessWidgetsHelper *q); 49 | ~FramelessWidgetsHelperPrivate() override; 50 | 51 | void attach(); 52 | void detach(); 53 | 54 | void emitSignalForAllInstances(const char *signal); 55 | 56 | void setProperty(const char *name, const QVariant &value); 57 | Q_NODISCARD QVariant getProperty(const char *name, const QVariant &defaultValue = {}); 58 | 59 | #if FRAMELESSHELPER_CONFIG(mica_material) 60 | Q_NODISCARD MicaMaterial *getMicaMaterialIfAny() const; 61 | #endif 62 | #if FRAMELESSHELPER_CONFIG(border_painter) 63 | Q_NODISCARD WindowBorderPainter *getWindowBorderIfAny() const; 64 | #endif 65 | 66 | Q_NODISCARD static WidgetsSharedHelper *findOrCreateSharedHelper(QWidget *window); 67 | Q_NODISCARD static FramelessWidgetsHelper *findOrCreateFramelessHelper(QObject *object); 68 | 69 | void repaintAllChildren(); 70 | Q_INVOKABLE void doRepaintAllChildren(); 71 | 72 | Q_NODISCARD quint32 readyWaitTime() const; 73 | void setReadyWaitTime(const quint32 time); 74 | 75 | Q_NODISCARD QRect mapWidgetGeometryToScene(const QWidget * const widget) const; 76 | Q_NODISCARD bool isInSystemButtons(const QPoint &pos, Global::SystemButtonType *button) const; 77 | Q_NODISCARD bool isInTitleBarDraggableArea(const QPoint &pos) const; 78 | Q_NODISCARD bool shouldIgnoreMouseEvents(const QPoint &pos) const; 79 | void setSystemButtonState(const Global::SystemButtonType button, const Global::ButtonState state); 80 | Q_NODISCARD QWidget *findTopLevelWindow() const; 81 | 82 | QColor savedWindowBackgroundColor = {}; 83 | bool blurBehindWindowEnabled = false; 84 | QPointer window; // Initializing it with nullptr causes compilation errors on MinGW toolchain and old Qt versions (< 5.15). 85 | bool qpaReady = false; 86 | QSizePolicy savedSizePolicy = {}; 87 | quint32 qpaWaitTime = 0; 88 | QTimer repaintTimer{}; 89 | }; 90 | 91 | FRAMELESSHELPER_END_NAMESPACE 92 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/private/standardsystembutton_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | #if FRAMELESSHELPER_CONFIG(system_button) 31 | 32 | FRAMELESSHELPER_BEGIN_NAMESPACE 33 | 34 | class StandardSystemButton; 35 | class FRAMELESSHELPER_WIDGETS_API StandardSystemButtonPrivate : public QObject 36 | { 37 | FRAMELESSHELPER_PRIVATE_QT_CLASS(StandardSystemButton) 38 | 39 | public: 40 | explicit StandardSystemButtonPrivate(StandardSystemButton *q); 41 | ~StandardSystemButtonPrivate() override; 42 | 43 | Q_NODISCARD static QSize getRecommendedButtonSize(); 44 | 45 | Global::SystemButtonType buttonType = Global::SystemButtonType::Unknown; 46 | QString glyph = {}; 47 | QColor hoverColor = {}; 48 | QColor pressColor = {}; 49 | QColor normalColor = {}; 50 | QColor activeForegroundColor = {}; 51 | QColor inactiveForegroundColor = {}; 52 | bool active = false; 53 | std::optional glyphSize = std::nullopt; 54 | }; 55 | 56 | FRAMELESSHELPER_END_NAMESPACE 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/private/standardtitlebar_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | QT_BEGIN_NAMESPACE 32 | class QMouseEvent; 33 | QT_END_NAMESPACE 34 | 35 | #if FRAMELESSHELPER_CONFIG(titlebar) 36 | 37 | FRAMELESSHELPER_BEGIN_NAMESPACE 38 | 39 | #if FRAMELESSHELPER_CONFIG(system_button) 40 | class StandardSystemButton; 41 | #endif 42 | class ChromePalette; 43 | 44 | class StandardTitleBar; 45 | class FRAMELESSHELPER_WIDGETS_API StandardTitleBarPrivate : public QObject 46 | { 47 | FRAMELESSHELPER_PRIVATE_QT_CLASS(StandardTitleBar) 48 | 49 | public: 50 | struct FontMetrics 51 | { 52 | int width = 0; 53 | int height = 0; 54 | int ascent = 0; 55 | }; 56 | 57 | explicit StandardTitleBarPrivate(StandardTitleBar *q); 58 | ~StandardTitleBarPrivate() override; 59 | 60 | Q_NODISCARD QRect windowIconRect() const; 61 | Q_NODISCARD bool windowIconVisible_real() const; 62 | Q_NODISCARD bool isInTitleBarIconArea(const QPoint &pos) const; 63 | 64 | Q_NODISCARD QFont defaultFont() const; 65 | Q_NODISCARD FontMetrics titleLabelSize() const; 66 | Q_NODISCARD int titleLabelMaxWidth() const; 67 | 68 | Q_SLOT void updateMaximizeButton(); 69 | Q_SLOT void updateTitleBarColor(); 70 | Q_SLOT void updateChromeButtonColor(); 71 | Q_SLOT void retranslateUi(); 72 | 73 | Q_NODISCARD bool mouseEventHandler(QMouseEvent *event); 74 | 75 | void initialize(); 76 | 77 | #if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button)) 78 | StandardSystemButton *minimizeButton = nullptr; 79 | StandardSystemButton *maximizeButton = nullptr; 80 | StandardSystemButton *closeButton = nullptr; 81 | #endif 82 | QPointer window; // Initializing it with nullptr causes compilation errors on MinGW toolchain and old Qt versions (< 5.15). 83 | bool extended = false; 84 | Qt::Alignment labelAlignment = {}; 85 | bool hideWhenClose = false; 86 | ChromePalette *chromePalette = nullptr; 87 | bool titleLabelVisible = true; 88 | std::optional windowIconSize = std::nullopt; 89 | bool windowIconVisible = false; 90 | std::optional titleFont = std::nullopt; 91 | bool closeTriggered = false; 92 | 93 | protected: 94 | bool eventFilter(QObject *object, QEvent *event) override; 95 | }; 96 | 97 | FRAMELESSHELPER_END_NAMESPACE 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/private/widgetssharedhelper_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | FRAMELESSHELPER_BEGIN_NAMESPACE 31 | 32 | #if FRAMELESSHELPER_CONFIG(mica_material) 33 | class MicaMaterial; 34 | #endif 35 | #if FRAMELESSHELPER_CONFIG(border_painter) 36 | class WindowBorderPainter; 37 | #endif 38 | 39 | class FRAMELESSHELPER_WIDGETS_API WidgetsSharedHelper : public QObject 40 | { 41 | FRAMELESSHELPER_QT_CLASS(WidgetsSharedHelper) 42 | #if FRAMELESSHELPER_CONFIG(mica_material) 43 | Q_PROPERTY(bool micaEnabled READ isMicaEnabled WRITE setMicaEnabled NOTIFY micaEnabledChanged FINAL) 44 | #endif 45 | 46 | public: 47 | explicit WidgetsSharedHelper(QObject *parent = nullptr); 48 | ~WidgetsSharedHelper() override; 49 | 50 | void setup(QWidget *widget); 51 | 52 | #if FRAMELESSHELPER_CONFIG(mica_material) 53 | Q_NODISCARD bool isMicaEnabled() const; 54 | void setMicaEnabled(const bool value); 55 | Q_NODISCARD MicaMaterial *rawMicaMaterial() const; 56 | #endif 57 | #if FRAMELESSHELPER_CONFIG(border_painter) 58 | Q_NODISCARD WindowBorderPainter *rawWindowBorder() const; 59 | #endif 60 | 61 | protected: 62 | Q_NODISCARD bool eventFilter(QObject *object, QEvent *event) override; 63 | 64 | private Q_SLOTS: 65 | void updateContentsMargins(); 66 | void handleScreenChanged(QScreen *screen); 67 | 68 | private: 69 | #if FRAMELESSHELPER_CONFIG(mica_material) 70 | void repaintMica(); 71 | #endif 72 | #if FRAMELESSHELPER_CONFIG(border_painter) 73 | void repaintBorder(); 74 | #endif 75 | void emitCustomWindowStateSignals(); 76 | 77 | Q_SIGNALS: 78 | #if FRAMELESSHELPER_CONFIG(mica_material) 79 | void micaEnabledChanged(); 80 | #endif 81 | 82 | private: 83 | QPointer m_targetWidget; 84 | QPointer m_screen; 85 | qreal m_screenDpr = qreal(0); 86 | QMetaObject::Connection m_screenDpiChangeConnection = {}; 87 | QMetaObject::Connection m_screenChangeConnection = {}; 88 | #if FRAMELESSHELPER_CONFIG(mica_material) 89 | bool m_micaEnabled = false; 90 | MicaMaterial *m_micaMaterial = nullptr; 91 | QMetaObject::Connection m_micaRedrawConnection = {}; 92 | #endif 93 | #if FRAMELESSHELPER_CONFIG(border_painter) 94 | WindowBorderPainter *m_borderPainter = nullptr; 95 | QMetaObject::Connection m_borderRepaintConnection = {}; 96 | #endif 97 | }; 98 | 99 | FRAMELESSHELPER_END_NAMESPACE 100 | -------------------------------------------------------------------------------- /msbuild/FramelessHelper.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildThisFileDirectory)..\lib;$(MSBuildThisFileDirectory)..\lib\debug;$(MSBuildThisFileDirectory)..\lib\release;$(LibraryPath) 5 | 6 | 7 | $(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) 8 | 9 | 10 | 11 | %(PreprocessorDefinitions) 12 | 13 | 14 | FramelessHelperCore64d.lib;FramelessHelperWidgets64d.lib;FramelessHelperQuick64d.lib;%(AdditionalDependencies); 15 | FramelessHelperCore64.lib;FramelessHelperWidgets64.lib;FramelessHelperQuick64.lib;%(AdditionalDependencies); 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /qmake/core.pri: -------------------------------------------------------------------------------- 1 | QT += core core-private gui gui-private 2 | 3 | BASE_INC_DIR = $$PWD/../include 4 | COMMON_INC_DIR = $$BASE_INC_DIR/FramelessHelper 5 | CORE_PUB_INC_DIR = $$COMMON_INC_DIR/Core 6 | CORE_PRIV_INC_DIR = $$CORE_PUB_INC_DIR/private 7 | CORE_EXTRA_INC_DIR = $$PWD/inc/core 8 | CORE_SRC_DIR = $$PWD/../src/core 9 | 10 | INCLUDEPATH += \ 11 | $$BASE_INC_DIR \ 12 | $$COMMON_INC_DIR \ 13 | $$CORE_PUB_INC_DIR \ 14 | $$CORE_PRIV_INC_DIR \ 15 | $$CORE_EXTRA_INC_DIR 16 | 17 | DEPENDPATH += \ 18 | $$BASE_INC_DIR \ 19 | $$COMMON_INC_DIR \ 20 | $$CORE_PUB_INC_DIR \ 21 | $$CORE_PRIV_INC_DIR \ 22 | $$CORE_EXTRA_INC_DIR 23 | 24 | HEADERS += \ 25 | $$CORE_EXTRA_INC_DIR/framelesshelper.version \ 26 | $$CORE_EXTRA_INC_DIR/framelesshelper.config \ 27 | $$CORE_PUB_INC_DIR/chromepalette.h \ 28 | $$CORE_PUB_INC_DIR/framelesshelper_qt.h \ 29 | $$CORE_PUB_INC_DIR/framelesshelpercore_global.h \ 30 | $$CORE_PUB_INC_DIR/framelessmanager.h \ 31 | $$CORE_PUB_INC_DIR/micamaterial.h \ 32 | $$CORE_PUB_INC_DIR/utils.h \ 33 | $$CORE_PUB_INC_DIR/windowborderpainter.h \ 34 | $$CORE_PRIV_INC_DIR/chromepalette_p.h \ 35 | $$CORE_PRIV_INC_DIR/framelessconfig_p.h \ 36 | $$CORE_PRIV_INC_DIR/framelessmanager_p.h \ 37 | $$CORE_PRIV_INC_DIR/micamaterial_p.h \ 38 | $$CORE_PRIV_INC_DIR/sysapiloader_p.h \ 39 | $$CORE_PRIV_INC_DIR/windowborderpainter_p.h \ 40 | $$CORE_PRIV_INC_DIR/framelesshelpercore_global_p.h \ 41 | $$CORE_PRIV_INC_DIR/versionnumber_p.h \ 42 | $$CORE_PRIV_INC_DIR/scopeguard_p.h 43 | 44 | SOURCES += \ 45 | $$CORE_SRC_DIR/chromepalette.cpp \ 46 | $$CORE_SRC_DIR/framelessconfig.cpp \ 47 | $$CORE_SRC_DIR/framelesshelper_qt.cpp \ 48 | $$CORE_SRC_DIR/framelessmanager.cpp \ 49 | $$CORE_SRC_DIR/framelesshelpercore_global.cpp \ 50 | $$CORE_SRC_DIR/micamaterial.cpp \ 51 | $$CORE_SRC_DIR/sysapiloader.cpp \ 52 | $$CORE_SRC_DIR/utils.cpp \ 53 | $$CORE_SRC_DIR/windowborderpainter.cpp 54 | 55 | RESOURCES += \ 56 | $$CORE_SRC_DIR/framelesshelpercore.qrc 57 | 58 | win32 { 59 | HEADERS += \ 60 | $$CORE_PUB_INC_DIR/framelesshelper_win.h \ 61 | $$CORE_PUB_INC_DIR/framelesshelper_windows.h \ 62 | $$CORE_PRIV_INC_DIR/registrykey_p.h \ 63 | $$CORE_PRIV_INC_DIR/winverhelper_p.h 64 | SOURCES += \ 65 | $$CORE_SRC_DIR/framelesshelper_win.cpp \ 66 | $$CORE_SRC_DIR/utils_win.cpp \ 67 | $$CORE_SRC_DIR/registrykey.cpp \ 68 | $$CORE_SRC_DIR/winverhelper.cpp \ 69 | $$CORE_SRC_DIR/platformsupport_win.cpp 70 | LIBS += -luser32 -lgdi32 -lshell32 71 | } 72 | 73 | unix:!macx { 74 | CONFIG += link_pkgconfig 75 | PKGCONFIG += xcb gtk+-3.0 76 | DEFINES += GDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_6 77 | HEADERS += \ 78 | $$CORE_PUB_INC_DIR/framelesshelper_linux.h 79 | SOURCES += \ 80 | $$CORE_SRC_DIR/utils_linux.cpp \ 81 | $$CORE_SRC_DIR/platformsupport_linux.cpp 82 | } 83 | 84 | macx { 85 | SOURCES += $$CORE_SRC_DIR/utils_mac.mm 86 | #LIBS += "-framework AppKit" "-framework Cocoa" "-framework Foundation" # TODO 87 | } 88 | -------------------------------------------------------------------------------- /qmake/inc/core/framelesshelper.config: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | // Caution: This file is generated by CMake automatically during configure. 26 | // WARNING!!! DO NOT EDIT THIS FILE MANUALLY!!! 27 | // ALL YOUR MODIFICATIONS HERE WILL GET LOST AFTER RE-CONFIGURING!!! 28 | 29 | #pragma once 30 | 31 | #ifndef _FRAMELESSHELPER_CONFIG_INCLUDE_GUARD_ 32 | #define _FRAMELESSHELPER_CONFIG_INCLUDE_GUARD_ 33 | 34 | #define FRAMELESSHELPER_FEATURE_static_build 1 35 | #define FRAMELESSHELPER_FEATURE_widgets 1 36 | #define FRAMELESSHELPER_FEATURE_quick 1 37 | #define FRAMELESSHELPER_FEATURE_debug_output -1 38 | #define FRAMELESSHELPER_FEATURE_bundle_resource 1 39 | #define FRAMELESSHELPER_FEATURE_private_qt 1 40 | #define FRAMELESSHELPER_FEATURE_window 1 41 | #define FRAMELESSHELPER_FEATURE_titlebar 1 42 | #define FRAMELESSHELPER_FEATURE_translation 1 43 | #define FRAMELESSHELPER_FEATURE_mica_material 1 44 | #define FRAMELESSHELPER_FEATURE_border_painter 1 45 | #define FRAMELESSHELPER_FEATURE_system_button 1 46 | #if (defined(WIN32) || defined(_WIN32)) 47 | # define FRAMELESSHELPER_FEATURE_native_impl 1 48 | #else 49 | # define FRAMELESSHELPER_FEATURE_native_impl -1 50 | #endif 51 | 52 | #endif // _FRAMELESSHELPER_CONFIG_INCLUDE_GUARD_ 53 | -------------------------------------------------------------------------------- /qmake/inc/core/framelesshelper.version: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | // Caution: This file is generated by CMake automatically during configure. 26 | // WARNING!!! DO NOT EDIT THIS FILE MANUALLY!!! 27 | // ALL YOUR MODIFICATIONS HERE WILL GET LOST AFTER RE-CONFIGURING!!! 28 | 29 | #pragma once 30 | 31 | #ifndef _FRAMELESSHELPER_VERSION_INCLUDE_GUARD_ 32 | #define _FRAMELESSHELPER_VERSION_INCLUDE_GUARD_ 33 | 34 | #define __FRAMELESSHELPER_VERSION_MAJOR__ 2 35 | #define __FRAMELESSHELPER_VERSION_MINOR__ 5 36 | #define __FRAMELESSHELPER_VERSION_PATCH__ 0 37 | #define __FRAMELESSHELPER_VERSION_TWEAK__ 0 38 | #define __FRAMELESSHELPER_VERSION__ 0x02050000 39 | 40 | [[maybe_unused]] inline constexpr const unsigned long FRAMELESSHELPER_VERSION_MAJOR = 2; 41 | [[maybe_unused]] inline constexpr const unsigned long FRAMELESSHELPER_VERSION_MINOR = 5; 42 | [[maybe_unused]] inline constexpr const unsigned long FRAMELESSHELPER_VERSION_PATCH = 0; 43 | [[maybe_unused]] inline constexpr const unsigned long FRAMELESSHELPER_VERSION_TWEAK = 0; 44 | [[maybe_unused]] inline constexpr const unsigned long FRAMELESSHELPER_VERSION = 0x02050000; 45 | [[maybe_unused]] inline constexpr const char FRAMELESSHELPER_VERSION_STR[] = "2.5.0"; 46 | [[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_HASH_STR[] = "UNKNOWN"; 47 | [[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_SUBJECT_STR[] = "UNKNOWN"; 48 | [[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_AUTHOR_STR[] = "UNKNOWN"; 49 | [[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_DATETIME_STR[] = "UNKNOWN"; 50 | [[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_BRANCH_STR[] = "UNKNOWN"; 51 | [[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMPILER_NAME_STR[] = "UNKNOWN"; 52 | [[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMPILER_VERSION_STR[] = "UNKNOWN"; 53 | [[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMPILER_VENDOR_STR[] = "UNKNOWN"; 54 | [[maybe_unused]] inline constexpr const char FRAMELESSHELPER_BUILD_DATETIME_STR[] = "UNKNOWN"; 55 | [[maybe_unused]] inline constexpr const char FRAMELESSHELPER_ARCHITECTURE_STR[] = "UNKNOWN"; 56 | [[maybe_unused]] inline constexpr const char FRAMELESSHELPER_CMAKE_VERSION_STR[] = "UNKNOWN"; 57 | [[maybe_unused]] inline constexpr const char FRAMELESSHELPER_CMAKE_GENERATOR_STR[] = "UNKNOWN"; 58 | 59 | #endif // _FRAMELESSHELPER_VERSION_INCLUDE_GUARD_ 60 | -------------------------------------------------------------------------------- /qmake/quick.pri: -------------------------------------------------------------------------------- 1 | QT += \ 2 | quick quick-private \ 3 | quicktemplates2 quicktemplates2-private \ 4 | quickcontrols2 quickcontrols2-private 5 | 6 | BASE_INC_DIR = $$PWD/../include 7 | COMMON_INC_DIR = $$BASE_INC_DIR/FramelessHelper 8 | QUICK_PUB_INC_DIR = $$COMMON_INC_DIR/Quick 9 | QUICK_PRIV_INC_DIR = $$QUICK_PUB_INC_DIR/private 10 | QUICK_SRC_DIR = $$PWD/../src/quick 11 | 12 | INCLUDEPATH += \ 13 | $$BASE_INC_DIR \ 14 | $$COMMON_INC_DIR \ 15 | $$QUICK_PUB_INC_DIR \ 16 | $$QUICK_PRIV_INC_DIR 17 | 18 | DEPENDPATH += \ 19 | $$BASE_INC_DIR \ 20 | $$COMMON_INC_DIR \ 21 | $$QUICK_PUB_INC_DIR \ 22 | $$QUICK_PRIV_INC_DIR 23 | 24 | HEADERS += \ 25 | $$QUICK_PUB_INC_DIR/framelesshelperquick_global.h \ 26 | $$QUICK_PUB_INC_DIR/framelessquickmodule.h \ 27 | $$QUICK_PUB_INC_DIR/framelessquickhelper.h \ 28 | $$QUICK_PUB_INC_DIR/framelessquickutils.h \ 29 | $$QUICK_PUB_INC_DIR/quickchromepalette.h \ 30 | $$QUICK_PUB_INC_DIR/quickmicamaterial.h \ 31 | $$QUICK_PUB_INC_DIR/quickimageitem.h \ 32 | $$QUICK_PUB_INC_DIR/quickwindowborder.h \ 33 | $$QUICK_PRIV_INC_DIR/quickstandardsystembutton_p.h \ 34 | $$QUICK_PRIV_INC_DIR/quickstandardtitlebar_p.h \ 35 | $$QUICK_PRIV_INC_DIR/framelessquickhelper_p.h \ 36 | $$QUICK_PRIV_INC_DIR/framelessquickwindow_p.h \ 37 | $$QUICK_PRIV_INC_DIR/framelessquickwindow_p_p.h \ 38 | $$QUICK_PRIV_INC_DIR/framelessquickapplicationwindow_p.h \ 39 | $$QUICK_PRIV_INC_DIR/framelessquickapplicationwindow_p_p.h \ 40 | $$QUICK_PRIV_INC_DIR/quickmicamaterial_p.h \ 41 | $$QUICK_PRIV_INC_DIR/quickimageitem_p.h \ 42 | $$QUICK_PRIV_INC_DIR/quickwindowborder_p.h 43 | 44 | SOURCES += \ 45 | $$QUICK_SRC_DIR/quickstandardsystembutton.cpp \ 46 | $$QUICK_SRC_DIR/quickstandardtitlebar.cpp \ 47 | $$QUICK_SRC_DIR/framelessquickutils.cpp \ 48 | $$QUICK_SRC_DIR/framelessquickmodule.cpp \ 49 | $$QUICK_SRC_DIR/framelessquickwindow.cpp \ 50 | $$QUICK_SRC_DIR/framelessquickapplicationwindow.cpp \ 51 | $$QUICK_SRC_DIR/framelessquickhelper.cpp \ 52 | $$QUICK_SRC_DIR/quickchromepalette.cpp \ 53 | $$QUICK_SRC_DIR/framelesshelperquick_global.cpp \ 54 | $$QUICK_SRC_DIR/quickmicamaterial.cpp \ 55 | $$QUICK_SRC_DIR/quickimageitem.cpp \ 56 | $$QUICK_SRC_DIR/quickwindowborder.cpp 57 | -------------------------------------------------------------------------------- /qmake/widgets.pri: -------------------------------------------------------------------------------- 1 | QT += widgets 2 | 3 | BASE_INC_DIR = $$PWD/../include 4 | COMMON_INC_DIR = $$BASE_INC_DIR/FramelessHelper 5 | WIDGETS_PUB_INC_DIR = $$COMMON_INC_DIR/Widgets 6 | WIDGETS_PRIV_INC_DIR = $$WIDGETS_PUB_INC_DIR/private 7 | WIDGETS_SRC_DIR = $$PWD/../src/widgets 8 | 9 | INCLUDEPATH += \ 10 | $$BASE_INC_DIR \ 11 | $$COMMON_INC_DIR \ 12 | $$WIDGETS_PUB_INC_DIR \ 13 | $$WIDGETS_PRIV_INC_DIR 14 | 15 | DEPENDPATH += \ 16 | $$BASE_INC_DIR \ 17 | $$COMMON_INC_DIR \ 18 | $$WIDGETS_PUB_INC_DIR \ 19 | $$WIDGETS_PRIV_INC_DIR 20 | 21 | HEADERS += \ 22 | $$WIDGETS_PUB_INC_DIR/framelesshelperwidgets_global.h \ 23 | $$WIDGETS_PUB_INC_DIR/framelesswidget.h \ 24 | $$WIDGETS_PUB_INC_DIR/framelessmainwindow.h \ 25 | $$WIDGETS_PUB_INC_DIR/standardsystembutton.h \ 26 | $$WIDGETS_PUB_INC_DIR/framelesswidgetshelper.h \ 27 | $$WIDGETS_PUB_INC_DIR/standardtitlebar.h \ 28 | $$WIDGETS_PUB_INC_DIR/framelessdialog.h \ 29 | $$WIDGETS_PRIV_INC_DIR/framelesswidgetshelper_p.h \ 30 | $$WIDGETS_PRIV_INC_DIR/standardsystembutton_p.h \ 31 | $$WIDGETS_PRIV_INC_DIR/standardtitlebar_p.h \ 32 | $$WIDGETS_PRIV_INC_DIR/framelesswidget_p.h \ 33 | $$WIDGETS_PRIV_INC_DIR/framelessmainwindow_p.h \ 34 | $$WIDGETS_PRIV_INC_DIR/widgetssharedhelper_p.h \ 35 | $$WIDGETS_PRIV_INC_DIR/framelessdialog_p.h 36 | 37 | SOURCES += \ 38 | $$WIDGETS_SRC_DIR/framelessmainwindow.cpp \ 39 | $$WIDGETS_SRC_DIR/framelesswidgetshelper.cpp \ 40 | $$WIDGETS_SRC_DIR/framelesswidget.cpp \ 41 | $$WIDGETS_SRC_DIR/standardsystembutton.cpp \ 42 | $$WIDGETS_SRC_DIR/standardtitlebar.cpp \ 43 | $$WIDGETS_SRC_DIR/widgetssharedhelper.cpp \ 44 | $$WIDGETS_SRC_DIR/framelesshelperwidgets_global.cpp \ 45 | $$WIDGETS_SRC_DIR/framelessdialog.cpp 46 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #[[ 2 | MIT License 3 | 4 | Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | ]] 24 | 25 | if(TARGET Qt${QT_VERSION_MAJOR}::Core AND TARGET Qt${QT_VERSION_MAJOR}::Gui) 26 | add_subdirectory(core) 27 | endif() 28 | 29 | if(FRAMELESSHELPER_BUILD_WIDGETS AND TARGET Qt${QT_VERSION_MAJOR}::Widgets) 30 | add_subdirectory(widgets) 31 | endif() 32 | 33 | if(FRAMELESSHELPER_BUILD_QUICK AND TARGET Qt${QT_VERSION_MAJOR}::Quick) 34 | add_subdirectory(quick) 35 | endif() 36 | -------------------------------------------------------------------------------- /src/core/chromepalette.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/chromepalette.h" 2 | -------------------------------------------------------------------------------- /src/core/chromepalette_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/private/chromepalette_p.h" 2 | -------------------------------------------------------------------------------- /src/core/framelessconfig_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/private/framelessconfig_p.h" 2 | -------------------------------------------------------------------------------- /src/core/framelesshelper_linux.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/framelesshelper_linux.h" 2 | -------------------------------------------------------------------------------- /src/core/framelesshelper_qt.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/framelesshelper_qt.h" 2 | -------------------------------------------------------------------------------- /src/core/framelesshelper_win.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/framelesshelper_win.h" 2 | -------------------------------------------------------------------------------- /src/core/framelesshelper_windows.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/framelesshelper_windows.h" 2 | -------------------------------------------------------------------------------- /src/core/framelesshelpercore.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | resources/fonts/iconfont.ttf 4 | resources/images/noise.png 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/core/framelesshelpercore_global.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/framelesshelpercore_global.h" 2 | -------------------------------------------------------------------------------- /src/core/framelesshelpercore_global_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/private/framelesshelpercore_global_p.h" 2 | -------------------------------------------------------------------------------- /src/core/framelessmanager.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/framelessmanager.h" 2 | -------------------------------------------------------------------------------- /src/core/framelessmanager_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/private/framelessmanager_p.h" 2 | -------------------------------------------------------------------------------- /src/core/micamaterial.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/micamaterial.h" 2 | -------------------------------------------------------------------------------- /src/core/micamaterial_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/private/micamaterial_p.h" 2 | -------------------------------------------------------------------------------- /src/core/registrykey_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/private/registrykey_p.h" 2 | -------------------------------------------------------------------------------- /src/core/resources/fonts/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangwenx190/framelesshelper/3102b4ea3b0756d92e02ae1656d0cccc9f824a82/src/core/resources/fonts/iconfont.ttf -------------------------------------------------------------------------------- /src/core/resources/images/noise.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangwenx190/framelesshelper/3102b4ea3b0756d92e02ae1656d0cccc9f824a82/src/core/resources/images/noise.png -------------------------------------------------------------------------------- /src/core/scopeguard_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/private/scopeguard_p.h" 2 | -------------------------------------------------------------------------------- /src/core/sysapiloader_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/private/sysapiloader_p.h" 2 | -------------------------------------------------------------------------------- /src/core/utils.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/utils.h" 2 | -------------------------------------------------------------------------------- /src/core/versionnumber_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/private/versionnumber_p.h" 2 | -------------------------------------------------------------------------------- /src/core/windowborderpainter.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/windowborderpainter.h" 2 | -------------------------------------------------------------------------------- /src/core/windowborderpainter_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/private/windowborderpainter_p.h" 2 | -------------------------------------------------------------------------------- /src/core/winverhelper_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/private/winverhelper_p.h" 2 | -------------------------------------------------------------------------------- /src/quick/framelesshelperquick_global.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/framelesshelperquick_global.h" 2 | -------------------------------------------------------------------------------- /src/quick/framelessquickapplicationwindow_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p.h" 2 | -------------------------------------------------------------------------------- /src/quick/framelessquickapplicationwindow_p_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p_p.h" 2 | -------------------------------------------------------------------------------- /src/quick/framelessquickhelper.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/framelessquickhelper.h" 2 | -------------------------------------------------------------------------------- /src/quick/framelessquickhelper_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/private/framelessquickhelper_p.h" 2 | -------------------------------------------------------------------------------- /src/quick/framelessquickmodule.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/framelessquickmodule.h" 2 | -------------------------------------------------------------------------------- /src/quick/framelessquickutils.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/framelessquickutils.h" 2 | -------------------------------------------------------------------------------- /src/quick/framelessquickwindow_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/private/framelessquickwindow_p.h" 2 | -------------------------------------------------------------------------------- /src/quick/framelessquickwindow_p_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/private/framelessquickwindow_p_p.h" 2 | -------------------------------------------------------------------------------- /src/quick/quickchromepalette.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "quickchromepalette.h" 26 | 27 | #if FRAMELESSHELPER_CONFIG(titlebar) 28 | 29 | #include 30 | 31 | FRAMELESSHELPER_BEGIN_NAMESPACE 32 | 33 | #if FRAMELESSHELPER_CONFIG(debug_output) 34 | [[maybe_unused]] static Q_LOGGING_CATEGORY(lcQuickChromePalette, "wangwenx190.framelesshelper.quick.quickchromepalette") 35 | # define INFO qCInfo(lcQuickChromePalette) 36 | # define DEBUG qCDebug(lcQuickChromePalette) 37 | # define WARNING qCWarning(lcQuickChromePalette) 38 | # define CRITICAL qCCritical(lcQuickChromePalette) 39 | #else 40 | # define INFO QT_NO_QDEBUG_MACRO() 41 | # define DEBUG QT_NO_QDEBUG_MACRO() 42 | # define WARNING QT_NO_QDEBUG_MACRO() 43 | # define CRITICAL QT_NO_QDEBUG_MACRO() 44 | #endif 45 | 46 | QuickChromePalette::QuickChromePalette(QObject *parent) : ChromePalette(parent) 47 | { 48 | } 49 | 50 | QuickChromePalette::~QuickChromePalette() = default; 51 | 52 | void QuickChromePalette::classBegin() 53 | { 54 | } 55 | 56 | void QuickChromePalette::componentComplete() 57 | { 58 | } 59 | 60 | FRAMELESSHELPER_END_NAMESPACE 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/quick/quickchromepalette.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/quickchromepalette.h" 2 | -------------------------------------------------------------------------------- /src/quick/quickimageitem.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/quickimageitem.h" 2 | -------------------------------------------------------------------------------- /src/quick/quickimageitem_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/private/quickimageitem_p.h" 2 | -------------------------------------------------------------------------------- /src/quick/quickmicamaterial.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/quickmicamaterial.h" 2 | -------------------------------------------------------------------------------- /src/quick/quickmicamaterial_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/private/quickmicamaterial_p.h" 2 | -------------------------------------------------------------------------------- /src/quick/quickstandardsystembutton_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/private/quickstandardsystembutton_p.h" 2 | -------------------------------------------------------------------------------- /src/quick/quickstandardtitlebar_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/private/quickstandardtitlebar_p.h" 2 | -------------------------------------------------------------------------------- /src/quick/quickwindowborder.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/quickwindowborder.h" 2 | -------------------------------------------------------------------------------- /src/quick/quickwindowborder_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/private/quickwindowborder_p.h" 2 | -------------------------------------------------------------------------------- /src/widgets/framelessdialog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "framelessdialog.h" 26 | #include "framelessdialog_p.h" 27 | 28 | #if FRAMELESSHELPER_CONFIG(window) 29 | 30 | #include "framelesswidgetshelper.h" 31 | #include "widgetssharedhelper_p.h" 32 | #include 33 | 34 | FRAMELESSHELPER_BEGIN_NAMESPACE 35 | 36 | #if FRAMELESSHELPER_CONFIG(debug_output) 37 | [[maybe_unused]] static Q_LOGGING_CATEGORY(lcFramelessDialog, "wangwenx190.framelesshelper.widgets.framelessdialog") 38 | # define INFO qCInfo(lcFramelessDialog) 39 | # define DEBUG qCDebug(lcFramelessDialog) 40 | # define WARNING qCWarning(lcFramelessDialog) 41 | # define CRITICAL qCCritical(lcFramelessDialog) 42 | #else 43 | # define INFO QT_NO_QDEBUG_MACRO() 44 | # define DEBUG QT_NO_QDEBUG_MACRO() 45 | # define WARNING QT_NO_QDEBUG_MACRO() 46 | # define CRITICAL QT_NO_QDEBUG_MACRO() 47 | #endif 48 | 49 | using namespace Global; 50 | 51 | FramelessDialogPrivate::FramelessDialogPrivate(FramelessDialog *q) : QObject(q) 52 | { 53 | Q_ASSERT(q); 54 | if (!q) { 55 | return; 56 | } 57 | q_ptr = q; 58 | } 59 | 60 | FramelessDialogPrivate::~FramelessDialogPrivate() = default; 61 | 62 | FramelessDialogPrivate *FramelessDialogPrivate::get(FramelessDialog *pub) 63 | { 64 | Q_ASSERT(pub); 65 | if (!pub) { 66 | return nullptr; 67 | } 68 | return pub->d_func(); 69 | } 70 | 71 | const FramelessDialogPrivate *FramelessDialogPrivate::get(const FramelessDialog *pub) 72 | { 73 | Q_ASSERT(pub); 74 | if (!pub) { 75 | return nullptr; 76 | } 77 | return pub->d_func(); 78 | } 79 | 80 | FramelessDialog::FramelessDialog(QWidget *parent) 81 | : QDialog(parent), d_ptr(std::make_unique(this)) 82 | { 83 | FramelessWidgetsHelper::get(this)->extendsContentIntoTitleBar(); 84 | Q_D(FramelessDialog); 85 | d->sharedHelper = new WidgetsSharedHelper(d); 86 | d->sharedHelper->setup(this); 87 | } 88 | 89 | FramelessDialog::~FramelessDialog() = default; 90 | 91 | FRAMELESSHELPER_END_NAMESPACE 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /src/widgets/framelessdialog.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/framelessdialog.h" 2 | -------------------------------------------------------------------------------- /src/widgets/framelessdialog_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/private/framelessdialog_p.h" 2 | -------------------------------------------------------------------------------- /src/widgets/framelesshelperwidgets_global.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "framelesshelperwidgets_global.h" 26 | #include 27 | 28 | FRAMELESSHELPER_BEGIN_NAMESPACE 29 | 30 | #if FRAMELESSHELPER_CONFIG(debug_output) 31 | [[maybe_unused]] static Q_LOGGING_CATEGORY(lcWidgetsGlobal, "wangwenx190.framelesshelper.widgets.global") 32 | # define INFO qCInfo(lcWidgetsGlobal) 33 | # define DEBUG qCDebug(lcWidgetsGlobal) 34 | # define WARNING qCWarning(lcWidgetsGlobal) 35 | # define CRITICAL qCCritical(lcWidgetsGlobal) 36 | #else 37 | # define INFO QT_NO_QDEBUG_MACRO() 38 | # define DEBUG QT_NO_QDEBUG_MACRO() 39 | # define WARNING QT_NO_QDEBUG_MACRO() 40 | # define CRITICAL QT_NO_QDEBUG_MACRO() 41 | #endif 42 | 43 | void FramelessHelperWidgetsInitialize() 44 | { 45 | static bool inited = false; 46 | if (inited) { 47 | return; 48 | } 49 | inited = true; 50 | 51 | FramelessHelperCoreInitialize(); 52 | } 53 | 54 | void FramelessHelperWidgetsUninitialize() 55 | { 56 | static bool uninited = false; 57 | if (uninited) { 58 | return; 59 | } 60 | uninited = true; 61 | 62 | // ### TODO: The Widgets module-specific uninitialization. 63 | 64 | FramelessHelperCoreUninitialize(); 65 | } 66 | 67 | FRAMELESSHELPER_END_NAMESPACE 68 | -------------------------------------------------------------------------------- /src/widgets/framelesshelperwidgets_global.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/framelesshelperwidgets_global.h" 2 | -------------------------------------------------------------------------------- /src/widgets/framelessmainwindow.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "framelessmainwindow.h" 26 | #include "framelessmainwindow_p.h" 27 | 28 | #if FRAMELESSHELPER_CONFIG(window) 29 | 30 | #include "framelesswidgetshelper.h" 31 | #include "widgetssharedhelper_p.h" 32 | #include 33 | #include 34 | 35 | FRAMELESSHELPER_BEGIN_NAMESPACE 36 | 37 | #if FRAMELESSHELPER_CONFIG(debug_output) 38 | [[maybe_unused]] static Q_LOGGING_CATEGORY(lcFramelessMainWindow, "wangwenx190.framelesshelper.widgets.framelessmainwindow") 39 | # define INFO qCInfo(lcFramelessMainWindow) 40 | # define DEBUG qCDebug(lcFramelessMainWindow) 41 | # define WARNING qCWarning(lcFramelessMainWindow) 42 | # define CRITICAL qCCritical(lcFramelessMainWindow) 43 | #else 44 | # define INFO QT_NO_QDEBUG_MACRO() 45 | # define DEBUG QT_NO_QDEBUG_MACRO() 46 | # define WARNING QT_NO_QDEBUG_MACRO() 47 | # define CRITICAL QT_NO_QDEBUG_MACRO() 48 | #endif 49 | 50 | using namespace Global; 51 | 52 | FramelessMainWindowPrivate::FramelessMainWindowPrivate(FramelessMainWindow *q) : QObject(q) 53 | { 54 | Q_ASSERT(q); 55 | if (!q) { 56 | return; 57 | } 58 | q_ptr = q; 59 | } 60 | 61 | FramelessMainWindowPrivate::~FramelessMainWindowPrivate() = default; 62 | 63 | FramelessMainWindowPrivate *FramelessMainWindowPrivate::get(FramelessMainWindow *pub) 64 | { 65 | Q_ASSERT(pub); 66 | if (!pub) { 67 | return nullptr; 68 | } 69 | return pub->d_func(); 70 | } 71 | 72 | const FramelessMainWindowPrivate *FramelessMainWindowPrivate::get(const FramelessMainWindow *pub) 73 | { 74 | Q_ASSERT(pub); 75 | if (!pub) { 76 | return nullptr; 77 | } 78 | return pub->d_func(); 79 | } 80 | 81 | FramelessMainWindow::FramelessMainWindow(QWidget *parent, const Qt::WindowFlags flags) 82 | : QMainWindow(parent, flags), d_ptr(std::make_unique(this)) 83 | { 84 | FramelessWidgetsHelper::get(this)->extendsContentIntoTitleBar(); 85 | Q_D(FramelessMainWindow); 86 | d->sharedHelper = new WidgetsSharedHelper(d); 87 | d->sharedHelper->setup(this); 88 | } 89 | 90 | FramelessMainWindow::~FramelessMainWindow() = default; 91 | 92 | bool FramelessMainWindow::isNormal() const 93 | { 94 | return (Utils::windowStatesToWindowState(windowState()) == Qt::WindowNoState); 95 | } 96 | 97 | bool FramelessMainWindow::isZoomed() const 98 | { 99 | return (isMaximized() || isFullScreen()); 100 | } 101 | 102 | void FramelessMainWindow::toggleMaximized() 103 | { 104 | if (isMaximized()) { 105 | showNormal(); 106 | } else { 107 | showMaximized(); 108 | } 109 | } 110 | 111 | void FramelessMainWindow::toggleFullScreen() 112 | { 113 | Q_D(FramelessMainWindow); 114 | if (isFullScreen()) { 115 | setWindowState(d->savedWindowState); 116 | } else { 117 | d->savedWindowState = Utils::windowStatesToWindowState(windowState()); 118 | showFullScreen(); 119 | } 120 | } 121 | 122 | FRAMELESSHELPER_END_NAMESPACE 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /src/widgets/framelessmainwindow.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/framelessmainwindow.h" 2 | -------------------------------------------------------------------------------- /src/widgets/framelessmainwindow_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/private/framelessmainwindow_p.h" 2 | -------------------------------------------------------------------------------- /src/widgets/framelesswidget.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "framelesswidget.h" 26 | #include "framelesswidget_p.h" 27 | 28 | #if FRAMELESSHELPER_CONFIG(window) 29 | 30 | #include "framelesswidgetshelper.h" 31 | #include "widgetssharedhelper_p.h" 32 | #include 33 | #include 34 | 35 | FRAMELESSHELPER_BEGIN_NAMESPACE 36 | 37 | #if FRAMELESSHELPER_CONFIG(debug_output) 38 | [[maybe_unused]] static Q_LOGGING_CATEGORY(lcFramelessWidget, "wangwenx190.framelesshelper.widgets.framelesswidget") 39 | # define INFO qCInfo(lcFramelessWidget) 40 | # define DEBUG qCDebug(lcFramelessWidget) 41 | # define WARNING qCWarning(lcFramelessWidget) 42 | # define CRITICAL qCCritical(lcFramelessWidget) 43 | #else 44 | # define INFO QT_NO_QDEBUG_MACRO() 45 | # define DEBUG QT_NO_QDEBUG_MACRO() 46 | # define WARNING QT_NO_QDEBUG_MACRO() 47 | # define CRITICAL QT_NO_QDEBUG_MACRO() 48 | #endif 49 | 50 | using namespace Global; 51 | 52 | FramelessWidgetPrivate::FramelessWidgetPrivate(FramelessWidget *q) : QObject(q) 53 | { 54 | Q_ASSERT(q); 55 | if (!q) { 56 | return; 57 | } 58 | q_ptr = q; 59 | } 60 | 61 | FramelessWidgetPrivate::~FramelessWidgetPrivate() = default; 62 | 63 | FramelessWidgetPrivate *FramelessWidgetPrivate::get(FramelessWidget *pub) 64 | { 65 | Q_ASSERT(pub); 66 | if (!pub) { 67 | return nullptr; 68 | } 69 | return pub->d_func(); 70 | } 71 | 72 | const FramelessWidgetPrivate *FramelessWidgetPrivate::get(const FramelessWidget *pub) 73 | { 74 | Q_ASSERT(pub); 75 | if (!pub) { 76 | return nullptr; 77 | } 78 | return pub->d_func(); 79 | } 80 | 81 | FramelessWidget::FramelessWidget(QWidget *parent) 82 | : QWidget(parent, Qt::Window), d_ptr(std::make_unique(this)) 83 | { 84 | FramelessWidgetsHelper::get(this)->extendsContentIntoTitleBar(); 85 | Q_D(FramelessWidget); 86 | d->sharedHelper = new WidgetsSharedHelper(d); 87 | d->sharedHelper->setup(this); 88 | } 89 | 90 | FramelessWidget::~FramelessWidget() = default; 91 | 92 | bool FramelessWidget::isNormal() const 93 | { 94 | return (Utils::windowStatesToWindowState(windowState()) == Qt::WindowNoState); 95 | } 96 | 97 | bool FramelessWidget::isZoomed() const 98 | { 99 | return (isMaximized() || isFullScreen()); 100 | } 101 | 102 | void FramelessWidget::toggleMaximized() 103 | { 104 | if (isMaximized()) { 105 | showNormal(); 106 | } else { 107 | showMaximized(); 108 | } 109 | } 110 | 111 | void FramelessWidget::toggleFullScreen() 112 | { 113 | Q_D(FramelessWidget); 114 | if (isFullScreen()) { 115 | setWindowState(d->savedWindowState); 116 | } else { 117 | d->savedWindowState = Utils::windowStatesToWindowState(windowState()); 118 | showFullScreen(); 119 | } 120 | } 121 | 122 | FRAMELESSHELPER_END_NAMESPACE 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /src/widgets/framelesswidget.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/framelesswidget.h" 2 | -------------------------------------------------------------------------------- /src/widgets/framelesswidget_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/private/framelesswidget_p.h" 2 | -------------------------------------------------------------------------------- /src/widgets/framelesswidgetshelper.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/framelesswidgetshelper.h" 2 | -------------------------------------------------------------------------------- /src/widgets/framelesswidgetshelper_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/private/framelesswidgetshelper_p.h" 2 | -------------------------------------------------------------------------------- /src/widgets/standardsystembutton.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/standardsystembutton.h" 2 | -------------------------------------------------------------------------------- /src/widgets/standardsystembutton_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/private/standardsystembutton_p.h" 2 | -------------------------------------------------------------------------------- /src/widgets/standardtitlebar.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/standardtitlebar.h" 2 | -------------------------------------------------------------------------------- /src/widgets/standardtitlebar_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/private/standardtitlebar_p.h" 2 | -------------------------------------------------------------------------------- /src/widgets/widgetssharedhelper_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/private/widgetssharedhelper_p.h" 2 | --------------------------------------------------------------------------------