├── include └── FramelessHelper │ ├── Core │ ├── Utils │ ├── ChromePalette │ ├── MicaMaterial │ ├── FramelessHelper_Qt │ ├── FramelessManager │ ├── Global │ ├── FramelessHelper_Win │ ├── WindowBorderPainter │ ├── FramelessHelper_Linux │ ├── FramelessHelper_Windows │ ├── framelesshelper_qt.h │ ├── framelesshelper_win.h │ ├── private │ │ ├── framelessconfig_p.h │ │ ├── winverhelper_p.h │ │ ├── windowborderpainter_p.h │ │ ├── micamaterial_p.h │ │ ├── framelessmanager_p.h │ │ ├── scopeguard_p.h │ │ ├── chromepalette_p.h │ │ ├── registrykey_p.h │ │ └── sysapiloader_p.h │ ├── framelessmanager.h │ ├── micamaterial.h │ └── windowborderpainter.h │ ├── Quick │ ├── Global │ ├── QuickMicaMaterial │ ├── QuickWindowBorder │ ├── FramelessQuickHelper │ ├── FramelessQuickModule │ ├── FramelessQuickUtils │ ├── QuickChromePalette │ ├── framelessquickmodule.h │ ├── quickchromepalette.h │ ├── private │ │ ├── quickwindowborder_p.h │ │ ├── quickmicamaterial_p.h │ │ ├── framelessquickwindow_p_p.h │ │ ├── framelessquickapplicationwindow_p_p.h │ │ ├── quickimageitem_p.h │ │ ├── framelessquickwindow_p.h │ │ ├── framelessquickapplicationwindow_p.h │ │ └── framelessquickhelper_p.h │ ├── quickmicamaterial.h │ └── quickwindowborder.h │ └── Widgets │ ├── FramelessDialog │ ├── FramelessWidget │ ├── StandardTitleBar │ ├── FramelessMainWindow │ ├── Global │ ├── StandardSystemButton │ ├── FramelessWidgetsHelper │ ├── framelessdialog.h │ ├── framelesshelperwidgets_global.h │ ├── private │ ├── framelessdialog_p.h │ ├── framelesswidget_p.h │ ├── framelessmainwindow_p.h │ ├── standardsystembutton_p.h │ ├── widgetssharedhelper_p.h │ ├── standardtitlebar_p.h │ └── framelesswidgetshelper_p.h │ ├── framelesswidget.h │ └── framelessmainwindow.h ├── src ├── core │ ├── utils.h │ ├── micamaterial.h │ ├── chromepalette.h │ ├── framelessmanager.h │ ├── registrykey_p.h │ ├── scopeguard_p.h │ ├── chromepalette_p.h │ ├── framelesshelper_qt.h │ ├── framelesshelper_win.h │ ├── micamaterial_p.h │ ├── sysapiloader_p.h │ ├── versionnumber_p.h │ ├── windowborderpainter.h │ ├── winverhelper_p.h │ ├── framelessconfig_p.h │ ├── framelesshelper_linux.h │ ├── framelessmanager_p.h │ ├── framelesshelper_windows.h │ ├── framelesshelpercore_global.h │ ├── windowborderpainter_p.h │ ├── framelesshelpercore_global_p.h │ ├── resources │ │ ├── images │ │ │ └── noise.png │ │ └── fonts │ │ │ └── iconfont.ttf │ └── framelesshelpercore.qrc ├── quick │ ├── quickimageitem.h │ ├── quickchromepalette.h │ ├── quickmicamaterial.h │ ├── quickwindowborder.h │ ├── framelessquickhelper.h │ ├── framelessquickmodule.h │ ├── framelessquickutils.h │ ├── quickimageitem_p.h │ ├── quickmicamaterial_p.h │ ├── quickwindowborder_p.h │ ├── framelessquickhelper_p.h │ ├── framelessquickwindow_p.h │ ├── framelesshelperquick_global.h │ ├── framelessquickwindow_p_p.h │ ├── quickstandardtitlebar_p.h │ ├── quickstandardsystembutton_p.h │ ├── framelessquickapplicationwindow_p.h │ ├── framelessquickapplicationwindow_p_p.h │ └── quickchromepalette.cpp ├── widgets │ ├── framelessdialog.h │ ├── framelesswidget.h │ ├── standardtitlebar.h │ ├── framelessmainwindow.h │ ├── framelessdialog_p.h │ ├── framelesswidget_p.h │ ├── standardsystembutton.h │ ├── framelesswidgetshelper.h │ ├── standardtitlebar_p.h │ ├── framelessmainwindow_p.h │ ├── standardsystembutton_p.h │ ├── widgetssharedhelper_p.h │ ├── framelesshelperwidgets_global.h │ ├── framelesswidgetshelper_p.h │ ├── framelesshelperwidgets_global.cpp │ ├── framelessdialog.cpp │ └── framelesswidget.cpp └── CMakeLists.txt ├── .gitmodules ├── doc ├── mac_dark.png ├── mac_light.png ├── win_dark.png ├── win_light.png ├── QVogenClient.png ├── linux_dark.png └── linux_light.png ├── examples ├── shared │ ├── example.ico │ ├── log.h │ ├── settings.h │ ├── settings.cpp │ └── log.cpp ├── openglwidget │ ├── images.qrc │ ├── images │ │ └── qtlogo.png │ ├── mainwindow.h │ └── logo.h ├── quick │ ├── images │ │ ├── microsoft.png │ │ └── microsoft.svg │ ├── resources.qrc │ ├── quick.pro │ ├── scripts │ │ ├── d3d11.bat │ │ ├── d3d12.bat │ │ ├── opengl.bat │ │ └── vulkan.bat │ ├── qml │ │ └── HomePage.qml │ ├── quicksettings.h │ └── quicksettings.cpp ├── widget │ ├── widget.pro │ ├── widget.h │ ├── main.cpp │ └── CMakeLists.txt ├── dialog │ ├── dialog.h │ ├── main.cpp │ └── CMakeLists.txt ├── CMakeLists.txt └── mainwindow │ ├── mainwindow.h │ └── main.cpp ├── LICENSE ├── .gitignore ├── msbuild └── FramelessHelper.props ├── qmake ├── widgets.pri ├── inc │ └── core │ │ ├── framelesshelper.config │ │ └── framelesshelper.version ├── quick.pri └── core.pri ├── .github └── workflows │ └── ci.yml └── FramelessHelperConfig.cmake.in /include/FramelessHelper/Core/Utils: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/ChromePalette: -------------------------------------------------------------------------------- 1 | #include "chromepalette.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/MicaMaterial: -------------------------------------------------------------------------------- 1 | #include "micamaterial.h" 2 | -------------------------------------------------------------------------------- /src/core/utils.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/utils.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/FramelessHelper_Qt: -------------------------------------------------------------------------------- 1 | #include "framelesshelper_qt.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/FramelessManager: -------------------------------------------------------------------------------- 1 | #include "framelessmanager.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/Global: -------------------------------------------------------------------------------- 1 | #include "framelesshelpercore_global.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/Global: -------------------------------------------------------------------------------- 1 | #include "framelesshelperquick_global.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/QuickMicaMaterial: -------------------------------------------------------------------------------- 1 | #include "quickmicamaterial.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Quick/QuickWindowBorder: -------------------------------------------------------------------------------- 1 | #include "quickwindowborder.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/FramelessDialog: -------------------------------------------------------------------------------- 1 | #include "framelessdialog.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/FramelessWidget: -------------------------------------------------------------------------------- 1 | #include "framelesswidget.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/StandardTitleBar: -------------------------------------------------------------------------------- 1 | #include "standardtitlebar.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/FramelessHelper_Win: -------------------------------------------------------------------------------- 1 | #include "framelesshelper_win.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/WindowBorderPainter: -------------------------------------------------------------------------------- 1 | #include "windowborderpainter.h" 2 | -------------------------------------------------------------------------------- /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/QuickChromePalette: -------------------------------------------------------------------------------- 1 | #include "quickchromepalette.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/FramelessMainWindow: -------------------------------------------------------------------------------- 1 | #include "framelessmainwindow.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/Global: -------------------------------------------------------------------------------- 1 | #include "framelesshelperwidgets_global.h" 2 | -------------------------------------------------------------------------------- /src/core/micamaterial.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/micamaterial.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/FramelessHelper_Linux: -------------------------------------------------------------------------------- 1 | #include "framelesshelper_linux.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Core/FramelessHelper_Windows: -------------------------------------------------------------------------------- 1 | #include "framelesshelper_windows.h" 2 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/StandardSystemButton: -------------------------------------------------------------------------------- 1 | #include "standardsystembutton.h" 2 | -------------------------------------------------------------------------------- /src/core/chromepalette.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/chromepalette.h" 2 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "cmake"] 2 | path = cmake 3 | url = ../../wangwenx190/cmake-utils.git 4 | -------------------------------------------------------------------------------- /include/FramelessHelper/Widgets/FramelessWidgetsHelper: -------------------------------------------------------------------------------- 1 | #include "framelesswidgetshelper.h" 2 | -------------------------------------------------------------------------------- /src/core/framelessmanager.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/framelessmanager.h" 2 | -------------------------------------------------------------------------------- /src/core/registrykey_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/private/registrykey_p.h" 2 | -------------------------------------------------------------------------------- /src/core/scopeguard_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/private/scopeguard_p.h" 2 | -------------------------------------------------------------------------------- /src/quick/quickimageitem.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/quickimageitem.h" 2 | -------------------------------------------------------------------------------- /src/core/chromepalette_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/private/chromepalette_p.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/micamaterial_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/private/micamaterial_p.h" 2 | -------------------------------------------------------------------------------- /src/core/sysapiloader_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/private/sysapiloader_p.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/winverhelper_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/private/winverhelper_p.h" 2 | -------------------------------------------------------------------------------- /src/quick/quickchromepalette.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/quickchromepalette.h" 2 | -------------------------------------------------------------------------------- /src/quick/quickmicamaterial.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/quickmicamaterial.h" 2 | -------------------------------------------------------------------------------- /src/quick/quickwindowborder.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/quickwindowborder.h" 2 | -------------------------------------------------------------------------------- /src/widgets/framelessdialog.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/framelessdialog.h" 2 | -------------------------------------------------------------------------------- /src/widgets/framelesswidget.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/framelesswidget.h" 2 | -------------------------------------------------------------------------------- /src/widgets/standardtitlebar.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/standardtitlebar.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/framelessmanager_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/private/framelessmanager_p.h" 2 | -------------------------------------------------------------------------------- /src/quick/framelessquickhelper.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/framelessquickhelper.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/quickimageitem_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/private/quickimageitem_p.h" 2 | -------------------------------------------------------------------------------- /src/widgets/framelessmainwindow.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/framelessmainwindow.h" 2 | -------------------------------------------------------------------------------- /doc/mac_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qt-Widgets/framelesshelper-framelesswindow/HEAD/doc/mac_dark.png -------------------------------------------------------------------------------- /doc/mac_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qt-Widgets/framelesshelper-framelesswindow/HEAD/doc/mac_light.png -------------------------------------------------------------------------------- /doc/win_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qt-Widgets/framelesshelper-framelesswindow/HEAD/doc/win_dark.png -------------------------------------------------------------------------------- /doc/win_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qt-Widgets/framelesshelper-framelesswindow/HEAD/doc/win_light.png -------------------------------------------------------------------------------- /src/core/framelesshelper_windows.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/framelesshelper_windows.h" 2 | -------------------------------------------------------------------------------- /src/quick/quickmicamaterial_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/private/quickmicamaterial_p.h" 2 | -------------------------------------------------------------------------------- /src/quick/quickwindowborder_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/private/quickwindowborder_p.h" 2 | -------------------------------------------------------------------------------- /src/widgets/framelessdialog_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/private/framelessdialog_p.h" 2 | -------------------------------------------------------------------------------- /src/widgets/framelesswidget_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/private/framelesswidget_p.h" 2 | -------------------------------------------------------------------------------- /src/widgets/standardsystembutton.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/standardsystembutton.h" 2 | -------------------------------------------------------------------------------- /doc/QVogenClient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qt-Widgets/framelesshelper-framelesswindow/HEAD/doc/QVogenClient.png -------------------------------------------------------------------------------- /doc/linux_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qt-Widgets/framelesshelper-framelesswindow/HEAD/doc/linux_dark.png -------------------------------------------------------------------------------- /doc/linux_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qt-Widgets/framelesshelper-framelesswindow/HEAD/doc/linux_light.png -------------------------------------------------------------------------------- /src/core/framelesshelpercore_global.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/framelesshelpercore_global.h" 2 | -------------------------------------------------------------------------------- /src/core/windowborderpainter_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/private/windowborderpainter_p.h" 2 | -------------------------------------------------------------------------------- /src/quick/framelessquickhelper_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/private/framelessquickhelper_p.h" 2 | -------------------------------------------------------------------------------- /src/quick/framelessquickwindow_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/private/framelessquickwindow_p.h" 2 | -------------------------------------------------------------------------------- /src/widgets/framelesswidgetshelper.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/framelesswidgetshelper.h" 2 | -------------------------------------------------------------------------------- /src/widgets/standardtitlebar_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/private/standardtitlebar_p.h" 2 | -------------------------------------------------------------------------------- /src/quick/framelesshelperquick_global.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/framelesshelperquick_global.h" 2 | -------------------------------------------------------------------------------- /src/quick/framelessquickwindow_p_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/private/framelessquickwindow_p_p.h" 2 | -------------------------------------------------------------------------------- /src/quick/quickstandardtitlebar_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/private/quickstandardtitlebar_p.h" 2 | -------------------------------------------------------------------------------- /src/widgets/framelessmainwindow_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/private/framelessmainwindow_p.h" 2 | -------------------------------------------------------------------------------- /src/widgets/standardsystembutton_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/private/standardsystembutton_p.h" 2 | -------------------------------------------------------------------------------- /src/widgets/widgetssharedhelper_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/private/widgetssharedhelper_p.h" 2 | -------------------------------------------------------------------------------- /src/core/framelesshelpercore_global_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Core/private/framelesshelpercore_global_p.h" 2 | -------------------------------------------------------------------------------- /src/quick/quickstandardsystembutton_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/private/quickstandardsystembutton_p.h" 2 | -------------------------------------------------------------------------------- /src/widgets/framelesshelperwidgets_global.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/framelesshelperwidgets_global.h" 2 | -------------------------------------------------------------------------------- /src/widgets/framelesswidgetshelper_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Widgets/private/framelesswidgetshelper_p.h" 2 | -------------------------------------------------------------------------------- /examples/shared/example.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qt-Widgets/framelesshelper-framelesswindow/HEAD/examples/shared/example.ico -------------------------------------------------------------------------------- /src/quick/framelessquickapplicationwindow_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p.h" 2 | -------------------------------------------------------------------------------- /examples/openglwidget/images.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/qtlogo.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /examples/quick/images/microsoft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qt-Widgets/framelesshelper-framelesswindow/HEAD/examples/quick/images/microsoft.png -------------------------------------------------------------------------------- /src/core/resources/images/noise.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qt-Widgets/framelesshelper-framelesswindow/HEAD/src/core/resources/images/noise.png -------------------------------------------------------------------------------- /src/quick/framelessquickapplicationwindow_p_p.h: -------------------------------------------------------------------------------- 1 | #include "../../include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p_p.h" 2 | -------------------------------------------------------------------------------- /src/core/resources/fonts/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qt-Widgets/framelesshelper-framelesswindow/HEAD/src/core/resources/fonts/iconfont.ttf -------------------------------------------------------------------------------- /examples/openglwidget/images/qtlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qt-Widgets/framelesshelper-framelesswindow/HEAD/examples/openglwidget/images/qtlogo.png -------------------------------------------------------------------------------- /src/core/framelesshelpercore.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | resources/fonts/iconfont.ttf 4 | resources/images/noise.png 5 | 6 | 7 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/images/microsoft.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_MOVE(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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | DEFINES += \ 10 | FRAMELESSHELPER_WIDGETS_STATIC 11 | 12 | INCLUDEPATH += \ 13 | $$BASE_INC_DIR \ 14 | $$COMMON_INC_DIR \ 15 | $$WIDGETS_PUB_INC_DIR \ 16 | $$WIDGETS_PRIV_INC_DIR 17 | 18 | DEPENDPATH += \ 19 | $$BASE_INC_DIR \ 20 | $$COMMON_INC_DIR \ 21 | $$WIDGETS_PUB_INC_DIR \ 22 | $$WIDGETS_PRIV_INC_DIR 23 | 24 | HEADERS += \ 25 | $$WIDGETS_PUB_INC_DIR/framelesshelperwidgets_global.h \ 26 | $$WIDGETS_PUB_INC_DIR/framelesswidget.h \ 27 | $$WIDGETS_PUB_INC_DIR/framelessmainwindow.h \ 28 | $$WIDGETS_PUB_INC_DIR/standardsystembutton.h \ 29 | $$WIDGETS_PUB_INC_DIR/framelesswidgetshelper.h \ 30 | $$WIDGETS_PUB_INC_DIR/standardtitlebar.h \ 31 | $$WIDGETS_PUB_INC_DIR/framelessdialog.h \ 32 | $$WIDGETS_PRIV_INC_DIR/framelesswidgetshelper_p.h \ 33 | $$WIDGETS_PRIV_INC_DIR/standardsystembutton_p.h \ 34 | $$WIDGETS_PRIV_INC_DIR/standardtitlebar_p.h \ 35 | $$WIDGETS_PRIV_INC_DIR/framelesswidget_p.h \ 36 | $$WIDGETS_PRIV_INC_DIR/framelessmainwindow_p.h \ 37 | $$WIDGETS_PRIV_INC_DIR/widgetssharedhelper_p.h \ 38 | $$WIDGETS_PRIV_INC_DIR/framelessdialog_p.h 39 | 40 | SOURCES += \ 41 | $$WIDGETS_SRC_DIR/framelessmainwindow.cpp \ 42 | $$WIDGETS_SRC_DIR/framelesswidgetshelper.cpp \ 43 | $$WIDGETS_SRC_DIR/framelesswidget.cpp \ 44 | $$WIDGETS_SRC_DIR/standardsystembutton.cpp \ 45 | $$WIDGETS_SRC_DIR/standardtitlebar.cpp \ 46 | $$WIDGETS_SRC_DIR/widgetssharedhelper.cpp \ 47 | $$WIDGETS_SRC_DIR/framelesshelperwidgets_global.cpp \ 48 | $$WIDGETS_SRC_DIR/framelessdialog.cpp 49 | -------------------------------------------------------------------------------- /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_MOVE(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 | -------------------------------------------------------------------------------- /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 | 29 | FRAMELESSHELPER_BEGIN_NAMESPACE 30 | 31 | struct SystemParameters; 32 | 33 | class FRAMELESSHELPER_CORE_API FramelessHelperQt : public QObject 34 | { 35 | Q_OBJECT 36 | FRAMELESSHELPER_CLASS_INFO 37 | Q_DISABLE_COPY_MOVE(FramelessHelperQt) 38 | 39 | public: 40 | explicit FramelessHelperQt(QObject *parent = nullptr); 41 | ~FramelessHelperQt() override; 42 | 43 | static void addWindow(const SystemParameters *params); 44 | static void removeWindow(const WId windowId); 45 | 46 | protected: 47 | Q_NODISCARD bool eventFilter(QObject *object, QEvent *event) override; 48 | }; 49 | 50 | FRAMELESSHELPER_END_NAMESPACE 51 | -------------------------------------------------------------------------------- /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 | 30 | #if FRAMELESSHELPER_CONFIG(window) 31 | 32 | FRAMELESSHELPER_BEGIN_NAMESPACE 33 | 34 | class FramelessDialogPrivate; 35 | 36 | class FRAMELESSHELPER_WIDGETS_API FramelessDialog : public QDialog 37 | { 38 | Q_OBJECT 39 | FRAMELESSHELPER_CLASS_INFO 40 | Q_DECLARE_PRIVATE(FramelessDialog) 41 | Q_DISABLE_COPY_MOVE(FramelessDialog) 42 | 43 | public: 44 | explicit FramelessDialog(QWidget *parent = nullptr); 45 | ~FramelessDialog() override; 46 | 47 | private: 48 | QScopedPointer d_ptr; 49 | }; 50 | 51 | FRAMELESSHELPER_END_NAMESPACE 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /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_MOVE(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 | -------------------------------------------------------------------------------- /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 | FRAMELESSHELPER_BEGIN_NAMESPACE 33 | 34 | struct SystemParameters; 35 | 36 | class FRAMELESSHELPER_CORE_API FramelessHelperWin : public QAbstractNativeEventFilter 37 | { 38 | Q_DISABLE_COPY_MOVE(FramelessHelperWin) 39 | 40 | public: 41 | explicit FramelessHelperWin(); 42 | ~FramelessHelperWin() override; 43 | 44 | static void addWindow(const SystemParameters *params); 45 | static void removeWindow(const WId windowId); 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 // Q_OS_WINDOWS 53 | -------------------------------------------------------------------------------- /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 | Q_OBJECT 38 | FRAMELESSHELPER_CLASS_INFO 39 | #ifdef QML_ANONYMOUS 40 | QML_ANONYMOUS 41 | #endif 42 | Q_DISABLE_COPY_MOVE(QuickChromePalette) 43 | Q_INTERFACES(QQmlParserStatus) 44 | 45 | public: 46 | explicit QuickChromePalette(QObject *parent = nullptr); 47 | ~QuickChromePalette() override; 48 | 49 | protected: 50 | void classBegin() override; 51 | void componentComplete() override; 52 | }; 53 | 54 | FRAMELESSHELPER_END_NAMESPACE 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /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 | Q_OBJECT 34 | FRAMELESSHELPER_CLASS_INFO 35 | Q_DISABLE_COPY_MOVE(FramelessConfig) 36 | 37 | public: 38 | Q_NODISCARD static FramelessConfig *instance(); 39 | 40 | void reload(const bool force = false); 41 | 42 | void set(const Global::Option option, const bool on = true); 43 | Q_NODISCARD bool isSet(const Global::Option option) const; 44 | 45 | static void setLoadFromEnvironmentVariablesDisabled(const bool on = true); 46 | static void setLoadFromConfigurationFileDisabled(const bool on = true); 47 | 48 | private: 49 | explicit FramelessConfig(QObject *parent = nullptr); 50 | ~FramelessConfig() override; 51 | }; 52 | 53 | FRAMELESSHELPER_END_NAMESPACE 54 | -------------------------------------------------------------------------------- /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/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 | # ifdef FRAMELESSHELPER_WIDGETS_STATIC 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/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 FramelessDialog; 34 | class WidgetsSharedHelper; 35 | 36 | class FRAMELESSHELPER_WIDGETS_API FramelessDialogPrivate : public QObject 37 | { 38 | Q_OBJECT 39 | FRAMELESSHELPER_CLASS_INFO 40 | Q_DECLARE_PUBLIC(FramelessDialog) 41 | Q_DISABLE_COPY_MOVE(FramelessDialogPrivate) 42 | 43 | public: 44 | explicit FramelessDialogPrivate(FramelessDialog *q); 45 | ~FramelessDialogPrivate() override; 46 | 47 | Q_NODISCARD static FramelessDialogPrivate *get(FramelessDialog *pub); 48 | Q_NODISCARD static const FramelessDialogPrivate *get(const FramelessDialog *pub); 49 | 50 | FramelessDialog *q_ptr = nullptr; 51 | WidgetsSharedHelper *sharedHelper = nullptr; 52 | }; 53 | 54 | FRAMELESSHELPER_END_NAMESPACE 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /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_MOVE(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 | -------------------------------------------------------------------------------- /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 FramelessWidget; 34 | class WidgetsSharedHelper; 35 | 36 | class FRAMELESSHELPER_WIDGETS_API FramelessWidgetPrivate : public QObject 37 | { 38 | Q_OBJECT 39 | FRAMELESSHELPER_CLASS_INFO 40 | Q_DECLARE_PUBLIC(FramelessWidget) 41 | Q_DISABLE_COPY_MOVE(FramelessWidgetPrivate) 42 | 43 | public: 44 | explicit FramelessWidgetPrivate(FramelessWidget *q); 45 | ~FramelessWidgetPrivate() override; 46 | 47 | Q_NODISCARD static FramelessWidgetPrivate *get(FramelessWidget *pub); 48 | Q_NODISCARD static const FramelessWidgetPrivate *get(const FramelessWidget *pub); 49 | 50 | FramelessWidget *q_ptr = nullptr; 51 | Qt::WindowState savedWindowState = Qt::WindowNoState; 52 | WidgetsSharedHelper *sharedHelper = nullptr; 53 | }; 54 | 55 | FRAMELESSHELPER_END_NAMESPACE 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /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 | // Generated automatically by CMake. 26 | // WARNING! DO NOT EDIT THIS FILE MANUALLY! 27 | // ALL CHANGES WILL BE LOST AFTER RE-CONFIGURING! 28 | // Also please do not include this file directly, 29 | // it's designed to be included by FramelessHelper's own headers. 30 | 31 | #pragma once 32 | 33 | #ifndef _FRAMELESSHELPER_CONFIG_DEFINED_ 34 | #define _FRAMELESSHELPER_CONFIG_DEFINED_ 35 | 36 | #define FRAMELESSHELPER_FEATURE_static_build 1 37 | #define FRAMELESSHELPER_FEATURE_widgets 1 38 | #define FRAMELESSHELPER_FEATURE_quick 1 39 | #define FRAMELESSHELPER_FEATURE_debug_output -1 40 | #define FRAMELESSHELPER_FEATURE_bundle_resource 1 41 | #define FRAMELESSHELPER_FEATURE_private_qt 1 42 | #define FRAMELESSHELPER_FEATURE_window 1 43 | #define FRAMELESSHELPER_FEATURE_titlebar 1 44 | #define FRAMELESSHELPER_FEATURE_translation 1 45 | #define FRAMELESSHELPER_FEATURE_mica_material 1 46 | #define FRAMELESSHELPER_FEATURE_border_painter 1 47 | #define FRAMELESSHELPER_FEATURE_system_button 1 48 | 49 | #endif // _FRAMELESSHELPER_CONFIG_DEFINED_ 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 FramelessMainWindow; 34 | class WidgetsSharedHelper; 35 | 36 | class FRAMELESSHELPER_WIDGETS_API FramelessMainWindowPrivate : public QObject 37 | { 38 | Q_OBJECT 39 | FRAMELESSHELPER_CLASS_INFO 40 | Q_DECLARE_PUBLIC(FramelessMainWindow) 41 | Q_DISABLE_COPY_MOVE(FramelessMainWindowPrivate) 42 | 43 | public: 44 | explicit FramelessMainWindowPrivate(FramelessMainWindow *q); 45 | ~FramelessMainWindowPrivate() override; 46 | 47 | Q_NODISCARD static FramelessMainWindowPrivate *get(FramelessMainWindow *pub); 48 | Q_NODISCARD static const FramelessMainWindowPrivate *get(const FramelessMainWindow *pub); 49 | 50 | FramelessMainWindow *q_ptr = nullptr; 51 | Qt::WindowState savedWindowState = Qt::WindowNoState; 52 | WidgetsSharedHelper *sharedHelper = nullptr; 53 | }; 54 | 55 | FRAMELESSHELPER_END_NAMESPACE 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | DEFINES += \ 13 | FRAMELESSHELPER_QUICK_STATIC 14 | 15 | INCLUDEPATH += \ 16 | $$BASE_INC_DIR \ 17 | $$COMMON_INC_DIR \ 18 | $$QUICK_PUB_INC_DIR \ 19 | $$QUICK_PRIV_INC_DIR 20 | 21 | DEPENDPATH += \ 22 | $$BASE_INC_DIR \ 23 | $$COMMON_INC_DIR \ 24 | $$QUICK_PUB_INC_DIR \ 25 | $$QUICK_PRIV_INC_DIR 26 | 27 | HEADERS += \ 28 | $$QUICK_PUB_INC_DIR/framelesshelperquick_global.h \ 29 | $$QUICK_PUB_INC_DIR/framelessquickmodule.h \ 30 | $$QUICK_PUB_INC_DIR/framelessquickhelper.h \ 31 | $$QUICK_PUB_INC_DIR/framelessquickutils.h \ 32 | $$QUICK_PUB_INC_DIR/quickchromepalette.h \ 33 | $$QUICK_PUB_INC_DIR/quickmicamaterial.h \ 34 | $$QUICK_PUB_INC_DIR/quickimageitem.h \ 35 | $$QUICK_PUB_INC_DIR/quickwindowborder.h \ 36 | $$QUICK_PRIV_INC_DIR/quickstandardsystembutton_p.h \ 37 | $$QUICK_PRIV_INC_DIR/quickstandardtitlebar_p.h \ 38 | $$QUICK_PRIV_INC_DIR/framelessquickhelper_p.h \ 39 | $$QUICK_PRIV_INC_DIR/framelessquickwindow_p.h \ 40 | $$QUICK_PRIV_INC_DIR/framelessquickwindow_p_p.h \ 41 | $$QUICK_PRIV_INC_DIR/framelessquickapplicationwindow_p.h \ 42 | $$QUICK_PRIV_INC_DIR/framelessquickapplicationwindow_p_p.h \ 43 | $$QUICK_PRIV_INC_DIR/quickmicamaterial_p.h \ 44 | $$QUICK_PRIV_INC_DIR/quickimageitem_p.h \ 45 | $$QUICK_PRIV_INC_DIR/quickwindowborder_p.h 46 | 47 | SOURCES += \ 48 | $$QUICK_SRC_DIR/quickstandardsystembutton.cpp \ 49 | $$QUICK_SRC_DIR/quickstandardtitlebar.cpp \ 50 | $$QUICK_SRC_DIR/framelessquickutils.cpp \ 51 | $$QUICK_SRC_DIR/framelessquickmodule.cpp \ 52 | $$QUICK_SRC_DIR/framelessquickwindow.cpp \ 53 | $$QUICK_SRC_DIR/framelessquickapplicationwindow.cpp \ 54 | $$QUICK_SRC_DIR/framelessquickhelper.cpp \ 55 | $$QUICK_SRC_DIR/quickchromepalette.cpp \ 56 | $$QUICK_SRC_DIR/framelesshelperquick_global.cpp \ 57 | $$QUICK_SRC_DIR/quickmicamaterial.cpp \ 58 | $$QUICK_SRC_DIR/quickimageitem.cpp \ 59 | $$QUICK_SRC_DIR/quickwindowborder.cpp 60 | -------------------------------------------------------------------------------- /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_MOVE(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 | QShortcut *m_fullScreenShortcut = nullptr; 69 | QShortcut *m_cancelShortcut = nullptr; 70 | }; 71 | -------------------------------------------------------------------------------- /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 | 36 | class FRAMELESSHELPER_CORE_API WindowBorderPainterPrivate : public QObject 37 | { 38 | Q_OBJECT 39 | FRAMELESSHELPER_CLASS_INFO 40 | Q_DECLARE_PUBLIC(WindowBorderPainter) 41 | Q_DISABLE_COPY_MOVE(WindowBorderPainterPrivate) 42 | 43 | public: 44 | explicit WindowBorderPainterPrivate(WindowBorderPainter *q); 45 | ~WindowBorderPainterPrivate() override; 46 | 47 | Q_NODISCARD static WindowBorderPainterPrivate *get(WindowBorderPainter *q); 48 | Q_NODISCARD static const WindowBorderPainterPrivate *get(const WindowBorderPainter *q); 49 | 50 | WindowBorderPainter *q_ptr = nullptr; 51 | std::optional thickness = std::nullopt; 52 | std::optional edges = std::nullopt; 53 | std::optional activeColor = std::nullopt; 54 | std::optional inactiveColor = std::nullopt; 55 | }; 56 | 57 | FRAMELESSHELPER_END_NAMESPACE 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /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 QuickWindowBorder; 34 | class WindowBorderPainter; 35 | 36 | class FRAMELESSHELPER_QUICK_API QuickWindowBorderPrivate : public QObject 37 | { 38 | Q_OBJECT 39 | FRAMELESSHELPER_CLASS_INFO 40 | Q_DISABLE_COPY_MOVE(QuickWindowBorderPrivate) 41 | Q_DECLARE_PUBLIC(QuickWindowBorder) 42 | 43 | public: 44 | explicit QuickWindowBorderPrivate(QuickWindowBorder *q); 45 | ~QuickWindowBorderPrivate() override; 46 | 47 | Q_NODISCARD static QuickWindowBorderPrivate *get(QuickWindowBorder *q); 48 | Q_NODISCARD static const QuickWindowBorderPrivate *get(const QuickWindowBorder *q); 49 | 50 | Q_SLOT void update(); 51 | 52 | void initialize(); 53 | void rebindWindow(); 54 | 55 | QuickWindowBorder *q_ptr = nullptr; 56 | WindowBorderPainter *borderPainter = nullptr; 57 | QMetaObject::Connection activeChangeConnection = {}; 58 | QMetaObject::Connection visibilityChangeConnection = {}; 59 | }; 60 | 61 | FRAMELESSHELPER_END_NAMESPACE 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | class QuickMicaMaterial; 35 | 36 | class FRAMELESSHELPER_QUICK_API QuickMicaMaterialPrivate : public QObject 37 | { 38 | Q_OBJECT 39 | FRAMELESSHELPER_CLASS_INFO 40 | Q_DISABLE_COPY_MOVE(QuickMicaMaterialPrivate) 41 | Q_DECLARE_PUBLIC(QuickMicaMaterial) 42 | 43 | public: 44 | explicit QuickMicaMaterialPrivate(QuickMicaMaterial *q); 45 | ~QuickMicaMaterialPrivate() override; 46 | 47 | Q_NODISCARD static QuickMicaMaterialPrivate *get(QuickMicaMaterial *q); 48 | Q_NODISCARD static const QuickMicaMaterialPrivate *get(const QuickMicaMaterial *q); 49 | 50 | Q_SLOT void rebindWindow(); 51 | 52 | void initialize(); 53 | 54 | QuickMicaMaterial *q_ptr = nullptr; 55 | QMetaObject::Connection rootWindowXChangedConnection = {}; 56 | QMetaObject::Connection rootWindowYChangedConnection = {}; 57 | QMetaObject::Connection rootWindowActiveChangedConnection = {}; 58 | MicaMaterial *micaMaterial = nullptr; 59 | }; 60 | 61 | FRAMELESSHELPER_END_NAMESPACE 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /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 | 30 | #if FRAMELESSHELPER_CONFIG(window) 31 | 32 | FRAMELESSHELPER_BEGIN_NAMESPACE 33 | 34 | class FramelessWidgetPrivate; 35 | 36 | class FRAMELESSHELPER_WIDGETS_API FramelessWidget : public QWidget 37 | { 38 | Q_OBJECT 39 | FRAMELESSHELPER_CLASS_INFO 40 | Q_DECLARE_PRIVATE(FramelessWidget) 41 | Q_DISABLE_COPY_MOVE(FramelessWidget) 42 | Q_PROPERTY(bool hidden READ isHidden NOTIFY hiddenChanged FINAL) 43 | Q_PROPERTY(bool normal READ isNormal NOTIFY normalChanged FINAL) 44 | Q_PROPERTY(bool zoomed READ isZoomed NOTIFY zoomedChanged FINAL) 45 | 46 | public: 47 | explicit FramelessWidget(QWidget *parent = nullptr); 48 | ~FramelessWidget() override; 49 | 50 | Q_NODISCARD bool isNormal() const; 51 | Q_NODISCARD bool isZoomed() const; 52 | 53 | public Q_SLOTS: 54 | void toggleMaximized(); 55 | void toggleFullScreen(); 56 | 57 | Q_SIGNALS: 58 | void hiddenChanged(); 59 | void normalChanged(); 60 | void zoomedChanged(); 61 | 62 | private: 63 | QScopedPointer d_ptr; 64 | }; 65 | 66 | FRAMELESSHELPER_END_NAMESPACE 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /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 | class FramelessQuickWindow; 39 | 40 | class FRAMELESSHELPER_QUICK_API FramelessQuickWindowPrivate : public QObject 41 | { 42 | Q_OBJECT 43 | FRAMELESSHELPER_CLASS_INFO 44 | Q_DECLARE_PUBLIC(FramelessQuickWindow) 45 | Q_DISABLE_COPY_MOVE(FramelessQuickWindowPrivate) 46 | 47 | public: 48 | explicit FramelessQuickWindowPrivate(FramelessQuickWindow *q); 49 | ~FramelessQuickWindowPrivate() override; 50 | 51 | Q_NODISCARD static FramelessQuickWindowPrivate *get(FramelessQuickWindow *pub); 52 | Q_NODISCARD static const FramelessQuickWindowPrivate *get(const FramelessQuickWindow *pub); 53 | 54 | FramelessQuickWindow *q_ptr = nullptr; 55 | QQuickWindow::Visibility savedVisibility = QQuickWindow::Windowed; 56 | #if FRAMELESSHELPER_CONFIG(border_painter) 57 | QuickWindowBorder *windowBorder = nullptr; 58 | #endif 59 | }; 60 | 61 | FRAMELESSHELPER_END_NAMESPACE 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /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 | 30 | #if FRAMELESSHELPER_CONFIG(window) 31 | 32 | FRAMELESSHELPER_BEGIN_NAMESPACE 33 | 34 | class FramelessMainWindowPrivate; 35 | 36 | class FRAMELESSHELPER_WIDGETS_API FramelessMainWindow : public QMainWindow 37 | { 38 | Q_OBJECT 39 | FRAMELESSHELPER_CLASS_INFO 40 | Q_DECLARE_PRIVATE(FramelessMainWindow) 41 | Q_DISABLE_COPY_MOVE(FramelessMainWindow) 42 | Q_PROPERTY(bool hidden READ isHidden NOTIFY hiddenChanged FINAL) 43 | Q_PROPERTY(bool normal READ isNormal NOTIFY normalChanged FINAL) 44 | Q_PROPERTY(bool zoomed READ isZoomed NOTIFY zoomedChanged FINAL) 45 | 46 | public: 47 | explicit FramelessMainWindow(QWidget *parent = nullptr, const Qt::WindowFlags flags = {}); 48 | ~FramelessMainWindow() override; 49 | 50 | Q_NODISCARD bool isNormal() const; 51 | Q_NODISCARD bool isZoomed() const; 52 | 53 | public Q_SLOTS: 54 | void toggleMaximized(); 55 | void toggleFullScreen(); 56 | 57 | Q_SIGNALS: 58 | void hiddenChanged(); 59 | void normalChanged(); 60 | void zoomedChanged(); 61 | 62 | private: 63 | QScopedPointer d_ptr; 64 | }; 65 | 66 | FRAMELESSHELPER_END_NAMESPACE 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /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 | // Generated automatically by QMake. 26 | // WARNING! DO NOT EDIT THIS FILE MANUALLY! 27 | // ALL CHANGES WILL BE LOST AFTER RE-CONFIGURING! 28 | // Also please do not include this file directly, 29 | // it's designed to be included by FramelessHelper's own headers. 30 | 31 | #pragma once 32 | 33 | #ifndef _FRAMELESSHELPER_VERSION_DEFINED_ 34 | #define _FRAMELESSHELPER_VERSION_DEFINED_ 35 | 36 | [[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_MAJOR = 2; 37 | [[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_MINOR = 5; 38 | [[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_PATCH = 0; 39 | //[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_TWEAK = 0; 40 | [[maybe_unused]] inline constexpr const char FRAMELESSHELPER_VERSION_STR[] = "2.5.0"; 41 | [[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_STR[] = "UNKNOWN"; 42 | [[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMPILE_DATETIME_STR[] = "UNKNOWN"; 43 | 44 | #define __FRAMELESSHELPER_VERSION_MAJOR__ 2 45 | #define __FRAMELESSHELPER_VERSION_MINOR__ 5 46 | #define __FRAMELESSHELPER_VERSION_PATCH__ 0 47 | //#define __FRAMELESSHELPER_VERSION_TWEAK__ 0 48 | #define __FRAMELESSHELPER_VERSION__ 0x02050000 49 | #define __FRAMELESSHELPER__ 0x02050000 50 | 51 | #endif // _FRAMELESSHELPER_VERSION_DEFINED_ 52 | -------------------------------------------------------------------------------- /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 | 36 | class FRAMELESSHELPER_WIDGETS_API StandardSystemButtonPrivate : public QObject 37 | { 38 | Q_OBJECT 39 | FRAMELESSHELPER_CLASS_INFO 40 | Q_DECLARE_PUBLIC(StandardSystemButton) 41 | Q_DISABLE_COPY_MOVE(StandardSystemButtonPrivate) 42 | 43 | public: 44 | explicit StandardSystemButtonPrivate(StandardSystemButton *q); 45 | ~StandardSystemButtonPrivate() override; 46 | 47 | Q_NODISCARD static StandardSystemButtonPrivate *get(StandardSystemButton *pub); 48 | Q_NODISCARD static const StandardSystemButtonPrivate *get(const StandardSystemButton *pub); 49 | 50 | Q_NODISCARD static QSize getRecommendedButtonSize(); 51 | 52 | StandardSystemButton *q_ptr = nullptr; 53 | Global::SystemButtonType buttonType = Global::SystemButtonType::Unknown; 54 | QString glyph = {}; 55 | QColor hoverColor = {}; 56 | QColor pressColor = {}; 57 | QColor normalColor = {}; 58 | QColor activeForegroundColor = {}; 59 | QColor inactiveForegroundColor = {}; 60 | bool active = false; 61 | std::optional glyphSize = std::nullopt; 62 | }; 63 | 64 | FRAMELESSHELPER_END_NAMESPACE 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /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 | class FramelessQuickApplicationWindow; 39 | 40 | class FRAMELESSHELPER_QUICK_API FramelessQuickApplicationWindowPrivate : public QObject 41 | { 42 | Q_OBJECT 43 | FRAMELESSHELPER_CLASS_INFO 44 | Q_DECLARE_PUBLIC(FramelessQuickApplicationWindow) 45 | Q_DISABLE_COPY_MOVE(FramelessQuickApplicationWindowPrivate) 46 | 47 | public: 48 | explicit FramelessQuickApplicationWindowPrivate(FramelessQuickApplicationWindow *q); 49 | ~FramelessQuickApplicationWindowPrivate() override; 50 | 51 | Q_NODISCARD static FramelessQuickApplicationWindowPrivate *get(FramelessQuickApplicationWindow *pub); 52 | Q_NODISCARD static const FramelessQuickApplicationWindowPrivate *get(const FramelessQuickApplicationWindow *pub); 53 | 54 | FramelessQuickApplicationWindow *q_ptr = nullptr; 55 | QQuickWindow::Visibility savedVisibility = QQuickWindow::Windowed; 56 | #if FRAMELESSHELPER_CONFIG(border_painter) 57 | QuickWindowBorder *windowBorder = nullptr; 58 | #endif 59 | }; 60 | 61 | FRAMELESSHELPER_END_NAMESPACE 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /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 | Q_OBJECT 36 | FRAMELESSHELPER_CLASS_INFO 37 | #ifdef QML_NAMED_ELEMENT 38 | QML_NAMED_ELEMENT(ImageItem) 39 | #endif 40 | Q_DISABLE_COPY_MOVE(QuickImageItem) 41 | 42 | Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged FINAL) 43 | 44 | public: 45 | explicit QuickImageItem(QQuickItem *parent = nullptr); 46 | ~QuickImageItem() override; 47 | 48 | void paint(QPainter *painter) override; 49 | 50 | Q_NODISCARD QVariant source() const; 51 | void setSource(const QVariant &value); 52 | 53 | Q_SIGNALS: 54 | void sourceChanged(); 55 | 56 | protected: 57 | void classBegin() override; 58 | void componentComplete() override; 59 | 60 | private: 61 | void fromUrl(const QUrl &value, QPainter *painter) const; 62 | void fromString(const QString &value, QPainter *painter) const; 63 | void fromImage(const QImage &value, QPainter *painter) const; 64 | void fromPixmap(const QPixmap &value, QPainter *painter) const; 65 | void fromIcon(const QIcon &value, QPainter *painter) const; 66 | Q_NODISCARD QRectF paintArea() const; 67 | 68 | private: 69 | QVariant m_source = {}; 70 | }; 71 | 72 | FRAMELESSHELPER_END_NAMESPACE 73 | -------------------------------------------------------------------------------- /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 | FramelessHelper::Widgets::initialize(); 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 | FramelessHelper::Core::setApplicationOSThemeAware(); 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/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 | FramelessHelper::Widgets::initialize(); 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 | FramelessHelper::Core::setApplicationOSThemeAware(); 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/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 | FramelessHelper::Widgets::initialize(); 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 | FramelessHelper::Core::setApplicationOSThemeAware(); 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 | -------------------------------------------------------------------------------- /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 | 30 | #if FRAMELESSHELPER_CONFIG(mica_material) 31 | 32 | FRAMELESSHELPER_BEGIN_NAMESPACE 33 | 34 | class MicaMaterial; 35 | 36 | class FRAMELESSHELPER_CORE_API MicaMaterialPrivate : public QObject 37 | { 38 | Q_OBJECT 39 | FRAMELESSHELPER_CLASS_INFO 40 | Q_DISABLE_COPY_MOVE(MicaMaterialPrivate) 41 | Q_DECLARE_PUBLIC(MicaMaterial) 42 | 43 | public: 44 | explicit MicaMaterialPrivate(MicaMaterial *q); 45 | ~MicaMaterialPrivate() override; 46 | 47 | Q_NODISCARD static MicaMaterialPrivate *get(MicaMaterial *q); 48 | Q_NODISCARD static const MicaMaterialPrivate *get(const MicaMaterial *q); 49 | 50 | Q_NODISCARD static QColor systemFallbackColor(); 51 | 52 | Q_NODISCARD QPoint mapToWallpaper(const QPoint &pos) const; 53 | Q_NODISCARD QSize mapToWallpaper(const QSize &size) const; 54 | Q_NODISCARD QRect mapToWallpaper(const QRect &rect) const; 55 | 56 | Q_SLOT void maybeGenerateBlurredWallpaper(const bool force = false); 57 | Q_SLOT void updateMaterialBrush(); 58 | Q_SLOT void forceRebuildWallpaper(); 59 | 60 | void initialize(); 61 | void prepareGraphicsResources(); 62 | 63 | MicaMaterial *q_ptr = nullptr; 64 | QColor tintColor = {}; 65 | qreal tintOpacity = qreal(0); 66 | QColor fallbackColor = {}; 67 | qreal noiseOpacity = qreal(0); 68 | bool fallbackEnabled = true; 69 | QBrush micaBrush = {}; 70 | bool initialized = false; 71 | QSize wallpaperSize = {}; 72 | }; 73 | 74 | FRAMELESSHELPER_END_NAMESPACE 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /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 | 29 | FRAMELESSHELPER_BEGIN_NAMESPACE 30 | 31 | struct SystemParameters; 32 | class FramelessManagerPrivate; 33 | 34 | class FRAMELESSHELPER_CORE_API FramelessManager : public QObject 35 | { 36 | Q_OBJECT 37 | FRAMELESSHELPER_CLASS_INFO 38 | Q_DECLARE_PRIVATE(FramelessManager) 39 | Q_DISABLE_COPY_MOVE(FramelessManager) 40 | Q_PROPERTY(Global::SystemTheme systemTheme READ systemTheme WRITE setOverrideTheme NOTIFY systemThemeChanged FINAL) 41 | Q_PROPERTY(QColor systemAccentColor READ systemAccentColor NOTIFY systemThemeChanged FINAL) 42 | Q_PROPERTY(QString wallpaper READ wallpaper NOTIFY wallpaperChanged FINAL) 43 | Q_PROPERTY(Global::WallpaperAspectStyle wallpaperAspectStyle READ wallpaperAspectStyle NOTIFY wallpaperChanged FINAL) 44 | 45 | public: 46 | Q_NODISCARD static FramelessManager *instance(); 47 | 48 | Q_NODISCARD Global::SystemTheme systemTheme() const; 49 | Q_NODISCARD QColor systemAccentColor() const; 50 | Q_NODISCARD QString wallpaper() const; 51 | Q_NODISCARD Global::WallpaperAspectStyle wallpaperAspectStyle() const; 52 | 53 | public Q_SLOTS: 54 | void addWindow(const SystemParameters *params); 55 | void removeWindow(const WId windowId); 56 | void setOverrideTheme(const Global::SystemTheme theme); 57 | 58 | Q_SIGNALS: 59 | void systemThemeChanged(); 60 | void wallpaperChanged(); 61 | 62 | private: 63 | explicit FramelessManager(QObject *parent = nullptr); 64 | ~FramelessManager() override; 65 | 66 | private: 67 | QScopedPointer d_ptr; 68 | }; 69 | 70 | FRAMELESSHELPER_END_NAMESPACE 71 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 SystemParameters; 34 | class FramelessManager; 35 | 36 | class FRAMELESSHELPER_CORE_API FramelessManagerPrivate : public QObject 37 | { 38 | Q_OBJECT 39 | FRAMELESSHELPER_CLASS_INFO 40 | Q_DECLARE_PUBLIC(FramelessManager) 41 | Q_DISABLE_COPY_MOVE(FramelessManagerPrivate) 42 | 43 | public: 44 | explicit FramelessManagerPrivate(FramelessManager *q); 45 | ~FramelessManagerPrivate() override; 46 | 47 | Q_NODISCARD static FramelessManagerPrivate *get(FramelessManager *pub); 48 | Q_NODISCARD static const FramelessManagerPrivate *get(const FramelessManager *pub); 49 | 50 | static void initializeIconFont(); 51 | Q_NODISCARD static QFont getIconFont(); 52 | 53 | Q_SLOT void notifySystemThemeHasChangedOrNot(); 54 | Q_SLOT void notifyWallpaperHasChangedOrNot(); 55 | 56 | Q_NODISCARD bool isThemeOverrided() const; 57 | 58 | void initialize(); 59 | 60 | void doNotifySystemThemeHasChangedOrNot(); 61 | void doNotifyWallpaperHasChangedOrNot(); 62 | 63 | FramelessManager *q_ptr = nullptr; 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 | FRAMELESSHELPER_END_NAMESPACE 77 | -------------------------------------------------------------------------------- /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 | DEFINES += \ 11 | FRAMELESSHELPER_CORE_STATIC 12 | 13 | INCLUDEPATH += \ 14 | $$BASE_INC_DIR \ 15 | $$COMMON_INC_DIR \ 16 | $$CORE_PUB_INC_DIR \ 17 | $$CORE_PRIV_INC_DIR \ 18 | $$CORE_EXTRA_INC_DIR 19 | 20 | DEPENDPATH += \ 21 | $$BASE_INC_DIR \ 22 | $$COMMON_INC_DIR \ 23 | $$CORE_PUB_INC_DIR \ 24 | $$CORE_PRIV_INC_DIR \ 25 | $$CORE_EXTRA_INC_DIR 26 | 27 | HEADERS += \ 28 | $$CORE_EXTRA_INC_DIR/framelesshelper.version \ 29 | $$CORE_EXTRA_INC_DIR/framelesshelper.config \ 30 | $$CORE_PUB_INC_DIR/chromepalette.h \ 31 | $$CORE_PUB_INC_DIR/framelesshelper_qt.h \ 32 | $$CORE_PUB_INC_DIR/framelesshelpercore_global.h \ 33 | $$CORE_PUB_INC_DIR/framelessmanager.h \ 34 | $$CORE_PUB_INC_DIR/micamaterial.h \ 35 | $$CORE_PUB_INC_DIR/utils.h \ 36 | $$CORE_PUB_INC_DIR/windowborderpainter.h \ 37 | $$CORE_PRIV_INC_DIR/chromepalette_p.h \ 38 | $$CORE_PRIV_INC_DIR/framelessconfig_p.h \ 39 | $$CORE_PRIV_INC_DIR/framelessmanager_p.h \ 40 | $$CORE_PRIV_INC_DIR/micamaterial_p.h \ 41 | $$CORE_PRIV_INC_DIR/sysapiloader_p.h \ 42 | $$CORE_PRIV_INC_DIR/windowborderpainter_p.h \ 43 | $$CORE_PRIV_INC_DIR/framelesshelpercore_global_p.h \ 44 | $$CORE_PRIV_INC_DIR/versionnumber_p.h \ 45 | $$CORE_PRIV_INC_DIR/scopeguard_p.h 46 | 47 | SOURCES += \ 48 | $$CORE_SRC_DIR/chromepalette.cpp \ 49 | $$CORE_SRC_DIR/framelessconfig.cpp \ 50 | $$CORE_SRC_DIR/framelesshelper_qt.cpp \ 51 | $$CORE_SRC_DIR/framelessmanager.cpp \ 52 | $$CORE_SRC_DIR/framelesshelpercore_global.cpp \ 53 | $$CORE_SRC_DIR/micamaterial.cpp \ 54 | $$CORE_SRC_DIR/sysapiloader.cpp \ 55 | $$CORE_SRC_DIR/utils.cpp \ 56 | $$CORE_SRC_DIR/windowborderpainter.cpp 57 | 58 | RESOURCES += \ 59 | $$CORE_SRC_DIR/framelesshelpercore.qrc 60 | 61 | win32 { 62 | HEADERS += \ 63 | $$CORE_PUB_INC_DIR/framelesshelper_win.h \ 64 | $$CORE_PUB_INC_DIR/framelesshelper_windows.h \ 65 | $$CORE_PRIV_INC_DIR/registrykey_p.h \ 66 | $$CORE_PRIV_INC_DIR/winverhelper_p.h 67 | SOURCES += \ 68 | $$CORE_SRC_DIR/framelesshelper_win.cpp \ 69 | $$CORE_SRC_DIR/utils_win.cpp \ 70 | $$CORE_SRC_DIR/registrykey.cpp \ 71 | $$CORE_SRC_DIR/winverhelper.cpp \ 72 | $$CORE_SRC_DIR/platformsupport_win.cpp 73 | LIBS += -luser32 -lgdi32 -lshell32 74 | } 75 | 76 | unix:!macx { 77 | CONFIG += link_pkgconfig 78 | PKGCONFIG += xcb gtk+-3.0 79 | DEFINES += GDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_6 80 | HEADERS += \ 81 | $$CORE_PUB_INC_DIR/framelesshelper_linux.h 82 | SOURCES += \ 83 | $$CORE_SRC_DIR/utils_linux.cpp \ 84 | $$CORE_SRC_DIR/platformsupport_linux.cpp 85 | } 86 | 87 | macx { 88 | SOURCES += $$CORE_SRC_DIR/utils_mac.mm 89 | #LIBS += "-framework AppKit" "-framework Cocoa" "-framework Foundation" # TODO 90 | } 91 | -------------------------------------------------------------------------------- /.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.1] 22 | library-type: [shared, static] 23 | platform: [windows-latest, ubuntu-latest, macos-latest] 24 | include: 25 | - platform: windows-latest 26 | CC: cl 27 | CXX: cl 28 | LD: link 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 install llvm 77 | export PATH="/usr/local/opt/llvm/bin:$PATH" 78 | 79 | - name: Build library with CMake 80 | run: | 81 | mkdir ci 82 | cd ci 83 | 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 .. 84 | cmake --build . --target all --config Release --parallel 85 | cmake --install . --config Release --strip 86 | -------------------------------------------------------------------------------- /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 | Q_DISABLE_COPY(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 | -------------------------------------------------------------------------------- /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(new FramelessDialogPrivate(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 | -------------------------------------------------------------------------------- /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 | set(_@PROJECT_NAME@_supported_components Core Widgets Quick) 28 | 29 | foreach(_comp ${@PROJECT_NAME@_FIND_COMPONENTS}) 30 | if(_comp IN_LIST _@PROJECT_NAME@_supported_components) 31 | set(__target @PROJECT_NAME@::${_comp}) 32 | if(TARGET ${__target}) 33 | continue() 34 | else() 35 | set(__target_full @PROJECT_NAME@${_comp}) 36 | set(__targets_file "${CMAKE_CURRENT_LIST_DIR}/${__target_full}Targets.cmake") 37 | if(EXISTS "${__targets_file}") 38 | include("${__targets_file}") 39 | add_library(${__target} ALIAS @PROJECT_NAME@::${__target_full}) 40 | else() 41 | set(@PROJECT_NAME@_FOUND FALSE) 42 | 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.") 43 | break() 44 | endif() 45 | endif() 46 | else() 47 | set(@PROJECT_NAME@_FOUND FALSE) 48 | set(@PROJECT_NAME@_NOT_FOUND_MESSAGE "Unknown component: ${__target}.") 49 | break() 50 | endif() 51 | endforeach() 52 | 53 | if(NOT DEFINED @PROJECT_NAME@_FOUND) 54 | set(@PROJECT_NAME@_FOUND TRUE) 55 | set(@PROJECT_NAME@_VERSION "@PROJECT_VERSION@") 56 | set(@PROJECT_NAME@_VERSION_MAJOR "@PROJECT_VERSION_MAJOR@") 57 | set(@PROJECT_NAME@_VERSION_MINOR "@PROJECT_VERSION_MINOR@") 58 | set(@PROJECT_NAME@_VERSION_PATCH "@PROJECT_VERSION_PATCH@") 59 | #set(@PROJECT_NAME@_VERSION_TWEAK "@PROJECT_VERSION_TWEAK@") 60 | set(@PROJECT_NAME@_DESCRIPTION "@PROJECT_DESCRIPTION@") 61 | set(@PROJECT_NAME@_HOMEPAGE_URL "@PROJECT_HOMEPAGE_URL@") 62 | set(@PROJECT_NAME@_COMMIT "@PROJECT_VERSION_COMMIT@") 63 | set(@PROJECT_NAME@_COMPILE_DATETIME "@PROJECT_COMPILE_DATETIME@") 64 | endif() 65 | 66 | include(FeatureSummary) 67 | set_package_properties(@PROJECT_NAME@ PROPERTIES 68 | DESCRIPTION "@PROJECT_DESCRIPTION@" 69 | URL "@PROJECT_HOMEPAGE_URL@" 70 | ) -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | 29 | #if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(window)) 30 | 31 | #include 32 | 33 | FRAMELESSHELPER_BEGIN_NAMESPACE 34 | 35 | class FramelessQuickWindowPrivate; 36 | 37 | class FRAMELESSHELPER_QUICK_API FramelessQuickWindow : public QQuickWindowQmlImpl 38 | { 39 | Q_OBJECT 40 | FRAMELESSHELPER_CLASS_INFO 41 | #ifdef QML_NAMED_ELEMENT 42 | QML_NAMED_ELEMENT(FramelessWindow) 43 | #endif 44 | Q_DECLARE_PRIVATE(FramelessQuickWindow) 45 | Q_DISABLE_COPY_MOVE(FramelessQuickWindow) 46 | Q_PROPERTY(bool hidden READ isHidden NOTIFY hiddenChanged FINAL) 47 | Q_PROPERTY(bool normal READ isNormal NOTIFY normalChanged FINAL) 48 | Q_PROPERTY(bool minimized READ isMinimized NOTIFY minimizedChanged FINAL) 49 | Q_PROPERTY(bool maximized READ isMaximized NOTIFY maximizedChanged FINAL) 50 | Q_PROPERTY(bool zoomed READ isZoomed NOTIFY zoomedChanged FINAL) 51 | Q_PROPERTY(bool fullScreen READ isFullScreen NOTIFY fullScreenChanged FINAL) 52 | 53 | public: 54 | explicit FramelessQuickWindow(QWindow *parent = nullptr); 55 | ~FramelessQuickWindow() override; 56 | 57 | Q_NODISCARD bool isHidden() const; 58 | Q_NODISCARD bool isNormal() const; 59 | Q_NODISCARD bool isMinimized() const; 60 | Q_NODISCARD bool isMaximized() const; 61 | Q_NODISCARD bool isZoomed() const; 62 | Q_NODISCARD bool isFullScreen() const; 63 | 64 | public Q_SLOTS: 65 | void showMinimized2(); 66 | void toggleMaximized(); 67 | void toggleFullScreen(); 68 | 69 | protected: 70 | void classBegin() override; 71 | void componentComplete() override; 72 | 73 | Q_SIGNALS: 74 | void hiddenChanged(); 75 | void normalChanged(); 76 | void minimizedChanged(); 77 | void maximizedChanged(); 78 | void zoomedChanged(); 79 | void fullScreenChanged(); 80 | 81 | private: 82 | QScopedPointer d_ptr; 83 | }; 84 | 85 | FRAMELESSHELPER_END_NAMESPACE 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | 36 | class FRAMELESSHELPER_CORE_API ChromePalettePrivate : public QObject 37 | { 38 | Q_OBJECT 39 | FRAMELESSHELPER_CLASS_INFO 40 | Q_DECLARE_PUBLIC(ChromePalette) 41 | Q_DISABLE_COPY_MOVE(ChromePalettePrivate) 42 | 43 | public: 44 | explicit ChromePalettePrivate(ChromePalette *q); 45 | ~ChromePalettePrivate() override; 46 | 47 | Q_NODISCARD static ChromePalettePrivate *get(ChromePalette *q); 48 | Q_NODISCARD static const ChromePalettePrivate *get(const ChromePalette *q); 49 | 50 | Q_SLOT void refresh(); 51 | 52 | ChromePalette *q_ptr = nullptr; 53 | // System-defined ones: 54 | QColor titleBarActiveBackgroundColor_sys = {}; 55 | QColor titleBarInactiveBackgroundColor_sys = {}; 56 | QColor titleBarActiveForegroundColor_sys = {}; 57 | QColor titleBarInactiveForegroundColor_sys = {}; 58 | QColor chromeButtonNormalColor_sys = {}; 59 | QColor chromeButtonHoverColor_sys = {}; 60 | QColor chromeButtonPressColor_sys = {}; 61 | QColor closeButtonNormalColor_sys = {}; 62 | QColor closeButtonHoverColor_sys = {}; 63 | QColor closeButtonPressColor_sys = {}; 64 | // User-defined ones: 65 | std::optional titleBarActiveBackgroundColor = std::nullopt; 66 | std::optional titleBarInactiveBackgroundColor = std::nullopt; 67 | std::optional titleBarActiveForegroundColor = std::nullopt; 68 | std::optional titleBarInactiveForegroundColor = std::nullopt; 69 | std::optional chromeButtonNormalColor = std::nullopt; 70 | std::optional chromeButtonHoverColor = std::nullopt; 71 | std::optional chromeButtonPressColor = std::nullopt; 72 | std::optional closeButtonNormalColor = std::nullopt; 73 | std::optional closeButtonHoverColor = std::nullopt; 74 | std::optional closeButtonPressColor = std::nullopt; 75 | }; 76 | 77 | FRAMELESSHELPER_END_NAMESPACE 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /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 | 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 | class FramelessQuickApplicationWindowPrivate; 36 | 37 | class FRAMELESSHELPER_QUICK_API FramelessQuickApplicationWindow : public QQuickApplicationWindow 38 | { 39 | Q_OBJECT 40 | FRAMELESSHELPER_CLASS_INFO 41 | #ifdef QML_NAMED_ELEMENT 42 | QML_NAMED_ELEMENT(FramelessApplicationWindow) 43 | #endif 44 | Q_DECLARE_PRIVATE(FramelessQuickApplicationWindow) 45 | Q_DISABLE_COPY_MOVE(FramelessQuickApplicationWindow) 46 | Q_PROPERTY(bool hidden READ isHidden NOTIFY hiddenChanged FINAL) 47 | Q_PROPERTY(bool normal READ isNormal NOTIFY normalChanged FINAL) 48 | Q_PROPERTY(bool minimized READ isMinimized NOTIFY minimizedChanged FINAL) 49 | Q_PROPERTY(bool maximized READ isMaximized NOTIFY maximizedChanged FINAL) 50 | Q_PROPERTY(bool zoomed READ isZoomed NOTIFY zoomedChanged FINAL) 51 | Q_PROPERTY(bool fullScreen READ isFullScreen NOTIFY fullScreenChanged FINAL) 52 | 53 | public: 54 | explicit FramelessQuickApplicationWindow(QWindow *parent = nullptr); 55 | ~FramelessQuickApplicationWindow() override; 56 | 57 | Q_NODISCARD bool isHidden() const; 58 | Q_NODISCARD bool isNormal() const; 59 | Q_NODISCARD bool isMinimized() const; 60 | Q_NODISCARD bool isMaximized() const; 61 | Q_NODISCARD bool isZoomed() const; 62 | Q_NODISCARD bool isFullScreen() const; 63 | 64 | public Q_SLOTS: 65 | void showMinimized2(); 66 | void toggleMaximized(); 67 | void toggleFullScreen(); 68 | 69 | protected: 70 | void classBegin() override; 71 | void componentComplete() override; 72 | 73 | Q_SIGNALS: 74 | void hiddenChanged(); 75 | void normalChanged(); 76 | void minimizedChanged(); 77 | void maximizedChanged(); 78 | void zoomedChanged(); 79 | void fullScreenChanged(); 80 | 81 | private: 82 | QScopedPointer d_ptr; 83 | }; 84 | 85 | FRAMELESSHELPER_END_NAMESPACE 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /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 | 29 | #if FRAMELESSHELPER_CONFIG(mica_material) 30 | 31 | FRAMELESSHELPER_BEGIN_NAMESPACE 32 | 33 | class MicaMaterialPrivate; 34 | 35 | class FRAMELESSHELPER_CORE_API MicaMaterial : public QObject 36 | { 37 | Q_OBJECT 38 | FRAMELESSHELPER_CLASS_INFO 39 | Q_DISABLE_COPY_MOVE(MicaMaterial) 40 | Q_DECLARE_PRIVATE(MicaMaterial) 41 | 42 | Q_PROPERTY(QColor tintColor READ tintColor WRITE setTintColor NOTIFY tintColorChanged FINAL) 43 | Q_PROPERTY(qreal tintOpacity READ tintOpacity WRITE setTintOpacity NOTIFY tintOpacityChanged FINAL) 44 | Q_PROPERTY(QColor fallbackColor READ fallbackColor WRITE setFallbackColor NOTIFY fallbackColorChanged FINAL) 45 | Q_PROPERTY(qreal noiseOpacity READ noiseOpacity WRITE setNoiseOpacity NOTIFY noiseOpacityChanged FINAL) 46 | Q_PROPERTY(bool fallbackEnabled READ isFallbackEnabled WRITE setFallbackEnabled NOTIFY fallbackEnabledChanged FINAL) 47 | 48 | public: 49 | explicit MicaMaterial(QObject *parent = nullptr); 50 | ~MicaMaterial() override; 51 | 52 | Q_NODISCARD QColor tintColor() const; 53 | void setTintColor(const QColor &value); 54 | 55 | Q_NODISCARD qreal tintOpacity() const; 56 | void setTintOpacity(const qreal value); 57 | 58 | Q_NODISCARD QColor fallbackColor() const; 59 | void setFallbackColor(const QColor &value); 60 | 61 | Q_NODISCARD qreal noiseOpacity() const; 62 | void setNoiseOpacity(const qreal value); 63 | 64 | Q_NODISCARD bool isFallbackEnabled() const; 65 | void setFallbackEnabled(const bool value); 66 | 67 | public Q_SLOTS: 68 | void paint(QPainter *painter, const QRect &rect, const bool active = true); 69 | 70 | [[deprecated("Use another overload instead.")]] 71 | void paint(QPainter *painter, const QSize &size, const QPoint &pos, const bool active = true) 72 | { 73 | paint(painter, QRect{ pos, size }, active); 74 | } 75 | 76 | Q_SIGNALS: 77 | void tintColorChanged(); 78 | void tintOpacityChanged(); 79 | void fallbackColorChanged(); 80 | void noiseOpacityChanged(); 81 | void fallbackEnabledChanged(); 82 | void shouldRedraw(); 83 | 84 | private: 85 | QScopedPointer d_ptr; 86 | }; 87 | 88 | FRAMELESSHELPER_END_NAMESPACE 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /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 | 30 | #if FRAMELESSHELPER_CONFIG(mica_material) 31 | 32 | FRAMELESSHELPER_BEGIN_NAMESPACE 33 | 34 | class QuickMicaMaterialPrivate; 35 | 36 | class FRAMELESSHELPER_QUICK_API QuickMicaMaterial : public QQuickPaintedItem 37 | { 38 | Q_OBJECT 39 | FRAMELESSHELPER_CLASS_INFO 40 | #ifdef QML_NAMED_ELEMENT 41 | QML_NAMED_ELEMENT(MicaMaterial) 42 | #endif 43 | Q_DISABLE_COPY_MOVE(QuickMicaMaterial) 44 | Q_DECLARE_PRIVATE(QuickMicaMaterial) 45 | 46 | Q_PROPERTY(QColor tintColor READ tintColor WRITE setTintColor NOTIFY tintColorChanged FINAL) 47 | Q_PROPERTY(qreal tintOpacity READ tintOpacity WRITE setTintOpacity NOTIFY tintOpacityChanged FINAL) 48 | Q_PROPERTY(QColor fallbackColor READ fallbackColor WRITE setFallbackColor NOTIFY fallbackColorChanged FINAL) 49 | Q_PROPERTY(qreal noiseOpacity READ noiseOpacity WRITE setNoiseOpacity NOTIFY noiseOpacityChanged FINAL) 50 | Q_PROPERTY(bool fallbackEnabled READ isFallbackEnabled WRITE setFallbackEnabled NOTIFY fallbackEnabledChanged FINAL) 51 | 52 | public: 53 | explicit QuickMicaMaterial(QQuickItem *parent = nullptr); 54 | ~QuickMicaMaterial() override; 55 | 56 | void paint(QPainter *painter) override; 57 | 58 | Q_NODISCARD QColor tintColor() const; 59 | void setTintColor(const QColor &value); 60 | 61 | Q_NODISCARD qreal tintOpacity() const; 62 | void setTintOpacity(const qreal value); 63 | 64 | Q_NODISCARD QColor fallbackColor() const; 65 | void setFallbackColor(const QColor &value); 66 | 67 | Q_NODISCARD qreal noiseOpacity() const; 68 | void setNoiseOpacity(const qreal value); 69 | 70 | Q_NODISCARD bool isFallbackEnabled() const; 71 | void setFallbackEnabled(const bool value); 72 | 73 | Q_SIGNALS: 74 | void tintColorChanged(); 75 | void tintOpacityChanged(); 76 | void fallbackColorChanged(); 77 | void noiseOpacityChanged(); 78 | void fallbackEnabledChanged(); 79 | 80 | protected: 81 | void itemChange(const ItemChange change, const ItemChangeData &value) override; 82 | void classBegin() override; 83 | void componentComplete() override; 84 | 85 | private: 86 | QScopedPointer d_ptr; 87 | }; 88 | 89 | FRAMELESSHELPER_END_NAMESPACE 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | 29 | #if FRAMELESSHELPER_CONFIG(border_painter) 30 | 31 | FRAMELESSHELPER_BEGIN_NAMESPACE 32 | 33 | class WindowBorderPainterPrivate; 34 | 35 | class FRAMELESSHELPER_CORE_API WindowBorderPainter : public QObject 36 | { 37 | Q_OBJECT 38 | FRAMELESSHELPER_CLASS_INFO 39 | Q_DISABLE_COPY_MOVE(WindowBorderPainter) 40 | Q_DECLARE_PRIVATE(WindowBorderPainter) 41 | 42 | Q_PROPERTY(int thickness READ thickness WRITE setThickness NOTIFY thicknessChanged FINAL) 43 | Q_PROPERTY(Global::WindowEdges edges READ edges WRITE setEdges NOTIFY edgesChanged FINAL) 44 | Q_PROPERTY(QColor activeColor READ activeColor WRITE setActiveColor NOTIFY activeColorChanged FINAL) 45 | Q_PROPERTY(QColor inactiveColor READ inactiveColor WRITE setInactiveColor NOTIFY inactiveColorChanged FINAL) 46 | 47 | Q_PROPERTY(int nativeThickness READ nativeThickness NOTIFY nativeBorderChanged FINAL) 48 | Q_PROPERTY(Global::WindowEdges nativeEdges READ nativeEdges NOTIFY nativeBorderChanged FINAL) 49 | Q_PROPERTY(QColor nativeActiveColor READ nativeActiveColor NOTIFY nativeBorderChanged FINAL) 50 | Q_PROPERTY(QColor nativeInactiveColor READ nativeInactiveColor NOTIFY nativeBorderChanged FINAL) 51 | 52 | public: 53 | explicit WindowBorderPainter(QObject *parent = nullptr); 54 | ~WindowBorderPainter() override; 55 | 56 | Q_NODISCARD int thickness() const; 57 | Q_NODISCARD Global::WindowEdges edges() const; 58 | Q_NODISCARD QColor activeColor() const; 59 | Q_NODISCARD QColor inactiveColor() const; 60 | 61 | Q_NODISCARD int nativeThickness() const; 62 | Q_NODISCARD Global::WindowEdges nativeEdges() const; 63 | Q_NODISCARD QColor nativeActiveColor() const; 64 | Q_NODISCARD QColor nativeInactiveColor() const; 65 | 66 | public Q_SLOTS: 67 | void paint(QPainter *painter, const QSize &size, const bool active); 68 | void setThickness(const int value); 69 | void setEdges(const Global::WindowEdges value); 70 | void setActiveColor(const QColor &value); 71 | void setInactiveColor(const QColor &value); 72 | 73 | Q_SIGNALS: 74 | void thicknessChanged(); 75 | void edgesChanged(); 76 | void activeColorChanged(); 77 | void inactiveColorChanged(); 78 | void nativeBorderChanged(); 79 | void shouldRepaint(); 80 | 81 | private: 82 | QScopedPointer d_ptr; 83 | }; 84 | 85 | FRAMELESSHELPER_END_NAMESPACE 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /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 | 31 | #ifdef Q_OS_WINDOWS 32 | 33 | #ifndef REGISTRYKEY_FORCE_QSETTINGS 34 | # define REGISTRYKEY_FORCE_QSETTINGS (0) 35 | #endif // REGISTRYKEY_FORCE_QSETTINGS 36 | 37 | #ifndef REGISTRYKEY_IMPL 38 | # if ((QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) && !(REGISTRYKEY_FORCE_QSETTINGS) && !defined(FRAMELESSHELPER_CORE_NO_PRIVATE)) 39 | # define REGISTRYKEY_IMPL (1) 40 | # else // ((QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) || REGISTRYKEY_FORCE_QSETTINGS || defined(FRAMELESSHELPER_CORE_NO_PRIVATE)) 41 | # define REGISTRYKEY_IMPL (2) 42 | # endif // ((QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) && !REGISTRYKEY_FORCE_QSETTINGS && !defined(FRAMELESSHELPER_CORE_NO_PRIVATE)) 43 | #endif // REGISTRYKEY_IMPL 44 | 45 | #ifndef REGISTRYKEY_QWINREGISTRYKEY 46 | # define REGISTRYKEY_QWINREGISTRYKEY ((REGISTRYKEY_IMPL) == 1) 47 | #endif // REGISTRYKEY_QWINREGISTRYKEY 48 | 49 | #ifndef REGISTRYKEY_QSETTINGS 50 | # define REGISTRYKEY_QSETTINGS ((REGISTRYKEY_IMPL) == 2) 51 | #endif // REGISTRYKEY_QSETTINGS 52 | 53 | QT_BEGIN_NAMESPACE 54 | class QWinRegistryKey; 55 | class QSettings; 56 | QT_END_NAMESPACE 57 | 58 | FRAMELESSHELPER_BEGIN_NAMESPACE 59 | 60 | class FRAMELESSHELPER_CORE_API RegistryKey : public QObject 61 | { 62 | Q_OBJECT 63 | FRAMELESSHELPER_CLASS_INFO 64 | Q_DISABLE_COPY_MOVE(RegistryKey) 65 | 66 | public: 67 | explicit RegistryKey(const Global::RegistryRootKey root, const QString &key, QObject *parent = nullptr); 68 | ~RegistryKey() override; 69 | 70 | Q_NODISCARD Global::RegistryRootKey rootKey() const; 71 | Q_NODISCARD QString subKey() const; 72 | 73 | Q_NODISCARD bool isValid() const; 74 | 75 | Q_NODISCARD QVariant value(const QString &name) const; 76 | template 77 | Q_NODISCARD std::optional value(const QString &name) const 78 | { 79 | const QVariant var = value(name); 80 | if (var.isValid() && !var.isNull()) { 81 | return qvariant_cast(var); 82 | } 83 | return std::nullopt; 84 | } 85 | 86 | private: 87 | Global::RegistryRootKey m_rootKey = Global::RegistryRootKey::CurrentUser; 88 | QString m_subKey = {}; 89 | #if REGISTRYKEY_QWINREGISTRYKEY 90 | QScopedPointer m_registryKey; 91 | #else 92 | QScopedPointer m_settings; 93 | #endif 94 | }; 95 | 96 | FRAMELESSHELPER_END_NAMESPACE 97 | 98 | #endif // Q_OS_WINDOWS 99 | -------------------------------------------------------------------------------- /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 | Q_OBJECT 42 | FRAMELESSHELPER_CLASS_INFO 43 | Q_DISABLE_COPY_MOVE(WidgetsSharedHelper) 44 | #if FRAMELESSHELPER_CONFIG(mica_material) 45 | Q_PROPERTY(bool micaEnabled READ isMicaEnabled WRITE setMicaEnabled NOTIFY micaEnabledChanged FINAL) 46 | #endif 47 | 48 | public: 49 | explicit WidgetsSharedHelper(QObject *parent = nullptr); 50 | ~WidgetsSharedHelper() override; 51 | 52 | void setup(QWidget *widget); 53 | 54 | #if FRAMELESSHELPER_CONFIG(mica_material) 55 | Q_NODISCARD bool isMicaEnabled() const; 56 | void setMicaEnabled(const bool value); 57 | Q_NODISCARD MicaMaterial *rawMicaMaterial() const; 58 | #endif 59 | #if FRAMELESSHELPER_CONFIG(border_painter) 60 | Q_NODISCARD WindowBorderPainter *rawWindowBorder() const; 61 | #endif 62 | 63 | protected: 64 | Q_NODISCARD bool eventFilter(QObject *object, QEvent *event) override; 65 | 66 | private Q_SLOTS: 67 | void updateContentsMargins(); 68 | void handleScreenChanged(QScreen *screen); 69 | 70 | private: 71 | #if FRAMELESSHELPER_CONFIG(mica_material) 72 | void repaintMica(); 73 | #endif 74 | #if FRAMELESSHELPER_CONFIG(border_painter) 75 | void repaintBorder(); 76 | #endif 77 | void emitCustomWindowStateSignals(); 78 | 79 | Q_SIGNALS: 80 | #if FRAMELESSHELPER_CONFIG(mica_material) 81 | void micaEnabledChanged(); 82 | #endif 83 | 84 | private: 85 | QPointer m_targetWidget; 86 | QPointer m_screen; 87 | qreal m_screenDpr = qreal(0); 88 | QMetaObject::Connection m_screenDpiChangeConnection = {}; 89 | QMetaObject::Connection m_screenChangeConnection = {}; 90 | #if FRAMELESSHELPER_CONFIG(mica_material) 91 | bool m_micaEnabled = false; 92 | MicaMaterial *m_micaMaterial = nullptr; 93 | QMetaObject::Connection m_micaRedrawConnection = {}; 94 | #endif 95 | #if FRAMELESSHELPER_CONFIG(border_painter) 96 | WindowBorderPainter *m_borderPainter = nullptr; 97 | QMetaObject::Connection m_borderRepaintConnection = {}; 98 | #endif 99 | }; 100 | 101 | FRAMELESSHELPER_END_NAMESPACE 102 | -------------------------------------------------------------------------------- /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 | class StandardTitleBar; 44 | 45 | class FRAMELESSHELPER_WIDGETS_API StandardTitleBarPrivate : public QObject 46 | { 47 | Q_OBJECT 48 | FRAMELESSHELPER_CLASS_INFO 49 | Q_DECLARE_PUBLIC(StandardTitleBar) 50 | Q_DISABLE_COPY_MOVE(StandardTitleBarPrivate) 51 | 52 | public: 53 | struct FontMetrics 54 | { 55 | int width = 0; 56 | int height = 0; 57 | int ascent = 0; 58 | }; 59 | 60 | explicit StandardTitleBarPrivate(StandardTitleBar *q); 61 | ~StandardTitleBarPrivate() override; 62 | 63 | Q_NODISCARD static StandardTitleBarPrivate *get(StandardTitleBar *pub); 64 | Q_NODISCARD static const StandardTitleBarPrivate *get(const StandardTitleBar *pub); 65 | 66 | Q_NODISCARD QRect windowIconRect() const; 67 | Q_NODISCARD bool windowIconVisible_real() const; 68 | Q_NODISCARD bool isInTitleBarIconArea(const QPoint &pos) const; 69 | 70 | Q_NODISCARD QFont defaultFont() const; 71 | Q_NODISCARD FontMetrics titleLabelSize() const; 72 | 73 | Q_SLOT void updateMaximizeButton(); 74 | Q_SLOT void updateTitleBarColor(); 75 | Q_SLOT void updateChromeButtonColor(); 76 | Q_SLOT void retranslateUi(); 77 | 78 | Q_NODISCARD bool mouseEventHandler(QMouseEvent *event); 79 | 80 | void initialize(); 81 | 82 | StandardTitleBar *q_ptr = nullptr; 83 | #if (!defined(Q_OS_MACOS) && FRAMELESSHELPER_CONFIG(system_button)) 84 | StandardSystemButton *minimizeButton = nullptr; 85 | StandardSystemButton *maximizeButton = nullptr; 86 | StandardSystemButton *closeButton = nullptr; 87 | #endif 88 | QPointer window = nullptr; 89 | bool extended = false; 90 | Qt::Alignment labelAlignment = {}; 91 | bool hideWhenClose = false; 92 | ChromePalette *chromePalette = nullptr; 93 | bool titleLabelVisible = true; 94 | std::optional windowIconSize = std::nullopt; 95 | bool windowIconVisible = false; 96 | std::optional titleFont = std::nullopt; 97 | bool closeTriggered = false; 98 | 99 | protected: 100 | bool eventFilter(QObject *object, QEvent *event) override; 101 | }; 102 | 103 | FRAMELESSHELPER_END_NAMESPACE 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /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 | 30 | #if FRAMELESSHELPER_CONFIG(border_painter) 31 | 32 | FRAMELESSHELPER_BEGIN_NAMESPACE 33 | 34 | class QuickWindowBorderPrivate; 35 | 36 | class FRAMELESSHELPER_QUICK_API QuickWindowBorder : public QQuickPaintedItem 37 | { 38 | Q_OBJECT 39 | FRAMELESSHELPER_CLASS_INFO 40 | #ifdef QML_NAMED_ELEMENT 41 | QML_NAMED_ELEMENT(WindowBorder) 42 | #endif 43 | Q_DISABLE_COPY_MOVE(QuickWindowBorder) 44 | Q_DECLARE_PRIVATE(QuickWindowBorder) 45 | 46 | Q_PROPERTY(qreal thickness READ thickness WRITE setThickness NOTIFY thicknessChanged FINAL) 47 | Q_PROPERTY(QuickGlobal::WindowEdges edges READ edges WRITE setEdges NOTIFY edgesChanged FINAL) 48 | Q_PROPERTY(QColor activeColor READ activeColor WRITE setActiveColor NOTIFY activeColorChanged FINAL) 49 | Q_PROPERTY(QColor inactiveColor READ inactiveColor WRITE setInactiveColor NOTIFY inactiveColorChanged FINAL) 50 | 51 | Q_PROPERTY(qreal nativeThickness READ nativeThickness NOTIFY nativeBorderChanged FINAL) 52 | Q_PROPERTY(QuickGlobal::WindowEdges nativeEdges READ nativeEdges NOTIFY nativeBorderChanged FINAL) 53 | Q_PROPERTY(QColor nativeActiveColor READ nativeActiveColor NOTIFY nativeBorderChanged FINAL) 54 | Q_PROPERTY(QColor nativeInactiveColor READ nativeInactiveColor NOTIFY nativeBorderChanged FINAL) 55 | 56 | public: 57 | explicit QuickWindowBorder(QQuickItem *parent = nullptr); 58 | ~QuickWindowBorder() override; 59 | 60 | void paint(QPainter *painter) override; 61 | 62 | Q_NODISCARD qreal thickness() const; 63 | Q_NODISCARD QuickGlobal::WindowEdges edges() const; 64 | Q_NODISCARD QColor activeColor() const; 65 | Q_NODISCARD QColor inactiveColor() const; 66 | 67 | Q_NODISCARD qreal nativeThickness() const; 68 | Q_NODISCARD QuickGlobal::WindowEdges nativeEdges() const; 69 | Q_NODISCARD QColor nativeActiveColor() const; 70 | Q_NODISCARD QColor nativeInactiveColor() const; 71 | 72 | public Q_SLOTS: 73 | void setThickness(const qreal value); 74 | void setEdges(const QuickGlobal::WindowEdges value); 75 | void setActiveColor(const QColor &value); 76 | void setInactiveColor(const QColor &value); 77 | 78 | protected: 79 | void itemChange(const ItemChange change, const ItemChangeData &value) override; 80 | void classBegin() override; 81 | void componentComplete() override; 82 | 83 | Q_SIGNALS: 84 | void thicknessChanged(); 85 | void edgesChanged(); 86 | void activeColorChanged(); 87 | void inactiveColorChanged(); 88 | void nativeBorderChanged(); 89 | 90 | private: 91 | QScopedPointer d_ptr; 92 | }; 93 | 94 | FRAMELESSHELPER_END_NAMESPACE 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /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 | 30 | QT_BEGIN_NAMESPACE 31 | class QQuickItem; 32 | QT_END_NAMESPACE 33 | 34 | FRAMELESSHELPER_BEGIN_NAMESPACE 35 | 36 | #if FRAMELESSHELPER_CONFIG(mica_material) 37 | class QuickMicaMaterial; 38 | #endif 39 | #if FRAMELESSHELPER_CONFIG(border_painter) 40 | class QuickWindowBorder; 41 | #endif 42 | class FramelessQuickHelper; 43 | struct FramelessQuickHelperData; 44 | 45 | class FRAMELESSHELPER_QUICK_API FramelessQuickHelperPrivate : public QObject 46 | { 47 | Q_OBJECT 48 | FRAMELESSHELPER_CLASS_INFO 49 | Q_DECLARE_PUBLIC(FramelessQuickHelper) 50 | Q_DISABLE_COPY_MOVE(FramelessQuickHelperPrivate) 51 | 52 | public: 53 | explicit FramelessQuickHelperPrivate(FramelessQuickHelper *q); 54 | ~FramelessQuickHelperPrivate() override; 55 | 56 | Q_NODISCARD static FramelessQuickHelperPrivate *get(FramelessQuickHelper *pub); 57 | Q_NODISCARD static const FramelessQuickHelperPrivate *get(const FramelessQuickHelper *pub); 58 | 59 | void attach(); 60 | void detach(); 61 | 62 | void emitSignalForAllInstances(const char *signal); 63 | 64 | void setProperty(const char *name, const QVariant &value); 65 | Q_NODISCARD QVariant getProperty(const char *name, const QVariant &defaultValue = {}); 66 | 67 | #if FRAMELESSHELPER_CONFIG(mica_material) 68 | Q_NODISCARD QuickMicaMaterial *findOrCreateMicaMaterial() const; 69 | #endif 70 | #if FRAMELESSHELPER_CONFIG(border_painter) 71 | Q_NODISCARD QuickWindowBorder *findOrCreateWindowBorder() const; 72 | #endif 73 | 74 | Q_NODISCARD static FramelessQuickHelper *findOrCreateFramelessHelper(QObject *object); 75 | 76 | void repaintAllChildren(const quint32 delay = 0) const; 77 | 78 | Q_NODISCARD quint32 readyWaitTime() const; 79 | void setReadyWaitTime(const quint32 time); 80 | 81 | Q_NODISCARD QRect mapItemGeometryToScene(const QQuickItem * const item) const; 82 | Q_NODISCARD bool isInSystemButtons(const QPoint &pos, QuickGlobal::SystemButtonType *button) const; 83 | Q_NODISCARD bool isInTitleBarDraggableArea(const QPoint &pos) const; 84 | Q_NODISCARD bool shouldIgnoreMouseEvents(const QPoint &pos) const; 85 | void setSystemButtonState(const QuickGlobal::SystemButtonType button, const QuickGlobal::ButtonState state); 86 | Q_NODISCARD const FramelessQuickHelperData *getWindowData() const; 87 | Q_NODISCARD FramelessQuickHelperData *getWindowDataMutable() const; 88 | void rebindWindow(); 89 | 90 | FramelessQuickHelper *q_ptr = nullptr; 91 | QColor savedWindowBackgroundColor = {}; 92 | bool blurBehindWindowEnabled = false; 93 | std::optional extendIntoTitleBar = std::nullopt; 94 | bool qpaReady = false; 95 | quint32 qpaWaitTime = 0; 96 | }; 97 | 98 | FRAMELESSHELPER_END_NAMESPACE 99 | -------------------------------------------------------------------------------- /examples/dialog/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 | set(DEMO_NAME FramelessHelperDemo-Dialog) 26 | 27 | if(FRAMELESSHELPER_ENABLE_UNIVERSAL_BUILD) 28 | set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE) 29 | endif() 30 | 31 | if(FRAMELESSHELPER_EXAMPLES_STANDALONE) 32 | cmake_minimum_required(VERSION 3.20) 33 | project(${DEMO_NAME} VERSION 1.0) 34 | include(../../cmake/utils.cmake) 35 | setup_project( 36 | QT_PROJECT 37 | LANGUAGES CXX RC 38 | NO_WARNING 39 | ENABLE_LTO 40 | ) 41 | find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) 42 | find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) 43 | find_package(FramelessHelper REQUIRED COMPONENTS Core Widgets) 44 | endif() 45 | 46 | add_executable(${DEMO_NAME}) 47 | 48 | target_sources(${DEMO_NAME} PRIVATE 49 | ../shared/log.h 50 | ../shared/log.cpp 51 | ../shared/settings.h 52 | ../shared/settings.cpp 53 | dialog.h 54 | dialog.cpp 55 | main.cpp 56 | ) 57 | 58 | if(WIN32) 59 | set(__rc_path "${PROJECT_BINARY_DIR}/${DEMO_NAME}.rc") 60 | if(NOT EXISTS "${__rc_path}") 61 | generate_win32_rc_file( 62 | PATH "${__rc_path}" 63 | VERSION "${PROJECT_VERSION}" 64 | COMPANY "wangwenx190" 65 | DESCRIPTION "FramelessHelper Demo Application: Dialog" 66 | COPYRIGHT "MIT License" 67 | PRODUCT "FramelessHelper Demo" 68 | ICONS "../shared/example.ico" 69 | ) 70 | endif() 71 | set(__manifest_path "${PROJECT_BINARY_DIR}/${DEMO_NAME}.manifest") 72 | if(NOT EXISTS "${__manifest_path}") 73 | generate_win32_manifest_file( 74 | PATH "${__manifest_path}" 75 | ID "org.wangwenx190.demo.Dialog" 76 | VERSION "${PROJECT_VERSION}" 77 | VISTA_COMPAT 78 | WIN7_COMPAT 79 | WIN8_COMPAT 80 | WIN8_1_COMPAT 81 | WIN10_COMPAT 82 | WIN11_COMPAT 83 | XAML_ISLANDS_COMPAT 84 | UTF8_CODEPAGE 85 | ) 86 | endif() 87 | target_sources(${DEMO_NAME} PRIVATE 88 | "${__rc_path}" 89 | "${__manifest_path}" 90 | ) 91 | endif() 92 | 93 | target_link_libraries(${DEMO_NAME} PRIVATE 94 | Qt${QT_VERSION_MAJOR}::Widgets 95 | FramelessHelper::Core 96 | FramelessHelper::Widgets 97 | ) 98 | 99 | setup_gui_app( 100 | TARGETS ${DEMO_NAME} 101 | BUNDLE_ID "org.wangwenx190.demo.Dialog" 102 | BUNDLE_VERSION "1.0.0" 103 | BUNDLE_VERSION_SHORT "1.0" 104 | ) 105 | 106 | if(FRAMELESSHELPER_EXAMPLES_DEPLOYQT) 107 | set(__extra_flags) 108 | if(FRAMELESSHELPER_NO_INSTALL) 109 | set(__extra_flags NO_INSTALL) 110 | endif() 111 | deploy_qt_runtime(TARGET ${DEMO_NAME} ${__extra_flags}) 112 | endif() 113 | 114 | #dump_target_info(TARGETS ${DEMO_NAME}) 115 | -------------------------------------------------------------------------------- /examples/widget/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 | set(DEMO_NAME FramelessHelperDemo-Widget) 26 | 27 | if(FRAMELESSHELPER_ENABLE_UNIVERSAL_BUILD) 28 | set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE) 29 | endif() 30 | 31 | if(FRAMELESSHELPER_EXAMPLES_STANDALONE) 32 | cmake_minimum_required(VERSION 3.20) 33 | project(${DEMO_NAME} VERSION 1.0) 34 | include(../../cmake/utils.cmake) 35 | setup_project( 36 | QT_PROJECT 37 | LANGUAGES CXX RC 38 | NO_WARNING 39 | ENABLE_LTO 40 | ) 41 | find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) 42 | find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) 43 | find_package(FramelessHelper REQUIRED COMPONENTS Core Widgets) 44 | endif() 45 | 46 | add_executable(${DEMO_NAME}) 47 | 48 | target_sources(${DEMO_NAME} PRIVATE 49 | ../shared/log.h 50 | ../shared/log.cpp 51 | ../shared/settings.h 52 | ../shared/settings.cpp 53 | widget.h 54 | widget.cpp 55 | main.cpp 56 | ) 57 | 58 | if(WIN32) 59 | set(__rc_path "${PROJECT_BINARY_DIR}/${DEMO_NAME}.rc") 60 | if(NOT EXISTS "${__rc_path}") 61 | generate_win32_rc_file( 62 | PATH "${__rc_path}" 63 | VERSION "${PROJECT_VERSION}" 64 | COMPANY "wangwenx190" 65 | DESCRIPTION "FramelessHelper Demo Application: Widget" 66 | COPYRIGHT "MIT License" 67 | PRODUCT "FramelessHelper Demo" 68 | ICONS "../shared/example.ico" 69 | ) 70 | endif() 71 | set(__manifest_path "${PROJECT_BINARY_DIR}/${DEMO_NAME}.manifest") 72 | if(NOT EXISTS "${__manifest_path}") 73 | generate_win32_manifest_file( 74 | PATH "${__manifest_path}" 75 | ID "org.wangwenx190.demo.Widget" 76 | VERSION "${PROJECT_VERSION}" 77 | VISTA_COMPAT 78 | WIN7_COMPAT 79 | WIN8_COMPAT 80 | WIN8_1_COMPAT 81 | WIN10_COMPAT 82 | WIN11_COMPAT 83 | XAML_ISLANDS_COMPAT 84 | UTF8_CODEPAGE 85 | ) 86 | endif() 87 | target_sources(${DEMO_NAME} PRIVATE 88 | "${__rc_path}" 89 | "${__manifest_path}" 90 | ) 91 | endif() 92 | 93 | target_link_libraries(${DEMO_NAME} PRIVATE 94 | Qt${QT_VERSION_MAJOR}::Widgets 95 | FramelessHelper::Core 96 | FramelessHelper::Widgets 97 | ) 98 | 99 | setup_gui_app( 100 | TARGETS ${DEMO_NAME} 101 | BUNDLE_ID "org.wangwenx190.demo.Widget" 102 | BUNDLE_VERSION "1.0.0" 103 | BUNDLE_VERSION_SHORT "1.0" 104 | ) 105 | 106 | if(FRAMELESSHELPER_EXAMPLES_DEPLOYQT) 107 | set(__extra_flags) 108 | if(FRAMELESSHELPER_NO_INSTALL) 109 | set(__extra_flags NO_INSTALL) 110 | endif() 111 | deploy_qt_runtime(TARGET ${DEMO_NAME} ${__extra_flags}) 112 | endif() 113 | 114 | #dump_target_info(TARGETS ${DEMO_NAME}) 115 | -------------------------------------------------------------------------------- /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(new FramelessWidgetPrivate(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 | -------------------------------------------------------------------------------- /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 | 31 | FRAMELESSHELPER_BEGIN_NAMESPACE 32 | 33 | #if FRAMELESSHELPER_CONFIG(mica_material) 34 | class MicaMaterial; 35 | #endif 36 | #if FRAMELESSHELPER_CONFIG(border_painter) 37 | class WindowBorderPainter; 38 | #endif 39 | class FramelessWidgetsHelper; 40 | struct FramelessWidgetsHelperData; 41 | class WidgetsSharedHelper; 42 | 43 | class FRAMELESSHELPER_WIDGETS_API FramelessWidgetsHelperPrivate : public QObject 44 | { 45 | Q_OBJECT 46 | FRAMELESSHELPER_CLASS_INFO 47 | Q_DECLARE_PUBLIC(FramelessWidgetsHelper) 48 | Q_DISABLE_COPY_MOVE(FramelessWidgetsHelperPrivate) 49 | 50 | public: 51 | explicit FramelessWidgetsHelperPrivate(FramelessWidgetsHelper *q); 52 | ~FramelessWidgetsHelperPrivate() override; 53 | 54 | Q_NODISCARD static FramelessWidgetsHelperPrivate *get(FramelessWidgetsHelper *pub); 55 | Q_NODISCARD static const FramelessWidgetsHelperPrivate *get(const FramelessWidgetsHelper *pub); 56 | 57 | void attach(); 58 | void detach(); 59 | 60 | void emitSignalForAllInstances(const char *signal); 61 | 62 | void setProperty(const char *name, const QVariant &value); 63 | Q_NODISCARD QVariant getProperty(const char *name, const QVariant &defaultValue = {}); 64 | 65 | #if FRAMELESSHELPER_CONFIG(mica_material) 66 | Q_NODISCARD MicaMaterial *getMicaMaterialIfAny() const; 67 | #endif 68 | #if FRAMELESSHELPER_CONFIG(border_painter) 69 | Q_NODISCARD WindowBorderPainter *getWindowBorderIfAny() const; 70 | #endif 71 | 72 | Q_NODISCARD static WidgetsSharedHelper *findOrCreateSharedHelper(QWidget *window); 73 | Q_NODISCARD static FramelessWidgetsHelper *findOrCreateFramelessHelper(QObject *object); 74 | 75 | void repaintAllChildren(const quint32 delay = 0) const; 76 | 77 | Q_NODISCARD quint32 readyWaitTime() const; 78 | void setReadyWaitTime(const quint32 time); 79 | 80 | Q_NODISCARD QRect mapWidgetGeometryToScene(const QWidget * const widget) const; 81 | Q_NODISCARD bool isInSystemButtons(const QPoint &pos, Global::SystemButtonType *button) const; 82 | Q_NODISCARD bool isInTitleBarDraggableArea(const QPoint &pos) const; 83 | Q_NODISCARD bool shouldIgnoreMouseEvents(const QPoint &pos) const; 84 | void setSystemButtonState(const Global::SystemButtonType button, const Global::ButtonState state); 85 | Q_NODISCARD QWidget *findTopLevelWindow() const; 86 | Q_NODISCARD const FramelessWidgetsHelperData *getWindowData() const; 87 | Q_NODISCARD FramelessWidgetsHelperData *getWindowDataMutable() const; 88 | 89 | FramelessWidgetsHelper *q_ptr = nullptr; 90 | QColor savedWindowBackgroundColor = {}; 91 | bool blurBehindWindowEnabled = false; 92 | QPointer window = nullptr; 93 | bool qpaReady = false; 94 | QSizePolicy savedSizePolicy = {}; 95 | quint32 qpaWaitTime = 0; 96 | }; 97 | 98 | FRAMELESSHELPER_END_NAMESPACE 99 | -------------------------------------------------------------------------------- /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 | Q_OBJECT 34 | FRAMELESSHELPER_CLASS_INFO 35 | Q_DISABLE_COPY_MOVE(SysApiLoader) 36 | 37 | public: 38 | Q_NODISCARD static SysApiLoader *instance(); 39 | 40 | Q_NODISCARD static QString platformSharedLibrarySuffixName(); 41 | Q_NODISCARD static QString platformSystemLibraryDirectory(); 42 | Q_NODISCARD static QString generateUniqueKey(const QString &library, const QString &function); 43 | 44 | Q_NODISCARD static QFunctionPointer resolve(const QString &library, const char *function); 45 | Q_NODISCARD static QFunctionPointer resolve(const QString &library, const QString &function); 46 | 47 | Q_NODISCARD bool isAvailable(const QString &library, const QString &function); 48 | 49 | Q_NODISCARD QFunctionPointer get(const QString &library, const QString &function); 50 | 51 | template 52 | Q_NODISCARD T get(const QString &library, const QString &function) 53 | { 54 | return reinterpret_cast(get(library, function)); 55 | } 56 | 57 | private: 58 | explicit SysApiLoader(QObject *parent = nullptr); 59 | ~SysApiLoader() override; 60 | }; 61 | 62 | FRAMELESSHELPER_END_NAMESPACE 63 | 64 | #define API_AVAILABLE(lib, func) \ 65 | (FRAMELESSHELPER_PREPEND_NAMESPACE(SysApiLoader)::instance()->isAvailable(k##lib, k##func)) 66 | 67 | #define API_CALL_FUNCTION(lib, func, ...) \ 68 | ((FRAMELESSHELPER_PREPEND_NAMESPACE(SysApiLoader)::instance()->get(k##lib, k##func))(__VA_ARGS__)) 69 | 70 | #define API_CALL_FUNCTION2(lib, func, type, ...) \ 71 | ((FRAMELESSHELPER_PREPEND_NAMESPACE(SysApiLoader)::instance()->get(k##lib, k##func))(__VA_ARGS__)) 72 | 73 | #define API_CALL_FUNCTION3(lib, func, name, ...) \ 74 | ((FRAMELESSHELPER_PREPEND_NAMESPACE(SysApiLoader)::instance()->get(k##lib, k##name))(__VA_ARGS__)) 75 | 76 | #define API_CALL_FUNCTION4(lib, func, ...) API_CALL_FUNCTION3(lib, _##func, func, __VA_ARGS__) 77 | 78 | #define API_CALL_FUNCTION5(lib, func, ...) API_CALL_FUNCTION3(lib, func##2, func, __VA_ARGS__) 79 | 80 | #ifdef Q_OS_WINDOWS 81 | # define API_USER_AVAILABLE(func) API_AVAILABLE(user32, func) 82 | # define API_THEME_AVAILABLE(func) API_AVAILABLE(uxtheme, func) 83 | # define API_DWM_AVAILABLE(func) API_AVAILABLE(dwmapi, func) 84 | # define API_SHCORE_AVAILABLE(func) API_AVAILABLE(shcore, func) 85 | # define API_WINMM_AVAILABLE(func) API_AVAILABLE(winmm, func) 86 | # define API_D2D_AVAILABLE(func) API_AVAILABLE(d2d1, func) 87 | # define API_NT_AVAILABLE(func) API_AVAILABLE(ntdll, func) 88 | #endif // Q_OS_WINDOWS 89 | 90 | #if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) 91 | # define API_XLIB_AVAILABLE(func) API_AVAILABLE(libX11, func) 92 | # define API_XCB_AVAILABLE(func) API_AVAILABLE(libxcb, func) 93 | # define API_GTK_AVAILABLE(func) API_AVAILABLE(libgtk, func) 94 | #endif // Q_OS_LINUX 95 | --------------------------------------------------------------------------------