forked from github_mirror/framelesshelper
minor tweaks
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
ffa9bc912b
commit
75f19218c6
|
@ -266,7 +266,7 @@ Please refer to the demo projects to see more detailed usages: [examples](./exam
|
||||||
- Change your system theme to "Basic" (in contrary to "Windows Aero").
|
- Change your system theme to "Basic" (in contrary to "Windows Aero").
|
||||||
- If you have multiple graphics cards, try to use another one instead.
|
- If you have multiple graphics cards, try to use another one instead.
|
||||||
- Upgrade your operating system to at least Windows 11.
|
- Upgrade your operating system to at least Windows 11.
|
||||||
- Remove the `WS_THICKFRAME` and `WS_OVERLAPPED` styles from your window (doing so will break FramelessHelper's functionalities).
|
- Remove the `WS_THICKFRAME` and `WS_OVERLAPPED` styles from your window, and maybe also add the `WS_POPUP` style at the same time (doing so will break FramelessHelper's functionalities).
|
||||||
- Force your application use the ANGLE backend instead of the Desktop OpenGL.
|
- Force your application use the ANGLE backend instead of the Desktop OpenGL.
|
||||||
- Force your application use pure software rendering instead of rendering through OpenGL.
|
- Force your application use pure software rendering instead of rendering through OpenGL.
|
||||||
- Or just don't use OpenGL at all, try to use Direct3D/Vulkan/Metal instead.
|
- Or just don't use OpenGL at all, try to use Direct3D/Vulkan/Metal instead.
|
||||||
|
|
|
@ -64,6 +64,7 @@ private:
|
||||||
QScopedPointer<QQuickRectangle> m_backgroundItem;
|
QScopedPointer<QQuickRectangle> m_backgroundItem;
|
||||||
QuickGlobal::SystemButtonType m_buttonType = QuickGlobal::SystemButtonType::Unknown;
|
QuickGlobal::SystemButtonType m_buttonType = QuickGlobal::SystemButtonType::Unknown;
|
||||||
QMetaObject::Connection m_windowActiveConnection = {};
|
QMetaObject::Connection m_windowActiveConnection = {};
|
||||||
|
bool m_settingIconCode = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
|
@ -71,7 +71,7 @@ FRAMELESSHELPER_BYTEARRAY_CONSTANT2(ValueOne, "1")
|
||||||
|
|
||||||
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 = 7;
|
static constexpr const int kIconFontPointSize = 8;
|
||||||
|
|
||||||
FramelessManagerPrivate::FramelessManagerPrivate(FramelessManager *q) : QObject(q)
|
FramelessManagerPrivate::FramelessManagerPrivate(FramelessManager *q) : QObject(q)
|
||||||
{
|
{
|
||||||
|
|
|
@ -580,6 +580,7 @@ void Utils::showSystemMenu(const WId windowId, const QPoint &pos, const bool sel
|
||||||
if (!windowId || !isWindowFixedSize) {
|
if (!windowId || !isWindowFixedSize) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto hWnd = reinterpret_cast<HWND>(windowId);
|
const auto hWnd = reinterpret_cast<HWND>(windowId);
|
||||||
const HMENU hMenu = GetSystemMenu(hWnd, FALSE);
|
const HMENU hMenu = GetSystemMenu(hWnd, FALSE);
|
||||||
if (!hMenu) {
|
if (!hMenu) {
|
||||||
|
@ -588,11 +589,13 @@ void Utils::showSystemMenu(const WId windowId, const QPoint &pos, const bool sel
|
||||||
// as an error so just ignore it and return early.
|
// as an error so just ignore it and return early.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tweak the menu items according to the current window status.
|
||||||
const bool maxOrFull = (IsMaximized(hWnd) || isFullScreen(windowId));
|
const bool maxOrFull = (IsMaximized(hWnd) || isFullScreen(windowId));
|
||||||
const bool fixedSize = isWindowFixedSize();
|
const bool fixedSize = isWindowFixedSize();
|
||||||
EnableMenuItem(hMenu, SC_RESTORE, (MF_BYCOMMAND | ((maxOrFull && !fixedSize) ? MFS_ENABLED : MFS_DISABLED)));
|
EnableMenuItem(hMenu, SC_RESTORE, (MF_BYCOMMAND | ((maxOrFull && !fixedSize) ? MFS_ENABLED : MFS_DISABLED)));
|
||||||
// The first menu item should be selected by default if the menu is brought
|
// The first menu item should be selected by default if the menu is brought
|
||||||
// by keyboard. I don't know how to pre-select a menu item but it seems
|
// up by keyboard. I don't know how to pre-select a menu item but it seems
|
||||||
// highlight can do the job. However, there's an annoying issue if we do
|
// highlight can do the job. However, there's an annoying issue if we do
|
||||||
// this manually: the highlighted menu item is really only highlighted,
|
// this manually: the highlighted menu item is really only highlighted,
|
||||||
// not selected, so even if the mouse cursor hovers on other menu items
|
// not selected, so even if the mouse cursor hovers on other menu items
|
||||||
|
@ -606,16 +609,21 @@ void Utils::showSystemMenu(const WId windowId, const QPoint &pos, const bool sel
|
||||||
EnableMenuItem(hMenu, SC_MINIMIZE, (MF_BYCOMMAND | MFS_ENABLED));
|
EnableMenuItem(hMenu, SC_MINIMIZE, (MF_BYCOMMAND | MFS_ENABLED));
|
||||||
EnableMenuItem(hMenu, SC_MAXIMIZE, (MF_BYCOMMAND | ((!maxOrFull && !fixedSize) ? MFS_ENABLED : MFS_DISABLED)));
|
EnableMenuItem(hMenu, SC_MAXIMIZE, (MF_BYCOMMAND | ((!maxOrFull && !fixedSize) ? MFS_ENABLED : MFS_DISABLED)));
|
||||||
EnableMenuItem(hMenu, SC_CLOSE, (MF_BYCOMMAND | MFS_ENABLED));
|
EnableMenuItem(hMenu, SC_CLOSE, (MF_BYCOMMAND | MFS_ENABLED));
|
||||||
|
|
||||||
// The default menu item will appear in bold font. There can only be one default
|
// The default menu item will appear in bold font. There can only be one default
|
||||||
// menu item per menu at most. Set the item ID to "UINT_MAX" (or simply "-1")
|
// menu item per menu at most. Set the item ID to "UINT_MAX" (or simply "-1")
|
||||||
// can clear the default item for the given menu.
|
// can clear the default item for the given menu.
|
||||||
SetMenuDefaultItem(hMenu, SC_CLOSE, FALSE);
|
SetMenuDefaultItem(hMenu, SC_CLOSE, FALSE);
|
||||||
const auto result = TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft()
|
|
||||||
|
// Popup the system menu at the required position.
|
||||||
|
const int result = TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft()
|
||||||
? TPM_RIGHTALIGN : TPM_LEFTALIGN)), pos.x(), pos.y(), 0, hWnd, nullptr);
|
? TPM_RIGHTALIGN : TPM_LEFTALIGN)), pos.x(), pos.y(), 0, hWnd, nullptr);
|
||||||
// The user canceled the menu, no need to continue.
|
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
|
// The user canceled the menu, no need to continue.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send the command that the user choses to the corresponding window.
|
||||||
if (PostMessageW(hWnd, WM_SYSCOMMAND, result, 0) == FALSE) {
|
if (PostMessageW(hWnd, WM_SYSCOMMAND, result, 0) == FALSE) {
|
||||||
qWarning() << getSystemErrorMessage(kPostMessageW);
|
qWarning() << getSystemErrorMessage(kPostMessageW);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,9 @@ void QuickStandardSystemButton::setButtonType(const QuickGlobal::SystemButtonTyp
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_buttonType = type;
|
m_buttonType = type;
|
||||||
|
m_settingIconCode = true;
|
||||||
updateForeground();
|
updateForeground();
|
||||||
|
m_settingIconCode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickStandardSystemButton::updateForeground()
|
void QuickStandardSystemButton::updateForeground()
|
||||||
|
@ -67,11 +69,13 @@ void QuickStandardSystemButton::updateForeground()
|
||||||
if (m_buttonType == QuickGlobal::SystemButtonType::Unknown) {
|
if (m_buttonType == QuickGlobal::SystemButtonType::Unknown) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (m_settingIconCode) {
|
||||||
const QString iconCode = Utils::getSystemButtonIconCode(
|
const QString iconCode = Utils::getSystemButtonIconCode(
|
||||||
FRAMELESSHELPER_ENUM_QUICK_TO_CORE(SystemButtonType, m_buttonType));
|
FRAMELESSHELPER_ENUM_QUICK_TO_CORE(SystemButtonType, m_buttonType));
|
||||||
if (m_contentItem->text() != iconCode) {
|
if (m_contentItem->text() != iconCode) {
|
||||||
m_contentItem->setText(iconCode);
|
m_contentItem->setText(iconCode);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
const QColor iconColor = [this]() -> QColor {
|
const QColor iconColor = [this]() -> QColor {
|
||||||
const bool active = [this]() -> bool {
|
const bool active = [this]() -> bool {
|
||||||
const QQuickWindow * const w = window();
|
const QQuickWindow * const w = window();
|
||||||
|
|
Loading…
Reference in New Issue