forked from github_mirror/framelesshelper
adjust the project structure again
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
ebd69353a0
commit
56f2638363
|
@ -0,0 +1 @@
|
||||||
|
#include <framelesshelpercore_global.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 <QtCore/qobject.h>
|
||||||
|
|
||||||
|
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
|
|
@ -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 <QtCore/qabstractnativeeventfilter.h>
|
||||||
|
|
||||||
|
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
|
|
@ -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 <sdkddkver.h>
|
||||||
|
|
||||||
|
#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 <windows.h>
|
||||||
|
#include <shellapi.h>
|
||||||
|
#include <dwmapi.h>
|
||||||
|
|
||||||
|
#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<int>(static_cast<short>(LOWORD(lp))))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GET_Y_LPARAM
|
||||||
|
# define GET_Y_LPARAM(lp) (static_cast<int>(static_cast<short>(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 <QtCore/qstring.h>
|
||||||
|
|
||||||
|
[[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;
|
|
@ -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 <QtCore/qglobal.h>
|
||||||
|
#include <QtCore/qobject.h>
|
||||||
|
#include <QtCore/qsize.h>
|
||||||
|
#include <QtGui/qcolor.h>
|
||||||
|
|
||||||
|
#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 <QtCore/qstringview.h>
|
||||||
|
#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
|
|
@ -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 <QtCore/qobject.h>
|
||||||
|
|
||||||
|
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<FramelessWindowsManagerPrivate> d_ptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
FRAMELESSHELPER_END_NAMESPACE
|
|
@ -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 <QtGui/qwindowdefs.h>
|
||||||
|
|
||||||
|
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
|
|
@ -0,0 +1 @@
|
||||||
|
#include <framelesshelperquick_global.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
|
|
@ -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 <QtQuick/qquickimageprovider.h>
|
||||||
|
|
||||||
|
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
|
|
@ -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 <framelesshelpercore_global.h>
|
||||||
|
|
||||||
|
#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
|
|
@ -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 <QtCore/qobject.h>
|
||||||
|
|
||||||
|
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
|
|
@ -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 <QtCore/qobject.h>
|
||||||
|
|
||||||
|
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
|
|
@ -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 <QtCore/qobject.h>
|
||||||
|
#include <QtGui/qcolor.h>
|
||||||
|
|
||||||
|
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
|
|
@ -0,0 +1 @@
|
||||||
|
#include <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 <framelesshelpercore_global.h>
|
||||||
|
|
||||||
|
#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
|
|
@ -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 <QtWidgets/qmainwindow.h>
|
||||||
|
|
||||||
|
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<FramelessWidgetsHelper> m_helper;
|
||||||
|
};
|
||||||
|
|
||||||
|
FRAMELESSHELPER_END_NAMESPACE
|
|
@ -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 <QtWidgets/qwidget.h>
|
||||||
|
|
||||||
|
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<FramelessWidgetsHelper> m_helper;
|
||||||
|
};
|
||||||
|
|
||||||
|
FRAMELESSHELPER_END_NAMESPACE
|
|
@ -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 <QtCore/qobject.h>
|
||||||
|
#include <QtGui/qwindowdefs.h>
|
||||||
|
|
||||||
|
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
|
|
@ -79,7 +79,6 @@ target_link_libraries(${SUB_PROJ_NAME} PRIVATE
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(${SUB_PROJ_NAME} PUBLIC
|
target_include_directories(${SUB_PROJ_NAME} PUBLIC
|
||||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
|
|
||||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/../../include/FramelessHelper/Core"
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/../../include/FramelessHelper/Core"
|
||||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/../../include"
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/../../include"
|
||||||
)
|
)
|
||||||
|
|
|
@ -22,31 +22,4 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#include "../../include/FramelessHelper/Core/framelesshelper_qt.h"
|
||||||
|
|
||||||
#include "framelesshelpercore_global.h"
|
|
||||||
#include <QtCore/qobject.h>
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
|
@ -22,33 +22,4 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#include "../../include/FramelessHelper/Core/framelesshelper_win.h"
|
||||||
|
|
||||||
#include "framelesshelpercore_global.h"
|
|
||||||
#include <QtCore/qabstractnativeeventfilter.h>
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
|
@ -22,167 +22,4 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#include "../../include/FramelessHelper/Core/framelesshelper_windows.h"
|
||||||
|
|
||||||
#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 <sdkddkver.h>
|
|
||||||
|
|
||||||
#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 <windows.h>
|
|
||||||
#include <shellapi.h>
|
|
||||||
#include <dwmapi.h>
|
|
||||||
|
|
||||||
#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<int>(static_cast<short>(LOWORD(lp))))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef GET_Y_LPARAM
|
|
||||||
# define GET_Y_LPARAM(lp) (static_cast<int>(static_cast<short>(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 <QtCore/qstring.h>
|
|
||||||
|
|
||||||
[[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;
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/org.wangwenx190.FramelessHelper">
|
<qresource prefix="/org.wangwenx190.FramelessHelper">
|
||||||
|
<file>images/LICENSE</file>
|
||||||
|
<file>images/LICENSE-CODE</file>
|
||||||
<file>images/dark/chrome-close.svg</file>
|
<file>images/dark/chrome-close.svg</file>
|
||||||
<file>images/dark/chrome-maximize.svg</file>
|
<file>images/dark/chrome-maximize.svg</file>
|
||||||
<file>images/dark/chrome-minimize.svg</file>
|
<file>images/dark/chrome-minimize.svg</file>
|
||||||
|
|
|
@ -22,124 +22,4 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#include "../../include/FramelessHelper/Core/framelesshelpercore_global.h"
|
||||||
|
|
||||||
#include <QtCore/qglobal.h>
|
|
||||||
#include <QtCore/qobject.h>
|
|
||||||
#include <QtCore/qsize.h>
|
|
||||||
#include <QtGui/qcolor.h>
|
|
||||||
|
|
||||||
#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 <QtCore/qstringview.h>
|
|
||||||
#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
|
|
||||||
|
|
|
@ -22,39 +22,4 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#include "../../include/FramelessHelper/Core/framelesswindowsmanager.h"
|
||||||
|
|
||||||
#include "framelesshelpercore_global.h"
|
|
||||||
#include <QtCore/qobject.h>
|
|
||||||
|
|
||||||
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<FramelessWindowsManagerPrivate> d_ptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
|
||||||
|
|
|
@ -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.
|
|
@ -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
|
|
@ -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.
|
|
@ -22,99 +22,4 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#include "../../include/FramelessHelper/Core/utils.h"
|
||||||
|
|
||||||
#include "framelesshelpercore_global.h"
|
|
||||||
#include <QtGui/qwindowdefs.h>
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
|
@ -69,7 +69,6 @@ target_link_libraries(${SUB_PROJ_NAME} PUBLIC
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(${SUB_PROJ_NAME} PUBLIC
|
target_include_directories(${SUB_PROJ_NAME} PUBLIC
|
||||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
|
|
||||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/../../include/FramelessHelper/Quick"
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/../../include/FramelessHelper/Quick"
|
||||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/../../include"
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/../../include"
|
||||||
)
|
)
|
||||||
|
|
|
@ -22,21 +22,4 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#include "../../include/FramelessHelper/Quick/framelesshelper_quick.h"
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
|
@ -22,25 +22,4 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#include "../../include/FramelessHelper/Quick/framelesshelperimageprovider.h"
|
||||||
|
|
||||||
#include "framelesshelperquick_global.h"
|
|
||||||
#include <QtQuick/qquickimageprovider.h>
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
|
@ -22,18 +22,4 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#include "../../include/FramelessHelper/Quick/framelesshelperquick_global.h"
|
||||||
|
|
||||||
#include <framelesshelpercore_global.h>
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
|
@ -22,34 +22,4 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#include "../../include/FramelessHelper/Quick/framelessquickeventfilter.h"
|
||||||
|
|
||||||
#include "framelesshelperquick_global.h"
|
|
||||||
#include <QtCore/qobject.h>
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
|
@ -22,37 +22,4 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#include "../../include/FramelessHelper/Quick/framelessquickhelper.h"
|
||||||
|
|
||||||
#include "framelesshelperquick_global.h"
|
|
||||||
#include <QtCore/qobject.h>
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
|
@ -22,61 +22,4 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#include "../../include/FramelessHelper/Quick/framelessquickutils.h"
|
||||||
|
|
||||||
#include "framelesshelperquick_global.h"
|
|
||||||
#include <QtCore/qobject.h>
|
|
||||||
#include <QtGui/qcolor.h>
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
|
@ -56,7 +56,6 @@ target_link_libraries(${SUB_PROJ_NAME} PUBLIC
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(${SUB_PROJ_NAME} PUBLIC
|
target_include_directories(${SUB_PROJ_NAME} PUBLIC
|
||||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
|
|
||||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/../../include/FramelessHelper/Widgets"
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/../../include/FramelessHelper/Widgets"
|
||||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/../../include"
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/../../include"
|
||||||
)
|
)
|
||||||
|
|
|
@ -22,18 +22,4 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#include "../../include/FramelessHelper/Widgets/framelesshelperwidgets_global.h"
|
||||||
|
|
||||||
#include <framelesshelpercore_global.h>
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
|
@ -22,48 +22,4 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#include "../../include/FramelessHelper/Widgets/framelessmainwindow.h"
|
||||||
|
|
||||||
#include "framelesshelperwidgets_global.h"
|
|
||||||
#include <QtWidgets/qmainwindow.h>
|
|
||||||
|
|
||||||
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<FramelessWidgetsHelper> m_helper;
|
|
||||||
};
|
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
|
||||||
|
|
|
@ -22,53 +22,4 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#include "../../include/FramelessHelper/Widgets/framelesswidget.h"
|
||||||
|
|
||||||
#include "framelesshelperwidgets_global.h"
|
|
||||||
#include <QtWidgets/qwidget.h>
|
|
||||||
|
|
||||||
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<FramelessWidgetsHelper> m_helper;
|
|
||||||
};
|
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
|
||||||
|
|
|
@ -22,80 +22,4 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#include "../../include/FramelessHelper/Widgets/framelesswidgetshelper.h"
|
||||||
|
|
||||||
#include "framelesshelperwidgets_global.h"
|
|
||||||
#include <QtCore/qobject.h>
|
|
||||||
#include <QtGui/qwindowdefs.h>
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
Loading…
Reference in New Issue