[Qt-creator] One submenu for two plugins?

Thomas Meyer public at meyer-thomas.com
Wed May 22 12:25:50 CEST 2013


Thanks,
it works. :-)

I have only to adjust the two constants header files:
...
constcharMENU_ID[]="Kepler.Menu";
...

Thomas


Am 22.05.2013 11:52, schrieb Ziller Eike:
> On 22.05.2013, at 11:41, Thomas Meyer <public at meyer-thomas.com> wrote:
>
>> Hi,
>> I want to have the menu 'Tools' -> 'Kepler'.
>> With one plugin I want to add the action 'Ellipse Orbit...'
>> and with another plugin I want o add the action 'Eccentric Anomaly...'?
>>
>> In the eccentric anomaly plugin I have in the 'intialize' function the code:
>> ...
>>          QAction *action = new QAction(tr("Eccentric Anomaly..."), this);
>>      Core::Command *cmd = Core::ActionManager::registerAction(action,
>>                                                               Constants::ACTION_ID,
>>                                                               Core::Context(Core::Constants::C_GLOBAL));
>>      cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Meta+A")));
>>      connect(action, SIGNAL(triggered()),
>>              this, SLOT(showEccAnomDialog()));
>>      
>>      Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::MENU_ID);
>>      menu->menu()->setTitle(tr("Kepler"));
>>      menu->addAction(cmd);
>>      Core::ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu
>> );
>> ...
>>
>>
>>
>> Similar in the ellipse orbit plugin.
>> So, I get two 'Kepler' submenus, but I want only one.
>> How can I reach this?
> Usually we have a single plugin creating the menu, and the other depending on that plugins. If that doesn't fit your case, you can of course do
>
> Core::ActionContainer *menu = Core::ActionManager::actionContainer(Constants::MENU_ID);
> if (!menu) {
>      menu = Core::ActionManager::createMenu(Constants::MENU_ID);
>      menu->menu()->setTitle(tr("Kepler"));
> }
>
> in both plugins.
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20130522/08afa614/attachment.html>


More information about the Qt-creator mailing list