diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-06-04 17:24:49 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-06-04 17:24:49 (GMT) |
commit | 5c17f3abe1c43539db613da78414bc0b27928814 (patch) | |
tree | aeda95c710a5dd597d4e45a94f57729f0dc1a6dc /src/gui/widgets | |
parent | b70c535fb096652def0c4f6df6f9cd2827fa9c97 (diff) | |
parent | 398c022e8adefc6e71a6048da40c19f6169be831 (diff) | |
download | Qt-5c17f3abe1c43539db613da78414bc0b27928814.zip Qt-5c17f3abe1c43539db613da78414bc0b27928814.tar.gz Qt-5c17f3abe1c43539db613da78414bc0b27928814.tar.bz2 |
Merge commit 'origin/4.5'
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/qmenu_mac.mm | 52 | ||||
-rw-r--r-- | src/gui/widgets/qprogressbar.cpp | 2 |
2 files changed, 39 insertions, 15 deletions
diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 786633c..67656b4 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -907,8 +907,6 @@ static NSMenuItem *qt_mac_menu_merge_action(OSMenuRef merge, QMacMenuAction *act } } - if ([ret tag] != 0) - ret = 0; // already taken #endif return ret; } @@ -1168,15 +1166,15 @@ QMenuPrivate::QMacMenuPrivate::addAction(QMacMenuAction *action, QMacMenuAction GetMenuItemAttributes(action->menu, itemCount , &testattr); if (mergedItems.contains(action->command) && (testattr & kMenuItemAttrSeparator)) { - InsertMenuItemTextWithCFString(action->menu, 0, qMax(itemCount - 1, 0), attr, action->command); - index = itemCount; - } else { - MenuItemIndex tmpIndex; - AppendMenuItemTextWithCFString(action->menu, 0, attr, action->command, &tmpIndex); - index = tmpIndex; - if (mergedItems.contains(action->command)) - AppendMenuItemTextWithCFString(action->menu, 0, kMenuItemAttrSeparator, 0, &tmpIndex); - } + InsertMenuItemTextWithCFString(action->menu, 0, qMax(itemCount - 1, 0), attr, action->command); + index = itemCount; + } else { + MenuItemIndex tmpIndex; + AppendMenuItemTextWithCFString(action->menu, 0, attr, action->command, &tmpIndex); + index = tmpIndex; + if (mergedItems.contains(action->command)) + AppendMenuItemTextWithCFString(action->menu, 0, kMenuItemAttrSeparator, 0, &tmpIndex); + } #else [menu addItem:newItem]; #endif @@ -1477,11 +1475,18 @@ QMenuPrivate::QMacMenuPrivate::removeAction(QMacMenuAction *action) DeleteMenuItem(action->menu, qt_mac_menu_find_action(action->menu, action)); #else QMacCocoaAutoReleasePool pool; - QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); - if (action->menuItem == [loader quitMenuItem] || action->menuItem == [loader preferencesMenuItem]) - [action->menuItem setEnabled:false]; - else + if (action->merged) { + if (reinterpret_cast<QAction *>([action->menuItem tag]) == action->action) { + QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); + [action->menuItem setEnabled:false]; + if (action->menuItem != [loader quitMenuItem] + && action->menuItem != [loader preferencesMenuItem]) { + [[action->menuItem menu] removeItem:action->menuItem]; + } + } + } else { [[action->menuItem menu] removeItem:action->menuItem]; + } #endif actionItems.removeAll(action); } @@ -1936,6 +1941,23 @@ bool QMenuBar::macUpdateMenuBar() [loader ensureAppMenuInMenu:menu]; [NSApp setMainMenu:menu]; syncMenuBarItemsVisiblity(mb->d_func()->mac_menubar); + + if (OSMenuRef tmpMerge = QMenuPrivate::mergeMenuHash.value(menu)) { + if (QMenuMergeList *mergeList + = QMenuPrivate::mergeMenuItemsHash.value(tmpMerge)) { + const int mergeListSize = mergeList->size(); + + for (int i = 0; i < mergeListSize; ++i) { + const QMenuMergeItem &mergeItem = mergeList->at(i); + // Ideally we would call QMenuPrivate::syncAction, but that requires finding + // the original QMen and likely doing more work than we need. + // For example, enabled is handled below. + [mergeItem.menuItem setTag:reinterpret_cast<long>( + static_cast<QAction *>(mergeItem.action->action))]; + [mergeItem.menuItem setHidden:!(mergeItem.action->action->isVisible())]; + } + } + } #endif QWidget *modalWidget = qApp->activeModalWidget(); if (mb != menubars()->value(modalWidget)) { diff --git a/src/gui/widgets/qprogressbar.cpp b/src/gui/widgets/qprogressbar.cpp index 804220d..adc3582 100644 --- a/src/gui/widgets/qprogressbar.cpp +++ b/src/gui/widgets/qprogressbar.cpp @@ -349,6 +349,8 @@ void QProgressBar::setRange(int minimum, int maximum) \property QProgressBar::textVisible \brief whether the current completed percentage should be displayed + This property may be ignored by the style (e.g., QMacStyle never draws the text). + \sa textDirection */ void QProgressBar::setTextVisible(bool visible) |