macOS: don't show invisible separator items
Give QCocoaMenu access to the item's visibility property by adding a public getter, and respect that state when syncing the separator to the corresponding QCocoaNSMenuItems. Fixes: QTBUG-88651 Change-Id: I7e238e5d3be141ec8f4e8f6f3ab22d761094d2d2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> (cherry picked from commit a3f3af8a8fb8f8b09d1685df5ab836244f850a62) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
36bdb82c56
commit
b9588c0dfd
@ -303,9 +303,13 @@ void QCocoaMenu::syncSeparatorsCollapsible(bool enable)
|
||||
|
||||
for (NSMenuItem *item in m_nativeMenu.itemArray) {
|
||||
if (item.separatorItem) {
|
||||
if (auto *cocoaItem = qt_objc_cast<QCocoaNSMenuItem *>(item).platformMenuItem)
|
||||
cocoaItem->setVisible(!previousIsSeparator);
|
||||
item.hidden = previousIsSeparator;
|
||||
// hide item if previous was a separator, or if it's explicitly hidden
|
||||
bool itemVisible = !previousIsSeparator;
|
||||
if (auto *cocoaItem = qt_objc_cast<QCocoaNSMenuItem *>(item).platformMenuItem) {
|
||||
cocoaItem->setVisible(!previousIsSeparator && cocoaItem->isVisible());
|
||||
itemVisible = cocoaItem->isVisible();
|
||||
}
|
||||
item.hidden = !itemVisible;
|
||||
}
|
||||
|
||||
if (!item.hidden) {
|
||||
|
@ -117,6 +117,7 @@ public:
|
||||
inline bool isMerged() const { return m_merged; }
|
||||
inline bool isEnabled() const { return m_enabled && m_parentEnabled; }
|
||||
inline bool isSeparator() const { return m_isSeparator; }
|
||||
inline bool isVisible() const { return m_isVisible; }
|
||||
|
||||
QCocoaMenu *menu() const { return m_menu; }
|
||||
MenuRole effectiveRole() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user