From 56f2638363b4a05751e72b86b43cd47600ca2deb Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Mon, 21 Mar 2022 14:28:52 +0800 Subject: [PATCH] adjust the project structure again Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- include/FramelessHelper/Core/Global | 1 + .../FramelessHelper/Core/framelesshelper_qt.h | 52 +++ .../Core/framelesshelper_win.h | 54 +++ .../Core/framelesshelper_windows.h | 188 +++++++++ .../Core/framelesshelpercore_global.h | 145 +++++++ .../Core/framelesswindowsmanager.h | 60 +++ include/FramelessHelper/Core/utils.h | 120 ++++++ include/FramelessHelper/Quick/Global | 1 + .../Quick/framelesshelper_quick.h | 42 ++ .../Quick/framelesshelperimageprovider.h | 46 ++ .../Quick/framelesshelperquick_global.h | 39 ++ .../Quick/framelessquickeventfilter.h | 55 +++ .../Quick/framelessquickhelper.h | 58 +++ .../Quick/framelessquickutils.h | 82 ++++ include/FramelessHelper/Widgets/Global | 1 + .../Widgets/framelesshelperwidgets_global.h | 39 ++ .../Widgets/framelessmainwindow.h | 69 +++ .../FramelessHelper/Widgets/framelesswidget.h | 74 ++++ .../Widgets/framelesswidgetshelper.h | 101 +++++ src/core/CMakeLists.txt | 1 - src/core/framelesshelper_qt.h | 29 +- src/core/framelesshelper_win.h | 31 +- src/core/framelesshelper_windows.h | 165 +------- src/core/framelesshelpercore.qrc | 2 + src/core/framelesshelpercore_global.h | 122 +----- src/core/framelesswindowsmanager.h | 37 +- src/core/images/LICENSE | 395 ++++++++++++++++++ src/core/images/LICENSE-CODE | 21 + src/core/images/README | 10 + src/core/utils.h | 97 +---- src/quick/CMakeLists.txt | 1 - src/quick/framelesshelper_quick.h | 19 +- src/quick/framelesshelperimageprovider.h | 23 +- src/quick/framelesshelperquick_global.h | 16 +- src/quick/framelessquickeventfilter.h | 32 +- src/quick/framelessquickhelper.h | 35 +- src/quick/framelessquickutils.h | 59 +-- src/widgets/CMakeLists.txt | 1 - src/widgets/framelesshelperwidgets_global.h | 16 +- src/widgets/framelessmainwindow.h | 46 +- src/widgets/framelesswidget.h | 51 +-- src/widgets/framelesswidgetshelper.h | 78 +--- 42 files changed, 1671 insertions(+), 843 deletions(-) create mode 100644 include/FramelessHelper/Core/Global create mode 100644 include/FramelessHelper/Core/framelesshelper_qt.h create mode 100644 include/FramelessHelper/Core/framelesshelper_win.h create mode 100644 include/FramelessHelper/Core/framelesshelper_windows.h create mode 100644 include/FramelessHelper/Core/framelesshelpercore_global.h create mode 100644 include/FramelessHelper/Core/framelesswindowsmanager.h create mode 100644 include/FramelessHelper/Core/utils.h create mode 100644 include/FramelessHelper/Quick/Global create mode 100644 include/FramelessHelper/Quick/framelesshelper_quick.h create mode 100644 include/FramelessHelper/Quick/framelesshelperimageprovider.h create mode 100644 include/FramelessHelper/Quick/framelesshelperquick_global.h create mode 100644 include/FramelessHelper/Quick/framelessquickeventfilter.h create mode 100644 include/FramelessHelper/Quick/framelessquickhelper.h create mode 100644 include/FramelessHelper/Quick/framelessquickutils.h create mode 100644 include/FramelessHelper/Widgets/Global create mode 100644 include/FramelessHelper/Widgets/framelesshelperwidgets_global.h create mode 100644 include/FramelessHelper/Widgets/framelessmainwindow.h create mode 100644 include/FramelessHelper/Widgets/framelesswidget.h create mode 100644 include/FramelessHelper/Widgets/framelesswidgetshelper.h create mode 100644 src/core/images/LICENSE create mode 100644 src/core/images/LICENSE-CODE create mode 100644 src/core/images/README diff --git a/include/FramelessHelper/Core/Global b/include/FramelessHelper/Core/Global new file mode 100644 index 0000000..aba4dba --- /dev/null +++ b/include/FramelessHelper/Core/Global @@ -0,0 +1 @@ +#include diff --git a/include/FramelessHelper/Core/framelesshelper_qt.h b/include/FramelessHelper/Core/framelesshelper_qt.h new file mode 100644 index 0000000..a38618a --- /dev/null +++ b/include/FramelessHelper/Core/framelesshelper_qt.h @@ -0,0 +1,52 @@ +/* + * MIT License + * + * Copyright (C) 2022 by wangwenx190 (Yuhang Zhao) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +#include "framelesshelpercore_global.h" +#include + +QT_BEGIN_NAMESPACE +class QWindow; +QT_END_NAMESPACE + +FRAMELESSHELPER_BEGIN_NAMESPACE + +class FRAMELESSHELPER_CORE_API FramelessHelperQt : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY_MOVE(FramelessHelperQt) + +public: + explicit FramelessHelperQt(QObject *parent = nullptr); + ~FramelessHelperQt() override; + + static void addWindow(QWindow *window); + static void removeWindow(QWindow *window); + +protected: + Q_NODISCARD bool eventFilter(QObject *object, QEvent *event) override; +}; + +FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Core/framelesshelper_win.h b/include/FramelessHelper/Core/framelesshelper_win.h new file mode 100644 index 0000000..8e4c228 --- /dev/null +++ b/include/FramelessHelper/Core/framelesshelper_win.h @@ -0,0 +1,54 @@ +/* + * MIT License + * + * Copyright (C) 2022 by wangwenx190 (Yuhang Zhao) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +#include "framelesshelpercore_global.h" +#include + +QT_BEGIN_NAMESPACE +class QWindow; +QT_END_NAMESPACE + +FRAMELESSHELPER_BEGIN_NAMESPACE + +class FRAMELESSHELPER_CORE_API FramelessHelperWin : public QAbstractNativeEventFilter +{ + Q_DISABLE_COPY_MOVE(FramelessHelperWin) + +public: + explicit FramelessHelperWin(); + ~FramelessHelperWin() override; + + static void addWindow(QWindow *window); + static void removeWindow(QWindow *window); + +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + Q_NODISCARD bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) override; +#else + Q_NODISCARD bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override; +#endif +}; + +FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Core/framelesshelper_windows.h b/include/FramelessHelper/Core/framelesshelper_windows.h new file mode 100644 index 0000000..5fb4ced --- /dev/null +++ b/include/FramelessHelper/Core/framelesshelper_windows.h @@ -0,0 +1,188 @@ +/* + * MIT License + * + * Copyright (C) 2022 by wangwenx190 (Yuhang Zhao) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +#ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +#endif + +#ifndef UNICODE +# define UNICODE +#endif + +#ifndef _UNICODE +# define _UNICODE +#endif + +#ifndef _CRT_NON_CONFORMING_SWPRINTFS +# define _CRT_NON_CONFORMING_SWPRINTFS +#endif + +#ifndef _CRT_SECURE_NO_WARNINGS +# define _CRT_SECURE_NO_WARNINGS +#endif + +#ifndef NOMINMAX +# define NOMINMAX +#endif + +#include + +#ifndef _WIN32_WINNT_WIN10 +# define _WIN32_WINNT_WIN10 0x0A00 +#endif + +#ifndef NTDDI_WIN10_CO +# define NTDDI_WIN10_CO 0x0A00000B +#endif + +#ifndef WINVER +# define WINVER _WIN32_WINNT_WIN10 +#endif + +#ifndef _WIN32_WINNT +# define _WIN32_WINNT _WIN32_WINNT_WIN10 +#endif + +#ifndef NTDDI_VERSION +# define NTDDI_VERSION NTDDI_WIN10_CO +#endif + +#include +#include +#include + +#ifndef WM_NCUAHDRAWCAPTION +# define WM_NCUAHDRAWCAPTION (0x00AE) +#endif + +#ifndef WM_NCUAHDRAWFRAME +# define WM_NCUAHDRAWFRAME (0x00AF) +#endif + +#ifndef WM_DWMCOMPOSITIONCHANGED +# define WM_DWMCOMPOSITIONCHANGED (0x031E) +#endif + +#ifndef WM_DWMCOLORIZATIONCOLORCHANGED +# define WM_DWMCOLORIZATIONCOLORCHANGED (0x0320) +#endif + +#ifndef WM_DPICHANGED +# define WM_DPICHANGED (0x02E0) +#endif + +#ifndef SM_CXPADDEDBORDER +# define SM_CXPADDEDBORDER (92) +#endif + +#ifndef SM_CYPADDEDBORDER +# define SM_CYPADDEDBORDER SM_CXPADDEDBORDER +#endif + +#ifndef ABM_GETAUTOHIDEBAREX +# define ABM_GETAUTOHIDEBAREX (0x0000000b) +#endif + +#ifndef GET_X_LPARAM +# define GET_X_LPARAM(lp) (static_cast(static_cast(LOWORD(lp)))) +#endif + +#ifndef GET_Y_LPARAM +# define GET_Y_LPARAM(lp) (static_cast(static_cast(HIWORD(lp)))) +#endif + +#ifndef IsMinimized +# define IsMinimized(hwnd) (IsIconic(hwnd) != FALSE) +#endif + +#ifndef IsMaximized +# define IsMaximized(hwnd) (IsZoomed(hwnd) != FALSE) +#endif + +#ifndef MMSYSERR_NOERROR +# define MMSYSERR_NOERROR (0) +#endif + +#ifndef TIMERR_NOERROR +# define TIMERR_NOERROR (0) +#endif + +using MMRESULT = UINT; + +using TIMECAPS = struct timecaps_tag +{ + UINT wPeriodMin; // minimum period supported + UINT wPeriodMax; // maximum period supported +}; +using PTIMECAPS = TIMECAPS *; +using NPTIMECAPS = TIMECAPS NEAR *; +using LPTIMECAPS = TIMECAPS FAR *; + +using MONITOR_DPI_TYPE = enum MONITOR_DPI_TYPE +{ + MDT_EFFECTIVE_DPI = 0, + MDT_ANGULAR_DPI = 1, + MDT_RAW_DPI = 2, + MDT_DEFAULT = MDT_EFFECTIVE_DPI +}; + +EXTERN_C MMRESULT WINAPI +timeGetDevCaps( + _Out_writes_bytes_(cbtc) LPTIMECAPS ptc, + _In_ UINT cbtc +); + +EXTERN_C MMRESULT WINAPI +timeBeginPeriod( + _In_ UINT uPeriod +); + +EXTERN_C MMRESULT WINAPI +timeEndPeriod( + _In_ UINT uPeriod +); + +EXTERN_C HRESULT WINAPI +GetDpiForMonitor( + _In_ HMONITOR hMonitor, + _In_ MONITOR_DPI_TYPE dpiType, + _Out_ UINT *dpiX, + _Out_ UINT *dpiY +); + +#include + +[[maybe_unused]] static constexpr const int kAutoHideTaskBarThickness = 2; // The thickness of an auto-hide taskbar in pixels. + +[[maybe_unused]] static const QString kDwmRegistryKey = QStringLiteral(R"(Software\Microsoft\Windows\DWM)"); +[[maybe_unused]] static const QString kPersonalizeRegistryKey = QStringLiteral(R"(Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)"); +[[maybe_unused]] static const QString kThemeSettingChangeEventName = QStringLiteral("ImmersiveColorSet"); +[[maybe_unused]] static const QString kDwmColorKeyName = QStringLiteral("ColorPrevalence"); + +[[maybe_unused]] static constexpr const DWORD _DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19; +[[maybe_unused]] static constexpr const DWORD _DWMWA_USE_IMMERSIVE_DARK_MODE = 20; +[[maybe_unused]] static constexpr const DWORD _DWMWA_WINDOW_CORNER_PREFERENCE = 33; +[[maybe_unused]] static constexpr const DWORD _DWMWA_VISIBLE_FRAME_BORDER_THICKNESS = 37; diff --git a/include/FramelessHelper/Core/framelesshelpercore_global.h b/include/FramelessHelper/Core/framelesshelpercore_global.h new file mode 100644 index 0000000..88b6ba7 --- /dev/null +++ b/include/FramelessHelper/Core/framelesshelpercore_global.h @@ -0,0 +1,145 @@ +/* + * MIT License + * + * Copyright (C) 2022 by wangwenx190 (Yuhang Zhao) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +#include +#include +#include +#include + +#ifndef FRAMELESSHELPER_CORE_API +# ifdef FRAMELESSHELPER_CORE_STATIC +# define FRAMELESSHELPER_CORE_API +# else +# ifdef FRAMELESSHELPER_CORE_LIBRARY +# define FRAMELESSHELPER_CORE_API Q_DECL_EXPORT +# else +# define FRAMELESSHELPER_CORE_API Q_DECL_IMPORT +# endif +# endif +#endif + +#if defined(Q_OS_WIN) && !defined(Q_OS_WINDOWS) +# define Q_OS_WINDOWS +#endif + +#ifndef Q_DISABLE_COPY_MOVE +# define Q_DISABLE_COPY_MOVE(Class) \ + Q_DISABLE_COPY(Class) \ + Class(Class &&) = delete; \ + Class &operator=(Class &&) = delete; +#endif + +#if (QT_VERSION < QT_VERSION_CHECK(5, 7, 0)) +# define qAsConst(i) std::as_const(i) +#endif + +#if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0)) +# define QStringView const QString & +#else +# include +#endif + +#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) +# define qExchange(a, b) std::exchange(a, b) +# define Q_NAMESPACE_EXPORT(ns) Q_NAMESPACE +#endif + +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) +# define Q_NODISCARD [[nodiscard]] +#else +# define Q_NODISCARD +#endif + +#ifndef FRAMELESSHELPER_NAMESPACE +# define FRAMELESSHELPER_NAMESPACE __flh_ns +#endif + +#ifndef FRAMELESSHELPER_BEGIN_NAMESPACE +# define FRAMELESSHELPER_BEGIN_NAMESPACE namespace FRAMELESSHELPER_NAMESPACE { +#endif + +#ifndef FRAMELESSHELPER_END_NAMESPACE +# define FRAMELESSHELPER_END_NAMESPACE } +#endif + +#ifndef FRAMELESSHELPER_USE_NAMESPACE +# define FRAMELESSHELPER_USE_NAMESPACE using namespace FRAMELESSHELPER_NAMESPACE; +#endif + +#ifndef FRAMELESSHELPER_PREPEND_NAMESPACE +# define FRAMELESSHELPER_PREPEND_NAMESPACE(X) ::FRAMELESSHELPER_NAMESPACE::X +#endif + +FRAMELESSHELPER_BEGIN_NAMESPACE + +Q_NAMESPACE_EXPORT(FRAMELESSHELPER_CORE_API) + +[[maybe_unused]] static constexpr const int kDefaultResizeBorderThickness = 8; +[[maybe_unused]] static constexpr const int kDefaultCaptionHeight = 23; +[[maybe_unused]] static constexpr const int kDefaultTitleBarHeight = 30; +[[maybe_unused]] static constexpr const int kDefaultWindowFrameBorderThickness = 1; + +[[maybe_unused]] static const QColor kDefaultSystemLightColor = QStringLiteral("#f0f0f0"); +[[maybe_unused]] static const QColor kDefaultSystemDarkColor = QStringLiteral("#202020"); + +[[maybe_unused]] static constexpr const QSize kDefaultSystemButtonSize = {int(qRound(qreal(kDefaultTitleBarHeight) * 1.5)), kDefaultTitleBarHeight}; +[[maybe_unused]] static constexpr const QSize kDefaultSystemButtonIconSize = {16, 16}; + +[[maybe_unused]] static constexpr const char kInternalOptionsFlag[] = "FRAMELESSHELPER_INTERNAL_OPTIONS"; +[[maybe_unused]] static constexpr const char kUsePureQtImplFlag[] = "FRAMELESSHELPER_PURE_QT_IMPLEMENTATION"; +[[maybe_unused]] static constexpr const char kForceHideFrameBorderFlag[] = "FRAMELESSHELPER_FORCE_HIDE_FRAME_BORDER"; +[[maybe_unused]] static constexpr const char kForceShowFrameBorderFlag[] = "FRAMELESSHELPER_FORCE_SHOW_FRAME_BORDER"; + +[[maybe_unused]] static const QString kConfigFileName = QStringLiteral(".framelesshelper.ini"); +[[maybe_unused]] static const QString kUsePureQtImplKeyPath = QStringLiteral("Options/UsePureQtImplementation"); +[[maybe_unused]] static const QString kForceHideFrameBorderKeyPath = QStringLiteral("Options/ForceHideFrameBorder"); +[[maybe_unused]] static const QString kForceShowFrameBorderKeyPath = QStringLiteral("Options/ForceShowFrameBorder"); + +enum class Option : int +{ + Default = 0x00000000, // Default placeholder, have no effect. + ForceHideWindowFrameBorder = 0x00000001, // Windows only, force hide the window frame border even on Windows 10 and onwards. + ForceShowWindowFrameBorder = 0x00000002, // Windows only, force show the window frame border even on Windows 7 (~ 8.1). + DontDrawTopWindowFrameBorder = 0x00000004, // Windows only, don't draw the top window frame border even if the window frame border is visible. + EnableRoundedWindowCorners = 0x00000008, // Not implemented yet. + TransparentWindowBackground = 0x00000010, // Not implemented yet. + MaximizeButtonDocking = 0x00000020, // Windows only, enable the window docking feature introduced in Windows 11. + UseStandardWindowLayout = 0x00000040, // The standard window layout is a titlebar always on top and fill the window width. + BeCompatibleWithQtFramelessWindowHint = 0x00000080, // Windows only, make the code compatible with Qt::FramelessWindowHint. Don't use this option unless you really need that flag. + DontTouchQtInternals = 0x00000100, // Windows only, don't modify Qt's internal data. + DontTouchWindowFrameBorderColor = 0x00000200, // Windows only, don't change the window frame border color. + DontInstallSystemMenuHook = 0x00000400, // Windows only, don't install the system menu hook. + DisableSystemMenu = 0x00000800, // Windows only, don't open the system menu when right clicks the titlebar. + NoDoubleClickMaximizeToggle = 0x00001000, // Don't toggle the maximize state when double clicks the titlebar. + DisableResizing = 0x00002000, // Disable resizing of the window. + DisableDragging = 0x00004000, // Disable dragging through the titlebar of the window. + DontTouchCursorShape = 0x00008000 // Don't change the cursor shape while the mouse is hovering above the window. +}; +Q_DECLARE_FLAGS(Options, Option) +Q_FLAG_NS(Options) +Q_DECLARE_OPERATORS_FOR_FLAGS(Options) + +FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Core/framelesswindowsmanager.h b/include/FramelessHelper/Core/framelesswindowsmanager.h new file mode 100644 index 0000000..b2ab443 --- /dev/null +++ b/include/FramelessHelper/Core/framelesswindowsmanager.h @@ -0,0 +1,60 @@ +/* + * MIT License + * + * Copyright (C) 2022 by wangwenx190 (Yuhang Zhao) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +#include "framelesshelpercore_global.h" +#include + +QT_BEGIN_NAMESPACE +class QWindow; +QT_END_NAMESPACE + +FRAMELESSHELPER_BEGIN_NAMESPACE + +class FramelessWindowsManagerPrivate; + +class FRAMELESSHELPER_CORE_API FramelessWindowsManager : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(FramelessWindowsManager) + Q_DISABLE_COPY_MOVE(FramelessWindowsManager) + +public: + explicit FramelessWindowsManager(QObject *parent = nullptr); + ~FramelessWindowsManager() override; + + Q_NODISCARD static FramelessWindowsManager *instance(); + + void addWindow(QWindow *window); + void removeWindow(QWindow *window); + +Q_SIGNALS: + void systemThemeChanged(); + +private: + QScopedPointer d_ptr; +}; + +FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Core/utils.h b/include/FramelessHelper/Core/utils.h new file mode 100644 index 0000000..5470396 --- /dev/null +++ b/include/FramelessHelper/Core/utils.h @@ -0,0 +1,120 @@ +/* + * MIT License + * + * Copyright (C) 2022 by wangwenx190 (Yuhang Zhao) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +#include "framelesshelpercore_global.h" +#include + +FRAMELESSHELPER_BEGIN_NAMESPACE + +enum class SystemTheme : int +{ + Light = 0, + Dark = 1, + HighContrastLight = 2, + HighContrastDark = 3 +}; +Q_ENUM_NS(SystemTheme) + +enum class SystemButtonType : int +{ + WindowIcon = 0, + Minimize = 1, + Maximize = 2, + Restore = 3, + Close = 4 +}; +Q_ENUM_NS(SystemButtonType) + +enum class ResourceType : int +{ + Image = 0, + Pixmap = 1, + Icon = 2 +}; +Q_ENUM_NS(ResourceType) + +#ifdef Q_OS_WINDOWS +enum class DwmColorizationArea : int +{ + None = 0, + StartMenu_TaskBar_ActionCenter = 1, + TitleBar_WindowBorder = 2, + All = 3 +}; +Q_ENUM_NS(DwmColorizationArea) +#endif + +namespace Utils +{ + +[[nodiscard]] FRAMELESSHELPER_CORE_API Qt::CursorShape calculateCursorShape(const QWindow *window, const QPoint &pos); +[[nodiscard]] FRAMELESSHELPER_CORE_API Qt::Edges calculateWindowEdges(const QWindow *window, const QPoint &pos); +FRAMELESSHELPER_CORE_API void startSystemMove(QWindow *window); +FRAMELESSHELPER_CORE_API void startSystemResize(QWindow *window, const Qt::Edges edges); +[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowFixedSize(const QWindow *window); +[[nodiscard]] FRAMELESSHELPER_CORE_API QVariant getSystemButtonIconResource + (const SystemButtonType button, const SystemTheme theme, const ResourceType type); +FRAMELESSHELPER_CORE_API void sendMouseReleaseEvent(); + +#ifdef Q_OS_WINDOWS +[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin8OrGreater(); +[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin8Point1OrGreater(); +[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin10OrGreater(); +[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin101809OrGreater(); +[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin11OrGreater(); +[[nodiscard]] FRAMELESSHELPER_CORE_API bool isDwmCompositionEnabled(); +FRAMELESSHELPER_CORE_API void triggerFrameChange(const WId winId); +FRAMELESSHELPER_CORE_API void updateWindowFrameMargins(const WId winId, const bool reset); +FRAMELESSHELPER_CORE_API void updateInternalWindowFrameMargins(QWindow *window, const bool enable); +[[nodiscard]] FRAMELESSHELPER_CORE_API QString getSystemErrorMessage(const QString &function); +[[nodiscard]] FRAMELESSHELPER_CORE_API bool isFullScreen(const WId winId); +[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowNoState(const WId winId); +FRAMELESSHELPER_CORE_API void syncWmPaintWithDwm(); +FRAMELESSHELPER_CORE_API void showSystemMenu(const WId winId, const QPoint &pos); +[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getDwmColorizationColor(); +[[nodiscard]] FRAMELESSHELPER_CORE_API bool shouldAppsUseDarkMode(); +[[nodiscard]] FRAMELESSHELPER_CORE_API DwmColorizationArea getDwmColorizationArea(); +[[nodiscard]] FRAMELESSHELPER_CORE_API bool isHighContrastModeEnabled(); +[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getPrimaryScreenDpi(const bool horizontal); +[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getWindowDpi(const WId winId, const bool horizontal); +[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getResizeBorderThickness(const WId winId, const bool horizontal, const bool scaled); +[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getCaptionHeight(const WId winId, const bool scaled); +[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getTitleBarHeight(const WId winId, const bool scaled); +[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getFrameBorderThickness(const WId winId, const bool scaled); +[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getFrameBorderColor(const bool active); +FRAMELESSHELPER_CORE_API void updateWindowFrameBorderColor(const WId winId, const bool dark); +FRAMELESSHELPER_CORE_API void fixupQtInternals(const WId winId); +[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowFrameBorderVisible(); +[[nodiscard]] FRAMELESSHELPER_CORE_API bool isTitleBarColorized(); +[[nodiscard]] FRAMELESSHELPER_CORE_API bool isFrameBorderColorized(); +FRAMELESSHELPER_CORE_API void installSystemMenuHook(const WId winId); +FRAMELESSHELPER_CORE_API void uninstallSystemMenuHook(const WId winId); +FRAMELESSHELPER_CORE_API void tryToBeCompatibleWithQtFramelessWindowHint(QWindow *window, const bool enable); +#endif // Q_OS_WINDOWS + +} // namespace Utils + +FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Quick/Global b/include/FramelessHelper/Quick/Global new file mode 100644 index 0000000..c2dae33 --- /dev/null +++ b/include/FramelessHelper/Quick/Global @@ -0,0 +1 @@ +#include diff --git a/include/FramelessHelper/Quick/framelesshelper_quick.h b/include/FramelessHelper/Quick/framelesshelper_quick.h new file mode 100644 index 0000000..9b7bf2a --- /dev/null +++ b/include/FramelessHelper/Quick/framelesshelper_quick.h @@ -0,0 +1,42 @@ +/* + * MIT License + * + * Copyright (C) 2022 by wangwenx190 (Yuhang Zhao) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +#include "framelesshelperquick_global.h" + +QT_BEGIN_NAMESPACE +class QQmlEngine; +QT_END_NAMESPACE + +FRAMELESSHELPER_BEGIN_NAMESPACE + +namespace FramelessHelper::Quick +{ + +FRAMELESSHELPER_QUICK_API void registerTypes(QQmlEngine *engine); + +} + +FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Quick/framelesshelperimageprovider.h b/include/FramelessHelper/Quick/framelesshelperimageprovider.h new file mode 100644 index 0000000..f9a044a --- /dev/null +++ b/include/FramelessHelper/Quick/framelesshelperimageprovider.h @@ -0,0 +1,46 @@ +/* + * MIT License + * + * Copyright (C) 2022 by wangwenx190 (Yuhang Zhao) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +#include "framelesshelperquick_global.h" +#include + +FRAMELESSHELPER_BEGIN_NAMESPACE + +class FRAMELESSHELPER_QUICK_API FramelessHelperImageProvider : public QQuickImageProvider +{ +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + Q_OBJECT +#endif + Q_DISABLE_COPY_MOVE(FramelessHelperImageProvider) + +public: + explicit FramelessHelperImageProvider(); + ~FramelessHelperImageProvider() override; + + Q_NODISCARD QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) override; +}; + +FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Quick/framelesshelperquick_global.h b/include/FramelessHelper/Quick/framelesshelperquick_global.h new file mode 100644 index 0000000..8f7c103 --- /dev/null +++ b/include/FramelessHelper/Quick/framelesshelperquick_global.h @@ -0,0 +1,39 @@ +/* + * MIT License + * + * Copyright (C) 2022 by wangwenx190 (Yuhang Zhao) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +#include + +#ifndef FRAMELESSHELPER_QUICK_API +# ifdef FRAMELESSHELPER_QUICK_STATIC +# define FRAMELESSHELPER_QUICK_API +# else +# ifdef FRAMELESSHELPER_QUICK_LIBRARY +# define FRAMELESSHELPER_QUICK_API Q_DECL_EXPORT +# else +# define FRAMELESSHELPER_QUICK_API Q_DECL_IMPORT +# endif +# endif +#endif diff --git a/include/FramelessHelper/Quick/framelessquickeventfilter.h b/include/FramelessHelper/Quick/framelessquickeventfilter.h new file mode 100644 index 0000000..cffbeeb --- /dev/null +++ b/include/FramelessHelper/Quick/framelessquickeventfilter.h @@ -0,0 +1,55 @@ +/* + * MIT License + * + * Copyright (C) 2022 by wangwenx190 (Yuhang Zhao) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +#include "framelesshelperquick_global.h" +#include + +QT_BEGIN_NAMESPACE +class QQuickWindow; +class QQuickItem; +QT_END_NAMESPACE + +FRAMELESSHELPER_BEGIN_NAMESPACE + +class FRAMELESSHELPER_QUICK_API FramelessQuickEventFilter : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY_MOVE(FramelessQuickEventFilter) + +public: + explicit FramelessQuickEventFilter(QObject *parent = nullptr); + ~FramelessQuickEventFilter() override; + + Q_INVOKABLE static void addWindow(QQuickWindow *window); + Q_INVOKABLE static void removeWindow(QQuickWindow *window); + Q_INVOKABLE static void setTitleBarItem(QQuickWindow *window, QQuickItem *item); + Q_INVOKABLE static void setHitTestVisible(QQuickWindow *window, QQuickItem *item, const bool visible); + +protected: + Q_NODISCARD bool eventFilter(QObject *object, QEvent *event) override; +}; + +FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Quick/framelessquickhelper.h b/include/FramelessHelper/Quick/framelessquickhelper.h new file mode 100644 index 0000000..aa98880 --- /dev/null +++ b/include/FramelessHelper/Quick/framelessquickhelper.h @@ -0,0 +1,58 @@ +/* + * MIT License + * + * Copyright (C) 2022 by wangwenx190 (Yuhang Zhao) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +#include "framelesshelperquick_global.h" +#include + +QT_BEGIN_NAMESPACE +class QQuickWindow; +class QQuickItem; +QT_END_NAMESPACE + +FRAMELESSHELPER_BEGIN_NAMESPACE + +class FRAMELESSHELPER_QUICK_API FramelessQuickHelper : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY_MOVE(FramelessQuickHelper) +#ifdef QML_NAMED_ELEMENT + QML_NAMED_ELEMENT(FramelessHelper) +#endif +#ifdef QML_SINGLETON + QML_SINGLETON +#endif + +public: + explicit FramelessQuickHelper(QObject *parent = nullptr); + ~FramelessQuickHelper() override; + + Q_INVOKABLE static void addWindow(QQuickWindow *window); + Q_INVOKABLE static void removeWindow(QQuickWindow *window); + Q_INVOKABLE static void setTitleBarItem(QQuickWindow *window, QQuickItem *item); + Q_INVOKABLE static void setHitTestVisible(QQuickWindow *window, QQuickItem *item, const bool visible); +}; + +FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Quick/framelessquickutils.h b/include/FramelessHelper/Quick/framelessquickutils.h new file mode 100644 index 0000000..e5ff7ed --- /dev/null +++ b/include/FramelessHelper/Quick/framelessquickutils.h @@ -0,0 +1,82 @@ +/* + * MIT License + * + * Copyright (C) 2022 by wangwenx190 (Yuhang Zhao) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +#include "framelesshelperquick_global.h" +#include +#include + +QT_BEGIN_NAMESPACE +class QQuickWindow; +QT_END_NAMESPACE + +FRAMELESSHELPER_BEGIN_NAMESPACE + +class FRAMELESSHELPER_QUICK_API FramelessQuickUtils : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY_MOVE(FramelessQuickUtils) +#ifdef QML_NAMED_ELEMENT + QML_NAMED_ELEMENT(FramelessUtils) +#endif +#ifdef QML_SINGLETON + QML_SINGLETON +#endif + Q_PROPERTY(qreal titleBarHeight READ titleBarHeight CONSTANT FINAL) + Q_PROPERTY(bool frameBorderVisible READ frameBorderVisible CONSTANT FINAL) + Q_PROPERTY(qreal frameBorderThickness READ frameBorderThickness CONSTANT FINAL) + Q_PROPERTY(QColor frameBorderActiveColor READ frameBorderActiveColor NOTIFY frameBorderActiveColorChanged FINAL) + Q_PROPERTY(QColor frameBorderInactiveColor READ frameBorderInactiveColor NOTIFY frameBorderInactiveColorChanged FINAL) + Q_PROPERTY(bool darkModeEnabled READ darkModeEnabled NOTIFY darkModeEnabledChanged FINAL) + Q_PROPERTY(QColor systemAccentColor READ systemAccentColor NOTIFY systemAccentColorChanged FINAL) + Q_PROPERTY(bool titleBarColorVisible READ titleBarColorVisible NOTIFY titleBarColorVisibleChanged FINAL) + +public: + explicit FramelessQuickUtils(QObject *parent = nullptr); + ~FramelessQuickUtils() override; + + Q_NODISCARD static qreal titleBarHeight(); + Q_NODISCARD static bool frameBorderVisible(); + Q_NODISCARD static qreal frameBorderThickness(); + Q_NODISCARD static QColor frameBorderActiveColor(); + Q_NODISCARD static QColor frameBorderInactiveColor(); + Q_NODISCARD static bool darkModeEnabled(); + Q_NODISCARD static QColor systemAccentColor(); + Q_NODISCARD static bool titleBarColorVisible(); + + Q_INVOKABLE static void showMinimized2(QQuickWindow *window); + Q_INVOKABLE static void showSystemMenu(QQuickWindow *window, const QPoint &pos); + Q_INVOKABLE static void startSystemMove2(QQuickWindow *window); + Q_INVOKABLE static void startSystemResize2(QQuickWindow *window, const Qt::Edges edges); + +Q_SIGNALS: + void frameBorderActiveColorChanged(); + void frameBorderInactiveColorChanged(); + void darkModeEnabledChanged(); + void systemAccentColorChanged(); + void titleBarColorVisibleChanged(); +}; + +FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Widgets/Global b/include/FramelessHelper/Widgets/Global new file mode 100644 index 0000000..c5f0177 --- /dev/null +++ b/include/FramelessHelper/Widgets/Global @@ -0,0 +1 @@ +#include diff --git a/include/FramelessHelper/Widgets/framelesshelperwidgets_global.h b/include/FramelessHelper/Widgets/framelesshelperwidgets_global.h new file mode 100644 index 0000000..51a4d65 --- /dev/null +++ b/include/FramelessHelper/Widgets/framelesshelperwidgets_global.h @@ -0,0 +1,39 @@ +/* + * MIT License + * + * Copyright (C) 2022 by wangwenx190 (Yuhang Zhao) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +#include + +#ifndef FRAMELESSHELPER_WIDGETS_API +# ifdef FRAMELESSHELPER_WIDGETS_STATIC +# define FRAMELESSHELPER_WIDGETS_API +# else +# ifdef FRAMELESSHELPER_WIDGETS_LIBRARY +# define FRAMELESSHELPER_WIDGETS_API Q_DECL_EXPORT +# else +# define FRAMELESSHELPER_WIDGETS_API Q_DECL_IMPORT +# endif +# endif +#endif diff --git a/include/FramelessHelper/Widgets/framelessmainwindow.h b/include/FramelessHelper/Widgets/framelessmainwindow.h new file mode 100644 index 0000000..4728f9a --- /dev/null +++ b/include/FramelessHelper/Widgets/framelessmainwindow.h @@ -0,0 +1,69 @@ +/* + * MIT License + * + * Copyright (C) 2022 by wangwenx190 (Yuhang Zhao) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +#include "framelesshelperwidgets_global.h" +#include + +FRAMELESSHELPER_BEGIN_NAMESPACE + +class FramelessWidgetsHelper; + +class FRAMELESSHELPER_WIDGETS_API FramelessMainWindow : public QMainWindow +{ + Q_OBJECT + Q_DISABLE_COPY_MOVE(FramelessMainWindow) + Q_PROPERTY(QWidget* titleBarWidget READ titleBarWidget WRITE setTitleBarWidget NOTIFY titleBarWidgetChanged FINAL) + +public: + explicit FramelessMainWindow(QWidget *parent = nullptr, const Qt::WindowFlags flags = {}, const Options options = {}); + ~FramelessMainWindow() override; + + Q_NODISCARD Q_INVOKABLE bool isNormal() const; + Q_NODISCARD Q_INVOKABLE bool isZoomed() const; + + void setTitleBarWidget(QWidget *widget); + Q_NODISCARD QWidget *titleBarWidget() const; + + Q_INVOKABLE void setHitTestVisible(QWidget *widget, const bool visible); + + Q_INVOKABLE void toggleMaximized(); + +protected: + void changeEvent(QEvent *event) override; + void paintEvent(QPaintEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + void mouseDoubleClickEvent(QMouseEvent *event) override; + +Q_SIGNALS: + void titleBarWidgetChanged(); + void systemThemeChanged(); + +private: + QScopedPointer m_helper; +}; + +FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Widgets/framelesswidget.h b/include/FramelessHelper/Widgets/framelesswidget.h new file mode 100644 index 0000000..00b10ce --- /dev/null +++ b/include/FramelessHelper/Widgets/framelesswidget.h @@ -0,0 +1,74 @@ +/* + * MIT License + * + * Copyright (C) 2022 by wangwenx190 (Yuhang Zhao) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +#include "framelesshelperwidgets_global.h" +#include + +FRAMELESSHELPER_BEGIN_NAMESPACE + +class FramelessWidgetsHelper; + +class FRAMELESSHELPER_WIDGETS_API FramelessWidget : public QWidget +{ + Q_OBJECT + Q_DISABLE_COPY_MOVE(FramelessWidget) + Q_PROPERTY(QWidget* titleBarWidget READ titleBarWidget WRITE setTitleBarWidget NOTIFY titleBarWidgetChanged FINAL) + Q_PROPERTY(QWidget* contentWidget READ contentWidget WRITE setContentWidget NOTIFY contentWidgetChanged FINAL) + +public: + explicit FramelessWidget(QWidget *parent = nullptr, const Options options = {}); + ~FramelessWidget() override; + + Q_NODISCARD Q_INVOKABLE bool isNormal() const; + Q_NODISCARD Q_INVOKABLE bool isZoomed() const; + + void setTitleBarWidget(QWidget *widget); + Q_NODISCARD QWidget *titleBarWidget() const; + + void setContentWidget(QWidget *widget); + Q_NODISCARD QWidget *contentWidget() const; + + Q_INVOKABLE void setHitTestVisible(QWidget *widget, const bool visible); + + Q_INVOKABLE void toggleMaximized(); + +protected: + void changeEvent(QEvent *event) override; + void paintEvent(QPaintEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + void mouseDoubleClickEvent(QMouseEvent *event) override; + +Q_SIGNALS: + void titleBarWidgetChanged(); + void contentWidgetChanged(); + void systemThemeChanged(); + +private: + QScopedPointer m_helper; +}; + +FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Widgets/framelesswidgetshelper.h b/include/FramelessHelper/Widgets/framelesswidgetshelper.h new file mode 100644 index 0000000..8e8a927 --- /dev/null +++ b/include/FramelessHelper/Widgets/framelesswidgetshelper.h @@ -0,0 +1,101 @@ +/* + * MIT License + * + * Copyright (C) 2022 by wangwenx190 (Yuhang Zhao) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +#include "framelesshelperwidgets_global.h" +#include +#include + +QT_BEGIN_NAMESPACE +class QLabel; +class QPushButton; +class QVBoxLayout; +class QShowEvent; +class QPaintEvent; +class QMouseEvent; +QT_END_NAMESPACE + +FRAMELESSHELPER_BEGIN_NAMESPACE + +class FRAMELESSHELPER_WIDGETS_API FramelessWidgetsHelper : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY_MOVE(FramelessWidgetsHelper) + +public: + explicit FramelessWidgetsHelper(QWidget *q, const Options options = {}); + ~FramelessWidgetsHelper() override; + + Q_NODISCARD Q_INVOKABLE bool isNormal() const; + Q_NODISCARD Q_INVOKABLE bool isZoomed() const; + + Q_INVOKABLE void setTitleBarWidget(QWidget *widget); + Q_NODISCARD Q_INVOKABLE QWidget *titleBarWidget() const; + + Q_INVOKABLE void setContentWidget(QWidget *widget); + Q_NODISCARD Q_INVOKABLE QWidget *contentWidget() const; + + Q_INVOKABLE void setHitTestVisible(QWidget *widget, const bool visible); + + Q_INVOKABLE void toggleMaximized(); + + Q_INVOKABLE void changeEventHandler(QEvent *event); + Q_INVOKABLE void paintEventHandler(QPaintEvent *event); + Q_INVOKABLE void mousePressEventHandler(QMouseEvent *event); + Q_INVOKABLE void mouseReleaseEventHandler(QMouseEvent *event); + Q_INVOKABLE void mouseDoubleClickEventHandler(QMouseEvent *event); + +private: + void initialize(); + void createSystemTitleBar(); + void createUserContentContainer(); + void setupInitialUi(); + Q_NODISCARD bool isInTitleBarDraggableArea(const QPoint &pos) const; + Q_NODISCARD bool shouldDrawFrameBorder() const; + Q_NODISCARD bool shouldIgnoreMouseEvents(const QPoint &pos) const; + +private Q_SLOTS: + void updateContentsMargins(); + void updateSystemTitleBarStyleSheet(); + void updateSystemButtonsIcon(); + +private: + QWidget *q = nullptr; + bool m_initialized = false; + Options m_options = {}; + QWidget *m_systemTitleBarWidget = nullptr; + QLabel *m_systemWindowTitleLabel = nullptr; + QPushButton *m_systemMinimizeButton = nullptr; + QPushButton *m_systemMaximizeButton = nullptr; + QPushButton *m_systemCloseButton = nullptr; + QWidget *m_userTitleBarWidget = nullptr; + QWidget *m_userContentWidget = nullptr; + QVBoxLayout *m_mainLayout = nullptr; + QWidgetList m_hitTestVisibleWidgets = {}; + QWidget *m_userContentContainerWidget = nullptr; + QVBoxLayout *m_userContentContainerLayout = nullptr; +}; + +FRAMELESSHELPER_END_NAMESPACE diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 2522830..73079e6 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -79,7 +79,6 @@ target_link_libraries(${SUB_PROJ_NAME} PRIVATE ) target_include_directories(${SUB_PROJ_NAME} PUBLIC - "$" "$/../../include/FramelessHelper/Core" "$/../../include" ) diff --git a/src/core/framelesshelper_qt.h b/src/core/framelesshelper_qt.h index a38618a..6c34347 100644 --- a/src/core/framelesshelper_qt.h +++ b/src/core/framelesshelper_qt.h @@ -22,31 +22,4 @@ * SOFTWARE. */ -#pragma once - -#include "framelesshelpercore_global.h" -#include - -QT_BEGIN_NAMESPACE -class QWindow; -QT_END_NAMESPACE - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FRAMELESSHELPER_CORE_API FramelessHelperQt : public QObject -{ - Q_OBJECT - Q_DISABLE_COPY_MOVE(FramelessHelperQt) - -public: - explicit FramelessHelperQt(QObject *parent = nullptr); - ~FramelessHelperQt() override; - - static void addWindow(QWindow *window); - static void removeWindow(QWindow *window); - -protected: - Q_NODISCARD bool eventFilter(QObject *object, QEvent *event) override; -}; - -FRAMELESSHELPER_END_NAMESPACE +#include "../../include/FramelessHelper/Core/framelesshelper_qt.h" diff --git a/src/core/framelesshelper_win.h b/src/core/framelesshelper_win.h index 8e4c228..3dc9078 100644 --- a/src/core/framelesshelper_win.h +++ b/src/core/framelesshelper_win.h @@ -22,33 +22,4 @@ * SOFTWARE. */ -#pragma once - -#include "framelesshelpercore_global.h" -#include - -QT_BEGIN_NAMESPACE -class QWindow; -QT_END_NAMESPACE - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FRAMELESSHELPER_CORE_API FramelessHelperWin : public QAbstractNativeEventFilter -{ - Q_DISABLE_COPY_MOVE(FramelessHelperWin) - -public: - explicit FramelessHelperWin(); - ~FramelessHelperWin() override; - - static void addWindow(QWindow *window); - static void removeWindow(QWindow *window); - -#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - Q_NODISCARD bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) override; -#else - Q_NODISCARD bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override; -#endif -}; - -FRAMELESSHELPER_END_NAMESPACE +#include "../../include/FramelessHelper/Core/framelesshelper_win.h" diff --git a/src/core/framelesshelper_windows.h b/src/core/framelesshelper_windows.h index 5fb4ced..ce71f6c 100644 --- a/src/core/framelesshelper_windows.h +++ b/src/core/framelesshelper_windows.h @@ -22,167 +22,4 @@ * SOFTWARE. */ -#pragma once - -#ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -#endif - -#ifndef UNICODE -# define UNICODE -#endif - -#ifndef _UNICODE -# define _UNICODE -#endif - -#ifndef _CRT_NON_CONFORMING_SWPRINTFS -# define _CRT_NON_CONFORMING_SWPRINTFS -#endif - -#ifndef _CRT_SECURE_NO_WARNINGS -# define _CRT_SECURE_NO_WARNINGS -#endif - -#ifndef NOMINMAX -# define NOMINMAX -#endif - -#include - -#ifndef _WIN32_WINNT_WIN10 -# define _WIN32_WINNT_WIN10 0x0A00 -#endif - -#ifndef NTDDI_WIN10_CO -# define NTDDI_WIN10_CO 0x0A00000B -#endif - -#ifndef WINVER -# define WINVER _WIN32_WINNT_WIN10 -#endif - -#ifndef _WIN32_WINNT -# define _WIN32_WINNT _WIN32_WINNT_WIN10 -#endif - -#ifndef NTDDI_VERSION -# define NTDDI_VERSION NTDDI_WIN10_CO -#endif - -#include -#include -#include - -#ifndef WM_NCUAHDRAWCAPTION -# define WM_NCUAHDRAWCAPTION (0x00AE) -#endif - -#ifndef WM_NCUAHDRAWFRAME -# define WM_NCUAHDRAWFRAME (0x00AF) -#endif - -#ifndef WM_DWMCOMPOSITIONCHANGED -# define WM_DWMCOMPOSITIONCHANGED (0x031E) -#endif - -#ifndef WM_DWMCOLORIZATIONCOLORCHANGED -# define WM_DWMCOLORIZATIONCOLORCHANGED (0x0320) -#endif - -#ifndef WM_DPICHANGED -# define WM_DPICHANGED (0x02E0) -#endif - -#ifndef SM_CXPADDEDBORDER -# define SM_CXPADDEDBORDER (92) -#endif - -#ifndef SM_CYPADDEDBORDER -# define SM_CYPADDEDBORDER SM_CXPADDEDBORDER -#endif - -#ifndef ABM_GETAUTOHIDEBAREX -# define ABM_GETAUTOHIDEBAREX (0x0000000b) -#endif - -#ifndef GET_X_LPARAM -# define GET_X_LPARAM(lp) (static_cast(static_cast(LOWORD(lp)))) -#endif - -#ifndef GET_Y_LPARAM -# define GET_Y_LPARAM(lp) (static_cast(static_cast(HIWORD(lp)))) -#endif - -#ifndef IsMinimized -# define IsMinimized(hwnd) (IsIconic(hwnd) != FALSE) -#endif - -#ifndef IsMaximized -# define IsMaximized(hwnd) (IsZoomed(hwnd) != FALSE) -#endif - -#ifndef MMSYSERR_NOERROR -# define MMSYSERR_NOERROR (0) -#endif - -#ifndef TIMERR_NOERROR -# define TIMERR_NOERROR (0) -#endif - -using MMRESULT = UINT; - -using TIMECAPS = struct timecaps_tag -{ - UINT wPeriodMin; // minimum period supported - UINT wPeriodMax; // maximum period supported -}; -using PTIMECAPS = TIMECAPS *; -using NPTIMECAPS = TIMECAPS NEAR *; -using LPTIMECAPS = TIMECAPS FAR *; - -using MONITOR_DPI_TYPE = enum MONITOR_DPI_TYPE -{ - MDT_EFFECTIVE_DPI = 0, - MDT_ANGULAR_DPI = 1, - MDT_RAW_DPI = 2, - MDT_DEFAULT = MDT_EFFECTIVE_DPI -}; - -EXTERN_C MMRESULT WINAPI -timeGetDevCaps( - _Out_writes_bytes_(cbtc) LPTIMECAPS ptc, - _In_ UINT cbtc -); - -EXTERN_C MMRESULT WINAPI -timeBeginPeriod( - _In_ UINT uPeriod -); - -EXTERN_C MMRESULT WINAPI -timeEndPeriod( - _In_ UINT uPeriod -); - -EXTERN_C HRESULT WINAPI -GetDpiForMonitor( - _In_ HMONITOR hMonitor, - _In_ MONITOR_DPI_TYPE dpiType, - _Out_ UINT *dpiX, - _Out_ UINT *dpiY -); - -#include - -[[maybe_unused]] static constexpr const int kAutoHideTaskBarThickness = 2; // The thickness of an auto-hide taskbar in pixels. - -[[maybe_unused]] static const QString kDwmRegistryKey = QStringLiteral(R"(Software\Microsoft\Windows\DWM)"); -[[maybe_unused]] static const QString kPersonalizeRegistryKey = QStringLiteral(R"(Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)"); -[[maybe_unused]] static const QString kThemeSettingChangeEventName = QStringLiteral("ImmersiveColorSet"); -[[maybe_unused]] static const QString kDwmColorKeyName = QStringLiteral("ColorPrevalence"); - -[[maybe_unused]] static constexpr const DWORD _DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19; -[[maybe_unused]] static constexpr const DWORD _DWMWA_USE_IMMERSIVE_DARK_MODE = 20; -[[maybe_unused]] static constexpr const DWORD _DWMWA_WINDOW_CORNER_PREFERENCE = 33; -[[maybe_unused]] static constexpr const DWORD _DWMWA_VISIBLE_FRAME_BORDER_THICKNESS = 37; +#include "../../include/FramelessHelper/Core/framelesshelper_windows.h" diff --git a/src/core/framelesshelpercore.qrc b/src/core/framelesshelpercore.qrc index 2bad58a..2c99254 100644 --- a/src/core/framelesshelpercore.qrc +++ b/src/core/framelesshelpercore.qrc @@ -1,5 +1,7 @@ + images/LICENSE + images/LICENSE-CODE images/dark/chrome-close.svg images/dark/chrome-maximize.svg images/dark/chrome-minimize.svg diff --git a/src/core/framelesshelpercore_global.h b/src/core/framelesshelpercore_global.h index 88b6ba7..13d1be4 100644 --- a/src/core/framelesshelpercore_global.h +++ b/src/core/framelesshelpercore_global.h @@ -22,124 +22,4 @@ * SOFTWARE. */ -#pragma once - -#include -#include -#include -#include - -#ifndef FRAMELESSHELPER_CORE_API -# ifdef FRAMELESSHELPER_CORE_STATIC -# define FRAMELESSHELPER_CORE_API -# else -# ifdef FRAMELESSHELPER_CORE_LIBRARY -# define FRAMELESSHELPER_CORE_API Q_DECL_EXPORT -# else -# define FRAMELESSHELPER_CORE_API Q_DECL_IMPORT -# endif -# endif -#endif - -#if defined(Q_OS_WIN) && !defined(Q_OS_WINDOWS) -# define Q_OS_WINDOWS -#endif - -#ifndef Q_DISABLE_COPY_MOVE -# define Q_DISABLE_COPY_MOVE(Class) \ - Q_DISABLE_COPY(Class) \ - Class(Class &&) = delete; \ - Class &operator=(Class &&) = delete; -#endif - -#if (QT_VERSION < QT_VERSION_CHECK(5, 7, 0)) -# define qAsConst(i) std::as_const(i) -#endif - -#if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0)) -# define QStringView const QString & -#else -# include -#endif - -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) -# define qExchange(a, b) std::exchange(a, b) -# define Q_NAMESPACE_EXPORT(ns) Q_NAMESPACE -#endif - -#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) -# define Q_NODISCARD [[nodiscard]] -#else -# define Q_NODISCARD -#endif - -#ifndef FRAMELESSHELPER_NAMESPACE -# define FRAMELESSHELPER_NAMESPACE __flh_ns -#endif - -#ifndef FRAMELESSHELPER_BEGIN_NAMESPACE -# define FRAMELESSHELPER_BEGIN_NAMESPACE namespace FRAMELESSHELPER_NAMESPACE { -#endif - -#ifndef FRAMELESSHELPER_END_NAMESPACE -# define FRAMELESSHELPER_END_NAMESPACE } -#endif - -#ifndef FRAMELESSHELPER_USE_NAMESPACE -# define FRAMELESSHELPER_USE_NAMESPACE using namespace FRAMELESSHELPER_NAMESPACE; -#endif - -#ifndef FRAMELESSHELPER_PREPEND_NAMESPACE -# define FRAMELESSHELPER_PREPEND_NAMESPACE(X) ::FRAMELESSHELPER_NAMESPACE::X -#endif - -FRAMELESSHELPER_BEGIN_NAMESPACE - -Q_NAMESPACE_EXPORT(FRAMELESSHELPER_CORE_API) - -[[maybe_unused]] static constexpr const int kDefaultResizeBorderThickness = 8; -[[maybe_unused]] static constexpr const int kDefaultCaptionHeight = 23; -[[maybe_unused]] static constexpr const int kDefaultTitleBarHeight = 30; -[[maybe_unused]] static constexpr const int kDefaultWindowFrameBorderThickness = 1; - -[[maybe_unused]] static const QColor kDefaultSystemLightColor = QStringLiteral("#f0f0f0"); -[[maybe_unused]] static const QColor kDefaultSystemDarkColor = QStringLiteral("#202020"); - -[[maybe_unused]] static constexpr const QSize kDefaultSystemButtonSize = {int(qRound(qreal(kDefaultTitleBarHeight) * 1.5)), kDefaultTitleBarHeight}; -[[maybe_unused]] static constexpr const QSize kDefaultSystemButtonIconSize = {16, 16}; - -[[maybe_unused]] static constexpr const char kInternalOptionsFlag[] = "FRAMELESSHELPER_INTERNAL_OPTIONS"; -[[maybe_unused]] static constexpr const char kUsePureQtImplFlag[] = "FRAMELESSHELPER_PURE_QT_IMPLEMENTATION"; -[[maybe_unused]] static constexpr const char kForceHideFrameBorderFlag[] = "FRAMELESSHELPER_FORCE_HIDE_FRAME_BORDER"; -[[maybe_unused]] static constexpr const char kForceShowFrameBorderFlag[] = "FRAMELESSHELPER_FORCE_SHOW_FRAME_BORDER"; - -[[maybe_unused]] static const QString kConfigFileName = QStringLiteral(".framelesshelper.ini"); -[[maybe_unused]] static const QString kUsePureQtImplKeyPath = QStringLiteral("Options/UsePureQtImplementation"); -[[maybe_unused]] static const QString kForceHideFrameBorderKeyPath = QStringLiteral("Options/ForceHideFrameBorder"); -[[maybe_unused]] static const QString kForceShowFrameBorderKeyPath = QStringLiteral("Options/ForceShowFrameBorder"); - -enum class Option : int -{ - Default = 0x00000000, // Default placeholder, have no effect. - ForceHideWindowFrameBorder = 0x00000001, // Windows only, force hide the window frame border even on Windows 10 and onwards. - ForceShowWindowFrameBorder = 0x00000002, // Windows only, force show the window frame border even on Windows 7 (~ 8.1). - DontDrawTopWindowFrameBorder = 0x00000004, // Windows only, don't draw the top window frame border even if the window frame border is visible. - EnableRoundedWindowCorners = 0x00000008, // Not implemented yet. - TransparentWindowBackground = 0x00000010, // Not implemented yet. - MaximizeButtonDocking = 0x00000020, // Windows only, enable the window docking feature introduced in Windows 11. - UseStandardWindowLayout = 0x00000040, // The standard window layout is a titlebar always on top and fill the window width. - BeCompatibleWithQtFramelessWindowHint = 0x00000080, // Windows only, make the code compatible with Qt::FramelessWindowHint. Don't use this option unless you really need that flag. - DontTouchQtInternals = 0x00000100, // Windows only, don't modify Qt's internal data. - DontTouchWindowFrameBorderColor = 0x00000200, // Windows only, don't change the window frame border color. - DontInstallSystemMenuHook = 0x00000400, // Windows only, don't install the system menu hook. - DisableSystemMenu = 0x00000800, // Windows only, don't open the system menu when right clicks the titlebar. - NoDoubleClickMaximizeToggle = 0x00001000, // Don't toggle the maximize state when double clicks the titlebar. - DisableResizing = 0x00002000, // Disable resizing of the window. - DisableDragging = 0x00004000, // Disable dragging through the titlebar of the window. - DontTouchCursorShape = 0x00008000 // Don't change the cursor shape while the mouse is hovering above the window. -}; -Q_DECLARE_FLAGS(Options, Option) -Q_FLAG_NS(Options) -Q_DECLARE_OPERATORS_FOR_FLAGS(Options) - -FRAMELESSHELPER_END_NAMESPACE +#include "../../include/FramelessHelper/Core/framelesshelpercore_global.h" diff --git a/src/core/framelesswindowsmanager.h b/src/core/framelesswindowsmanager.h index b2ab443..e682e5d 100644 --- a/src/core/framelesswindowsmanager.h +++ b/src/core/framelesswindowsmanager.h @@ -22,39 +22,4 @@ * SOFTWARE. */ -#pragma once - -#include "framelesshelpercore_global.h" -#include - -QT_BEGIN_NAMESPACE -class QWindow; -QT_END_NAMESPACE - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FramelessWindowsManagerPrivate; - -class FRAMELESSHELPER_CORE_API FramelessWindowsManager : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(FramelessWindowsManager) - Q_DISABLE_COPY_MOVE(FramelessWindowsManager) - -public: - explicit FramelessWindowsManager(QObject *parent = nullptr); - ~FramelessWindowsManager() override; - - Q_NODISCARD static FramelessWindowsManager *instance(); - - void addWindow(QWindow *window); - void removeWindow(QWindow *window); - -Q_SIGNALS: - void systemThemeChanged(); - -private: - QScopedPointer d_ptr; -}; - -FRAMELESSHELPER_END_NAMESPACE +#include "../../include/FramelessHelper/Core/framelesswindowsmanager.h" diff --git a/src/core/images/LICENSE b/src/core/images/LICENSE new file mode 100644 index 0000000..a2c95fc --- /dev/null +++ b/src/core/images/LICENSE @@ -0,0 +1,395 @@ +Attribution 4.0 International + +======================================================================= + +Creative Commons Corporation ("Creative Commons") is not a law firm and +does not provide legal services or legal advice. Distribution of +Creative Commons public licenses does not create a lawyer-client or +other relationship. Creative Commons makes its licenses and related +information available on an "as-is" basis. Creative Commons gives no +warranties regarding its licenses, any material licensed under their +terms and conditions, or any related information. Creative Commons +disclaims all liability for damages resulting from their use to the +fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and +conditions that creators and other rights holders may use to share +original works of authorship and other material subject to copyright +and certain other rights specified in the public license below. The +following considerations are for informational purposes only, are not +exhaustive, and do not form part of our licenses. + + Considerations for licensors: Our public licenses are + intended for use by those authorized to give the public + permission to use material in ways otherwise restricted by + copyright and certain other rights. Our licenses are + irrevocable. Licensors should read and understand the terms + and conditions of the license they choose before applying it. + Licensors should also secure all rights necessary before + applying our licenses so that the public can reuse the + material as expected. Licensors should clearly mark any + material not subject to the license. This includes other CC- + licensed material, or material used under an exception or + limitation to copyright. More considerations for licensors: + wiki.creativecommons.org/Considerations_for_licensors + + Considerations for the public: By using one of our public + licenses, a licensor grants the public permission to use the + licensed material under specified terms and conditions. If + the licensor's permission is not necessary for any reason--for + example, because of any applicable exception or limitation to + copyright--then that use is not regulated by the license. Our + licenses grant only permissions under copyright and certain + other rights that a licensor has authority to grant. Use of + the licensed material may still be restricted for other + reasons, including because others have copyright or other + rights in the material. A licensor may make special requests, + such as asking that all changes be marked or described. + Although not required by our licenses, you are encouraged to + respect those requests where reasonable. More_considerations + for the public: + wiki.creativecommons.org/Considerations_for_licensees + +======================================================================= + +Creative Commons Attribution 4.0 International Public License + +By exercising the Licensed Rights (defined below), You accept and agree +to be bound by the terms and conditions of this Creative Commons +Attribution 4.0 International Public License ("Public License"). To the +extent this Public License may be interpreted as a contract, You are +granted the Licensed Rights in consideration of Your acceptance of +these terms and conditions, and the Licensor grants You such rights in +consideration of benefits the Licensor receives from making the +Licensed Material available under these terms and conditions. + + +Section 1 -- Definitions. + + a. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + + c. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + + d. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + + e. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + + f. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + + g. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + + h. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + + i. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + + j. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + + k. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + + +Section 2 -- Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + + a. reproduce and Share the Licensed Material, in whole or + in part; and + + b. produce, reproduce, and Share Adapted Material. + + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + + 3. Term. The term of this Public License is specified in Section + 6(a). + + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(a) + (4) never produces Adapted Material. + + 5. Downstream recipients. + + a. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + + b. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. + + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(a)(1)(A)(i). + + b. Other rights. + + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this + Public License. + + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties. + + +Section 3 -- License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the +following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified + form), You must: + + a. retain the following if it is supplied by the Licensor + with the Licensed Material: + + i. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of + warranties; + + v. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; + + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + + 3. If requested by the Licensor, You must remove any of the + information required by Section 3(a)(1)(A) to the extent + reasonably practicable. + + 4. If You Share Adapted Material You produce, the Adapter's + License You apply must not prevent recipients of the Adapted + Material from complying with this Public License. + + +Section 4 -- Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that +apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database; + + b. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material; and + + c. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not +replace Your obligations under this Public License where the Licensed +Rights include other Copyright and Similar Rights. + + +Section 5 -- Disclaimer of Warranties and Limitation of Liability. + + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. + + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + + c. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. + + +Section 6 -- Term and Termination. + + a. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under + Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. + + c. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. + + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. + + +Section 7 -- Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. + + +Section 8 -- Interpretation. + + a. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. + + c. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. + + d. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. + + +======================================================================= + +Creative Commons is not a party to its public +licenses. Notwithstanding, Creative Commons may elect to apply one of +its public licenses to material it publishes and in those instances +will be considered the “Licensor.” The text of the Creative Commons +public licenses is dedicated to the public domain under the CC0 Public +Domain Dedication. Except for the limited purpose of indicating that +material is shared under a Creative Commons public license or as +otherwise permitted by the Creative Commons policies published at +creativecommons.org/policies, Creative Commons does not authorize the +use of the trademark "Creative Commons" or any other trademark or logo +of Creative Commons without its prior written consent including, +without limitation, in connection with any unauthorized modifications +to any of its public licenses or any other arrangements, +understandings, or agreements concerning use of licensed material. For +the avoidance of doubt, this paragraph does not form part of the +public licenses. + +Creative Commons may be contacted at creativecommons.org. \ No newline at end of file diff --git a/src/core/images/LICENSE-CODE b/src/core/images/LICENSE-CODE new file mode 100644 index 0000000..9e841e7 --- /dev/null +++ b/src/core/images/LICENSE-CODE @@ -0,0 +1,21 @@ + MIT License + + Copyright (c) Microsoft Corporation. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE diff --git a/src/core/images/README b/src/core/images/README new file mode 100644 index 0000000..03ee5a1 --- /dev/null +++ b/src/core/images/README @@ -0,0 +1,10 @@ +All SVG images here are copied from https://github.com/microsoft/vscode-icons + +Original legal notices text: +Microsoft and any contributors grant you a license to the Microsoft documentation and other content in this repository under the Creative Commons Attribution 4.0 International Public License, see the LICENSE file, and grant you a license to any code in the repository under the MIT License, see the LICENSE-CODE file. + +Microsoft, Windows, Microsoft Azure and/or other Microsoft products and services referenced in the documentation may be either trademarks or registered trademarks of Microsoft in the United States and/or other countries. The licenses for this project do not grant you rights to use any Microsoft names, logos, or trademarks. Microsoft's general trademark guidelines can be found at http://go.microsoft.com/fwlink/?LinkID=254653. + +Privacy information can be found at https://privacy.microsoft.com/en-us/ + +Microsoft and any contributors reserve all other rights, whether under their respective copyrights, patents, or trademarks, whether by implication, estoppel or otherwise. diff --git a/src/core/utils.h b/src/core/utils.h index 5470396..684e708 100644 --- a/src/core/utils.h +++ b/src/core/utils.h @@ -22,99 +22,4 @@ * SOFTWARE. */ -#pragma once - -#include "framelesshelpercore_global.h" -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -enum class SystemTheme : int -{ - Light = 0, - Dark = 1, - HighContrastLight = 2, - HighContrastDark = 3 -}; -Q_ENUM_NS(SystemTheme) - -enum class SystemButtonType : int -{ - WindowIcon = 0, - Minimize = 1, - Maximize = 2, - Restore = 3, - Close = 4 -}; -Q_ENUM_NS(SystemButtonType) - -enum class ResourceType : int -{ - Image = 0, - Pixmap = 1, - Icon = 2 -}; -Q_ENUM_NS(ResourceType) - -#ifdef Q_OS_WINDOWS -enum class DwmColorizationArea : int -{ - None = 0, - StartMenu_TaskBar_ActionCenter = 1, - TitleBar_WindowBorder = 2, - All = 3 -}; -Q_ENUM_NS(DwmColorizationArea) -#endif - -namespace Utils -{ - -[[nodiscard]] FRAMELESSHELPER_CORE_API Qt::CursorShape calculateCursorShape(const QWindow *window, const QPoint &pos); -[[nodiscard]] FRAMELESSHELPER_CORE_API Qt::Edges calculateWindowEdges(const QWindow *window, const QPoint &pos); -FRAMELESSHELPER_CORE_API void startSystemMove(QWindow *window); -FRAMELESSHELPER_CORE_API void startSystemResize(QWindow *window, const Qt::Edges edges); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowFixedSize(const QWindow *window); -[[nodiscard]] FRAMELESSHELPER_CORE_API QVariant getSystemButtonIconResource - (const SystemButtonType button, const SystemTheme theme, const ResourceType type); -FRAMELESSHELPER_CORE_API void sendMouseReleaseEvent(); - -#ifdef Q_OS_WINDOWS -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin8OrGreater(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin8Point1OrGreater(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin10OrGreater(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin101809OrGreater(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin11OrGreater(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isDwmCompositionEnabled(); -FRAMELESSHELPER_CORE_API void triggerFrameChange(const WId winId); -FRAMELESSHELPER_CORE_API void updateWindowFrameMargins(const WId winId, const bool reset); -FRAMELESSHELPER_CORE_API void updateInternalWindowFrameMargins(QWindow *window, const bool enable); -[[nodiscard]] FRAMELESSHELPER_CORE_API QString getSystemErrorMessage(const QString &function); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isFullScreen(const WId winId); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowNoState(const WId winId); -FRAMELESSHELPER_CORE_API void syncWmPaintWithDwm(); -FRAMELESSHELPER_CORE_API void showSystemMenu(const WId winId, const QPoint &pos); -[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getDwmColorizationColor(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool shouldAppsUseDarkMode(); -[[nodiscard]] FRAMELESSHELPER_CORE_API DwmColorizationArea getDwmColorizationArea(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isHighContrastModeEnabled(); -[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getPrimaryScreenDpi(const bool horizontal); -[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getWindowDpi(const WId winId, const bool horizontal); -[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getResizeBorderThickness(const WId winId, const bool horizontal, const bool scaled); -[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getCaptionHeight(const WId winId, const bool scaled); -[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getTitleBarHeight(const WId winId, const bool scaled); -[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getFrameBorderThickness(const WId winId, const bool scaled); -[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getFrameBorderColor(const bool active); -FRAMELESSHELPER_CORE_API void updateWindowFrameBorderColor(const WId winId, const bool dark); -FRAMELESSHELPER_CORE_API void fixupQtInternals(const WId winId); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowFrameBorderVisible(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isTitleBarColorized(); -[[nodiscard]] FRAMELESSHELPER_CORE_API bool isFrameBorderColorized(); -FRAMELESSHELPER_CORE_API void installSystemMenuHook(const WId winId); -FRAMELESSHELPER_CORE_API void uninstallSystemMenuHook(const WId winId); -FRAMELESSHELPER_CORE_API void tryToBeCompatibleWithQtFramelessWindowHint(QWindow *window, const bool enable); -#endif // Q_OS_WINDOWS - -} // namespace Utils - -FRAMELESSHELPER_END_NAMESPACE +#include "../../include/FramelessHelper/Core/utils.h" diff --git a/src/quick/CMakeLists.txt b/src/quick/CMakeLists.txt index 31239ad..7a641ac 100644 --- a/src/quick/CMakeLists.txt +++ b/src/quick/CMakeLists.txt @@ -69,7 +69,6 @@ target_link_libraries(${SUB_PROJ_NAME} PUBLIC ) target_include_directories(${SUB_PROJ_NAME} PUBLIC - "$" "$/../../include/FramelessHelper/Quick" "$/../../include" ) diff --git a/src/quick/framelesshelper_quick.h b/src/quick/framelesshelper_quick.h index 9b7bf2a..3cbfdf1 100644 --- a/src/quick/framelesshelper_quick.h +++ b/src/quick/framelesshelper_quick.h @@ -22,21 +22,4 @@ * SOFTWARE. */ -#pragma once - -#include "framelesshelperquick_global.h" - -QT_BEGIN_NAMESPACE -class QQmlEngine; -QT_END_NAMESPACE - -FRAMELESSHELPER_BEGIN_NAMESPACE - -namespace FramelessHelper::Quick -{ - -FRAMELESSHELPER_QUICK_API void registerTypes(QQmlEngine *engine); - -} - -FRAMELESSHELPER_END_NAMESPACE +#include "../../include/FramelessHelper/Quick/framelesshelper_quick.h" diff --git a/src/quick/framelesshelperimageprovider.h b/src/quick/framelesshelperimageprovider.h index f9a044a..1be1054 100644 --- a/src/quick/framelesshelperimageprovider.h +++ b/src/quick/framelesshelperimageprovider.h @@ -22,25 +22,4 @@ * SOFTWARE. */ -#pragma once - -#include "framelesshelperquick_global.h" -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FRAMELESSHELPER_QUICK_API FramelessHelperImageProvider : public QQuickImageProvider -{ -#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - Q_OBJECT -#endif - Q_DISABLE_COPY_MOVE(FramelessHelperImageProvider) - -public: - explicit FramelessHelperImageProvider(); - ~FramelessHelperImageProvider() override; - - Q_NODISCARD QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) override; -}; - -FRAMELESSHELPER_END_NAMESPACE +#include "../../include/FramelessHelper/Quick/framelesshelperimageprovider.h" diff --git a/src/quick/framelesshelperquick_global.h b/src/quick/framelesshelperquick_global.h index 8f7c103..b32b26c 100644 --- a/src/quick/framelesshelperquick_global.h +++ b/src/quick/framelesshelperquick_global.h @@ -22,18 +22,4 @@ * SOFTWARE. */ -#pragma once - -#include - -#ifndef FRAMELESSHELPER_QUICK_API -# ifdef FRAMELESSHELPER_QUICK_STATIC -# define FRAMELESSHELPER_QUICK_API -# else -# ifdef FRAMELESSHELPER_QUICK_LIBRARY -# define FRAMELESSHELPER_QUICK_API Q_DECL_EXPORT -# else -# define FRAMELESSHELPER_QUICK_API Q_DECL_IMPORT -# endif -# endif -#endif +#include "../../include/FramelessHelper/Quick/framelesshelperquick_global.h" diff --git a/src/quick/framelessquickeventfilter.h b/src/quick/framelessquickeventfilter.h index cffbeeb..9bc33dd 100644 --- a/src/quick/framelessquickeventfilter.h +++ b/src/quick/framelessquickeventfilter.h @@ -22,34 +22,4 @@ * SOFTWARE. */ -#pragma once - -#include "framelesshelperquick_global.h" -#include - -QT_BEGIN_NAMESPACE -class QQuickWindow; -class QQuickItem; -QT_END_NAMESPACE - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FRAMELESSHELPER_QUICK_API FramelessQuickEventFilter : public QObject -{ - Q_OBJECT - Q_DISABLE_COPY_MOVE(FramelessQuickEventFilter) - -public: - explicit FramelessQuickEventFilter(QObject *parent = nullptr); - ~FramelessQuickEventFilter() override; - - Q_INVOKABLE static void addWindow(QQuickWindow *window); - Q_INVOKABLE static void removeWindow(QQuickWindow *window); - Q_INVOKABLE static void setTitleBarItem(QQuickWindow *window, QQuickItem *item); - Q_INVOKABLE static void setHitTestVisible(QQuickWindow *window, QQuickItem *item, const bool visible); - -protected: - Q_NODISCARD bool eventFilter(QObject *object, QEvent *event) override; -}; - -FRAMELESSHELPER_END_NAMESPACE +#include "../../include/FramelessHelper/Quick/framelessquickeventfilter.h" diff --git a/src/quick/framelessquickhelper.h b/src/quick/framelessquickhelper.h index aa98880..4f4e9b3 100644 --- a/src/quick/framelessquickhelper.h +++ b/src/quick/framelessquickhelper.h @@ -22,37 +22,4 @@ * SOFTWARE. */ -#pragma once - -#include "framelesshelperquick_global.h" -#include - -QT_BEGIN_NAMESPACE -class QQuickWindow; -class QQuickItem; -QT_END_NAMESPACE - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FRAMELESSHELPER_QUICK_API FramelessQuickHelper : public QObject -{ - Q_OBJECT - Q_DISABLE_COPY_MOVE(FramelessQuickHelper) -#ifdef QML_NAMED_ELEMENT - QML_NAMED_ELEMENT(FramelessHelper) -#endif -#ifdef QML_SINGLETON - QML_SINGLETON -#endif - -public: - explicit FramelessQuickHelper(QObject *parent = nullptr); - ~FramelessQuickHelper() override; - - Q_INVOKABLE static void addWindow(QQuickWindow *window); - Q_INVOKABLE static void removeWindow(QQuickWindow *window); - Q_INVOKABLE static void setTitleBarItem(QQuickWindow *window, QQuickItem *item); - Q_INVOKABLE static void setHitTestVisible(QQuickWindow *window, QQuickItem *item, const bool visible); -}; - -FRAMELESSHELPER_END_NAMESPACE +#include "../../include/FramelessHelper/Quick/framelessquickhelper.h" diff --git a/src/quick/framelessquickutils.h b/src/quick/framelessquickutils.h index e5ff7ed..e7c774d 100644 --- a/src/quick/framelessquickutils.h +++ b/src/quick/framelessquickutils.h @@ -22,61 +22,4 @@ * SOFTWARE. */ -#pragma once - -#include "framelesshelperquick_global.h" -#include -#include - -QT_BEGIN_NAMESPACE -class QQuickWindow; -QT_END_NAMESPACE - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FRAMELESSHELPER_QUICK_API FramelessQuickUtils : public QObject -{ - Q_OBJECT - Q_DISABLE_COPY_MOVE(FramelessQuickUtils) -#ifdef QML_NAMED_ELEMENT - QML_NAMED_ELEMENT(FramelessUtils) -#endif -#ifdef QML_SINGLETON - QML_SINGLETON -#endif - Q_PROPERTY(qreal titleBarHeight READ titleBarHeight CONSTANT FINAL) - Q_PROPERTY(bool frameBorderVisible READ frameBorderVisible CONSTANT FINAL) - Q_PROPERTY(qreal frameBorderThickness READ frameBorderThickness CONSTANT FINAL) - Q_PROPERTY(QColor frameBorderActiveColor READ frameBorderActiveColor NOTIFY frameBorderActiveColorChanged FINAL) - Q_PROPERTY(QColor frameBorderInactiveColor READ frameBorderInactiveColor NOTIFY frameBorderInactiveColorChanged FINAL) - Q_PROPERTY(bool darkModeEnabled READ darkModeEnabled NOTIFY darkModeEnabledChanged FINAL) - Q_PROPERTY(QColor systemAccentColor READ systemAccentColor NOTIFY systemAccentColorChanged FINAL) - Q_PROPERTY(bool titleBarColorVisible READ titleBarColorVisible NOTIFY titleBarColorVisibleChanged FINAL) - -public: - explicit FramelessQuickUtils(QObject *parent = nullptr); - ~FramelessQuickUtils() override; - - Q_NODISCARD static qreal titleBarHeight(); - Q_NODISCARD static bool frameBorderVisible(); - Q_NODISCARD static qreal frameBorderThickness(); - Q_NODISCARD static QColor frameBorderActiveColor(); - Q_NODISCARD static QColor frameBorderInactiveColor(); - Q_NODISCARD static bool darkModeEnabled(); - Q_NODISCARD static QColor systemAccentColor(); - Q_NODISCARD static bool titleBarColorVisible(); - - Q_INVOKABLE static void showMinimized2(QQuickWindow *window); - Q_INVOKABLE static void showSystemMenu(QQuickWindow *window, const QPoint &pos); - Q_INVOKABLE static void startSystemMove2(QQuickWindow *window); - Q_INVOKABLE static void startSystemResize2(QQuickWindow *window, const Qt::Edges edges); - -Q_SIGNALS: - void frameBorderActiveColorChanged(); - void frameBorderInactiveColorChanged(); - void darkModeEnabledChanged(); - void systemAccentColorChanged(); - void titleBarColorVisibleChanged(); -}; - -FRAMELESSHELPER_END_NAMESPACE +#include "../../include/FramelessHelper/Quick/framelessquickutils.h" diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index c13740d..383ea23 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -56,7 +56,6 @@ target_link_libraries(${SUB_PROJ_NAME} PUBLIC ) target_include_directories(${SUB_PROJ_NAME} PUBLIC - "$" "$/../../include/FramelessHelper/Widgets" "$/../../include" ) diff --git a/src/widgets/framelesshelperwidgets_global.h b/src/widgets/framelesshelperwidgets_global.h index 51a4d65..2cd1de3 100644 --- a/src/widgets/framelesshelperwidgets_global.h +++ b/src/widgets/framelesshelperwidgets_global.h @@ -22,18 +22,4 @@ * SOFTWARE. */ -#pragma once - -#include - -#ifndef FRAMELESSHELPER_WIDGETS_API -# ifdef FRAMELESSHELPER_WIDGETS_STATIC -# define FRAMELESSHELPER_WIDGETS_API -# else -# ifdef FRAMELESSHELPER_WIDGETS_LIBRARY -# define FRAMELESSHELPER_WIDGETS_API Q_DECL_EXPORT -# else -# define FRAMELESSHELPER_WIDGETS_API Q_DECL_IMPORT -# endif -# endif -#endif +#include "../../include/FramelessHelper/Widgets/framelesshelperwidgets_global.h" diff --git a/src/widgets/framelessmainwindow.h b/src/widgets/framelessmainwindow.h index 4728f9a..2f5d9c6 100644 --- a/src/widgets/framelessmainwindow.h +++ b/src/widgets/framelessmainwindow.h @@ -22,48 +22,4 @@ * SOFTWARE. */ -#pragma once - -#include "framelesshelperwidgets_global.h" -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FramelessWidgetsHelper; - -class FRAMELESSHELPER_WIDGETS_API FramelessMainWindow : public QMainWindow -{ - Q_OBJECT - Q_DISABLE_COPY_MOVE(FramelessMainWindow) - Q_PROPERTY(QWidget* titleBarWidget READ titleBarWidget WRITE setTitleBarWidget NOTIFY titleBarWidgetChanged FINAL) - -public: - explicit FramelessMainWindow(QWidget *parent = nullptr, const Qt::WindowFlags flags = {}, const Options options = {}); - ~FramelessMainWindow() override; - - Q_NODISCARD Q_INVOKABLE bool isNormal() const; - Q_NODISCARD Q_INVOKABLE bool isZoomed() const; - - void setTitleBarWidget(QWidget *widget); - Q_NODISCARD QWidget *titleBarWidget() const; - - Q_INVOKABLE void setHitTestVisible(QWidget *widget, const bool visible); - - Q_INVOKABLE void toggleMaximized(); - -protected: - void changeEvent(QEvent *event) override; - void paintEvent(QPaintEvent *event) override; - void mousePressEvent(QMouseEvent *event) override; - void mouseReleaseEvent(QMouseEvent *event) override; - void mouseDoubleClickEvent(QMouseEvent *event) override; - -Q_SIGNALS: - void titleBarWidgetChanged(); - void systemThemeChanged(); - -private: - QScopedPointer m_helper; -}; - -FRAMELESSHELPER_END_NAMESPACE +#include "../../include/FramelessHelper/Widgets/framelessmainwindow.h" diff --git a/src/widgets/framelesswidget.h b/src/widgets/framelesswidget.h index 00b10ce..478372e 100644 --- a/src/widgets/framelesswidget.h +++ b/src/widgets/framelesswidget.h @@ -22,53 +22,4 @@ * SOFTWARE. */ -#pragma once - -#include "framelesshelperwidgets_global.h" -#include - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FramelessWidgetsHelper; - -class FRAMELESSHELPER_WIDGETS_API FramelessWidget : public QWidget -{ - Q_OBJECT - Q_DISABLE_COPY_MOVE(FramelessWidget) - Q_PROPERTY(QWidget* titleBarWidget READ titleBarWidget WRITE setTitleBarWidget NOTIFY titleBarWidgetChanged FINAL) - Q_PROPERTY(QWidget* contentWidget READ contentWidget WRITE setContentWidget NOTIFY contentWidgetChanged FINAL) - -public: - explicit FramelessWidget(QWidget *parent = nullptr, const Options options = {}); - ~FramelessWidget() override; - - Q_NODISCARD Q_INVOKABLE bool isNormal() const; - Q_NODISCARD Q_INVOKABLE bool isZoomed() const; - - void setTitleBarWidget(QWidget *widget); - Q_NODISCARD QWidget *titleBarWidget() const; - - void setContentWidget(QWidget *widget); - Q_NODISCARD QWidget *contentWidget() const; - - Q_INVOKABLE void setHitTestVisible(QWidget *widget, const bool visible); - - Q_INVOKABLE void toggleMaximized(); - -protected: - void changeEvent(QEvent *event) override; - void paintEvent(QPaintEvent *event) override; - void mousePressEvent(QMouseEvent *event) override; - void mouseReleaseEvent(QMouseEvent *event) override; - void mouseDoubleClickEvent(QMouseEvent *event) override; - -Q_SIGNALS: - void titleBarWidgetChanged(); - void contentWidgetChanged(); - void systemThemeChanged(); - -private: - QScopedPointer m_helper; -}; - -FRAMELESSHELPER_END_NAMESPACE +#include "../../include/FramelessHelper/Widgets/framelesswidget.h" diff --git a/src/widgets/framelesswidgetshelper.h b/src/widgets/framelesswidgetshelper.h index 8e8a927..bc4d8fa 100644 --- a/src/widgets/framelesswidgetshelper.h +++ b/src/widgets/framelesswidgetshelper.h @@ -22,80 +22,4 @@ * SOFTWARE. */ -#pragma once - -#include "framelesshelperwidgets_global.h" -#include -#include - -QT_BEGIN_NAMESPACE -class QLabel; -class QPushButton; -class QVBoxLayout; -class QShowEvent; -class QPaintEvent; -class QMouseEvent; -QT_END_NAMESPACE - -FRAMELESSHELPER_BEGIN_NAMESPACE - -class FRAMELESSHELPER_WIDGETS_API FramelessWidgetsHelper : public QObject -{ - Q_OBJECT - Q_DISABLE_COPY_MOVE(FramelessWidgetsHelper) - -public: - explicit FramelessWidgetsHelper(QWidget *q, const Options options = {}); - ~FramelessWidgetsHelper() override; - - Q_NODISCARD Q_INVOKABLE bool isNormal() const; - Q_NODISCARD Q_INVOKABLE bool isZoomed() const; - - Q_INVOKABLE void setTitleBarWidget(QWidget *widget); - Q_NODISCARD Q_INVOKABLE QWidget *titleBarWidget() const; - - Q_INVOKABLE void setContentWidget(QWidget *widget); - Q_NODISCARD Q_INVOKABLE QWidget *contentWidget() const; - - Q_INVOKABLE void setHitTestVisible(QWidget *widget, const bool visible); - - Q_INVOKABLE void toggleMaximized(); - - Q_INVOKABLE void changeEventHandler(QEvent *event); - Q_INVOKABLE void paintEventHandler(QPaintEvent *event); - Q_INVOKABLE void mousePressEventHandler(QMouseEvent *event); - Q_INVOKABLE void mouseReleaseEventHandler(QMouseEvent *event); - Q_INVOKABLE void mouseDoubleClickEventHandler(QMouseEvent *event); - -private: - void initialize(); - void createSystemTitleBar(); - void createUserContentContainer(); - void setupInitialUi(); - Q_NODISCARD bool isInTitleBarDraggableArea(const QPoint &pos) const; - Q_NODISCARD bool shouldDrawFrameBorder() const; - Q_NODISCARD bool shouldIgnoreMouseEvents(const QPoint &pos) const; - -private Q_SLOTS: - void updateContentsMargins(); - void updateSystemTitleBarStyleSheet(); - void updateSystemButtonsIcon(); - -private: - QWidget *q = nullptr; - bool m_initialized = false; - Options m_options = {}; - QWidget *m_systemTitleBarWidget = nullptr; - QLabel *m_systemWindowTitleLabel = nullptr; - QPushButton *m_systemMinimizeButton = nullptr; - QPushButton *m_systemMaximizeButton = nullptr; - QPushButton *m_systemCloseButton = nullptr; - QWidget *m_userTitleBarWidget = nullptr; - QWidget *m_userContentWidget = nullptr; - QVBoxLayout *m_mainLayout = nullptr; - QWidgetList m_hitTestVisibleWidgets = {}; - QWidget *m_userContentContainerWidget = nullptr; - QVBoxLayout *m_userContentContainerLayout = nullptr; -}; - -FRAMELESSHELPER_END_NAMESPACE +#include "../../include/FramelessHelper/Widgets/framelesswidgetshelper.h"