[Qt-creator] One submenu for two plugins?
Ziller Eike
Eike.Ziller at digia.com
Wed May 22 11:52:14 CEST 2013
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.
--
Eike Ziller, Senior Software Engineer - Digia, Qt
Digia Germany GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Anja Wasenius
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B
More information about the Qt-creator
mailing list