summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2009-05-29 09:12:37 (GMT)
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2009-05-29 09:15:24 (GMT)
commit7de43fbe1dda9dd823483412cd66c44a6932023b (patch)
treedf2a316fe167e9947404c4eb10b6a7874fb55419
parentb946da648af0c5fa1c73fe1e57b0b1e08fb14d13 (diff)
downloadQt-7de43fbe1dda9dd823483412cd66c44a6932023b.zip
Qt-7de43fbe1dda9dd823483412cd66c44a6932023b.tar.gz
Qt-7de43fbe1dda9dd823483412cd66c44a6932023b.tar.bz2
Mac: App menus reactivated when a sheet is used on a modal dialog.
We need to check all window anchestors of the sheet to make sure that there it is not in effekt application modal Task-number: 254543 Reviewed-by: Trenton Schulz
-rw-r--r--src/gui/widgets/qmenu_mac.mm28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm
index cce083f..87c886c 100644
--- a/src/gui/widgets/qmenu_mac.mm
+++ b/src/gui/widgets/qmenu_mac.mm
@@ -1829,6 +1829,9 @@ OSMenuRef QMenuBar::macMenu() { return d_func()->macMenu(); }
*/
static bool qt_mac_is_ancestor(QWidget* possibleAncestor, QWidget *child)
{
+ if (!possibleAncestor)
+ return false;
+
QWidget * current = child->parentWidget();
while (current != 0) {
if (current == possibleAncestor)
@@ -1847,22 +1850,19 @@ static bool qt_mac_should_disable_menu(QMenuBar *menuBar, QWidget *modalWidget)
{
if (modalWidget == 0 || menuBar == 0)
return false;
- const Qt::WindowModality modality = modalWidget->windowModality();
- if (modality == Qt::ApplicationModal) {
- return true;
- } else if (modality == Qt::WindowModal) {
- QWidget * parent = menuBar->parentWidget();
-
- // Special case for the global menu bar: It's not associated
- // with a window so don't disable it.
- if (parent == 0)
- return false;
- // Disable menu entries in menu bars that belong to ancestors of
- // the modal widget, leave entries in unrelated menu bars enabled.
- return qt_mac_is_ancestor(parent, modalWidget);
+ // If there is an application modal window on
+ // screen, the entries of the menubar should be disabled:
+ QWidget *w = modalWidget;
+ while (w) {
+ if (w->isVisible() && w->windowModality() == Qt::ApplicationModal)
+ return true;
+ w = w->parentWidget();
}
- return false; // modality == NonModal
+
+ // INVARIANT: modalWidget is window modal. Disable menu entries
+ // if the menu bar belongs to an ancestor of modalWidget:
+ return qt_mac_is_ancestor(menuBar->parentWidget(), modalWidget);
}
static void cancelAllMenuTracking()