void Action::initialize() { const ActionsManager::ActionDefinition definition(getDefinition()); switch (m_identifier) { case ActionsManager::PreferencesAction: setMenuRole(QAction::PreferencesRole); break; case ActionsManager::AboutQtAction: setMenuRole(QAction::AboutQtRole); break; case ActionsManager::ExitAction: setMenuRole(QAction::QuitRole); break; case ActionsManager::AboutApplicationAction: setMenuRole(QAction::AboutRole); break; default: break; } setShortcutContext(Qt::WidgetShortcut); if (definition.isValid()) { if (definition.flags.testFlag(ActionsManager::ActionDefinition::IsCheckableFlag)) { setCheckable(true); } if (definition.flags.testFlag(ActionsManager::ActionDefinition::IsDeprecatedFlag)) { Console::addMessage(tr("Creating instance of deprecated action: %1").arg(ActionsManager::getActionName(m_identifier)), Console::OtherCategory, Console::WarningLevel); } connect(this, &Action::triggered, this, &Action::triggerAction); } updateIcon(); updateState(); connect(ActionsManager::getInstance(), &ActionsManager::shortcutsChanged, this, &Action::updateShortcut); }
void Plugin::fillMenu () { auto menu = Proxy_->GetMWProxy ()->GetMainMenu (); QMenu *lcMenu = 0; QList<QAction*> firstLevelActions; Q_FOREACH (auto action, menu->actions ()) if (action->menu ()) { MenuBar_->addAction (action); if (!lcMenu) lcMenu = action->menu (); } else { if (action->menuRole () == QAction::TextHeuristicRole) action->setMenuRole (QAction::ApplicationSpecificRole); firstLevelActions << action; } Q_FOREACH (auto act, firstLevelActions) lcMenu->addAction (act); if (!lcMenu->actions ().isEmpty ()) MenuBar_->addMenu (lcMenu); const auto& actors = Proxy_->GetPluginsManager ()-> GetAllCastableRoots<IActionsExporter*> (); Q_FOREACH (auto actor, actors) connect (actor, SIGNAL (gotActions (QList<QAction*>, LeechCraft::ActionsEmbedPlace)), this, SLOT (handleGotActions (QList<QAction*>, LeechCraft::ActionsEmbedPlace))); }
/* UIAction stuff: */ UIAction::UIAction(QObject *pParent, UIActionType type) : QIWithRetranslateUI3<QAction>(pParent) , m_type(type) { /* By default there is no specific menu role. * It will be set explicitly later. */ setMenuRole(QAction::NoRole); }
/* UIAction stuff: */ UIAction::UIAction(UIActionPool *pParent, UIActionType type) : QIWithRetranslateUI3<QAction>(pParent) , m_pActionPool(pParent) , m_type(type) , m_actionPoolType(pParent->type()) , m_fShortcutHidden(false) { /* By default there is no specific menu role. * It will be set explicitly later. */ setMenuRole(QAction::NoRole); }
UIActionSimpleAbout(QObject *pParent) : UIActionSimple(pParent, ":/about_16px.png") { setMenuRole(QAction::AboutRole); switch (gActionPool->type()) { case UIActionPoolType_Selector: setShortcut(gSS->keySequence(UISelectorShortcuts::AboutShortcut)); break; case UIActionPoolType_Runtime: setShortcut(gMS->keySequence(UIMachineShortcuts::AboutShortcut)); break; } retranslateUi(); }
UIActionSimpleCheckForUpdates(QObject *pParent) : UIActionSimple(pParent, ":/refresh_16px.png", ":/refresh_disabled_16px.png") { setMenuRole(QAction::ApplicationSpecificRole); switch (gActionPool->type()) { case UIActionPoolType_Selector: setShortcut(gSS->keySequence(UISelectorShortcuts::UpdateShortcut)); break; case UIActionPoolType_Runtime: setShortcut(gMS->keySequence(UIMachineShortcuts::UpdateShortcut)); break; } retranslateUi(); }
UIActionSimpleExit(UIActionPool *pParent) : UIActionSimple(pParent, ":/exit_16px.png") { setMenuRole(QAction::QuitRole); retranslateUi(); }
UIActionSimplePreferencesDialog(UIActionPool *pParent) : UIActionSimple(pParent, ":/global_settings_16px.png") { setMenuRole(QAction::PreferencesRole); retranslateUi(); }
UIActionSimpleAbout(UIActionPool *pParent) : UIActionSimple(pParent, ":/about_16px.png") { setMenuRole(QAction::AboutRole); retranslateUi(); }
UIActionSimpleCheckForUpdates(UIActionPool *pParent) : UIActionSimple(pParent, ":/refresh_16px.png", ":/refresh_disabled_16px.png") { setMenuRole(QAction::ApplicationSpecificRole); retranslateUi(); }
PerformCloseAction(QObject *pParent) : UISimpleAction(pParent, ":/exit_16px.png") { setMenuRole(QAction::QuitRole); retranslateUi(); }
UIActionSimpleNetworkAccessManager(UIActionPool *pParent) : UIActionSimple(pParent, ":/nw_16px.png", ":/nw_disabled_16px.png") { setMenuRole(QAction::ApplicationSpecificRole); retranslateUi(); }
UIActionSimpleResetWarnings(UIActionPool *pParent) : UIActionSimple(pParent, ":/reset_warnings_16px.png") { setMenuRole(QAction::ApplicationSpecificRole); retranslateUi(); }
UIActionSimplePerformClose(UIActionPool *pParent) : UIActionSimple(pParent, ":/exit_16px.png") { setMenuRole(QAction::QuitRole); }
int QAction::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 15) qt_static_metacall(this, _c, _id, _a); _id -= 15; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< bool*>(_v) = isCheckable(); break; case 1: *reinterpret_cast< bool*>(_v) = isChecked(); break; case 2: *reinterpret_cast< bool*>(_v) = isEnabled(); break; case 3: *reinterpret_cast< QIcon*>(_v) = icon(); break; case 4: *reinterpret_cast< QString*>(_v) = text(); break; case 5: *reinterpret_cast< QString*>(_v) = iconText(); break; case 6: *reinterpret_cast< QString*>(_v) = toolTip(); break; case 7: *reinterpret_cast< QString*>(_v) = statusTip(); break; case 8: *reinterpret_cast< QString*>(_v) = whatsThis(); break; case 9: *reinterpret_cast< QFont*>(_v) = font(); break; case 10: *reinterpret_cast< QKeySequence*>(_v) = shortcut(); break; case 11: *reinterpret_cast< Qt::ShortcutContext*>(_v) = shortcutContext(); break; case 12: *reinterpret_cast< bool*>(_v) = autoRepeat(); break; case 13: *reinterpret_cast< bool*>(_v) = isVisible(); break; case 14: *reinterpret_cast< MenuRole*>(_v) = menuRole(); break; case 15: *reinterpret_cast< SoftKeyRole*>(_v) = softKeyRole(); break; case 16: *reinterpret_cast< bool*>(_v) = isIconVisibleInMenu(); break; case 17: *reinterpret_cast< Priority*>(_v) = priority(); break; } _id -= 18; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setCheckable(*reinterpret_cast< bool*>(_v)); break; case 1: setChecked(*reinterpret_cast< bool*>(_v)); break; case 2: setEnabled(*reinterpret_cast< bool*>(_v)); break; case 3: setIcon(*reinterpret_cast< QIcon*>(_v)); break; case 4: setText(*reinterpret_cast< QString*>(_v)); break; case 5: setIconText(*reinterpret_cast< QString*>(_v)); break; case 6: setToolTip(*reinterpret_cast< QString*>(_v)); break; case 7: setStatusTip(*reinterpret_cast< QString*>(_v)); break; case 8: setWhatsThis(*reinterpret_cast< QString*>(_v)); break; case 9: setFont(*reinterpret_cast< QFont*>(_v)); break; case 10: setShortcut(*reinterpret_cast< QKeySequence*>(_v)); break; case 11: setShortcutContext(*reinterpret_cast< Qt::ShortcutContext*>(_v)); break; case 12: setAutoRepeat(*reinterpret_cast< bool*>(_v)); break; case 13: setVisible(*reinterpret_cast< bool*>(_v)); break; case 14: setMenuRole(*reinterpret_cast< MenuRole*>(_v)); break; case 15: setSoftKeyRole(*reinterpret_cast< SoftKeyRole*>(_v)); break; case 16: setIconVisibleInMenu(*reinterpret_cast< bool*>(_v)); break; case 17: setPriority(*reinterpret_cast< Priority*>(_v)); break; } _id -= 18; } else if (_c == QMetaObject::ResetProperty) { _id -= 18; } else if (_c == QMetaObject::QueryPropertyDesignable) { bool *_b = reinterpret_cast<bool*>(_a[0]); switch (_id) { case 1: *_b = isCheckable(); break; } _id -= 18; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 18; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 18; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 18; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 18; } #endif // QT_NO_PROPERTIES return _id; }