src/gui/widgets/qmenu.cpp
branchRCL_3
changeset 7 3f74d0d4af4c
parent 5 d3bac044e0f0
child 13 c0432d11811c
equal deleted inserted replaced
6:dee5afe5301f 7:3f74d0d4af4c
   115         // make the torn-off menu a sibling of p (instead of a child)
   115         // make the torn-off menu a sibling of p (instead of a child)
   116         QWidget *parentWidget = d->causedStack.isEmpty() ? p : d->causedStack.last();
   116         QWidget *parentWidget = d->causedStack.isEmpty() ? p : d->causedStack.last();
   117         if (parentWidget->parentWidget())
   117         if (parentWidget->parentWidget())
   118             parentWidget = parentWidget->parentWidget();
   118             parentWidget = parentWidget->parentWidget();
   119         setParent(parentWidget, Qt::Window | Qt::Tool);
   119         setParent(parentWidget, Qt::Window | Qt::Tool);
   120 	setAttribute(Qt::WA_DeleteOnClose, true);
   120         setAttribute(Qt::WA_DeleteOnClose, true);
   121         setAttribute(Qt::WA_X11NetWmWindowTypeMenu, true);
   121         setAttribute(Qt::WA_X11NetWmWindowTypeMenu, true);
   122         setWindowTitle(p->windowTitle());
   122         setWindowTitle(p->windowTitle());
   123         setEnabled(p->isEnabled());
   123         setEnabled(p->isEnabled());
   124         //QObject::connect(this, SIGNAL(triggered(QAction*)), this, SLOT(onTrigger(QAction*)));
   124         //QObject::connect(this, SIGNAL(triggered(QAction*)), this, SLOT(onTrigger(QAction*)));
   125         //QObject::connect(this, SIGNAL(hovered(QAction*)), this, SLOT(onHovered(QAction*)));
   125         //QObject::connect(this, SIGNAL(hovered(QAction*)), this, SLOT(onHovered(QAction*)));
   166     }
   166     }
   167 
   167 
   168 #ifdef QT_SOFTKEYS_ENABLED
   168 #ifdef QT_SOFTKEYS_ENABLED
   169     selectAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::SelectSoftKey, Qt::Key_Select, q);
   169     selectAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::SelectSoftKey, Qt::Key_Select, q);
   170     cancelAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::CancelSoftKey, Qt::Key_Back, q);
   170     cancelAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::CancelSoftKey, Qt::Key_Back, q);
   171     selectAction->setVisible(false); // Don't show these in the menu
   171     selectAction->setPriority(QAction::HighPriority);
   172     cancelAction->setVisible(false);
   172     cancelAction->setPriority(QAction::HighPriority);
   173     q->addAction(selectAction);
   173     q->addAction(selectAction);
   174     q->addAction(cancelAction);
   174     q->addAction(cancelAction);
   175 #endif
   175 #endif
   176 }
   176 }
   177 
   177 
  1224     if (action->menu())
  1224     if (action->menu())
  1225         option->menuItemType = QStyleOptionMenuItem::SubMenu;
  1225         option->menuItemType = QStyleOptionMenuItem::SubMenu;
  1226     else if (action->isSeparator())
  1226     else if (action->isSeparator())
  1227         option->menuItemType = QStyleOptionMenuItem::Separator;
  1227         option->menuItemType = QStyleOptionMenuItem::Separator;
  1228     else if (d->defaultAction == action)
  1228     else if (d->defaultAction == action)
  1229 	    option->menuItemType = QStyleOptionMenuItem::DefaultItem;
  1229         option->menuItemType = QStyleOptionMenuItem::DefaultItem;
  1230     else
  1230     else
  1231         option->menuItemType = QStyleOptionMenuItem::Normal;
  1231         option->menuItemType = QStyleOptionMenuItem::Normal;
  1232     if (action->isIconVisibleInMenu())
  1232     if (action->isIconVisibleInMenu())
  1233         option->icon = action->icon();
  1233         option->icon = action->icon();
  1234     QString textAndAccel = action->text();
  1234     QString textAndAccel = action->text();
  1717     \sa removeAction()
  1717     \sa removeAction()
  1718 */
  1718 */
  1719 void QMenu::clear()
  1719 void QMenu::clear()
  1720 {
  1720 {
  1721     QList<QAction*> acts = actions();
  1721     QList<QAction*> acts = actions();
       
  1722 
  1722     for(int i = 0; i < acts.size(); i++) {
  1723     for(int i = 0; i < acts.size(); i++) {
       
  1724 #ifdef QT_SOFTKEYS_ENABLED
       
  1725         Q_D(QMenu);
       
  1726         // Lets not touch to our internal softkey actions
       
  1727         if(acts[i] == d->selectAction || acts[i] == d->cancelAction)
       
  1728             continue;
       
  1729 #endif
  1723         removeAction(acts[i]);
  1730         removeAction(acts[i]);
  1724         if (acts[i]->parent() == this && acts[i]->d_func()->widgets.isEmpty())
  1731         if (acts[i]->parent() == this && acts[i]->d_func()->widgets.isEmpty())
  1725             delete acts[i];
  1732             delete acts[i];
  1726     }
  1733     }
  1727 }
  1734 }
  2405         if (QAction *action = d->actionAt(static_cast<QHelpEvent*>(e)->pos())) {
  2412         if (QAction *action = d->actionAt(static_cast<QHelpEvent*>(e)->pos())) {
  2406             if (action->whatsThis().size() || action->menu())
  2413             if (action->whatsThis().size() || action->menu())
  2407                 e->accept();
  2414                 e->accept();
  2408         }
  2415         }
  2409         return true;
  2416         return true;
       
  2417 #endif
       
  2418 #ifdef QT_SOFTKEYS_ENABLED
       
  2419     case QEvent::LanguageChange: {
       
  2420         d->selectAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::SelectSoftKey));
       
  2421         d->cancelAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::CancelSoftKey));
       
  2422         }
       
  2423         break;
  2410 #endif
  2424 #endif
  2411     default:
  2425     default:
  2412         break;
  2426         break;
  2413     }
  2427     }
  2414     return QWidget::event(e);
  2428     return QWidget::event(e);
  2917     else if (e->type() == QEvent::ActionChanged)
  2931     else if (e->type() == QEvent::ActionChanged)
  2918         d->symbian_menu->syncAction(e->action());
  2932         d->symbian_menu->syncAction(e->action());
  2919 #endif
  2933 #endif
  2920     if (isVisible()) {
  2934     if (isVisible()) {
  2921         d->updateActionRects();
  2935         d->updateActionRects();
  2922 	resize(sizeHint());
  2936         resize(sizeHint());
  2923         update();
  2937         update();
  2924     }
  2938     }
  2925 }
  2939 }
  2926 
  2940 
  2927 /*!
  2941 /*!