コード例 #1
0
QAction* RangeProfilePlotManager::createAction()
{
   QAction* pWindowAction = NULL;
   // Add a menu command to invoke the window
   MenuBar* pMenuBar = Service<DesktopServices>()->getMainMenuBar();
   if (pMenuBar != NULL)
   {
      QAction* pBeforeAction = NULL;
      QAction* pToolsAction = pMenuBar->getMenuItem("&Tools");
      if (pToolsAction != NULL)
      {
         QMenu* pMenu = pToolsAction->menu();
         if (pMenu != NULL)
         {
            QList<QAction*> actions = pMenu->actions();
            for (int i = 0; i < actions.count(); ++i)
            {
               QAction* pAction = actions[i];
               if (pAction != NULL)
               {
                  if ((pAction->text() == "S&cripting Window") && (pAction != actions.back()))
                  {
                     pBeforeAction = actions[i + 1];
                     break;
                  }
               }
            }
         }
      }

      pWindowAction = pMenuBar->addCommand("&Tools/&" + getName(), getName(), pBeforeAction);
      if (pWindowAction != NULL)
      {
         pWindowAction->setAutoRepeat(false);
         pWindowAction->setCheckable(true);
         pWindowAction->setToolTip(QString::fromStdString(getName()));
         pWindowAction->setStatusTip("Toggles the display of the " + QString::fromStdString(getName()));
      }
   }
   return pWindowAction;
}
コード例 #2
0
QAction* AnnotationImagePalette::createAction()
{
   QAction* pWindowAction = NULL;

   // Add a menu command to invoke the window
   MenuBar* pMenuBar = Service<DesktopServices>()->getMainMenuBar();
   if (pMenuBar != NULL)
   {
      QAction* pBeforeAction = NULL;
      QAction* pToolsAction = pMenuBar->getMenuItem("&Tools");
      if (pToolsAction != NULL)
      {
         QMenu* pMenu = pToolsAction->menu();
         if (pMenu != NULL)
         {
            QList<QAction*> actions = pMenu->actions();
            for (int i = 0; i < actions.count(); ++i)
            {
               QAction* pAction = actions[i];
               if (pAction != NULL)
               {
                  if ((pAction->text() == "S&cripting Window") && (pAction != actions.back()))
                  {
                     pBeforeAction = actions[i + 1];
                     break;
                  }
               }
            }
         }
      }

      pWindowAction = pMenuBar->addCommand("&Tools/&Annotation Image Palette", getName(), pBeforeAction);
      if (pWindowAction != NULL)
      {
         pWindowAction->setToolTip("Annotation Image Palette");
         pWindowAction->setStatusTip("Toggles the display of the Annotation Image Palette");
      }
   }
   return pWindowAction;
}