SpectralLibraryMatchResults::~SpectralLibraryMatchResults() { Service<DesktopServices> pDesktop; // remove toolbar button and menu item QAction* pAction = getAction(); if (pAction != NULL) { ToolBar* pToolBar = static_cast<ToolBar*>(pDesktop->getWindow("Spectral", TOOLBAR)); if (pToolBar != NULL) { pToolBar->removeItem(pAction); MenuBar* pMenuBar = pToolBar->getMenuBar(); if (pMenuBar != NULL) { pMenuBar->removeMenuItem(pAction); } } } // dockwindow should still exist so detach from it DockWindow* pWindow = getDockWindow(); if (pWindow != NULL) { pWindow->detach(SIGNAL_NAME(DockWindow, AboutToShowContextMenu), Slot(this, &SpectralLibraryMatchResults::updateContextMenu)); } }
QAction* SpectralLibraryMatchResults::createAction() { // Add toolbar button and menu item to invoke the window QAction* pShowAction(NULL); ToolBar* pToolBar = static_cast<ToolBar*>(Service<DesktopServices>()->getWindow("Spectral", TOOLBAR)); if (pToolBar != NULL) { MenuBar* pMenuBar = pToolBar->getMenuBar(); if (pMenuBar != NULL) { QAction* pMenuAction = pMenuBar->getMenuItem("/Spectral/Support Tools"); if (pMenuAction != NULL) { QMenu* pMenu = pMenuBar->getMenu(pMenuAction); if (pMenu != NULL) { pShowAction = pMenu->addAction("Spectral Library Match Results Window"); if (pShowAction != NULL) { QPixmap pixShowResults(ShowResultsIcon); pShowAction->setIcon(QIcon(pixShowResults)); pShowAction->setCheckable(true); pShowAction->setAutoRepeat(false); pShowAction->setStatusTip("Toggles the display of the Spectral Library Match Results Window"); pToolBar->addSeparator(); pToolBar->addButton(pShowAction); } } } } } return pShowAction; }