void MacMenu::_release(QObject *o) { XBAR_SEND( MSG("unregisterMenu") << (qlonglong)o ); QMenuBar *menu = qobject_cast<QMenuBar*>(o); if (!menu) return; items.removeAll(menu); menu->removeEventFilter(this); QWidget *dad = menu->parentWidget(); if (dad && dad->layout()) dad->layout()->setMenuBar(menu); menu->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); menu->adjustSize(); // menu->updateGeometry(); }
bool KxMenuItem::saveToShelf(int whichAction) { // First check that this is not a submenu item or separator if(menu() != NULL || isSeparator()) return false; // Only menu items from main menu bar are allowed to be saved to shelf. // Get topmost parent menu QMenu *menu = qobject_cast<QMenu *>(parent()); QMenu *parentMenu = qobject_cast<QMenu *>(menu->parentWidget()); while(parentMenu) { menu = parentMenu; parentMenu = qobject_cast<QMenu *>(menu->parentWidget()); } // Now get the menu bar QMenuBar *mbar = qobject_cast<QMenuBar *>(menu->parentWidget()); // Bail if parentWidget() is not a QMenuBar // if( mbar != NULL ){ // Check if this is main menu bar QVariant v = qApp->property("mainWindow"); if(v.isValid()) { QWidget *mainWindow = (QWidget *)(v.value<void *>()); if(mbar->parentWidget() == mainWindow) { //QString menuName; //QString cmdStr(kShelfMenuItemCmd); QAction *a = whichAction == kMainAction ? this : this->optionBoxAction(); if(NULL != a) { // gUIInventory->fullName(a, menuName); //cmdStr.append(menuName); // cmdStr.appendChar(kBackSlashDoubleQuote); //theCommandEngine->executeCommand( cmdStr ); return true; } } } } return false; }