QAction *QMenuProto::defaultAction() const { QMenu *item = qscriptvalue_cast<QMenu*>(thisObject()); if (item) return item->defaultAction(); return 0; }
QStyleOptionMenuItem KxMenuItemWidget::getStyleOption() const { QWidget *q = parentWidget(); QMenu *menu = (QMenu *)q; KxMenuItem *action = fMenuItem; QStyleOptionMenuItem opt; opt.initFrom(this); opt.palette = q->palette(); opt.state = QStyle::State_None; if (q->window()->isActiveWindow()) opt.state |= QStyle::State_Active; if (q->isEnabled() && action->isEnabled() && (!action->menu() || action->menu()->isEnabled())) opt.state |= QStyle::State_Enabled; else opt.palette.setCurrentColorGroup(QPalette::Disabled); opt.font = action->font(); if (menu->activeAction() == action && !action->isSeparator()) { opt.state |= QStyle::State_Selected; // | (mouseDown ? QStyle::State_Sunken : QStyle::State_None); } if (!action->isCheckable()) { opt.checkType = QStyleOptionMenuItem::NotCheckable; } else { opt.checkType = (action->actionGroup() && action->actionGroup()->isExclusive()) ? QStyleOptionMenuItem::Exclusive : QStyleOptionMenuItem::NonExclusive; opt.checked = action->isChecked(); } if (action->menu()) opt.menuItemType = QStyleOptionMenuItem::SubMenu; else if (action->isSeparator()) opt.menuItemType = QStyleOptionMenuItem::Separator; else if (menu->defaultAction() == action) opt.menuItemType = QStyleOptionMenuItem::DefaultItem; else opt.menuItemType = QStyleOptionMenuItem::Normal; opt.icon = action->icon(); opt.text = action->text(); opt.menuRect = q->rect(); return opt; }