forked from github_mirror/framelesshelper
code simplification, minor re-structure
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
b413d0b1e6
commit
2806cc811b
|
@ -32,7 +32,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// Not necessary, but better call this function, before the construction
|
// Not necessary, but better call this function, before the construction
|
||||||
// of any Q(Core|Gui)Application instances.
|
// of any Q(Core|Gui)Application instances.
|
||||||
FramelessHelper::Core::initialize();
|
FramelessHelper::Widgets::initialize();
|
||||||
|
|
||||||
QApplication application(argc, argv);
|
QApplication application(argc, argv);
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// Not necessary, but better call this function, before the construction
|
// Not necessary, but better call this function, before the construction
|
||||||
// of any Q(Core|Gui)Application instances.
|
// of any Q(Core|Gui)Application instances.
|
||||||
FramelessHelper::Core::initialize();
|
FramelessHelper::Widgets::initialize();
|
||||||
|
|
||||||
QApplication application(argc, argv);
|
QApplication application(argc, argv);
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// Not necessary, but better call this function, before the construction
|
// Not necessary, but better call this function, before the construction
|
||||||
// of any Q(Core|Gui)Application instances.
|
// of any Q(Core|Gui)Application instances.
|
||||||
FramelessHelper::Core::initialize();
|
FramelessHelper::Quick::initialize();
|
||||||
|
|
||||||
QGuiApplication application(argc, argv);
|
QGuiApplication application(argc, argv);
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// Not necessary, but better call this function, before the construction
|
// Not necessary, but better call this function, before the construction
|
||||||
// of any Q(Core|Gui)Application instances.
|
// of any Q(Core|Gui)Application instances.
|
||||||
FramelessHelper::Core::initialize();
|
FramelessHelper::Quick::initialize();
|
||||||
|
|
||||||
QGuiApplication application(argc, argv);
|
QGuiApplication application(argc, argv);
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// Not necessary, but better call this function, before the construction
|
// Not necessary, but better call this function, before the construction
|
||||||
// of any Q(Core|Gui)Application instances.
|
// of any Q(Core|Gui)Application instances.
|
||||||
FramelessHelper::Core::initialize();
|
FramelessHelper::Widgets::initialize();
|
||||||
|
|
||||||
QApplication application(argc, argv);
|
QApplication application(argc, argv);
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// Not necessary, but better call this function, before the construction
|
// Not necessary, but better call this function, before the construction
|
||||||
// of any Q(Core|Gui)Application instances.
|
// of any Q(Core|Gui)Application instances.
|
||||||
FramelessHelper::Core::initialize();
|
FramelessHelper::Widgets::initialize();
|
||||||
|
|
||||||
QApplication application(argc, argv);
|
QApplication application(argc, argv);
|
||||||
|
|
||||||
|
|
|
@ -124,3 +124,5 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(ChromePalette))
|
||||||
|
|
|
@ -45,3 +45,5 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessHelperQt))
|
||||||
|
|
|
@ -43,3 +43,5 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessHelperWin))
|
||||||
|
|
|
@ -160,8 +160,7 @@
|
||||||
using NTSTATUS = LONG;
|
using NTSTATUS = LONG;
|
||||||
|
|
||||||
#ifndef WINMMAPI
|
#ifndef WINMMAPI
|
||||||
|
# define WINMMAPI DECLSPEC_IMPORT
|
||||||
#define WINMMAPI EXTERN_C DECLSPEC_IMPORT
|
|
||||||
|
|
||||||
using MMRESULT = UINT;
|
using MMRESULT = UINT;
|
||||||
|
|
||||||
|
@ -173,7 +172,6 @@ using TIMECAPS = struct TIMECAPS
|
||||||
using PTIMECAPS = TIMECAPS *;
|
using PTIMECAPS = TIMECAPS *;
|
||||||
using NPTIMECAPS = TIMECAPS NEAR *;
|
using NPTIMECAPS = TIMECAPS NEAR *;
|
||||||
using LPTIMECAPS = TIMECAPS FAR *;
|
using LPTIMECAPS = TIMECAPS FAR *;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using PROCESS_DPI_AWARENESS = enum PROCESS_DPI_AWARENESS
|
using PROCESS_DPI_AWARENESS = enum PROCESS_DPI_AWARENESS
|
||||||
|
@ -290,6 +288,8 @@ using LPWINDOWCOMPOSITIONATTRIBDATA = WINDOWCOMPOSITIONATTRIBDATA FAR *;
|
||||||
using GetWindowCompositionAttributePtr = BOOL(WINAPI *)(HWND, PWINDOWCOMPOSITIONATTRIBDATA);
|
using GetWindowCompositionAttributePtr = BOOL(WINAPI *)(HWND, PWINDOWCOMPOSITIONATTRIBDATA);
|
||||||
using SetWindowCompositionAttributePtr = BOOL(WINAPI *)(HWND, PWINDOWCOMPOSITIONATTRIBDATA);
|
using SetWindowCompositionAttributePtr = BOOL(WINAPI *)(HWND, PWINDOWCOMPOSITIONATTRIBDATA);
|
||||||
|
|
||||||
|
EXTERN_C_START
|
||||||
|
|
||||||
WINMMAPI MMRESULT WINAPI
|
WINMMAPI MMRESULT WINAPI
|
||||||
timeGetDevCaps(
|
timeGetDevCaps(
|
||||||
_Out_writes_bytes_(cbtc) LPTIMECAPS ptc,
|
_Out_writes_bytes_(cbtc) LPTIMECAPS ptc,
|
||||||
|
@ -306,12 +306,12 @@ timeEndPeriod(
|
||||||
_In_ UINT uPeriod
|
_In_ UINT uPeriod
|
||||||
);
|
);
|
||||||
|
|
||||||
EXTERN_C HRESULT WINAPI
|
DECLSPEC_IMPORT HRESULT WINAPI
|
||||||
SetProcessDpiAwareness(
|
SetProcessDpiAwareness(
|
||||||
_In_ PROCESS_DPI_AWARENESS value
|
_In_ PROCESS_DPI_AWARENESS value
|
||||||
);
|
);
|
||||||
|
|
||||||
EXTERN_C HRESULT WINAPI
|
DECLSPEC_IMPORT HRESULT WINAPI
|
||||||
GetDpiForMonitor(
|
GetDpiForMonitor(
|
||||||
_In_ HMONITOR hMonitor,
|
_In_ HMONITOR hMonitor,
|
||||||
_In_ MONITOR_DPI_TYPE dpiType,
|
_In_ MONITOR_DPI_TYPE dpiType,
|
||||||
|
@ -350,6 +350,8 @@ SetProcessDPIAware(
|
||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
|
EXTERN_C_END
|
||||||
|
|
||||||
[[maybe_unused]] static constexpr const int kAutoHideTaskBarThickness = 2; // The thickness of an auto-hide taskbar in pixels.
|
[[maybe_unused]] static constexpr const int kAutoHideTaskBarThickness = 2; // The thickness of an auto-hide taskbar in pixels.
|
||||||
|
|
||||||
[[maybe_unused]] static constexpr const wchar_t kDwmRegistryKey[] = LR"(Software\Microsoft\Windows\DWM)";
|
[[maybe_unused]] static constexpr const wchar_t kDwmRegistryKey[] = LR"(Software\Microsoft\Windows\DWM)";
|
||||||
|
|
|
@ -59,3 +59,5 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessManager))
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "framelesshelpercore_global.h"
|
#include "framelesshelpercore_global.h"
|
||||||
#include <QtCore/qobject.h>
|
#include <QtCore/qobject.h>
|
||||||
#include <QtCore/qpointer.h>
|
#include <QtCore/qpointer.h>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
@ -39,23 +40,6 @@ class FRAMELESSHELPER_CORE_API ChromePalettePrivate : public QObject
|
||||||
Q_DISABLE_COPY_MOVE(ChromePalettePrivate)
|
Q_DISABLE_COPY_MOVE(ChromePalettePrivate)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class MaskFlag
|
|
||||||
{
|
|
||||||
TitleBarActiveBackgroundColor = 0x00000001,
|
|
||||||
TitleBarInactiveBackgroundColor = 0x00000002,
|
|
||||||
TitleBarActiveForegroundColor = 0x00000004,
|
|
||||||
TitleBarInactiveForegroundColor = 0x00000008,
|
|
||||||
ChromeButtonNormalColor = 0x00000010,
|
|
||||||
ChromeButtonHoverColor = 0x00000020,
|
|
||||||
ChromeButtonPressColor = 0x00000040,
|
|
||||||
CloseButtonNormalColor = 0x00000080,
|
|
||||||
CloseButtonHoverColor = 0x00000100,
|
|
||||||
CloseButtonPressColor = 0x00000200
|
|
||||||
};
|
|
||||||
Q_ENUM(MaskFlag)
|
|
||||||
Q_DECLARE_FLAGS(Mask, MaskFlag)
|
|
||||||
Q_FLAG(Mask)
|
|
||||||
|
|
||||||
explicit ChromePalettePrivate(ChromePalette *q);
|
explicit ChromePalettePrivate(ChromePalette *q);
|
||||||
~ChromePalettePrivate() override;
|
~ChromePalettePrivate() override;
|
||||||
|
|
||||||
|
@ -67,7 +51,6 @@ public Q_SLOTS:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<ChromePalette> q_ptr = nullptr;
|
QPointer<ChromePalette> q_ptr = nullptr;
|
||||||
Mask mask = {};
|
|
||||||
// System-defined ones:
|
// System-defined ones:
|
||||||
QColor titleBarActiveBackgroundColor_sys = {};
|
QColor titleBarActiveBackgroundColor_sys = {};
|
||||||
QColor titleBarInactiveBackgroundColor_sys = {};
|
QColor titleBarInactiveBackgroundColor_sys = {};
|
||||||
|
@ -80,18 +63,18 @@ private:
|
||||||
QColor closeButtonHoverColor_sys = {};
|
QColor closeButtonHoverColor_sys = {};
|
||||||
QColor closeButtonPressColor_sys = {};
|
QColor closeButtonPressColor_sys = {};
|
||||||
// User-defined ones:
|
// User-defined ones:
|
||||||
QColor titleBarActiveBackgroundColor = {};
|
std::optional<QColor> titleBarActiveBackgroundColor = std::nullopt;
|
||||||
QColor titleBarInactiveBackgroundColor = {};
|
std::optional<QColor> titleBarInactiveBackgroundColor = std::nullopt;
|
||||||
QColor titleBarActiveForegroundColor = {};
|
std::optional<QColor> titleBarActiveForegroundColor = std::nullopt;
|
||||||
QColor titleBarInactiveForegroundColor = {};
|
std::optional<QColor> titleBarInactiveForegroundColor = std::nullopt;
|
||||||
QColor chromeButtonNormalColor = {};
|
std::optional<QColor> chromeButtonNormalColor = std::nullopt;
|
||||||
QColor chromeButtonHoverColor = {};
|
std::optional<QColor> chromeButtonHoverColor = std::nullopt;
|
||||||
QColor chromeButtonPressColor = {};
|
std::optional<QColor> chromeButtonPressColor = std::nullopt;
|
||||||
QColor closeButtonNormalColor = {};
|
std::optional<QColor> closeButtonNormalColor = std::nullopt;
|
||||||
QColor closeButtonHoverColor = {};
|
std::optional<QColor> closeButtonHoverColor = std::nullopt;
|
||||||
QColor closeButtonPressColor = {};
|
std::optional<QColor> closeButtonPressColor = std::nullopt;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(ChromePalettePrivate::Mask)
|
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(ChromePalettePrivate))
|
||||||
|
|
|
@ -50,3 +50,5 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessConfig))
|
||||||
|
|
|
@ -66,3 +66,5 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessManagerPrivate))
|
||||||
|
|
|
@ -63,6 +63,8 @@ private:
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(SysApiLoader))
|
||||||
|
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
# define API_WIN_AVAILABLE(lib, func) (SysApiLoader::instance()->isAvailable(k##lib, k##func))
|
# define API_WIN_AVAILABLE(lib, func) (SysApiLoader::instance()->isAvailable(k##lib, k##func))
|
||||||
# define API_USER_AVAILABLE(func) API_WIN_AVAILABLE(user32, func)
|
# define API_USER_AVAILABLE(func) API_WIN_AVAILABLE(user32, func)
|
||||||
|
|
|
@ -190,4 +190,12 @@ private:
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace FramelessHelper::Quick
|
||||||
|
{
|
||||||
|
FRAMELESSHELPER_QUICK_API void initialize();
|
||||||
|
FRAMELESSHELPER_QUICK_API void uninitialize();
|
||||||
|
} // namespace FramelessHelper::Quick
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickGlobal))
|
||||||
|
|
|
@ -88,5 +88,6 @@ private:
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickHelper))
|
||||||
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickHelper))
|
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickHelper))
|
||||||
QML_DECLARE_TYPEINFO(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickHelper), QML_HAS_ATTACHED_PROPERTIES)
|
QML_DECLARE_TYPEINFO(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickHelper), QML_HAS_ATTACHED_PROPERTIES)
|
||||||
|
|
|
@ -86,4 +86,5 @@ Q_SIGNALS:
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickUtils))
|
||||||
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickUtils))
|
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickUtils))
|
||||||
|
|
|
@ -87,3 +87,5 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickHelperPrivate))
|
||||||
|
|
|
@ -80,5 +80,6 @@ private:
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickWindow))
|
||||||
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickWindow))
|
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickWindow))
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -82,4 +82,6 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickWindowPrivate))
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -95,5 +95,6 @@ private:
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardSystemButton))
|
||||||
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardSystemButton))
|
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardSystemButton))
|
||||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
|
|
|
@ -114,5 +114,6 @@ private:
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardTitleBar))
|
||||||
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardTitleBar))
|
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardTitleBar))
|
||||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
|
|
|
@ -45,4 +45,5 @@ public:
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickChromePalette))
|
||||||
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickChromePalette))
|
QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickChromePalette))
|
||||||
|
|
|
@ -37,3 +37,13 @@
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
namespace FramelessHelper::Widgets
|
||||||
|
{
|
||||||
|
FRAMELESSHELPER_WIDGETS_API void initialize();
|
||||||
|
FRAMELESSHELPER_WIDGETS_API void uninitialize();
|
||||||
|
} // namespace FramelessHelper::Widgets
|
||||||
|
|
||||||
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
|
@ -61,3 +61,5 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessMainWindow))
|
||||||
|
|
|
@ -61,3 +61,5 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessWidget))
|
||||||
|
|
|
@ -77,3 +77,5 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessWidgetsHelper))
|
||||||
|
|
|
@ -61,3 +61,5 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessMainWindowPrivate))
|
||||||
|
|
|
@ -61,3 +61,5 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessWidgetPrivate))
|
||||||
|
|
|
@ -84,3 +84,5 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessWidgetsHelperPrivate))
|
||||||
|
|
|
@ -92,3 +92,5 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(StandardSystemButtonPrivate))
|
||||||
|
|
|
@ -64,6 +64,9 @@ public:
|
||||||
|
|
||||||
void paintTitleBar(QPaintEvent *event);
|
void paintTitleBar(QPaintEvent *event);
|
||||||
|
|
||||||
|
Q_NODISCARD bool titleLabelVisible() const;
|
||||||
|
void setTitleLabelVisible(const bool value);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void updateMaximizeButton();
|
void updateMaximizeButton();
|
||||||
void updateTitleBarColor();
|
void updateTitleBarColor();
|
||||||
|
@ -86,6 +89,9 @@ private:
|
||||||
Qt::Alignment m_labelAlignment = {};
|
Qt::Alignment m_labelAlignment = {};
|
||||||
bool m_hideWhenClose = false;
|
bool m_hideWhenClose = false;
|
||||||
QScopedPointer<ChromePalette> m_chromePalette;
|
QScopedPointer<ChromePalette> m_chromePalette;
|
||||||
|
bool m_titleLabelVisible = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(StandardTitleBarPrivate))
|
||||||
|
|
|
@ -61,3 +61,5 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(WidgetsSharedHelper))
|
||||||
|
|
|
@ -90,3 +90,5 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(StandardSystemButton))
|
||||||
|
|
|
@ -45,6 +45,7 @@ class FRAMELESSHELPER_WIDGETS_API StandardTitleBar : public QWidget
|
||||||
Q_PROPERTY(bool extended READ isExtended WRITE setExtended NOTIFY extendedChanged FINAL)
|
Q_PROPERTY(bool extended READ isExtended WRITE setExtended NOTIFY extendedChanged FINAL)
|
||||||
Q_PROPERTY(bool hideWhenClose READ isHideWhenClose WRITE setHideWhenClose NOTIFY hideWhenCloseChanged FINAL)
|
Q_PROPERTY(bool hideWhenClose READ isHideWhenClose WRITE setHideWhenClose NOTIFY hideWhenCloseChanged FINAL)
|
||||||
Q_PROPERTY(ChromePalette* chromePalette READ chromePalette CONSTANT FINAL)
|
Q_PROPERTY(ChromePalette* chromePalette READ chromePalette CONSTANT FINAL)
|
||||||
|
Q_PROPERTY(bool titleLabelVisible READ titleLabelVisible WRITE setTitleLabelVisible NOTIFY titleLabelVisibleChanged FINAL)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit StandardTitleBar(QWidget *parent = nullptr);
|
explicit StandardTitleBar(QWidget *parent = nullptr);
|
||||||
|
@ -65,6 +66,9 @@ public:
|
||||||
|
|
||||||
Q_NODISCARD ChromePalette *chromePalette() const;
|
Q_NODISCARD ChromePalette *chromePalette() const;
|
||||||
|
|
||||||
|
Q_NODISCARD bool titleLabelVisible() const;
|
||||||
|
void setTitleLabelVisible(const bool value);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
|
|
||||||
|
@ -72,9 +76,12 @@ Q_SIGNALS:
|
||||||
void extendedChanged();
|
void extendedChanged();
|
||||||
void titleLabelAlignmentChanged();
|
void titleLabelAlignmentChanged();
|
||||||
void hideWhenCloseChanged();
|
void hideWhenCloseChanged();
|
||||||
|
void titleLabelVisibleChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<StandardTitleBarPrivate> d_ptr;
|
QScopedPointer<StandardTitleBarPrivate> d_ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(StandardTitleBar))
|
||||||
|
|
|
@ -54,6 +54,7 @@ set(SOURCES
|
||||||
framelessconfig.cpp
|
framelessconfig.cpp
|
||||||
sysapiloader.cpp
|
sysapiloader.cpp
|
||||||
chromepalette.cpp
|
chromepalette.cpp
|
||||||
|
global.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
@ -125,12 +126,12 @@ else()
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (APPLE)
|
if(APPLE)
|
||||||
target_link_libraries(${SUB_PROJ_NAME} PRIVATE
|
target_link_libraries(${SUB_PROJ_NAME} PRIVATE
|
||||||
"-framework Foundation"
|
"-framework Foundation"
|
||||||
"-framework Cocoa"
|
"-framework Cocoa"
|
||||||
)
|
)
|
||||||
elseif (UNIX)
|
elseif(UNIX)
|
||||||
target_compile_definitions(${SUB_PROJ_NAME} PRIVATE
|
target_compile_definitions(${SUB_PROJ_NAME} PRIVATE
|
||||||
GDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_6
|
GDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_6
|
||||||
)
|
)
|
||||||
|
|
|
@ -133,8 +133,8 @@ ChromePalette::~ChromePalette() = default;
|
||||||
QColor ChromePalette::titleBarActiveBackgroundColor() const
|
QColor ChromePalette::titleBarActiveBackgroundColor() const
|
||||||
{
|
{
|
||||||
Q_D(const ChromePalette);
|
Q_D(const ChromePalette);
|
||||||
if (d->mask & ChromePalettePrivate::MaskFlag::TitleBarActiveBackgroundColor) {
|
if (d->titleBarActiveBackgroundColor.has_value()) {
|
||||||
return d->titleBarActiveBackgroundColor;
|
return d->titleBarActiveBackgroundColor.value();
|
||||||
}
|
}
|
||||||
return d->titleBarActiveBackgroundColor_sys;
|
return d->titleBarActiveBackgroundColor_sys;
|
||||||
}
|
}
|
||||||
|
@ -142,8 +142,8 @@ QColor ChromePalette::titleBarActiveBackgroundColor() const
|
||||||
QColor ChromePalette::titleBarInactiveBackgroundColor() const
|
QColor ChromePalette::titleBarInactiveBackgroundColor() const
|
||||||
{
|
{
|
||||||
Q_D(const ChromePalette);
|
Q_D(const ChromePalette);
|
||||||
if (d->mask & ChromePalettePrivate::MaskFlag::TitleBarInactiveBackgroundColor) {
|
if (d->titleBarInactiveBackgroundColor.has_value()) {
|
||||||
return d->titleBarInactiveBackgroundColor;
|
return d->titleBarInactiveBackgroundColor.value();
|
||||||
}
|
}
|
||||||
return d->titleBarInactiveBackgroundColor_sys;
|
return d->titleBarInactiveBackgroundColor_sys;
|
||||||
}
|
}
|
||||||
|
@ -151,8 +151,8 @@ QColor ChromePalette::titleBarInactiveBackgroundColor() const
|
||||||
QColor ChromePalette::titleBarActiveForegroundColor() const
|
QColor ChromePalette::titleBarActiveForegroundColor() const
|
||||||
{
|
{
|
||||||
Q_D(const ChromePalette);
|
Q_D(const ChromePalette);
|
||||||
if (d->mask & ChromePalettePrivate::MaskFlag::TitleBarActiveForegroundColor) {
|
if (d->titleBarActiveForegroundColor.has_value()) {
|
||||||
return d->titleBarActiveForegroundColor;
|
return d->titleBarActiveForegroundColor.value();
|
||||||
}
|
}
|
||||||
return d->titleBarActiveForegroundColor_sys;
|
return d->titleBarActiveForegroundColor_sys;
|
||||||
}
|
}
|
||||||
|
@ -160,8 +160,8 @@ QColor ChromePalette::titleBarActiveForegroundColor() const
|
||||||
QColor ChromePalette::titleBarInactiveForegroundColor() const
|
QColor ChromePalette::titleBarInactiveForegroundColor() const
|
||||||
{
|
{
|
||||||
Q_D(const ChromePalette);
|
Q_D(const ChromePalette);
|
||||||
if (d->mask & ChromePalettePrivate::MaskFlag::TitleBarInactiveForegroundColor) {
|
if (d->titleBarInactiveForegroundColor.has_value()) {
|
||||||
return d->titleBarInactiveForegroundColor;
|
return d->titleBarInactiveForegroundColor.value();
|
||||||
}
|
}
|
||||||
return d->titleBarInactiveForegroundColor_sys;
|
return d->titleBarInactiveForegroundColor_sys;
|
||||||
}
|
}
|
||||||
|
@ -169,8 +169,8 @@ QColor ChromePalette::titleBarInactiveForegroundColor() const
|
||||||
QColor ChromePalette::chromeButtonNormalColor() const
|
QColor ChromePalette::chromeButtonNormalColor() const
|
||||||
{
|
{
|
||||||
Q_D(const ChromePalette);
|
Q_D(const ChromePalette);
|
||||||
if (d->mask & ChromePalettePrivate::MaskFlag::ChromeButtonNormalColor) {
|
if (d->chromeButtonNormalColor.has_value()) {
|
||||||
return d->chromeButtonNormalColor;
|
return d->chromeButtonNormalColor.value();
|
||||||
}
|
}
|
||||||
return d->chromeButtonNormalColor_sys;
|
return d->chromeButtonNormalColor_sys;
|
||||||
}
|
}
|
||||||
|
@ -178,8 +178,8 @@ QColor ChromePalette::chromeButtonNormalColor() const
|
||||||
QColor ChromePalette::chromeButtonHoverColor() const
|
QColor ChromePalette::chromeButtonHoverColor() const
|
||||||
{
|
{
|
||||||
Q_D(const ChromePalette);
|
Q_D(const ChromePalette);
|
||||||
if (d->mask & ChromePalettePrivate::MaskFlag::ChromeButtonHoverColor) {
|
if (d->chromeButtonHoverColor.has_value()) {
|
||||||
return d->chromeButtonHoverColor;
|
return d->chromeButtonHoverColor.value();
|
||||||
}
|
}
|
||||||
return d->chromeButtonHoverColor_sys;
|
return d->chromeButtonHoverColor_sys;
|
||||||
}
|
}
|
||||||
|
@ -187,8 +187,8 @@ QColor ChromePalette::chromeButtonHoverColor() const
|
||||||
QColor ChromePalette::chromeButtonPressColor() const
|
QColor ChromePalette::chromeButtonPressColor() const
|
||||||
{
|
{
|
||||||
Q_D(const ChromePalette);
|
Q_D(const ChromePalette);
|
||||||
if (d->mask & ChromePalettePrivate::MaskFlag::ChromeButtonPressColor) {
|
if (d->chromeButtonPressColor.has_value()) {
|
||||||
return d->chromeButtonPressColor;
|
return d->chromeButtonPressColor.value();
|
||||||
}
|
}
|
||||||
return d->chromeButtonPressColor_sys;
|
return d->chromeButtonPressColor_sys;
|
||||||
}
|
}
|
||||||
|
@ -196,8 +196,8 @@ QColor ChromePalette::chromeButtonPressColor() const
|
||||||
QColor ChromePalette::closeButtonNormalColor() const
|
QColor ChromePalette::closeButtonNormalColor() const
|
||||||
{
|
{
|
||||||
Q_D(const ChromePalette);
|
Q_D(const ChromePalette);
|
||||||
if (d->mask & ChromePalettePrivate::MaskFlag::CloseButtonNormalColor) {
|
if (d->closeButtonNormalColor.has_value()) {
|
||||||
return d->closeButtonNormalColor;
|
return d->closeButtonNormalColor.value();
|
||||||
}
|
}
|
||||||
return d->closeButtonNormalColor_sys;
|
return d->closeButtonNormalColor_sys;
|
||||||
}
|
}
|
||||||
|
@ -205,8 +205,8 @@ QColor ChromePalette::closeButtonNormalColor() const
|
||||||
QColor ChromePalette::closeButtonHoverColor() const
|
QColor ChromePalette::closeButtonHoverColor() const
|
||||||
{
|
{
|
||||||
Q_D(const ChromePalette);
|
Q_D(const ChromePalette);
|
||||||
if (d->mask & ChromePalettePrivate::MaskFlag::CloseButtonHoverColor) {
|
if (d->closeButtonHoverColor.has_value()) {
|
||||||
return d->closeButtonHoverColor;
|
return d->closeButtonHoverColor.value();
|
||||||
}
|
}
|
||||||
return d->closeButtonHoverColor_sys;
|
return d->closeButtonHoverColor_sys;
|
||||||
}
|
}
|
||||||
|
@ -214,8 +214,8 @@ QColor ChromePalette::closeButtonHoverColor() const
|
||||||
QColor ChromePalette::closeButtonPressColor() const
|
QColor ChromePalette::closeButtonPressColor() const
|
||||||
{
|
{
|
||||||
Q_D(const ChromePalette);
|
Q_D(const ChromePalette);
|
||||||
if (d->mask & ChromePalettePrivate::MaskFlag::CloseButtonPressColor) {
|
if (d->closeButtonPressColor.has_value()) {
|
||||||
return d->closeButtonPressColor;
|
return d->closeButtonPressColor.value();
|
||||||
}
|
}
|
||||||
return d->closeButtonPressColor_sys;
|
return d->closeButtonPressColor_sys;
|
||||||
}
|
}
|
||||||
|
@ -227,11 +227,11 @@ void ChromePalette::setTitleBarActiveBackgroundColor(const QColor &value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(ChromePalette);
|
Q_D(ChromePalette);
|
||||||
if (d->titleBarActiveBackgroundColor == value) {
|
if (d->titleBarActiveBackgroundColor.has_value()
|
||||||
|
&& (d->titleBarActiveBackgroundColor.value() == value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->titleBarActiveBackgroundColor = value;
|
d->titleBarActiveBackgroundColor = value;
|
||||||
d->mask |= ChromePalettePrivate::MaskFlag::TitleBarActiveBackgroundColor;
|
|
||||||
Q_EMIT titleBarActiveBackgroundColorChanged();
|
Q_EMIT titleBarActiveBackgroundColorChanged();
|
||||||
Q_EMIT titleBarColorChanged();
|
Q_EMIT titleBarColorChanged();
|
||||||
}
|
}
|
||||||
|
@ -239,8 +239,7 @@ void ChromePalette::setTitleBarActiveBackgroundColor(const QColor &value)
|
||||||
void ChromePalette::resetTitleBarActiveBackgroundColor()
|
void ChromePalette::resetTitleBarActiveBackgroundColor()
|
||||||
{
|
{
|
||||||
Q_D(ChromePalette);
|
Q_D(ChromePalette);
|
||||||
d->titleBarActiveBackgroundColor = {};
|
d->titleBarActiveBackgroundColor = std::nullopt;
|
||||||
d->mask &= ~ChromePalettePrivate::Mask(ChromePalettePrivate::MaskFlag::TitleBarActiveBackgroundColor);
|
|
||||||
Q_EMIT titleBarActiveBackgroundColorChanged();
|
Q_EMIT titleBarActiveBackgroundColorChanged();
|
||||||
Q_EMIT titleBarColorChanged();
|
Q_EMIT titleBarColorChanged();
|
||||||
}
|
}
|
||||||
|
@ -252,11 +251,11 @@ void ChromePalette::setTitleBarInactiveBackgroundColor(const QColor &value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(ChromePalette);
|
Q_D(ChromePalette);
|
||||||
if (d->titleBarInactiveBackgroundColor == value) {
|
if (d->titleBarInactiveBackgroundColor.has_value()
|
||||||
|
&& (d->titleBarInactiveBackgroundColor.value() == value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->titleBarInactiveBackgroundColor = value;
|
d->titleBarInactiveBackgroundColor = value;
|
||||||
d->mask |= ChromePalettePrivate::MaskFlag::TitleBarInactiveBackgroundColor;
|
|
||||||
Q_EMIT titleBarInactiveBackgroundColorChanged();
|
Q_EMIT titleBarInactiveBackgroundColorChanged();
|
||||||
Q_EMIT titleBarColorChanged();
|
Q_EMIT titleBarColorChanged();
|
||||||
}
|
}
|
||||||
|
@ -264,8 +263,7 @@ void ChromePalette::setTitleBarInactiveBackgroundColor(const QColor &value)
|
||||||
void ChromePalette::resetTitleBarInactiveBackgroundColor()
|
void ChromePalette::resetTitleBarInactiveBackgroundColor()
|
||||||
{
|
{
|
||||||
Q_D(ChromePalette);
|
Q_D(ChromePalette);
|
||||||
d->titleBarInactiveBackgroundColor = {};
|
d->titleBarInactiveBackgroundColor = std::nullopt;
|
||||||
d->mask &= ~ChromePalettePrivate::Mask(ChromePalettePrivate::MaskFlag::TitleBarInactiveBackgroundColor);
|
|
||||||
Q_EMIT titleBarInactiveBackgroundColorChanged();
|
Q_EMIT titleBarInactiveBackgroundColorChanged();
|
||||||
Q_EMIT titleBarColorChanged();
|
Q_EMIT titleBarColorChanged();
|
||||||
}
|
}
|
||||||
|
@ -277,11 +275,11 @@ void ChromePalette::setTitleBarActiveForegroundColor(const QColor &value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(ChromePalette);
|
Q_D(ChromePalette);
|
||||||
if (d->titleBarActiveForegroundColor == value) {
|
if (d->titleBarActiveForegroundColor.has_value()
|
||||||
|
&& (d->titleBarActiveForegroundColor.value() == value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->titleBarActiveForegroundColor = value;
|
d->titleBarActiveForegroundColor = value;
|
||||||
d->mask |= ChromePalettePrivate::MaskFlag::TitleBarActiveForegroundColor;
|
|
||||||
Q_EMIT titleBarActiveForegroundColorChanged();
|
Q_EMIT titleBarActiveForegroundColorChanged();
|
||||||
Q_EMIT titleBarColorChanged();
|
Q_EMIT titleBarColorChanged();
|
||||||
}
|
}
|
||||||
|
@ -289,8 +287,7 @@ void ChromePalette::setTitleBarActiveForegroundColor(const QColor &value)
|
||||||
void ChromePalette::resetTitleBarActiveForegroundColor()
|
void ChromePalette::resetTitleBarActiveForegroundColor()
|
||||||
{
|
{
|
||||||
Q_D(ChromePalette);
|
Q_D(ChromePalette);
|
||||||
d->titleBarActiveForegroundColor = {};
|
d->titleBarActiveForegroundColor = std::nullopt;
|
||||||
d->mask &= ~ChromePalettePrivate::Mask(ChromePalettePrivate::MaskFlag::TitleBarActiveForegroundColor);
|
|
||||||
Q_EMIT titleBarActiveForegroundColorChanged();
|
Q_EMIT titleBarActiveForegroundColorChanged();
|
||||||
Q_EMIT titleBarColorChanged();
|
Q_EMIT titleBarColorChanged();
|
||||||
}
|
}
|
||||||
|
@ -302,11 +299,11 @@ void ChromePalette::setTitleBarInactiveForegroundColor(const QColor &value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(ChromePalette);
|
Q_D(ChromePalette);
|
||||||
if (d->titleBarInactiveForegroundColor == value) {
|
if (d->titleBarInactiveForegroundColor.has_value()
|
||||||
|
&& (d->titleBarInactiveForegroundColor.value() == value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->titleBarInactiveForegroundColor = value;
|
d->titleBarInactiveForegroundColor = value;
|
||||||
d->mask |= ChromePalettePrivate::MaskFlag::TitleBarInactiveForegroundColor;
|
|
||||||
Q_EMIT titleBarInactiveForegroundColorChanged();
|
Q_EMIT titleBarInactiveForegroundColorChanged();
|
||||||
Q_EMIT titleBarColorChanged();
|
Q_EMIT titleBarColorChanged();
|
||||||
}
|
}
|
||||||
|
@ -314,8 +311,7 @@ void ChromePalette::setTitleBarInactiveForegroundColor(const QColor &value)
|
||||||
void ChromePalette::resetTitleBarInactiveForegroundColor()
|
void ChromePalette::resetTitleBarInactiveForegroundColor()
|
||||||
{
|
{
|
||||||
Q_D(ChromePalette);
|
Q_D(ChromePalette);
|
||||||
d->titleBarInactiveForegroundColor = {};
|
d->titleBarInactiveForegroundColor = std::nullopt;
|
||||||
d->mask &= ~ChromePalettePrivate::Mask(ChromePalettePrivate::MaskFlag::TitleBarInactiveForegroundColor);
|
|
||||||
Q_EMIT titleBarInactiveForegroundColorChanged();
|
Q_EMIT titleBarInactiveForegroundColorChanged();
|
||||||
Q_EMIT titleBarColorChanged();
|
Q_EMIT titleBarColorChanged();
|
||||||
}
|
}
|
||||||
|
@ -327,11 +323,11 @@ void ChromePalette::setChromeButtonNormalColor(const QColor &value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(ChromePalette);
|
Q_D(ChromePalette);
|
||||||
if (d->chromeButtonNormalColor == value) {
|
if (d->chromeButtonNormalColor.has_value()
|
||||||
|
&& (d->chromeButtonNormalColor.value() == value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->chromeButtonNormalColor = value;
|
d->chromeButtonNormalColor = value;
|
||||||
d->mask |= ChromePalettePrivate::MaskFlag::ChromeButtonNormalColor;
|
|
||||||
Q_EMIT chromeButtonNormalColorChanged();
|
Q_EMIT chromeButtonNormalColorChanged();
|
||||||
Q_EMIT chromeButtonColorChanged();
|
Q_EMIT chromeButtonColorChanged();
|
||||||
}
|
}
|
||||||
|
@ -339,8 +335,7 @@ void ChromePalette::setChromeButtonNormalColor(const QColor &value)
|
||||||
void ChromePalette::resetChromeButtonNormalColor()
|
void ChromePalette::resetChromeButtonNormalColor()
|
||||||
{
|
{
|
||||||
Q_D(ChromePalette);
|
Q_D(ChromePalette);
|
||||||
d->chromeButtonNormalColor = {};
|
d->chromeButtonNormalColor = std::nullopt;
|
||||||
d->mask &= ~ChromePalettePrivate::Mask(ChromePalettePrivate::MaskFlag::ChromeButtonNormalColor);
|
|
||||||
Q_EMIT chromeButtonNormalColorChanged();
|
Q_EMIT chromeButtonNormalColorChanged();
|
||||||
Q_EMIT chromeButtonColorChanged();
|
Q_EMIT chromeButtonColorChanged();
|
||||||
}
|
}
|
||||||
|
@ -352,11 +347,11 @@ void ChromePalette::setChromeButtonHoverColor(const QColor &value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(ChromePalette);
|
Q_D(ChromePalette);
|
||||||
if (d->chromeButtonHoverColor == value) {
|
if (d->chromeButtonHoverColor.has_value()
|
||||||
|
&& (d->chromeButtonHoverColor.value() == value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->chromeButtonHoverColor = value;
|
d->chromeButtonHoverColor = value;
|
||||||
d->mask |= ChromePalettePrivate::MaskFlag::ChromeButtonHoverColor;
|
|
||||||
Q_EMIT chromeButtonHoverColorChanged();
|
Q_EMIT chromeButtonHoverColorChanged();
|
||||||
Q_EMIT chromeButtonColorChanged();
|
Q_EMIT chromeButtonColorChanged();
|
||||||
}
|
}
|
||||||
|
@ -364,8 +359,7 @@ void ChromePalette::setChromeButtonHoverColor(const QColor &value)
|
||||||
void ChromePalette::resetChromeButtonHoverColor()
|
void ChromePalette::resetChromeButtonHoverColor()
|
||||||
{
|
{
|
||||||
Q_D(ChromePalette);
|
Q_D(ChromePalette);
|
||||||
d->chromeButtonHoverColor = {};
|
d->chromeButtonHoverColor = std::nullopt;
|
||||||
d->mask &= ~ChromePalettePrivate::Mask(ChromePalettePrivate::MaskFlag::ChromeButtonHoverColor);
|
|
||||||
Q_EMIT chromeButtonHoverColorChanged();
|
Q_EMIT chromeButtonHoverColorChanged();
|
||||||
Q_EMIT chromeButtonColorChanged();
|
Q_EMIT chromeButtonColorChanged();
|
||||||
}
|
}
|
||||||
|
@ -377,11 +371,11 @@ void ChromePalette::setChromeButtonPressColor(const QColor &value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(ChromePalette);
|
Q_D(ChromePalette);
|
||||||
if (d->chromeButtonPressColor == value) {
|
if (d->chromeButtonPressColor.has_value()
|
||||||
|
&& (d->chromeButtonPressColor.value() == value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->chromeButtonPressColor = value;
|
d->chromeButtonPressColor = value;
|
||||||
d->mask |= ChromePalettePrivate::MaskFlag::ChromeButtonPressColor;
|
|
||||||
Q_EMIT chromeButtonPressColorChanged();
|
Q_EMIT chromeButtonPressColorChanged();
|
||||||
Q_EMIT chromeButtonColorChanged();
|
Q_EMIT chromeButtonColorChanged();
|
||||||
}
|
}
|
||||||
|
@ -389,8 +383,7 @@ void ChromePalette::setChromeButtonPressColor(const QColor &value)
|
||||||
void ChromePalette::resetChromeButtonPressColor()
|
void ChromePalette::resetChromeButtonPressColor()
|
||||||
{
|
{
|
||||||
Q_D(ChromePalette);
|
Q_D(ChromePalette);
|
||||||
d->chromeButtonPressColor = {};
|
d->chromeButtonPressColor = std::nullopt;
|
||||||
d->mask &= ~ChromePalettePrivate::Mask(ChromePalettePrivate::MaskFlag::ChromeButtonPressColor);
|
|
||||||
Q_EMIT chromeButtonPressColorChanged();
|
Q_EMIT chromeButtonPressColorChanged();
|
||||||
Q_EMIT chromeButtonColorChanged();
|
Q_EMIT chromeButtonColorChanged();
|
||||||
}
|
}
|
||||||
|
@ -402,11 +395,11 @@ void ChromePalette::setCloseButtonNormalColor(const QColor &value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(ChromePalette);
|
Q_D(ChromePalette);
|
||||||
if (d->closeButtonNormalColor == value) {
|
if (d->closeButtonNormalColor.has_value()
|
||||||
|
&& (d->closeButtonNormalColor.value() == value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->closeButtonNormalColor = value;
|
d->closeButtonNormalColor = value;
|
||||||
d->mask |= ChromePalettePrivate::MaskFlag::CloseButtonNormalColor;
|
|
||||||
Q_EMIT closeButtonNormalColorChanged();
|
Q_EMIT closeButtonNormalColorChanged();
|
||||||
Q_EMIT chromeButtonColorChanged();
|
Q_EMIT chromeButtonColorChanged();
|
||||||
}
|
}
|
||||||
|
@ -414,8 +407,7 @@ void ChromePalette::setCloseButtonNormalColor(const QColor &value)
|
||||||
void ChromePalette::resetCloseButtonNormalColor()
|
void ChromePalette::resetCloseButtonNormalColor()
|
||||||
{
|
{
|
||||||
Q_D(ChromePalette);
|
Q_D(ChromePalette);
|
||||||
d->closeButtonNormalColor = {};
|
d->closeButtonNormalColor = std::nullopt;
|
||||||
d->mask &= ~ChromePalettePrivate::Mask(ChromePalettePrivate::MaskFlag::CloseButtonNormalColor);
|
|
||||||
Q_EMIT closeButtonNormalColorChanged();
|
Q_EMIT closeButtonNormalColorChanged();
|
||||||
Q_EMIT chromeButtonColorChanged();
|
Q_EMIT chromeButtonColorChanged();
|
||||||
}
|
}
|
||||||
|
@ -427,11 +419,11 @@ void ChromePalette::setCloseButtonHoverColor(const QColor &value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(ChromePalette);
|
Q_D(ChromePalette);
|
||||||
if (d->closeButtonHoverColor == value) {
|
if (d->closeButtonHoverColor.has_value()
|
||||||
|
&& (d->closeButtonHoverColor.value() == value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->closeButtonHoverColor = value;
|
d->closeButtonHoverColor = value;
|
||||||
d->mask |= ChromePalettePrivate::MaskFlag::CloseButtonHoverColor;
|
|
||||||
Q_EMIT closeButtonHoverColorChanged();
|
Q_EMIT closeButtonHoverColorChanged();
|
||||||
Q_EMIT chromeButtonColorChanged();
|
Q_EMIT chromeButtonColorChanged();
|
||||||
}
|
}
|
||||||
|
@ -439,8 +431,7 @@ void ChromePalette::setCloseButtonHoverColor(const QColor &value)
|
||||||
void ChromePalette::resetCloseButtonHoverColor()
|
void ChromePalette::resetCloseButtonHoverColor()
|
||||||
{
|
{
|
||||||
Q_D(ChromePalette);
|
Q_D(ChromePalette);
|
||||||
d->closeButtonHoverColor = {};
|
d->closeButtonHoverColor = std::nullopt;
|
||||||
d->mask &= ~ChromePalettePrivate::Mask(ChromePalettePrivate::MaskFlag::CloseButtonHoverColor);
|
|
||||||
Q_EMIT closeButtonHoverColorChanged();
|
Q_EMIT closeButtonHoverColorChanged();
|
||||||
Q_EMIT chromeButtonColorChanged();
|
Q_EMIT chromeButtonColorChanged();
|
||||||
}
|
}
|
||||||
|
@ -452,11 +443,11 @@ void ChromePalette::setCloseButtonPressColor(const QColor &value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(ChromePalette);
|
Q_D(ChromePalette);
|
||||||
if (d->closeButtonPressColor == value) {
|
if (d->closeButtonPressColor.has_value()
|
||||||
|
&& (d->closeButtonPressColor.value() == value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->closeButtonPressColor = value;
|
d->closeButtonPressColor = value;
|
||||||
d->mask |= ChromePalettePrivate::MaskFlag::CloseButtonPressColor;
|
|
||||||
Q_EMIT closeButtonPressColorChanged();
|
Q_EMIT closeButtonPressColorChanged();
|
||||||
Q_EMIT chromeButtonColorChanged();
|
Q_EMIT chromeButtonColorChanged();
|
||||||
}
|
}
|
||||||
|
@ -464,8 +455,7 @@ void ChromePalette::setCloseButtonPressColor(const QColor &value)
|
||||||
void ChromePalette::resetCloseButtonPressColor()
|
void ChromePalette::resetCloseButtonPressColor()
|
||||||
{
|
{
|
||||||
Q_D(ChromePalette);
|
Q_D(ChromePalette);
|
||||||
d->closeButtonPressColor = {};
|
d->closeButtonPressColor = std::nullopt;
|
||||||
d->mask &= ~ChromePalettePrivate::Mask(ChromePalettePrivate::MaskFlag::CloseButtonPressColor);
|
|
||||||
Q_EMIT closeButtonPressColorChanged();
|
Q_EMIT closeButtonPressColorChanged();
|
||||||
Q_EMIT chromeButtonColorChanged();
|
Q_EMIT chromeButtonColorChanged();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include "framelessmanager_p.h"
|
#include "framelessmanager_p.h"
|
||||||
#include <QtCore/qmutex.h>
|
#include <QtCore/qmutex.h>
|
||||||
#include <QtCore/qdebug.h>
|
#include <QtCore/qdebug.h>
|
||||||
#include <QtGui/qguiapplication.h>
|
|
||||||
#include <QtGui/qscreen.h>
|
#include <QtGui/qscreen.h>
|
||||||
#include <QtGui/qwindow.h>
|
#include <QtGui/qwindow.h>
|
||||||
#include <QtGui/qfontdatabase.h>
|
#include <QtGui/qfontdatabase.h>
|
||||||
|
@ -37,30 +36,6 @@
|
||||||
# include "framelesshelper_win.h"
|
# include "framelesshelper_win.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef COMPILER_STRING
|
|
||||||
# ifdef Q_CC_CLANG // Must be before GNU, because Clang claims to be GNU too.
|
|
||||||
# define COMPILER_STRING __VERSION__ // Already includes the compiler's name.
|
|
||||||
# elif defined(Q_CC_GHS)
|
|
||||||
# define COMPILER_STRING "GHS " QT_STRINGIFY(__GHS_VERSION_NUMBER)
|
|
||||||
# elif defined(Q_CC_GNU)
|
|
||||||
# define COMPILER_STRING "GCC " __VERSION__
|
|
||||||
# elif defined(Q_CC_MSVC)
|
|
||||||
# if (_MSC_VER < 1910)
|
|
||||||
# define COMPILER_STRING "MSVC 2015"
|
|
||||||
# elif (_MSC_VER < 1917)
|
|
||||||
# define COMPILER_STRING "MSVC 2017"
|
|
||||||
# elif (_MSC_VER < 1930)
|
|
||||||
# define COMPILER_STRING "MSVC 2019"
|
|
||||||
# elif (_MSC_VER < 2000)
|
|
||||||
# define COMPILER_STRING "MSVC 2022"
|
|
||||||
# else
|
|
||||||
# define COMPILER_STRING "MSVC version " QT_STRINGIFY(_MSC_VER)
|
|
||||||
# endif
|
|
||||||
# else
|
|
||||||
# define COMPILER_STRING "UNKNOWN"
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// The "Q_INIT_RESOURCE()" macro can't be used within a namespace,
|
// The "Q_INIT_RESOURCE()" macro can't be used within a namespace,
|
||||||
// so we wrap it into a separate function outside of the namespace and
|
// so we wrap it into a separate function outside of the namespace and
|
||||||
// then call it instead inside the namespace, that's also the recommended
|
// then call it instead inside the namespace, that's also the recommended
|
||||||
|
@ -84,16 +59,6 @@ Q_GLOBAL_STATIC(FramelessManagerHelper, g_helper)
|
||||||
|
|
||||||
Q_GLOBAL_STATIC(FramelessManager, g_manager)
|
Q_GLOBAL_STATIC(FramelessManager, g_manager)
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
|
||||||
static constexpr const char QT_QPA_ENV_VAR[] = "QT_QPA_PLATFORM";
|
|
||||||
FRAMELESSHELPER_BYTEARRAY_CONSTANT(xcb)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
|
||||||
static constexpr const char MAC_LAYER_ENV_VAR[] = "QT_MAC_WANTS_LAYER";
|
|
||||||
FRAMELESSHELPER_BYTEARRAY_CONSTANT2(ValueOne, "1")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
FRAMELESSHELPER_STRING_CONSTANT2(IconFontFilePath, ":/org.wangwenx190.FramelessHelper/resources/fonts/Segoe Fluent Icons.ttf")
|
FRAMELESSHELPER_STRING_CONSTANT2(IconFontFilePath, ":/org.wangwenx190.FramelessHelper/resources/fonts/Segoe Fluent Icons.ttf")
|
||||||
FRAMELESSHELPER_STRING_CONSTANT2(IconFontName, "Segoe Fluent Icons")
|
FRAMELESSHELPER_STRING_CONSTANT2(IconFontName, "Segoe Fluent Icons")
|
||||||
static constexpr const int kIconFontPointSize = 8;
|
static constexpr const int kIconFontPointSize = 8;
|
||||||
|
@ -291,87 +256,4 @@ void FramelessManager::addWindow(const SystemParameters ¶ms)
|
||||||
d->addWindow(params);
|
d->addWindow(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessHelper::Core::initialize()
|
|
||||||
{
|
|
||||||
static bool inited = false;
|
|
||||||
if (inited) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
inited = true;
|
|
||||||
#ifdef Q_OS_LINUX
|
|
||||||
// Qt's Wayland experience is not good, so we force the XCB backend here.
|
|
||||||
// TODO: Remove this hack once Qt's Wayland implementation is good enough.
|
|
||||||
// We are setting the preferred QPA backend, so we have to set it early
|
|
||||||
// enough, that is, before the construction of any Q(Gui)Application
|
|
||||||
// instances. QCoreApplication won't instantiate the platform plugin.
|
|
||||||
qputenv(QT_QPA_ENV_VAR, kxcb);
|
|
||||||
#endif
|
|
||||||
#ifdef Q_OS_MACOS
|
|
||||||
// This has become the default setting since some unknown Qt version,
|
|
||||||
// check whether we can remove this hack safely or not.
|
|
||||||
qputenv(MAC_LAYER_ENV_VAR, kValueOne);
|
|
||||||
#endif
|
|
||||||
#ifdef Q_OS_WINDOWS
|
|
||||||
// This is equivalent to set the "dpiAware" and "dpiAwareness" field in
|
|
||||||
// your manifest file. It works through out Windows Vista to Windows 11.
|
|
||||||
// It's highly recommended to enable the highest DPI awareness level
|
|
||||||
// (currently it's PerMonitor Version 2, or PMv2 for short) for any GUI
|
|
||||||
// applications, to allow your user interface scale to an appropriate
|
|
||||||
// size and still stay sharp, though you will have to do the calculation
|
|
||||||
// and resize by yourself.
|
|
||||||
Utils::tryToEnableHighestDpiAwarenessLevel();
|
|
||||||
#endif
|
|
||||||
// This attribute is known to be __NOT__ compatible with QGLWidget.
|
|
||||||
// Please consider migrating to the recommended QOpenGLWidget instead.
|
|
||||||
QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
|
|
||||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
|
||||||
// Enable high DPI scaling by default, but only for Qt5 applications,
|
|
||||||
// because this has become the default setting since Qt6 and it can't
|
|
||||||
// be changed from outside anymore (except for internal testing purposes).
|
|
||||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
||||||
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
|
||||||
#endif
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
|
||||||
// Non-integer scale factors will cause Qt have some painting defects
|
|
||||||
// for both Qt Widgets and Qt Quick applications, and it's still not
|
|
||||||
// totally fixed till now (Qt 6.5), so we round the scale factors to
|
|
||||||
// get a better looking. Non-integer scale factors will also cause
|
|
||||||
// flicker and jitter during window resizing.
|
|
||||||
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Round);
|
|
||||||
#endif
|
|
||||||
qRegisterMetaType<Option>();
|
|
||||||
qRegisterMetaType<SystemTheme>();
|
|
||||||
qRegisterMetaType<SystemButtonType>();
|
|
||||||
qRegisterMetaType<DwmColorizationArea>();
|
|
||||||
qRegisterMetaType<Anchor>();
|
|
||||||
qRegisterMetaType<ButtonState>();
|
|
||||||
qRegisterMetaType<WindowsVersion>();
|
|
||||||
qRegisterMetaType<ApplicationType>();
|
|
||||||
qRegisterMetaType<BlurMode>();
|
|
||||||
qRegisterMetaType<VersionNumber>();
|
|
||||||
qRegisterMetaType<SystemParameters>();
|
|
||||||
qRegisterMetaType<VersionInfo>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessHelper::Core::uninitialize()
|
|
||||||
{
|
|
||||||
// Currently nothing to do here.
|
|
||||||
}
|
|
||||||
|
|
||||||
VersionInfo FramelessHelper::Core::version()
|
|
||||||
{
|
|
||||||
static const VersionInfo result = []() -> VersionInfo {
|
|
||||||
VersionInfo ver = {};
|
|
||||||
ver.version.major = FRAMELESSHELPER_VERSION_MAJOR;
|
|
||||||
ver.version.minor = FRAMELESSHELPER_VERSION_MINOR;
|
|
||||||
ver.version.patch = FRAMELESSHELPER_VERSION_PATCH;
|
|
||||||
ver.version.tweak = FRAMELESSHELPER_VERSION_TWEAK;
|
|
||||||
ver.commit = QUtf8String(FRAMELESSHELPER_COMMIT_STR);
|
|
||||||
ver.compileDateTime = QUtf8String(FRAMELESSHELPER_COMPILE_DATETIME);
|
|
||||||
ver.compiler = QUtf8String(COMPILER_STRING);
|
|
||||||
return ver;
|
|
||||||
}();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
|
@ -0,0 +1,174 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "framelesshelpercore_global.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "framelessmanager.h"
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
# include "framelesshelper_win.h"
|
||||||
|
#endif
|
||||||
|
#include "framelesshelper_qt.h"
|
||||||
|
#include "chromepalette.h"
|
||||||
|
#include <QtGui/qguiapplication.h>
|
||||||
|
|
||||||
|
#ifndef COMPILER_STRING
|
||||||
|
# ifdef Q_CC_CLANG // Must be before GNU, because Clang claims to be GNU too.
|
||||||
|
# define COMPILER_STRING __VERSION__ // Already includes the compiler's name.
|
||||||
|
# elif defined(Q_CC_GHS)
|
||||||
|
# define COMPILER_STRING "GHS " QT_STRINGIFY(__GHS_VERSION_NUMBER)
|
||||||
|
# elif defined(Q_CC_GNU)
|
||||||
|
# define COMPILER_STRING "GCC " __VERSION__
|
||||||
|
# elif defined(Q_CC_MSVC)
|
||||||
|
# if (_MSC_VER < 1910)
|
||||||
|
# define COMPILER_STRING "MSVC 2015"
|
||||||
|
# elif (_MSC_VER < 1917)
|
||||||
|
# define COMPILER_STRING "MSVC 2017"
|
||||||
|
# elif (_MSC_VER < 1930)
|
||||||
|
# define COMPILER_STRING "MSVC 2019"
|
||||||
|
# elif (_MSC_VER < 2000)
|
||||||
|
# define COMPILER_STRING "MSVC 2022"
|
||||||
|
# else
|
||||||
|
# define COMPILER_STRING "MSVC version " QT_STRINGIFY(_MSC_VER)
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# define COMPILER_STRING "UNKNOWN"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
static constexpr const char QT_QPA_ENV_VAR[] = "QT_QPA_PLATFORM";
|
||||||
|
FRAMELESSHELPER_BYTEARRAY_CONSTANT(xcb)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
static constexpr const char MAC_LAYER_ENV_VAR[] = "QT_MAC_WANTS_LAYER";
|
||||||
|
FRAMELESSHELPER_BYTEARRAY_CONSTANT2(ValueOne, "1")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
using namespace Global;
|
||||||
|
|
||||||
|
namespace FramelessHelper::Core
|
||||||
|
{
|
||||||
|
|
||||||
|
void initialize()
|
||||||
|
{
|
||||||
|
static bool inited = false;
|
||||||
|
if (inited) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
inited = true;
|
||||||
|
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
// Qt's Wayland experience is not good, so we force the XCB backend here.
|
||||||
|
// TODO: Remove this hack once Qt's Wayland implementation is good enough.
|
||||||
|
// We are setting the preferred QPA backend, so we have to set it early
|
||||||
|
// enough, that is, before the construction of any Q(Gui)Application
|
||||||
|
// instances. QCoreApplication won't instantiate the platform plugin.
|
||||||
|
qputenv(QT_QPA_ENV_VAR, kxcb);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
// This has become the default setting since some unknown Qt version,
|
||||||
|
// check whether we can remove this hack safely or not.
|
||||||
|
qputenv(MAC_LAYER_ENV_VAR, kValueOne);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
// This is equivalent to set the "dpiAware" and "dpiAwareness" field in
|
||||||
|
// your manifest file. It works through out Windows Vista to Windows 11.
|
||||||
|
// It's highly recommended to enable the highest DPI awareness level
|
||||||
|
// (currently it's PerMonitor Version 2, or PMv2 for short) for any GUI
|
||||||
|
// applications, to allow your user interface scale to an appropriate
|
||||||
|
// size and still stay sharp, though you will have to do the calculation
|
||||||
|
// and resize by yourself.
|
||||||
|
Utils::tryToEnableHighestDpiAwarenessLevel();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// This attribute is known to be __NOT__ compatible with QGLWidget.
|
||||||
|
// Please consider migrating to the recommended QOpenGLWidget instead.
|
||||||
|
QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
|
||||||
|
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||||
|
// Enable high DPI scaling by default, but only for Qt5 applications,
|
||||||
|
// because this has become the default setting since Qt6 and it can't
|
||||||
|
// be changed from outside anymore (except for internal testing purposes).
|
||||||
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||||
|
// Non-integer scale factors will cause Qt have some painting defects
|
||||||
|
// for both Qt Widgets and Qt Quick applications, and it's still not
|
||||||
|
// totally fixed till now (Qt 6.5), so we round the scale factors to
|
||||||
|
// get a better looking. Non-integer scale factors will also cause
|
||||||
|
// flicker and jitter during window resizing.
|
||||||
|
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Round);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
qRegisterMetaType<Option>();
|
||||||
|
qRegisterMetaType<SystemTheme>();
|
||||||
|
qRegisterMetaType<SystemButtonType>();
|
||||||
|
qRegisterMetaType<DwmColorizationArea>();
|
||||||
|
qRegisterMetaType<Anchor>();
|
||||||
|
qRegisterMetaType<ButtonState>();
|
||||||
|
qRegisterMetaType<WindowsVersion>();
|
||||||
|
qRegisterMetaType<ApplicationType>();
|
||||||
|
qRegisterMetaType<BlurMode>();
|
||||||
|
qRegisterMetaType<VersionNumber>();
|
||||||
|
qRegisterMetaType<SystemParameters>();
|
||||||
|
qRegisterMetaType<VersionInfo>();
|
||||||
|
qRegisterMetaType<FramelessManager>();
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
qRegisterMetaType<FramelessHelperWin>();
|
||||||
|
#endif
|
||||||
|
qRegisterMetaType<FramelessHelperQt>();
|
||||||
|
qRegisterMetaType<ChromePalette>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void uninitialize()
|
||||||
|
{
|
||||||
|
// Currently nothing to do here.
|
||||||
|
}
|
||||||
|
|
||||||
|
VersionInfo version()
|
||||||
|
{
|
||||||
|
static const VersionInfo result = []() -> VersionInfo {
|
||||||
|
VersionInfo ver = {};
|
||||||
|
ver.version.major = FRAMELESSHELPER_VERSION_MAJOR;
|
||||||
|
ver.version.minor = FRAMELESSHELPER_VERSION_MINOR;
|
||||||
|
ver.version.patch = FRAMELESSHELPER_VERSION_PATCH;
|
||||||
|
ver.version.tweak = FRAMELESSHELPER_VERSION_TWEAK;
|
||||||
|
ver.commit = QUtf8String(FRAMELESSHELPER_COMMIT_STR);
|
||||||
|
ver.compileDateTime = QUtf8String(FRAMELESSHELPER_COMPILE_DATETIME);
|
||||||
|
ver.compiler = QUtf8String(COMPILER_STRING);
|
||||||
|
return ver;
|
||||||
|
}();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FRAMELESSHELPER_END_NAMESPACE
|
|
@ -62,7 +62,7 @@ struct Win32UtilsHelper
|
||||||
|
|
||||||
Q_GLOBAL_STATIC(Win32UtilsHelper, g_utilsHelper)
|
Q_GLOBAL_STATIC(Win32UtilsHelper, g_utilsHelper)
|
||||||
|
|
||||||
static constexpr const wchar_t DUMMY_WINDOW_CLASS_NAME[] = L"FRAMELESSHELPER_DUMMY_WINDOW_CLASS";
|
static constexpr const wchar_t kDummyWindowClassName[] = L"FRAMELESSHELPER_DUMMY_WINDOW_CLASS";
|
||||||
static const QString qDwmRegistryKey = QString::fromWCharArray(kDwmRegistryKey);
|
static const QString qDwmRegistryKey = QString::fromWCharArray(kDwmRegistryKey);
|
||||||
static const QString qPersonalizeRegistryKey = QString::fromWCharArray(kPersonalizeRegistryKey);
|
static const QString qPersonalizeRegistryKey = QString::fromWCharArray(kPersonalizeRegistryKey);
|
||||||
static const QString qDwmColorKeyName = QString::fromWCharArray(kDwmColorKeyName);
|
static const QString qDwmColorKeyName = QString::fromWCharArray(kDwmColorKeyName);
|
||||||
|
@ -210,13 +210,13 @@ private:
|
||||||
wcex.cbSize = sizeof(wcex);
|
wcex.cbSize = sizeof(wcex);
|
||||||
wcex.lpfnWndProc = DefWindowProcW;
|
wcex.lpfnWndProc = DefWindowProcW;
|
||||||
wcex.hInstance = instance;
|
wcex.hInstance = instance;
|
||||||
wcex.lpszClassName = DUMMY_WINDOW_CLASS_NAME;
|
wcex.lpszClassName = kDummyWindowClassName;
|
||||||
const ATOM atom = RegisterClassExW(&wcex);
|
const ATOM atom = RegisterClassExW(&wcex);
|
||||||
if (!atom) {
|
if (!atom) {
|
||||||
qWarning() << Utils::getSystemErrorMessage(kRegisterClassExW);
|
qWarning() << Utils::getSystemErrorMessage(kRegisterClassExW);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
const HWND window = CreateWindowExW(0, DUMMY_WINDOW_CLASS_NAME, nullptr,
|
const HWND window = CreateWindowExW(0, kDummyWindowClassName, nullptr,
|
||||||
WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, nullptr, nullptr, instance, nullptr);
|
WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, nullptr, nullptr, instance, nullptr);
|
||||||
if (!window) {
|
if (!window) {
|
||||||
qWarning() << Utils::getSystemErrorMessage(kCreateWindowExW);
|
qWarning() << Utils::getSystemErrorMessage(kCreateWindowExW);
|
||||||
|
@ -1477,7 +1477,8 @@ bool Utils::setBlurBehindWindowEnabled(const WId windowId, const BlurMode mode,
|
||||||
const auto pSetWindowCompositionAttribute =
|
const auto pSetWindowCompositionAttribute =
|
||||||
reinterpret_cast<SetWindowCompositionAttributePtr>(
|
reinterpret_cast<SetWindowCompositionAttributePtr>(
|
||||||
SysApiLoader::instance()->get(kSetWindowCompositionAttribute));
|
SysApiLoader::instance()->get(kSetWindowCompositionAttribute));
|
||||||
static const bool isBuild22523OrGreater = doCompareWindowsVersion({10, 0, 22523});
|
//static const bool isWin11Insider2OrGreater = doCompareWindowsVersion({10, 0, 22557});
|
||||||
|
static const bool isWin11Insider1OrGreater = doCompareWindowsVersion({10, 0, 22523});
|
||||||
static const bool isWin11OrGreater = isWindowsVersionOrGreater(WindowsVersion::_11_21H2);
|
static const bool isWin11OrGreater = isWindowsVersionOrGreater(WindowsVersion::_11_21H2);
|
||||||
static const bool isWin10OrGreater = isWindowsVersionOrGreater(WindowsVersion::_10_1507);
|
static const bool isWin10OrGreater = isWindowsVersionOrGreater(WindowsVersion::_10_1507);
|
||||||
const BlurMode blurMode = [mode]() -> BlurMode {
|
const BlurMode blurMode = [mode]() -> BlurMode {
|
||||||
|
@ -1509,7 +1510,7 @@ bool Utils::setBlurBehindWindowEnabled(const WId windowId, const BlurMode mode,
|
||||||
return mode;
|
return mode;
|
||||||
}();
|
}();
|
||||||
if (blurMode == BlurMode::Disable) {
|
if (blurMode == BlurMode::Disable) {
|
||||||
if (isBuild22523OrGreater) {
|
if (isWin11Insider1OrGreater) {
|
||||||
const _DWM_SYSTEMBACKDROP_TYPE dwmsbt = _DWMSBT_NONE;
|
const _DWM_SYSTEMBACKDROP_TYPE dwmsbt = _DWMSBT_NONE;
|
||||||
const HRESULT hr = API_CALL_FUNCTION(DwmSetWindowAttribute,
|
const HRESULT hr = API_CALL_FUNCTION(DwmSetWindowAttribute,
|
||||||
hwnd, _DWMWA_SYSTEMBACKDROP_TYPE, &dwmsbt, sizeof(dwmsbt));
|
hwnd, _DWMWA_SYSTEMBACKDROP_TYPE, &dwmsbt, sizeof(dwmsbt));
|
||||||
|
@ -1547,7 +1548,7 @@ bool Utils::setBlurBehindWindowEnabled(const WId windowId, const BlurMode mode,
|
||||||
const MARGINS margins = {-1, -1, -1, -1};
|
const MARGINS margins = {-1, -1, -1, -1};
|
||||||
HRESULT hr = API_CALL_FUNCTION(DwmExtendFrameIntoClientArea, hwnd, &margins);
|
HRESULT hr = API_CALL_FUNCTION(DwmExtendFrameIntoClientArea, hwnd, &margins);
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
if (isBuild22523OrGreater) {
|
if (isWin11Insider1OrGreater) {
|
||||||
// ### FIXME: Is it necessary to enable the host backdrop brush in the first place? To be checked.
|
// ### FIXME: Is it necessary to enable the host backdrop brush in the first place? To be checked.
|
||||||
const BOOL enable = TRUE;
|
const BOOL enable = TRUE;
|
||||||
hr = API_CALL_FUNCTION(DwmSetWindowAttribute, hwnd,
|
hr = API_CALL_FUNCTION(DwmSetWindowAttribute, hwnd,
|
||||||
|
|
|
@ -48,6 +48,7 @@ set(SOURCES
|
||||||
framelessquickwindow.cpp
|
framelessquickwindow.cpp
|
||||||
framelessquickhelper.cpp
|
framelessquickhelper.cpp
|
||||||
quickchromepalette.cpp
|
quickchromepalette.cpp
|
||||||
|
global.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if(WIN32 AND NOT FRAMELESSHELPER_BUILD_STATIC)
|
if(WIN32 AND NOT FRAMELESSHELPER_BUILD_STATIC)
|
||||||
|
|
|
@ -181,7 +181,7 @@ void FramelessQuickHelperPrivate::attachToWindow()
|
||||||
// we reach here, and all the modifications from the Qt side will be lost
|
// we reach here, and all the modifications from the Qt side will be lost
|
||||||
// due to QPA will reset the position and size of the window during it's
|
// due to QPA will reset the position and size of the window during it's
|
||||||
// initialization process.
|
// initialization process.
|
||||||
QTimer::singleShot(200, this, [this](){
|
QTimer::singleShot(0, this, [this](){
|
||||||
if (FramelessConfig::instance()->isSet(Option::CenterWindowBeforeShow)) {
|
if (FramelessConfig::instance()->isSet(Option::CenterWindowBeforeShow)) {
|
||||||
moveWindowToDesktopCenter();
|
moveWindowToDesktopCenter();
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,14 @@ void FramelessHelper::Quick::registerTypes(QQmlEngine *engine)
|
||||||
if (!engine) {
|
if (!engine) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In most cases we don't need to register the QML types for multiple times.
|
||||||
|
static bool reg = false;
|
||||||
|
if (reg) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
reg = true;
|
||||||
|
|
||||||
qRegisterMetaType<QuickGlobal::SystemTheme>();
|
qRegisterMetaType<QuickGlobal::SystemTheme>();
|
||||||
qRegisterMetaType<QuickGlobal::SystemButtonType>();
|
qRegisterMetaType<QuickGlobal::SystemButtonType>();
|
||||||
qRegisterMetaType<QuickGlobal::DwmColorizationArea>();
|
qRegisterMetaType<QuickGlobal::DwmColorizationArea>();
|
||||||
|
@ -62,6 +70,17 @@ void FramelessHelper::Quick::registerTypes(QQmlEngine *engine)
|
||||||
qRegisterMetaType<QuickGlobal::WindowsVersion>();
|
qRegisterMetaType<QuickGlobal::WindowsVersion>();
|
||||||
qRegisterMetaType<QuickGlobal::ApplicationType>();
|
qRegisterMetaType<QuickGlobal::ApplicationType>();
|
||||||
qRegisterMetaType<QuickGlobal::BlurMode>();
|
qRegisterMetaType<QuickGlobal::BlurMode>();
|
||||||
|
|
||||||
|
qRegisterMetaType<QuickGlobal>();
|
||||||
|
qRegisterMetaType<FramelessQuickUtils>();
|
||||||
|
qRegisterMetaType<QuickChromePalette>();
|
||||||
|
qRegisterMetaType<FramelessQuickHelper>();
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
|
qRegisterMetaType<QuickStandardSystemButton>();
|
||||||
|
qRegisterMetaType<QuickStandardTitleBar>();
|
||||||
|
qRegisterMetaType<FramelessQuickWindow>();
|
||||||
|
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
|
|
||||||
qmlRegisterUncreatableType<QuickGlobal>(QUICK_URI_FULL, "FramelessHelperConstants",
|
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."));
|
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"),
|
qmlRegisterSingletonType<FramelessQuickUtils>(QUICK_URI_EXPAND("FramelessUtils"),
|
||||||
|
@ -71,9 +90,11 @@ void FramelessHelper::Quick::registerTypes(QQmlEngine *engine)
|
||||||
return new FramelessQuickUtils;
|
return new FramelessQuickUtils;
|
||||||
});
|
});
|
||||||
qmlRegisterAnonymousType<QuickChromePalette>(QUICK_URI_SHORT);
|
qmlRegisterAnonymousType<QuickChromePalette>(QUICK_URI_SHORT);
|
||||||
|
|
||||||
qmlRegisterRevision<QWindow, 254>(QUICK_URI_FULL);
|
qmlRegisterRevision<QWindow, 254>(QUICK_URI_FULL);
|
||||||
qmlRegisterRevision<QQuickWindow, 254>(QUICK_URI_FULL);
|
qmlRegisterRevision<QQuickWindow, 254>(QUICK_URI_FULL);
|
||||||
qmlRegisterRevision<QQuickItem, 254>(QUICK_URI_FULL);
|
qmlRegisterRevision<QQuickItem, 254>(QUICK_URI_FULL);
|
||||||
|
|
||||||
qmlRegisterType<FramelessQuickHelper>(QUICK_URI_EXPAND("FramelessHelper"));
|
qmlRegisterType<FramelessQuickHelper>(QUICK_URI_EXPAND("FramelessHelper"));
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
qmlRegisterType<QuickStandardSystemButton>(QUICK_URI_EXPAND("StandardSystemButton"));
|
qmlRegisterType<QuickStandardSystemButton>(QUICK_URI_EXPAND("StandardSystemButton"));
|
||||||
|
@ -87,6 +108,7 @@ void FramelessHelper::Quick::registerTypes(QQmlEngine *engine)
|
||||||
qmlRegisterTypeNotAvailable(QUICK_URI_EXPAND("FramelessWindow"),
|
qmlRegisterTypeNotAvailable(QUICK_URI_EXPAND("FramelessWindow"),
|
||||||
FRAMELESSHELPER_STRING_LITERAL("FramelessWindow is not available until Qt6."));
|
FRAMELESSHELPER_STRING_LITERAL("FramelessWindow is not available until Qt6."));
|
||||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
|
|
||||||
qmlRegisterModule(QUICK_URI_FULL);
|
qmlRegisterModule(QUICK_URI_FULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "framelesshelperquick_global.h"
|
||||||
|
|
||||||
|
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
namespace FramelessHelper::Quick
|
||||||
|
{
|
||||||
|
|
||||||
|
void initialize()
|
||||||
|
{
|
||||||
|
static bool inited = false;
|
||||||
|
if (inited) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
inited = true;
|
||||||
|
|
||||||
|
FramelessHelper::Core::initialize();
|
||||||
|
|
||||||
|
// ### TODO: The Quick module-specific initialization.
|
||||||
|
}
|
||||||
|
|
||||||
|
void uninitialize()
|
||||||
|
{
|
||||||
|
// ### TODO: The Quick module-specific uninitialization.
|
||||||
|
|
||||||
|
FramelessHelper::Core::uninitialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FRAMELESSHELPER_END_NAMESPACE
|
|
@ -46,6 +46,7 @@ set(SOURCES
|
||||||
standardsystembutton.cpp
|
standardsystembutton.cpp
|
||||||
standardtitlebar.cpp
|
standardtitlebar.cpp
|
||||||
widgetssharedhelper.cpp
|
widgetssharedhelper.cpp
|
||||||
|
global.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if(WIN32 AND NOT FRAMELESSHELPER_BUILD_STATIC)
|
if(WIN32 AND NOT FRAMELESSHELPER_BUILD_STATIC)
|
||||||
|
|
|
@ -304,7 +304,7 @@ void FramelessWidgetsHelperPrivate::attachToWindow()
|
||||||
// we reach here, and all the modifications from the Qt side will be lost
|
// we reach here, and all the modifications from the Qt side will be lost
|
||||||
// due to QPA will reset the position and size of the window during it's
|
// due to QPA will reset the position and size of the window during it's
|
||||||
// initialization process.
|
// initialization process.
|
||||||
QTimer::singleShot(200, this, [this](){
|
QTimer::singleShot(0, this, [this](){
|
||||||
if (FramelessConfig::instance()->isSet(Option::CenterWindowBeforeShow)) {
|
if (FramelessConfig::instance()->isSet(Option::CenterWindowBeforeShow)) {
|
||||||
moveWindowToDesktopCenter();
|
moveWindowToDesktopCenter();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "framelesshelperwidgets_global.h"
|
||||||
|
#include "standardtitlebar.h"
|
||||||
|
#include "standardsystembutton.h"
|
||||||
|
#include "framelesswidgetshelper.h"
|
||||||
|
#include "framelesswidget.h"
|
||||||
|
#include "framelessmainwindow.h"
|
||||||
|
|
||||||
|
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
namespace FramelessHelper::Widgets
|
||||||
|
{
|
||||||
|
|
||||||
|
void initialize()
|
||||||
|
{
|
||||||
|
static bool inited = false;
|
||||||
|
if (inited) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
inited = true;
|
||||||
|
|
||||||
|
FramelessHelper::Core::initialize();
|
||||||
|
|
||||||
|
qRegisterMetaType<StandardTitleBar>();
|
||||||
|
qRegisterMetaType<StandardSystemButton>();
|
||||||
|
qRegisterMetaType<FramelessWidgetsHelper>();
|
||||||
|
qRegisterMetaType<FramelessWidget>();
|
||||||
|
qRegisterMetaType<FramelessMainWindow>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void uninitialize()
|
||||||
|
{
|
||||||
|
// ### TODO: The Widgets module-specific uninitialization.
|
||||||
|
|
||||||
|
FramelessHelper::Core::uninitialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FRAMELESSHELPER_END_NAMESPACE
|
|
@ -145,6 +145,7 @@ void StandardTitleBarPrivate::paintTitleBar(QPaintEvent *event)
|
||||||
painter.setRenderHints(QPainter::Antialiasing |
|
painter.setRenderHints(QPainter::Antialiasing |
|
||||||
QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
|
QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
|
||||||
painter.fillRect(QRect(QPoint(0, 0), q->size()), backgroundColor);
|
painter.fillRect(QRect(QPoint(0, 0), q->size()), backgroundColor);
|
||||||
|
if (m_titleLabelVisible) {
|
||||||
const QString text = m_window->windowTitle();
|
const QString text = m_window->windowTitle();
|
||||||
if (!text.isEmpty()) {
|
if (!text.isEmpty()) {
|
||||||
const QFont font = [q]() -> QFont {
|
const QFont font = [q]() -> QFont {
|
||||||
|
@ -172,10 +173,27 @@ void StandardTitleBarPrivate::paintTitleBar(QPaintEvent *event)
|
||||||
}();
|
}();
|
||||||
painter.drawText(rect, m_labelAlignment, text);
|
painter.drawText(rect, m_labelAlignment, text);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
painter.restore();
|
painter.restore();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool StandardTitleBarPrivate::titleLabelVisible() const
|
||||||
|
{
|
||||||
|
return m_titleLabelVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StandardTitleBarPrivate::setTitleLabelVisible(const bool value)
|
||||||
|
{
|
||||||
|
if (m_titleLabelVisible == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_titleLabelVisible = value;
|
||||||
|
Q_Q(StandardTitleBar);
|
||||||
|
q->update();
|
||||||
|
Q_EMIT q->titleLabelVisibleChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void StandardTitleBarPrivate::updateMaximizeButton()
|
void StandardTitleBarPrivate::updateMaximizeButton()
|
||||||
{
|
{
|
||||||
const bool max = m_window->isMaximized();
|
const bool max = m_window->isMaximized();
|
||||||
|
@ -379,6 +397,18 @@ ChromePalette *StandardTitleBar::chromePalette() const
|
||||||
return d->chromePalette();
|
return d->chromePalette();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool StandardTitleBar::titleLabelVisible() const
|
||||||
|
{
|
||||||
|
Q_D(const StandardTitleBar);
|
||||||
|
return d->titleLabelVisible();
|
||||||
|
}
|
||||||
|
|
||||||
|
void StandardTitleBar::setTitleLabelVisible(const bool value)
|
||||||
|
{
|
||||||
|
Q_D(StandardTitleBar);
|
||||||
|
d->setTitleLabelVisible(value);
|
||||||
|
}
|
||||||
|
|
||||||
void StandardTitleBar::paintEvent(QPaintEvent *event)
|
void StandardTitleBar::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
Q_D(StandardTitleBar);
|
Q_D(StandardTitleBar);
|
||||||
|
|
Loading…
Reference in New Issue