diff options
author | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2016-07-15 11:51:36 -0700 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@theqtcompany.com> | 2016-08-17 18:21:53 +0000 |
commit | 9b491616f8353be243c5e5e98c864d09a25b99ea (patch) | |
tree | 56da56c45fa421060c2c687d7e0c67554a1a78aa /src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm | |
parent | 810363945f0038ad40a48e1c5a86e3451a028822 (diff) |
Cocoa QPA Menus: Propagate enabled state downwards
NSMenu has autoenableItems set to true by default, and
we keep it this way in Qt. This means that NSMenuItem's
enabled property is basically ignored and therefore
QCocoaMenuItem::syncModalState() is wrong.
What is also wrong, is syncModalState()'s name in both
QCocoaMenuItem and QCocoaMenu. Indeed, this function's
role should be to ensure that the enabled state is
properly propagated down the menu hierarchy, whether
the reason is being in the context of a modal dialog
or the parent menu having been disabled by the app.
Notice that the latter case is specially needed when
a menubar menu is explicitly disabled.
Therefore, we introduce a separate flag for the parent
enabled state in order to avoid polluting the app-set
enabled state flag. This is done in both QCocoaMenu
and QCocoaMenuItem.
In the case of QCocoaMenuItem, these two flags define
whether an NSMenuItem is enabled state conjointly, and
set from -[QCocoaMenuDelegate validateMenuItem:]. The
rest of the logic remains as before. Similar logic is
used in QCocoaMenu::isEnabled().
In addition, the presence of the second flag allows us
to show disabled submenus in the same fashion native
Cocoa applications do. This means, the submenu item
itself remains enabled, allowing to show the submenu
popup where all its menu items will appear disabled.
Bonus change: merged all the bool flags into a bitfield
and made the compiler happy about the ivar reordering
in QCocoaMenu and QCocoaMenuItem's constructor.
Task-number: QTBUG-54698
Task-number: QTBUG-55121
Change-Id: Ie156cb3aa57a519103908ad4605f7b43c57e5aef
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm')
0 files changed, 0 insertions, 0 deletions