#include <QmitkExtWorkbenchWindowAdvisor.h>
Public Member Functions | |
QmitkExtWorkbenchWindowAdvisor (berry::WorkbenchAdvisor *wbAdvisor, berry::IWorkbenchWindowConfigurer::Pointer configurer) | |
berry::ActionBarAdvisor::Pointer | CreateActionBarAdvisor (berry::IActionBarConfigurer::Pointer configurer) |
void * | CreateEmptyWindowContents (void *parent) |
void | PostWindowCreate () |
void | PreWindowOpen () |
void | ShowViewToolbar (bool show) |
void | ShowVersionInfo (bool show) |
void | SetProductName (const std::string &product) |
void | SetWindowIcon (const std::string &wndIcon) |
void | SetPerspectiveExcludeList (std::vector< std::string > v) |
std::vector< std::string > | GetPerspectiveExcludeList () |
Friends | |
struct | berry::PropertyChangeIntAdapter< QmitkExtWorkbenchWindowAdvisor > |
class | PartListenerForTitle |
class | PerspectiveListenerForTitle |
class | PartListenerForImageNavigator |
Definition at line 34 of file QmitkExtWorkbenchWindowAdvisor.h.
QmitkExtWorkbenchWindowAdvisor::QmitkExtWorkbenchWindowAdvisor | ( | berry::WorkbenchAdvisor * | wbAdvisor, |
berry::IWorkbenchWindowConfigurer::Pointer | configurer | ||
) |
Definition at line 275 of file QmitkExtWorkbenchWindowAdvisor.cpp.
References berry::Platform::GetConfiguration().
: QmitkCommonWorkbenchWindowAdvisor(configurer), lastInput(0), wbAdvisor(wbAdvisor), showViewToolbar(true), showVersionInfo(true) { productName = berry::Platform::GetConfiguration().getString("application.baseName"); }
berry::ActionBarAdvisor::Pointer QmitkExtWorkbenchWindowAdvisor::CreateActionBarAdvisor | ( | berry::IActionBarConfigurer::Pointer | configurer ) | [virtual] |
Reimplemented from berry::WorkbenchWindowAdvisor.
Definition at line 286 of file QmitkExtWorkbenchWindowAdvisor.cpp.
{ berry::ActionBarAdvisor::Pointer actionBarAdvisor( new QmitkExtActionBarAdvisor(configurer)); return actionBarAdvisor; }
void * QmitkExtWorkbenchWindowAdvisor::CreateEmptyWindowContents | ( | void * | parent ) | [virtual] |
Reimplemented from berry::WorkbenchWindowAdvisor.
Definition at line 294 of file QmitkExtWorkbenchWindowAdvisor.cpp.
{ QWidget* parentWidget = static_cast<QWidget*>(parent); QLabel* label = new QLabel(parentWidget); label->setText("<b>No perspectives are open. Open a perspective in the <i>Window->Open Perspective</i> menu.</b>"); label->setContentsMargins(10,10,10,10); label->setAlignment(Qt::AlignTop); label->setEnabled(false); parentWidget->layout()->addWidget(label); return label; }
std::vector< std::string > QmitkExtWorkbenchWindowAdvisor::GetPerspectiveExcludeList | ( | ) |
Definition at line 884 of file QmitkExtWorkbenchWindowAdvisor.cpp.
{
return this->perspectiveExcludeList;
}
void QmitkExtWorkbenchWindowAdvisor::PostWindowCreate | ( | ) | [virtual] |
Reimplemented from QmitkCommonWorkbenchWindowAdvisor.
Definition at line 326 of file QmitkExtWorkbenchWindowAdvisor.cpp.
References berry::IPerspectiveRegistry::GetPerspectives(), berry::IViewRegistry::GetViews(), berry::WorkbenchWindowAdvisor::GetWindowConfigurer(), berry::PlatformUI::GetWorkbench(), berry::SmartPointer< TObjectType >::IsNotNull(), PartListenerForImageNavigator, and QmitkStatusBar::SetSizeGripEnabled().
{ QmitkCommonWorkbenchWindowAdvisor::PostWindowCreate(); // very bad hack... berry::IWorkbenchWindow::Pointer window = this->GetWindowConfigurer()->GetWindow(); QMainWindow* mainWindow = static_cast<QMainWindow*> (window->GetShell()->GetControl()); if (!windowIcon.empty()) { mainWindow->setWindowIcon(QIcon(QString::fromStdString(windowIcon))); } /*mainWindow->setStyleSheet("color: white;" "background-color: #808080;" "selection-color: #659EC7;" "selection-background-color: #808080;" " QMenuBar {" "background-color: #808080; }");*/ // ==== Application menu ============================ QMenuBar* menuBar = mainWindow->menuBar(); QMenu* fileMenu = menuBar->addMenu("&File"); fileMenu->setObjectName("FileMenu"); QAction* fileOpenAction = new QmitkExtFileOpenAction(QIcon(":/org.mitk.gui.qt.ext/Load_48.png"), window); fileMenu->addAction(fileOpenAction); fileSaveProjectAction = new QmitkExtFileSaveProjectAction(window); fileSaveProjectAction->setIcon(QIcon(":/org.mitk.gui.qt.ext/Save_48.png")); fileMenu->addAction(fileSaveProjectAction); closeProjectAction = new QmitkCloseProjectAction(window); closeProjectAction->setIcon(QIcon(":/org.mitk.gui.qt.ext/Remove_48.png")); fileMenu->addAction(closeProjectAction); fileMenu->addSeparator(); QAction* fileExitAction = new QmitkFileExitAction(window); fileExitAction->setObjectName("QmitkFileExitAction"); fileMenu->addAction(fileExitAction); berry::IViewRegistry* viewRegistry = berry::PlatformUI::GetWorkbench()->GetViewRegistry(); const std::vector<berry::IViewDescriptor::Pointer>& viewDescriptors = viewRegistry->GetViews(); // another bad hack to get an edit/undo menu... QMenu* editMenu = menuBar->addMenu("&Edit"); undoAction = editMenu->addAction(QIcon(":/org.mitk.gui.qt.ext/Undo_48.png"), "&Undo", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onUndo()), QKeySequence("CTRL+Z")); undoAction->setToolTip("Undo the last action (not supported by all modules)"); redoAction = editMenu->addAction(QIcon(":/org.mitk.gui.qt.ext/Redo_48.png") , "&Redo", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onRedo()), QKeySequence("CTRL+Y")); redoAction->setToolTip("execute the last action that was undone again (not supported by all modules)"); imageNavigatorAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/Slider.png"), "&Image Navigator", NULL); QObject::connect(imageNavigatorAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onImageNavigator())); imageNavigatorAction->setCheckable(true); berry::IWorkbenchWindow::Pointer win = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow(); if(win.IsNotNull()) { // add part listener for image navigator imageNavigatorPartListener = new PartListenerForImageNavigator(imageNavigatorAction); win->GetPartService()->AddPartListener(imageNavigatorPartListener); berry::IViewPart::Pointer imageNavigatorView = win->GetActivePage()->FindView("org.mitk.views.imagenavigator"); imageNavigatorAction->setChecked(false); if (imageNavigatorView) { bool isImageNavigatorVisible = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->IsPartVisible(imageNavigatorView); if (isImageNavigatorVisible) imageNavigatorAction->setChecked(true); } } imageNavigatorAction->setToolTip("Open image navigator for navigating through image"); // toolbar for showing file open, undo, redo and other main actions QToolBar* mainActionsToolBar = new QToolBar; mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextBesideIcon ); mainActionsToolBar->addAction(fileOpenAction); mainActionsToolBar->addAction(fileSaveProjectAction); mainActionsToolBar->addAction(closeProjectAction); mainActionsToolBar->addAction(undoAction); mainActionsToolBar->addAction(redoAction); mainActionsToolBar->addAction(imageNavigatorAction); mainWindow->addToolBar(mainActionsToolBar); // ==== Window Menu ========================== QMenu* windowMenu = menuBar->addMenu("Window"); windowMenu->addAction("&New Window", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onNewWindow())); windowMenu->addSeparator(); QMenu* perspMenu = windowMenu->addMenu("&Open Perspective"); QMenu* viewMenu = windowMenu->addMenu("Show &View"); viewMenu->setObjectName("Show View"); windowMenu->addSeparator(); resetPerspAction = windowMenu->addAction("&Reset Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onResetPerspective())); closePerspAction = windowMenu->addAction("&Close Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onClosePerspective())); windowMenu->addSeparator(); windowMenu->addAction("&Preferences...", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onEditPreferences()), QKeySequence("CTRL+P")); // fill perspective menu berry::IPerspectiveRegistry* perspRegistry = window->GetWorkbench()->GetPerspectiveRegistry(); QActionGroup* perspGroup = new QActionGroup(menuBar); std::vector<berry::IPerspectiveDescriptor::Pointer> perspectives( perspRegistry->GetPerspectives()); bool skip = false; for (std::vector<berry::IPerspectiveDescriptor::Pointer>::iterator perspIt = perspectives.begin(); perspIt != perspectives.end(); ++perspIt) { // if perspectiveExcludeList is set, it contains the id-strings of perspectives, which // should not appear as an menu-entry in the perspective menu if (perspectiveExcludeList.size() > 0) { for (unsigned int i=0; i<perspectiveExcludeList.size(); i++) { if (perspectiveExcludeList.at(i) == (*perspIt)->GetId()) { skip = true; break; } } if (skip) { skip = false; continue; } } new berry::QtOpenPerspectiveAction(window, *perspIt, perspGroup); } perspMenu->addActions(perspGroup->actions()); // sort elements (converting vector to map...) std::vector<berry::IViewDescriptor::Pointer>::const_iterator iter; std::map<std::string, berry::IViewDescriptor::Pointer> VDMap; for (iter = viewDescriptors.begin(); iter != viewDescriptors.end(); ++iter) { if ((*iter)->GetId() == "org.blueberry.ui.internal.introview") continue; if ((*iter)->GetId() == "org.mitk.views.imagenavigator") continue; std::pair<std::string, berry::IViewDescriptor::Pointer> p( (*iter)->GetLabel(), (*iter)); VDMap.insert(p); } // ================================================== // ==== View Toolbar ================================== QToolBar* qToolbar = new QToolBar; std::map<std::string, berry::IViewDescriptor::Pointer>::const_iterator MapIter; for (MapIter = VDMap.begin(); MapIter != VDMap.end(); ++MapIter) { berry::QtShowViewAction* viewAction = new berry::QtShowViewAction(window, (*MapIter).second); viewActions.push_back(viewAction); viewMenu->addAction(viewAction); if (showViewToolbar) { qToolbar->addAction(viewAction); } } if (showViewToolbar) { mainWindow->addToolBar(qToolbar); } else delete qToolbar; // ==================================================== // ===== Help menu ==================================== QMenu* helpMenu = menuBar->addMenu("Help"); helpMenu->addAction("&Welcome",QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onIntro())); helpMenu->addAction("&Help Contents",QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onHelp()), QKeySequence("F1")); helpMenu->addAction("&About",QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onAbout())); // ===================================================== QStatusBar* qStatusBar = new QStatusBar(); //creating a QmitkStatusBar for Output on the QStatusBar and connecting it with the MainStatusBar QmitkStatusBar *statusBar = new QmitkStatusBar(qStatusBar); //disabling the SizeGrip in the lower right corner statusBar->SetSizeGripEnabled(false); QmitkProgressBar *progBar = new QmitkProgressBar(); qStatusBar->addPermanentWidget(progBar, 0); progBar->hide(); mainWindow->setStatusBar(qStatusBar); QmitkMemoryUsageIndicatorView* memoryIndicator = new QmitkMemoryUsageIndicatorView(); qStatusBar->addPermanentWidget(memoryIndicator, 0); }
void QmitkExtWorkbenchWindowAdvisor::PreWindowOpen | ( | ) | [virtual] |
Reimplemented from berry::WorkbenchWindowAdvisor.
Definition at line 539 of file QmitkExtWorkbenchWindowAdvisor.cpp.
References berry::WorkbenchWindowAdvisor::GetWindowConfigurer().
{ berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); // show the shortcut bar and progress indicator, which are hidden by // default //configurer->SetShowPerspectiveBar(true); //configurer->SetShowFastViewBars(true); //configurer->SetShowProgressIndicator(true); // // add the drag and drop support for the editor area // configurer.addEditorAreaTransfer(EditorInputTransfer.getInstance()); // configurer.addEditorAreaTransfer(ResourceTransfer.getInstance()); // configurer.addEditorAreaTransfer(FileTransfer.getInstance()); // configurer.addEditorAreaTransfer(MarkerTransfer.getInstance()); // configurer.configureEditorAreaDropListener(new EditorAreaDropAdapter( // configurer.getWindow())); this->HookTitleUpdateListeners(configurer); }
void QmitkExtWorkbenchWindowAdvisor::SetPerspectiveExcludeList | ( | std::vector< std::string > | v ) |
Definition at line 879 of file QmitkExtWorkbenchWindowAdvisor.cpp.
{ this->perspectiveExcludeList = v; }
void QmitkExtWorkbenchWindowAdvisor::SetProductName | ( | const std::string & | product ) |
Definition at line 316 of file QmitkExtWorkbenchWindowAdvisor.cpp.
{ productName = product; }
void QmitkExtWorkbenchWindowAdvisor::SetWindowIcon | ( | const std::string & | wndIcon ) |
Definition at line 321 of file QmitkExtWorkbenchWindowAdvisor.cpp.
Referenced by QmitkExtAppWorkbenchAdvisor::CreateWorkbenchWindowAdvisor().
{ windowIcon = wndIcon; }
void QmitkExtWorkbenchWindowAdvisor::ShowVersionInfo | ( | bool | show ) |
Definition at line 311 of file QmitkExtWorkbenchWindowAdvisor.cpp.
{ showVersionInfo = show; }
void QmitkExtWorkbenchWindowAdvisor::ShowViewToolbar | ( | bool | show ) |
Definition at line 306 of file QmitkExtWorkbenchWindowAdvisor.cpp.
{ showViewToolbar = show; }
friend struct berry::PropertyChangeIntAdapter< QmitkExtWorkbenchWindowAdvisor > [friend] |
Definition at line 89 of file QmitkExtWorkbenchWindowAdvisor.h.
friend class PartListenerForImageNavigator [friend] |
Definition at line 92 of file QmitkExtWorkbenchWindowAdvisor.h.
Referenced by PostWindowCreate().
friend class PartListenerForTitle [friend] |
Definition at line 90 of file QmitkExtWorkbenchWindowAdvisor.h.
friend class PerspectiveListenerForTitle [friend] |
Definition at line 91 of file QmitkExtWorkbenchWindowAdvisor.h.