summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoamenu.h
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@qt.io>2016-07-15 11:51:36 -0700
committerTimur Pocheptsov <timur.pocheptsov@theqtcompany.com>2016-08-17 18:21:53 +0000
commit9b491616f8353be243c5e5e98c864d09a25b99ea (patch)
tree56da56c45fa421060c2c687d7e0c67554a1a78aa /src/plugins/platforms/cocoa/qcocoamenu.h
parent810363945f0038ad40a48e1c5a86e3451a028822 (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/qcocoamenu.h')
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenu.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoamenu.h b/src/plugins/platforms/cocoa/qcocoamenu.h
index 98b0eb9c54..fed981bb19 100644
--- a/src/plugins/platforms/cocoa/qcocoamenu.h
+++ b/src/plugins/platforms/cocoa/qcocoamenu.h
@@ -65,7 +65,7 @@ public:
void syncSeparatorsCollapsible(bool enable) Q_DECL_OVERRIDE;
- void syncModalState(bool modal);
+ void propagateEnabledState(bool enabled);
void setIcon(const QIcon &icon) Q_DECL_OVERRIDE { Q_UNUSED(icon) }
@@ -98,9 +98,10 @@ private:
NSMenu *m_nativeMenu;
NSMenuItem *m_attachedItem;
quintptr m_tag;
- bool m_enabled;
- bool m_visible;
- bool m_isOpen;
+ bool m_enabled:1;
+ bool m_parentEnabled:1;
+ bool m_visible:1;
+ bool m_isOpen:1;
};
QT_END_NAMESPACE