forked from github_mirror/framelesshelper
minor tweaks
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
cf83b050d2
commit
775b1a2aab
|
@ -40,13 +40,13 @@ QT_END_NAMESPACE
|
|||
#ifndef FRAMELESSHELPER_CORE_API
|
||||
# ifdef FRAMELESSHELPER_CORE_STATIC
|
||||
# define FRAMELESSHELPER_CORE_API
|
||||
# else
|
||||
# else // FRAMELESSHELPER_CORE_STATIC
|
||||
# ifdef FRAMELESSHELPER_CORE_LIBRARY
|
||||
# define FRAMELESSHELPER_CORE_API Q_DECL_EXPORT
|
||||
# else
|
||||
# else // FRAMELESSHELPER_CORE_LIBRARY
|
||||
# define FRAMELESSHELPER_CORE_API Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
# endif // FRAMELESSHELPER_CORE_LIBRARY
|
||||
# endif // FRAMELESSHELPER_CORE_STATIC
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINDOWS)
|
||||
|
@ -211,10 +211,18 @@ Q_NAMESPACE_EXPORT(FRAMELESSHELPER_CORE_API)
|
|||
[[maybe_unused]] static constexpr const QSize kDefaultSystemButtonIconSize = {kDefaultWindowIconSize, kDefaultWindowIconSize};
|
||||
[[maybe_unused]] static constexpr const QSize kDefaultWindowSize = {160, 160}; // Value taken from QPA.
|
||||
|
||||
[[maybe_unused]] static Q_CONSTEXPR2 const QColor kDefaultBlackColor = {0, 0, 0}; // #000000
|
||||
[[maybe_unused]] static Q_CONSTEXPR2 const QColor kDefaultWhiteColor = {255, 255, 255}; // #FFFFFF
|
||||
[[maybe_unused]] static Q_CONSTEXPR2 const QColor kDefaultTransparentColor = {0, 0, 0, 0};
|
||||
[[maybe_unused]] static Q_CONSTEXPR2 const QColor kDefaultDarkGrayColor = {169, 169, 169}; // #A9A9A9
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
# define kDefaultBlackColor QColorConstants::Black
|
||||
# define kDefaultWhiteColor QColorConstants::White
|
||||
# define kDefaultTransparentColor QColorConstants::Transparent
|
||||
# define kDefaultDarkGrayColor QColorConstants::DarkGray
|
||||
#else // (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
[[maybe_unused]] static Q_CONSTEXPR2 const QColor kDefaultBlackColor = {0, 0, 0}; // #000000
|
||||
[[maybe_unused]] static Q_CONSTEXPR2 const QColor kDefaultWhiteColor = {255, 255, 255}; // #FFFFFF
|
||||
[[maybe_unused]] static Q_CONSTEXPR2 const QColor kDefaultTransparentColor = {0, 0, 0, 0};
|
||||
[[maybe_unused]] static Q_CONSTEXPR2 const QColor kDefaultDarkGrayColor = {169, 169, 169}; // #A9A9A9
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
|
||||
[[maybe_unused]] static Q_CONSTEXPR2 const QColor kDefaultSystemLightColor = {240, 240, 240}; // #F0F0F0
|
||||
[[maybe_unused]] static Q_CONSTEXPR2 const QColor kDefaultSystemDarkColor = {32, 32, 32}; // #202020
|
||||
[[maybe_unused]] static Q_CONSTEXPR2 const QColor kDefaultFrameBorderActiveColor = {77, 77, 77}; // #4D4D4D
|
||||
|
@ -257,6 +265,7 @@ enum class SystemButtonType
|
|||
};
|
||||
Q_ENUM_NS(SystemButtonType)
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
enum class DwmColorizationArea
|
||||
{
|
||||
None_ = 0, // Avoid name conflicts with X11 headers.
|
||||
|
@ -265,18 +274,7 @@ enum class DwmColorizationArea
|
|||
All = 3
|
||||
};
|
||||
Q_ENUM_NS(DwmColorizationArea)
|
||||
|
||||
enum class Anchor
|
||||
{
|
||||
Top = 0,
|
||||
Bottom = 1,
|
||||
Left = 2,
|
||||
Right = 3,
|
||||
HorizontalCenter = 4,
|
||||
VerticalCenter = 5,
|
||||
Center = 6
|
||||
};
|
||||
Q_ENUM_NS(Anchor)
|
||||
#endif // Q_OS_WINDOWS
|
||||
|
||||
enum class ButtonState
|
||||
{
|
||||
|
@ -287,6 +285,7 @@ enum class ButtonState
|
|||
};
|
||||
Q_ENUM_NS(ButtonState)
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
enum class WindowsVersion
|
||||
{
|
||||
_2000 = 0,
|
||||
|
@ -318,6 +317,7 @@ enum class WindowsVersion
|
|||
Latest = _11_22H2
|
||||
};
|
||||
Q_ENUM_NS(WindowsVersion)
|
||||
#endif // Q_OS_WINDOWS
|
||||
|
||||
enum class ApplicationType
|
||||
{
|
||||
|
@ -493,6 +493,7 @@ struct SystemParameters
|
|||
}
|
||||
};
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
[[maybe_unused]] static constexpr const VersionNumber WindowsVersions[] =
|
||||
{
|
||||
{ 5, 0, 2195}, // Windows 2000
|
||||
|
@ -523,6 +524,7 @@ struct SystemParameters
|
|||
{10, 0, 22621}, // Windows 11 Version 22H2 (22H2)
|
||||
};
|
||||
static_assert(std::size(WindowsVersions) == (static_cast<int>(WindowsVersion::Latest) + 1));
|
||||
#endif // Q_OS_WINDOWS
|
||||
|
||||
struct VersionInfo
|
||||
{
|
||||
|
|
|
@ -35,14 +35,14 @@
|
|||
#ifndef FRAMELESSHELPER_QUICK_API
|
||||
# ifdef FRAMELESSHELPER_QUICK_STATIC
|
||||
# define FRAMELESSHELPER_QUICK_API
|
||||
# else
|
||||
# else // FRAMELESSHELPER_QUICK_STATIC
|
||||
# ifdef FRAMELESSHELPER_QUICK_LIBRARY
|
||||
# define FRAMELESSHELPER_QUICK_API Q_DECL_EXPORT
|
||||
# else
|
||||
# else // FRAMELESSHELPER_QUICK_LIBRARY
|
||||
# define FRAMELESSHELPER_QUICK_API Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
# endif // FRAMELESSHELPER_QUICK_LIBRARY
|
||||
# endif // FRAMELESSHELPER_QUICK_STATIC
|
||||
#endif // FRAMELESSHELPER_QUICK_API
|
||||
|
||||
#ifndef FRAMELESSHELPER_QUICK_ENUM_VALUE
|
||||
# define FRAMELESSHELPER_QUICK_ENUM_VALUE(Enum, Value) \
|
||||
|
@ -102,6 +102,7 @@ struct FRAMELESSHELPER_QUICK_API QuickGlobal
|
|||
};
|
||||
Q_ENUM(SystemButtonType)
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
enum class DwmColorizationArea
|
||||
{
|
||||
FRAMELESSHELPER_QUICK_ENUM_VALUE(DwmColorizationArea, None_)
|
||||
|
@ -110,18 +111,7 @@ struct FRAMELESSHELPER_QUICK_API QuickGlobal
|
|||
FRAMELESSHELPER_QUICK_ENUM_VALUE(DwmColorizationArea, All)
|
||||
};
|
||||
Q_ENUM(DwmColorizationArea)
|
||||
|
||||
enum class Anchor
|
||||
{
|
||||
FRAMELESSHELPER_QUICK_ENUM_VALUE(Anchor, Top)
|
||||
FRAMELESSHELPER_QUICK_ENUM_VALUE(Anchor, Bottom)
|
||||
FRAMELESSHELPER_QUICK_ENUM_VALUE(Anchor, Left)
|
||||
FRAMELESSHELPER_QUICK_ENUM_VALUE(Anchor, Right)
|
||||
FRAMELESSHELPER_QUICK_ENUM_VALUE(Anchor, HorizontalCenter)
|
||||
FRAMELESSHELPER_QUICK_ENUM_VALUE(Anchor, VerticalCenter)
|
||||
FRAMELESSHELPER_QUICK_ENUM_VALUE(Anchor, Center)
|
||||
};
|
||||
Q_ENUM(Anchor)
|
||||
#endif // Q_OS_WINDOWS
|
||||
|
||||
enum class ButtonState
|
||||
{
|
||||
|
@ -132,6 +122,7 @@ struct FRAMELESSHELPER_QUICK_API QuickGlobal
|
|||
};
|
||||
Q_ENUM(ButtonState)
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
enum class WindowsVersion
|
||||
{
|
||||
FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _2000)
|
||||
|
@ -164,6 +155,7 @@ struct FRAMELESSHELPER_QUICK_API QuickGlobal
|
|||
};
|
||||
Q_ENUM(WindowsVersion)
|
||||
static_assert(static_cast<int>(WindowsVersion::Latest) == static_cast<int>(Global::WindowsVersion::Latest));
|
||||
#endif // Q_OS_WINDOWS
|
||||
|
||||
enum class ApplicationType
|
||||
{
|
||||
|
|
|
@ -143,10 +143,13 @@ void initialize()
|
|||
qRegisterMetaType<Option>();
|
||||
qRegisterMetaType<SystemTheme>();
|
||||
qRegisterMetaType<SystemButtonType>();
|
||||
#ifdef Q_OS_WINDOWS
|
||||
qRegisterMetaType<DwmColorizationArea>();
|
||||
qRegisterMetaType<Anchor>();
|
||||
#endif
|
||||
qRegisterMetaType<ButtonState>();
|
||||
#ifdef Q_OS_WINDOWS
|
||||
qRegisterMetaType<WindowsVersion>();
|
||||
#endif
|
||||
qRegisterMetaType<ApplicationType>();
|
||||
qRegisterMetaType<BlurMode>();
|
||||
qRegisterMetaType<WallpaperAspectStyle>();
|
||||
|
|
|
@ -133,6 +133,7 @@ FRAMELESSHELPER_STRING_CONSTANT(GetScaleFactorForMonitor)
|
|||
FRAMELESSHELPER_STRING_CONSTANT(WallpaperStyle)
|
||||
FRAMELESSHELPER_STRING_CONSTANT(TileWallpaper)
|
||||
FRAMELESSHELPER_STRING_CONSTANT(UnregisterClassW)
|
||||
FRAMELESSHELPER_STRING_CONSTANT(DestroyWindow)
|
||||
|
||||
struct Win32UtilsHelperData
|
||||
{
|
||||
|
@ -185,9 +186,9 @@ class HumbleComPtr
|
|||
public:
|
||||
explicit HumbleComPtr() = default;
|
||||
|
||||
explicit HumbleComPtr(std::nullptr_t ptr)
|
||||
explicit HumbleComPtr(T *ptr)
|
||||
{
|
||||
Q_UNUSED(ptr);
|
||||
p = ptr;
|
||||
}
|
||||
|
||||
~HumbleComPtr()
|
||||
|
@ -234,14 +235,19 @@ private:
|
|||
|
||||
struct WindowClassCleaner
|
||||
{
|
||||
explicit WindowClassCleaner(const std::wstring &name)
|
||||
explicit WindowClassCleaner(const HWND hWnd, const std::wstring &Class) : _hWnd(hWnd), _Class(Class)
|
||||
{
|
||||
this->name = name;
|
||||
Q_ASSERT(_hWnd);
|
||||
Q_ASSERT(!_Class.empty());
|
||||
}
|
||||
|
||||
~WindowClassCleaner()
|
||||
{
|
||||
if (name.empty()) {
|
||||
if (!_hWnd || _Class.empty()) {
|
||||
return;
|
||||
}
|
||||
if (DestroyWindow(_hWnd) == FALSE) {
|
||||
WARNING << Utils::getSystemErrorMessage(kDestroyWindow);
|
||||
return;
|
||||
}
|
||||
const HINSTANCE instance = GetModuleHandleW(nullptr);
|
||||
|
@ -249,7 +255,7 @@ struct WindowClassCleaner
|
|||
WARNING << Utils::getSystemErrorMessage(kGetModuleHandleW);
|
||||
return;
|
||||
}
|
||||
if (UnregisterClassW(name.c_str(), instance) == FALSE) {
|
||||
if (UnregisterClassW(_Class.c_str(), instance) == FALSE) {
|
||||
WARNING << Utils::getSystemErrorMessage(kUnregisterClassW);
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +264,8 @@ private:
|
|||
Q_DISABLE_COPY_MOVE(WindowClassCleaner)
|
||||
|
||||
private:
|
||||
std::wstring name = {};
|
||||
const HWND _hWnd = nullptr;
|
||||
const std::wstring _Class = {};
|
||||
};
|
||||
|
||||
[[nodiscard]] static inline QString hkcuRegistryKey()
|
||||
|
@ -304,7 +311,6 @@ private:
|
|||
WARNING << Utils::getSystemErrorMessage(kRegisterClassExW);
|
||||
return nullptr;
|
||||
}
|
||||
static const auto cleaner = WindowClassCleaner(kDummyWindowClassName);
|
||||
}
|
||||
const HWND window = CreateWindowExW(0, kDummyWindowClassName, nullptr,
|
||||
WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, nullptr, nullptr, instance, nullptr);
|
||||
|
@ -312,6 +318,7 @@ private:
|
|||
WARNING << Utils::getSystemErrorMessage(kCreateWindowExW);
|
||||
return nullptr;
|
||||
}
|
||||
static const auto cleaner = WindowClassCleaner(window, kDummyWindowClassName);
|
||||
return window;
|
||||
}();
|
||||
return hwnd;
|
||||
|
|
|
@ -74,10 +74,13 @@ void FramelessHelper::Quick::registerTypes(QQmlEngine *engine)
|
|||
|
||||
qRegisterMetaType<QuickGlobal::SystemTheme>();
|
||||
qRegisterMetaType<QuickGlobal::SystemButtonType>();
|
||||
#ifdef Q_OS_WINDOWS
|
||||
qRegisterMetaType<QuickGlobal::DwmColorizationArea>();
|
||||
qRegisterMetaType<QuickGlobal::Anchor>();
|
||||
#endif
|
||||
qRegisterMetaType<QuickGlobal::ButtonState>();
|
||||
#ifdef Q_OS_WINDOWS
|
||||
qRegisterMetaType<QuickGlobal::WindowsVersion>();
|
||||
#endif
|
||||
qRegisterMetaType<QuickGlobal::ApplicationType>();
|
||||
qRegisterMetaType<QuickGlobal::BlurMode>();
|
||||
|
||||
|
@ -96,6 +99,7 @@ void FramelessHelper::Quick::registerTypes(QQmlEngine *engine)
|
|||
qRegisterMetaType<QuickMicaMaterialPrivate>();
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
|
||||
// @uri org.wangwenx190.FramelessHelper
|
||||
qmlRegisterUncreatableType<QuickGlobal>(QUICK_URI_FULL, "FramelessHelperConstants",
|
||||
FRAMELESSHELPER_STRING_LITERAL("The FramelessHelperConstants namespace is not creatable, you can only use it to access it's enums."));
|
||||
qmlRegisterSingletonType<FramelessQuickUtils>(QUICK_URI_EXPAND("FramelessUtils"),
|
||||
|
|
Loading…
Reference in New Issue