diff -r 41300fa6a67c -r f7bc934e204c src/gui/widgets/qmenu_symbian.cpp --- a/src/gui/widgets/qmenu_symbian.cpp Tue Feb 02 00:43:10 2010 +0200 +++ b/src/gui/widgets/qmenu_symbian.cpp Wed Mar 31 11:06:36 2010 +0300 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -81,6 +81,7 @@ static uint qt_symbian_menu_static_cmd_id = QT_SYMBIAN_FIRST_MENU_ITEM; static QPointer widgetWithContextMenu; static QList contextMenuActionList; +static QWidget* actionMenu = NULL; static int contexMenuCommand=0; bool menuExists() @@ -224,8 +225,26 @@ } #ifdef Q_WS_S60 +void qt_symbian_next_menu_from_action(QWidget *actionContainer) +{ + actionMenu = actionContainer; +} + void qt_symbian_show_toplevel( CEikMenuPane* menuPane) { + if (actionMenu) { + QMenuBarPrivate *mb = 0; + mb = menubars()->value(actionMenu); + qt_symbian_menu_static_cmd_id = QT_SYMBIAN_FIRST_MENU_ITEM; + deleteAll( &symbianMenus ); + Q_ASSERT(mb); + mb->symbian_menubar->rebuild(); + for (int i = 0; i < symbianMenus.count(); ++i) + QT_TRAP_THROWING(menuPane->AddMenuItemL(symbianMenus.at(i)->menuItemData)); + actionMenu = NULL; + return; + } + if (!menuExists()) return; rebuildMenu(); @@ -237,6 +256,14 @@ { SymbianMenuItem* menu = qt_symbian_find_menu(id, symbianMenus); if (menu) { + // Normally first AddMenuItemL call for menuPane will create the item array. + // However if we don't have any items, we still need the item array. Otherwise + // menupane will crash. That's why we create item array here manually, and + // AddMenuItemL will then use the existing array. + CEikMenuPane::CItemArray* itemArray = q_check_ptr(new CEikMenuPane::CItemArray); + menuPane->SetItemArray(itemArray); + menuPane->SetItemArrayOwnedExternally(EFalse); + for (int i = 0; i < menu->children.count(); ++i) QT_TRAP_THROWING(menuPane->AddMenuItemL(menu->children.at(i)->menuItemData)); } @@ -271,10 +298,16 @@ void QMenuBarPrivate::symbianCreateMenuBar(QWidget *parent) { Q_Q(QMenuBar); - if (parent && parent->isWindow()){ - menubars()->insert(q->window(), this); - symbian_menubar = new QSymbianMenuBarPrivate(this); - nativeMenuBars.append(q); + if (parent) { + if(parent->isWindow()) { + menubars()->insert(q->window(), this); + symbian_menubar = new QSymbianMenuBarPrivate(this); + nativeMenuBars.append(q); + } else { + menubars()->insert(q->parentWidget(), this); + symbian_menubar = new QSymbianMenuBarPrivate(this); + nativeMenuBars.append(q); + } } } @@ -284,12 +317,21 @@ int index = nativeMenuBars.indexOf(q); nativeMenuBars.removeAt(index); menubars()->remove(q->window(), this); + menubars()->remove(q->parentWidget(), this); rebuildMenu(); if (symbian_menubar) delete symbian_menubar; symbian_menubar = 0; } +void QMenuBarPrivate::reparentMenuBar(QWidget *oldParent, QWidget *newParent) +{ + if (menubars()->contains(oldParent)) { + QMenuBarPrivate *object = menubars()->take(oldParent); + menubars()->insert(newParent, object); + } +} + QMenuBarPrivate::QSymbianMenuBarPrivate::QSymbianMenuBarPrivate(QMenuBarPrivate *menubar) { d = menubar;