Ignore this, figured it out.

Here is the code, maybe it will be useful for someone later.

void BaseWorkbenchWindowAdvisor::PostWindowCreate()

{

  QmitkExtWorkbenchWindowAdvisor::PostWindowCreate();


  berry::IWorkbenchWindow::Pointer window =
this->GetWindowConfigurer()->GetWindow();

  QMainWindow* mainWindow =
static_cast<QMainWindow*>(window->GetShell()->GetControl());

  QMenuBar* menuBar = mainWindow->menuBar();

  QList<QMenu *> menus = menuBar->findChildren<QMenu*>();


  for (QMenu* menu: menus)

  {

    for (QAction* action: menu->actions())

    {

      if (action->text() == "&Reset Perspective")

      {

        berry::CommandContributionItemParameter::Pointer param(

              new berry::CommandContributionItemParameter(

                window.GetPointer(),

                QString(),

                berry::IWorkbenchCommandConstants::WINDOW_SAVE_PERSPECTIVE_AS,

                berry::CommandContributionItem::STYLE_PUSH));

        param->label = "Save Perspective &As...";

        m_SavePerspectiveItem = new berry::CommandContributionItem(param);

        m_SavePerspectiveItem->Fill(menu, action);

      }

    }

  }

}


Cheers,
Miklos


On 2 May 2017 at 11:31, Miklos Espak <m.es...@ucl.ac.uk> wrote:

> Hi,
>
> I noticed that the BlueBerry framework allows saving perspective with a
> given name. This feature would be quite handy for us.
>
> Is there a way to make BlueBerry create a Save Perspective action?
>
> As I see, it is enabled only if the command contributions are enabled, and
> for that you would need to change the USE_EXPERIMENTAL_COMMAND_CONTRIBUTIONS
> static variable to true in an MITK source file.
>
> We have a customised workbench window advisor that derives from
> QmitkExtWorkbenchWindowAdvisor. We can add new actions in
> PostWindowCreate().
>
> Cheers,
> Miklos
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mitk-users mailing list
mitk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to