win: allow user disable specific system menu items
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
598de50290
commit
a0c825930e
|
@ -252,6 +252,12 @@ Q_NAMESPACE_EXPORT(FRAMELESSHELPER_CORE_API)
|
|||
= FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_DONT_OVERRIDE_CURSOR");
|
||||
[[maybe_unused]] inline const QByteArray kDontToggleMaximizeVar
|
||||
= FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_DONT_TOGGLE_MAXIMIZE");
|
||||
[[maybe_unused]] inline const QByteArray kSysMenuDisableMinimizeVar
|
||||
= FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_SYSTEM_MENU_DISABLE_MINIMIZE");
|
||||
[[maybe_unused]] inline const QByteArray kSysMenuDisableMaximizeVar
|
||||
= FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_SYSTEM_MENU_DISABLE_MAXIMIZE");
|
||||
[[maybe_unused]] inline const QByteArray kSysMenuDisableRestoreVar
|
||||
= FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_SYSTEM_MENU_DISABLE_RESTORE");
|
||||
|
||||
enum class Option
|
||||
{
|
||||
|
|
|
@ -781,10 +781,13 @@ void Utils::showSystemMenu(const WId windowId, const QPoint &pos, const bool sel
|
|||
return;
|
||||
}
|
||||
|
||||
// Tweak the menu items according to the current window status.
|
||||
// Tweak the menu items according to the current window status and user settings.
|
||||
const bool disableRestore = params->getProperty(kSysMenuDisableRestoreVar, false).toBool();
|
||||
const bool disableMinimize = params->getProperty(kSysMenuDisableMinimizeVar, false).toBool();
|
||||
const bool disableMaximize = params->getProperty(kSysMenuDisableMaximizeVar, false).toBool();
|
||||
const bool maxOrFull = (IsMaximized(hWnd) || isFullScreen(windowId));
|
||||
const bool fixedSize = params->isWindowFixedSize();
|
||||
EnableMenuItem(hMenu, SC_RESTORE, (MF_BYCOMMAND | ((maxOrFull && !fixedSize) ? MFS_ENABLED : MFS_DISABLED)));
|
||||
EnableMenuItem(hMenu, SC_RESTORE, (MF_BYCOMMAND | ((maxOrFull && !fixedSize && !disableRestore) ? MFS_ENABLED : MFS_DISABLED)));
|
||||
// The first menu item should be selected by default if the menu is brought
|
||||
// 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
|
||||
|
@ -796,9 +799,9 @@ void Utils::showSystemMenu(const WId windowId, const QPoint &pos, const bool sel
|
|||
// the menu look kind of weird. Currently I don't know how to fix this issue.
|
||||
HiliteMenuItem(hWnd, hMenu, SC_RESTORE, (MF_BYCOMMAND | (selectFirstEntry ? MFS_HILITE : MFS_UNHILITE)));
|
||||
EnableMenuItem(hMenu, SC_MOVE, (MF_BYCOMMAND | (!maxOrFull ? MFS_ENABLED : MFS_DISABLED)));
|
||||
EnableMenuItem(hMenu, SC_SIZE, (MF_BYCOMMAND | ((!maxOrFull && !fixedSize) ? MFS_ENABLED : MFS_DISABLED)));
|
||||
EnableMenuItem(hMenu, SC_MINIMIZE, (MF_BYCOMMAND | MFS_ENABLED));
|
||||
EnableMenuItem(hMenu, SC_MAXIMIZE, (MF_BYCOMMAND | ((!maxOrFull && !fixedSize) ? MFS_ENABLED : MFS_DISABLED)));
|
||||
EnableMenuItem(hMenu, SC_SIZE, (MF_BYCOMMAND | ((!maxOrFull && !fixedSize && !(disableMinimize || disableMaximize)) ? MFS_ENABLED : MFS_DISABLED)));
|
||||
EnableMenuItem(hMenu, SC_MINIMIZE, (MF_BYCOMMAND | (disableMinimize ? MFS_DISABLED : MFS_ENABLED)));
|
||||
EnableMenuItem(hMenu, SC_MAXIMIZE, (MF_BYCOMMAND | ((!maxOrFull && !fixedSize && !disableMaximize) ? MFS_ENABLED : MFS_DISABLED)));
|
||||
EnableMenuItem(hMenu, SC_CLOSE, (MF_BYCOMMAND | MFS_ENABLED));
|
||||
|
||||
// The default menu item will appear in bold font. There can only be one default
|
||||
|
|
Loading…
Reference in New Issue