18 #include <QMainWindow> 23 #include <QTextStream> 26 #include <ctkPluginException.h> 27 #include <service/event/ctkEventAdmin.h> 43 #include <internal/berryQtShowViewAction.h> 44 #include <internal/berryQtOpenPerspectiveAction.h> 62 #include <itkConfigure.h> 63 #include <vtkConfigure.h> 69 #include <vtkVersionMacros.h> 72 #include "internal/QmitkExtWorkbenchWindowAdvisorHack.h" 73 #include "internal/QmitkCommonExtPlugin.h" 77 #include <QToolButton> 78 #include <QMessageBox> 79 #include <QMouseEvent> 83 QmitkExtWorkbenchWindowAdvisorHack* QmitkExtWorkbenchWindowAdvisorHack::undohack =
84 new QmitkExtWorkbenchWindowAdvisorHack();
86 QString QmitkExtWorkbenchWindowAdvisor::QT_SETTINGS_FILENAME =
"QtSettings.ini";
109 windowAdvisor->UpdateTitle(
false);
117 windowAdvisor->UpdateTitle(
false);
123 windowAdvisor->UpdateTitle(
false);
128 if (!windowAdvisor->lastActiveEditor.Expired() &&
129 ref->GetPart(
false) == windowAdvisor->lastActiveEditor.Lock())
131 windowAdvisor->UpdateTitle(
true);
137 if (!windowAdvisor->lastActiveEditor.Expired() &&
138 ref->GetPart(
false) == windowAdvisor->lastActiveEditor.Lock())
140 windowAdvisor->UpdateTitle(
false);
152 PartListenerForViewNavigator(QAction* act)
153 : viewNavigatorAction(act)
157 Events::Types GetPartEventTypes()
const override 165 if (ref->GetId()==
"org.mitk.views.viewnavigatorview")
167 viewNavigatorAction->setChecked(
true);
173 if (ref->GetId()==
"org.mitk.views.viewnavigatorview")
175 viewNavigatorAction->setChecked(
false);
181 if (ref->GetId()==
"org.mitk.views.viewnavigatorview")
183 viewNavigatorAction->setChecked(
true);
189 if (ref->GetId()==
"org.mitk.views.viewnavigatorview")
191 viewNavigatorAction->setChecked(
false);
196 QAction* viewNavigatorAction;
203 PartListenerForImageNavigator(QAction* act)
204 : imageNavigatorAction(act)
208 Events::Types GetPartEventTypes()
const override 216 if (ref->GetId()==
"org.mitk.views.imagenavigator")
218 imageNavigatorAction->setChecked(
true);
224 if (ref->GetId()==
"org.mitk.views.imagenavigator")
226 imageNavigatorAction->setChecked(
false);
232 if (ref->GetId()==
"org.mitk.views.imagenavigator")
234 imageNavigatorAction->setChecked(
true);
240 if (ref->GetId()==
"org.mitk.views.imagenavigator")
242 imageNavigatorAction->setChecked(
false);
247 QAction* imageNavigatorAction;
256 , perspectivesClosed(
false)
260 Events::Types GetPerspectiveEventTypes()
const override 276 windowAdvisor->UpdateTitle(
false);
283 windowAdvisor->UpdateTitle(
false);
289 windowAdvisor->UpdateTitle(
false);
295 if (perspectivesClosed)
297 QListIterator<QAction*> i(windowAdvisor->viewActions);
300 i.next()->setEnabled(
true);
304 if(windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor(
"org.mitk.editors.dicomeditor"))
306 windowAdvisor->openDicomEditorAction->setEnabled(
true);
308 if (windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor(
"org.mitk.editors.stdmultiwidget"))
310 windowAdvisor->openStdMultiWidgetEditorAction->setEnabled(
true);
312 if (windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor(
"org.mitk.editors.mxnmultiwidget"))
314 windowAdvisor->openMxNMultiWidgetEditorAction->setEnabled(
true);
317 windowAdvisor->fileSaveProjectAction->setEnabled(
true);
318 windowAdvisor->closeProjectAction->setEnabled(
true);
319 windowAdvisor->undoAction->setEnabled(
true);
320 windowAdvisor->redoAction->setEnabled(
true);
321 windowAdvisor->imageNavigatorAction->setEnabled(
true);
322 windowAdvisor->viewNavigatorAction->setEnabled(
true);
323 windowAdvisor->resetPerspAction->setEnabled(
true);
324 if( windowAdvisor->GetShowClosePerspectiveMenuItem() )
326 windowAdvisor->closePerspAction->setEnabled(
true);
330 perspectivesClosed =
false;
337 bool allClosed =
true;
338 if (wnd->GetActivePage())
340 QList<berry::IPerspectiveDescriptor::Pointer>
perspectives(wnd->GetActivePage()->GetOpenPerspectives());
346 perspectivesClosed =
true;
348 QListIterator<QAction*> i(windowAdvisor->viewActions);
351 i.next()->setEnabled(
false);
354 if(windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor(
"org.mitk.editors.dicomeditor"))
356 windowAdvisor->openDicomEditorAction->setEnabled(
false);
358 if (windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor(
"org.mitk.editors.stdmultiwidget"))
360 windowAdvisor->openStdMultiWidgetEditorAction->setEnabled(
false);
362 if (windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor(
"org.mitk.editors.mxnmultiwidget"))
364 windowAdvisor->openMxNMultiWidgetEditorAction->setEnabled(
false);
367 windowAdvisor->fileSaveProjectAction->setEnabled(
false);
368 windowAdvisor->closeProjectAction->setEnabled(
false);
369 windowAdvisor->undoAction->setEnabled(
false);
370 windowAdvisor->redoAction->setEnabled(
false);
371 windowAdvisor->imageNavigatorAction->setEnabled(
false);
372 windowAdvisor->viewNavigatorAction->setEnabled(
false);
373 windowAdvisor->resetPerspAction->setEnabled(
false);
374 if( windowAdvisor->GetShowClosePerspectiveMenuItem() )
376 windowAdvisor->closePerspAction->setEnabled(
false);
383 bool perspectivesClosed;
395 Events::Types GetPerspectiveEventTypes()
const override 403 QAction* action = windowAdvisor->mapPerspIdToAction[perspective->GetId()];
406 action->setChecked(
true);
413 QAction* action = windowAdvisor->mapPerspIdToAction[perspective->GetId()];
416 action->setChecked(
false);
426 :
berry::WorkbenchWindowAdvisor(configurer)
428 , wbAdvisor(wbAdvisor)
429 , showViewToolbar(true)
430 , showPerspectiveToolbar(false)
431 , showVersionInfo(true)
432 , showMitkVersionInfo(true)
433 , showViewMenuItem(true)
434 , showNewWindowMenuItem(false)
435 , showClosePerspectiveMenuItem(true)
436 , viewNavigatorFound(false)
437 , showMemoryIndicator(true)
440 productName = QCoreApplication::applicationName();
441 viewExcludeList.push_back(
"org.mitk.views.viewnavigatorview");
453 return actionBarAdvisor;
463 QWidget* parentWidget =
static_cast<QWidget*
>(parent);
464 auto label =
new QLabel(parentWidget);
465 label->setText(
"<b>No perspectives are open. Open a perspective in the <i>Window->Open Perspective</i> menu.</b>");
466 label->setContentsMargins(10,10,10,10);
467 label->setAlignment(Qt::AlignTop);
468 label->setEnabled(
false);
469 parentWidget->layout()->addWidget(label);
475 showClosePerspectiveMenuItem = show;
480 return showClosePerspectiveMenuItem;
485 showMemoryIndicator = show;
490 return showMemoryIndicator;
495 showNewWindowMenuItem = show;
500 showViewToolbar = show;
505 showViewMenuItem = show;
510 showPerspectiveToolbar = show;
515 showVersionInfo = show;
520 showMitkVersionInfo = show;
525 productName = product;
530 windowIcon = wndIcon;
537 QMainWindow* mainWindow = qobject_cast<QMainWindow*> (window->GetShell()->GetControl());
539 if (!windowIcon.isEmpty())
541 mainWindow->setWindowIcon(QIcon(windowIcon));
543 mainWindow->setContextMenuPolicy(Qt::PreventContextMenu);
546 QIcon::setThemeSearchPaths(QStringList() << QStringLiteral(
":/org_mitk_icons/icons/"));
547 QIcon::setThemeName(QStringLiteral(
"awesome"));
551 QMenuBar* menuBar = mainWindow->menuBar();
552 menuBar->setContextMenuPolicy(Qt::PreventContextMenu);
555 menuBar->setNativeMenuBar(
true);
557 menuBar->setNativeMenuBar(
false);
560 auto basePath = QStringLiteral(
":/org_mitk_icons/icons/awesome/scalable/actions/");
563 fileOpenAction->setShortcut(QKeySequence::Open);
565 fileSaveAction->setShortcut(QKeySequence::Save);
571 auto perspGroup =
new QActionGroup(menuBar);
572 std::map<QString, berry::IViewDescriptor::Pointer> VDMap;
575 QList<berry::IViewDescriptor::Pointer>::const_iterator iter;
579 const QList<berry::IViewDescriptor::Pointer> viewDescriptors = viewRegistry->
GetViews();
582 for (iter = viewDescriptors.begin(); iter != viewDescriptors.end(); ++iter)
586 if (viewExcludeList.size() > 0)
588 for (
int i=0; i<viewExcludeList.size(); i++)
590 if (viewExcludeList.at(i) == (*iter)->GetId())
603 if ((*iter)->GetId() ==
"org.blueberry.ui.internal.introview")
605 if ((*iter)->GetId() ==
"org.mitk.views.imagenavigator")
607 if ((*iter)->GetId() ==
"org.mitk.views.viewnavigatorview")
610 std::pair<QString, berry::IViewDescriptor::Pointer> p((*iter)->GetLabel(), (*iter));
614 std::map<QString, berry::IViewDescriptor::Pointer>::const_iterator MapIter;
615 for (MapIter = VDMap.begin(); MapIter != VDMap.end(); ++MapIter)
617 berry::QtShowViewAction* viewAction =
new berry::QtShowViewAction(window, (*MapIter).second);
618 viewActions.push_back(viewAction);
623 QMenu* fileMenu = menuBar->addMenu(
"&File");
624 fileMenu->setObjectName(
"FileMenu");
625 fileMenu->addAction(fileOpenAction);
626 fileMenu->addAction(fileSaveAction);
627 fileMenu->addAction(fileSaveProjectAction);
628 fileMenu->addAction(closeProjectAction);
629 fileMenu->addSeparator();
633 fileExitAction->setShortcut(QKeySequence::Quit);
634 fileExitAction->setObjectName(
"QmitkFileExitAction");
635 fileMenu->addAction(fileExitAction);
638 QMenu* editMenu = menuBar->addMenu(
"&Edit");
641 QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onUndo()),
642 QKeySequence(
"CTRL+Z"));
643 undoAction->setToolTip(
"Undo the last action (not supported by all modules)");
646 QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onRedo()),
647 QKeySequence(
"CTRL+Y"));
648 redoAction->setToolTip(
"execute the last action that was undone again (not supported by all modules)");
651 QMenu* windowMenu = menuBar->addMenu(
"Window");
652 if (showNewWindowMenuItem)
654 windowMenu->addAction(
"&New Window", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onNewWindow()));
655 windowMenu->addSeparator();
658 QMenu* perspMenu = windowMenu->addMenu(
"&Open Perspective");
660 QMenu* viewMenu =
nullptr;
661 if (showViewMenuItem)
663 viewMenu = windowMenu->addMenu(
"Show &View");
664 viewMenu->setObjectName(
"Show View");
666 windowMenu->addSeparator();
667 resetPerspAction = windowMenu->addAction(
"&Reset Perspective",
668 QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onResetPerspective()));
670 if(showClosePerspectiveMenuItem)
671 closePerspAction = windowMenu->addAction(
"&Close Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onClosePerspective()));
673 windowMenu->addSeparator();
674 windowMenu->addAction(
"&Preferences...",
675 QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onEditPreferences()),
676 QKeySequence(
"CTRL+P"));
680 window->GetWorkbench()->GetPerspectiveRegistry();
682 QList<berry::IPerspectiveDescriptor::Pointer>
perspectives(
686 for (QList<berry::IPerspectiveDescriptor::Pointer>::iterator perspIt =
691 if (perspectiveExcludeList.size() > 0)
693 for (
int i=0; i<perspectiveExcludeList.size(); i++)
695 if (perspectiveExcludeList.at(i) == (*perspIt)->GetId())
708 QAction* perspAction =
new berry::QtOpenPerspectiveAction(window, *perspIt, perspGroup);
709 mapPerspIdToAction.insert((*perspIt)->GetId(), perspAction);
711 perspMenu->addActions(perspGroup->actions());
713 if (showViewMenuItem)
715 for (
auto viewAction : viewActions)
717 viewMenu->addAction(viewAction);
722 QMenu* helpMenu = menuBar->addMenu(
"&Help");
723 helpMenu->addAction(
"&Welcome",
this, SLOT(
onIntro()));
725 helpMenu->addAction(
"&Context Help",
this, SLOT(
onHelp()), QKeySequence(
"F1"));
726 helpMenu->addAction(
"&About",
this, SLOT(
onAbout()));
732 undoAction->setShortcut(QKeySequence::Undo);
734 redoAction->setShortcut(QKeySequence::Redo);
738 auto mainActionsToolBar =
new QToolBar;
739 mainActionsToolBar->setObjectName(
"mainActionsToolBar");
740 mainActionsToolBar->setContextMenuPolicy(Qt::PreventContextMenu);
742 mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextUnderIcon );
744 mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextBesideIcon );
747 basePath = QStringLiteral(
":/org.mitk.gui.qt.ext/");
749 bool imageNavigatorViewFound = window->GetWorkbench()->GetViewRegistry()->Find(
"org.mitk.views.imagenavigator");
751 if (this->
GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor(
"org.mitk.editors.dicomeditor"))
755 if (this->
GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor(
"org.mitk.editors.stdmultiwidget"))
759 if (this->
GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor(
"org.mitk.editors.mxnmultiwidget"))
764 if (imageNavigatorViewFound)
766 QObject::connect(imageNavigatorAction, SIGNAL(triggered(
bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onImageNavigator()));
767 imageNavigatorAction->setCheckable(
true);
771 window->GetPartService()->AddPartListener(imageNavigatorPartListener.data());
773 imageNavigatorAction->setChecked(
false);
774 if (imageNavigatorView)
776 bool isImageNavigatorVisible = window->GetActivePage()->IsPartVisible(imageNavigatorView);
777 if (isImageNavigatorVisible)
778 imageNavigatorAction->setChecked(
true);
780 imageNavigatorAction->setToolTip(
"Toggle image navigator for navigating through image");
784 viewNavigatorFound = window->GetWorkbench()->GetViewRegistry()->Find(
"org.mitk.views.viewnavigatorview");
785 if (viewNavigatorFound)
787 QObject::connect(viewNavigatorAction, SIGNAL(triggered(
bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onViewNavigator()));
788 viewNavigatorAction->setCheckable(
true);
792 window->GetPartService()->AddPartListener(viewNavigatorPartListener.data());
794 viewNavigatorAction->setChecked(
false);
795 if (viewnavigatorview)
797 bool isViewNavigatorVisible = window->GetActivePage()->IsPartVisible(viewnavigatorview);
798 if (isViewNavigatorVisible)
799 viewNavigatorAction->setChecked(
true);
801 viewNavigatorAction->setToolTip(
"Toggle View Navigator");
804 mainActionsToolBar->addAction(fileOpenAction);
805 mainActionsToolBar->addAction(fileSaveProjectAction);
806 mainActionsToolBar->addAction(closeProjectAction);
807 mainActionsToolBar->addAction(undoAction);
808 mainActionsToolBar->addAction(redoAction);
809 if(this->
GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor(
"org.mitk.editors.dicomeditor"))
811 mainActionsToolBar->addAction(openDicomEditorAction);
813 if (this->
GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor(
"org.mitk.editors.stdmultiwidget"))
815 mainActionsToolBar->addAction(openStdMultiWidgetEditorAction);
817 if (this->
GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor(
"org.mitk.editors.mxnmultiwidget"))
819 mainActionsToolBar->addAction(openMxNMultiWidgetEditorAction);
822 if (imageNavigatorViewFound)
824 mainActionsToolBar->addAction(imageNavigatorAction);
826 if (viewNavigatorFound)
828 mainActionsToolBar->addAction(viewNavigatorAction);
830 mainWindow->addToolBar(mainActionsToolBar);
833 auto qPerspectiveToolbar =
new QToolBar;
834 qPerspectiveToolbar->setObjectName(
"perspectiveToolBar");
836 if (showPerspectiveToolbar)
838 qPerspectiveToolbar->addActions(perspGroup->actions());
839 mainWindow->addToolBar(qPerspectiveToolbar);
842 delete qPerspectiveToolbar;
852 QMultiMap<QString, berry::IViewDescriptor::Pointer> categoryViewDescriptorMap;
854 for (
auto labelViewDescriptorPair : VDMap)
856 auto viewDescriptor = labelViewDescriptorPair.second;
857 auto category = !viewDescriptor->GetCategoryPath().isEmpty()
858 ? viewDescriptor->GetCategoryPath().back()
861 categoryViewDescriptorMap.insert(category, viewDescriptor);
866 for (
auto category : categoryViewDescriptorMap.uniqueKeys())
868 auto viewDescriptorsInCurrentCategory = categoryViewDescriptorMap.values(category);
870 if (!viewDescriptorsInCurrentCategory.isEmpty())
872 auto toolbar =
new QToolBar;
873 toolbar->setObjectName(category +
" View Toolbar");
874 mainWindow->addToolBar(toolbar);
876 if (showCategoryNames && !category.isEmpty())
878 auto categoryButton =
new QToolButton;
879 categoryButton->setToolButtonStyle(Qt::ToolButtonTextOnly);
880 categoryButton->setText(category);
881 categoryButton->setStyleSheet(
"background: transparent; margin: 0; padding: 0;");
882 toolbar->addWidget(categoryButton);
884 connect(categoryButton, &QToolButton::clicked, [toolbar]()
886 for (QWidget* widget : toolbar->findChildren<QWidget*>())
888 if (QStringLiteral(
"qt_toolbar_ext_button") == widget->objectName() && widget->isVisible())
890 QMouseEvent pressEvent(QEvent::MouseButtonPress, QPointF(0.0f, 0.0f), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
891 QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPointF(0.0f, 0.0f), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
892 QApplication::sendEvent(widget, &pressEvent);
893 QApplication::sendEvent(widget, &releaseEvent);
899 for (
auto viewDescriptor : viewDescriptorsInCurrentCategory)
901 auto viewAction =
new berry::QtShowViewAction(window, viewDescriptor);
902 toolbar->addAction(viewAction);
908 QSettings settings(GetQSettingsFile(), QSettings::IniFormat);
909 mainWindow->restoreState(settings.value(
"ToolbarPosition").toByteArray());
911 auto qStatusBar =
new QStatusBar();
916 statusBar->SetSizeGripEnabled(
false);
920 qStatusBar->addPermanentWidget(progBar, 0);
925 mainWindow->setStatusBar(qStatusBar);
927 if (showMemoryIndicator)
930 qStatusBar->addPermanentWidget(memoryIndicator, 0);
952 this->HookTitleUpdateListeners(configurer);
955 configurer->GetWindow()->AddPerspectiveListener(menuPerspectiveListener.data());
957 configurer->AddEditorAreaTransfer(QStringList(
"text/uri-list"));
958 configurer->ConfigureEditorAreaDropListener(dropTargetListener.data());
967 ctkPluginContext* context = QmitkCommonExtPlugin::getContext();
983 QmitkExtWorkbenchWindowAdvisorHack::undohack->onIntro();
988 QmitkExtWorkbenchWindowAdvisorHack::undohack->onHelp();
993 QmitkExtWorkbenchWindowAdvisorHack::undohack->onHelpOpenHelpPerspective();
998 QmitkExtWorkbenchWindowAdvisorHack::undohack->onAbout();
1006 QmitkExtWorkbenchWindowAdvisorHack::QmitkExtWorkbenchWindowAdvisorHack()
1011 QmitkExtWorkbenchWindowAdvisorHack::~QmitkExtWorkbenchWindowAdvisorHack()
1015 void QmitkExtWorkbenchWindowAdvisorHack::onUndo()
1023 if (descriptions.size() >= 1)
1025 MITK_INFO <<
"Undo " << descriptions.front().second;
1036 void QmitkExtWorkbenchWindowAdvisorHack::onRedo()
1044 if (descriptions.size() >= 1)
1046 MITK_INFO <<
"Redo " << descriptions.front().second;
1063 if( wbench ==
nullptr )
1067 if( wbench_window.
IsNull() )
1071 if( wbench_page.
IsNull() )
1074 auto wbench_view = wbench_page->FindView( view_query_name );
1076 if( wbench_view.IsNotNull() )
1078 bool isViewVisible = wbench_page->IsPartVisible( wbench_view );
1081 wbench_page->HideView( wbench_view );
1087 wbench_page->ShowView( view_query_name );
1090 void QmitkExtWorkbenchWindowAdvisorHack::onImageNavigator()
1096 void QmitkExtWorkbenchWindowAdvisorHack::onViewNavigator()
1102 void QmitkExtWorkbenchWindowAdvisorHack::onEditPreferences()
1105 _PreferencesDialog.exec();
1108 void QmitkExtWorkbenchWindowAdvisorHack::onQuit()
1113 void QmitkExtWorkbenchWindowAdvisorHack::onResetPerspective()
1118 void QmitkExtWorkbenchWindowAdvisorHack::onClosePerspective()
1122 page->ClosePerspective(page->GetPerspective(),
true,
true);
1125 void QmitkExtWorkbenchWindowAdvisorHack::onNewWindow()
1130 void QmitkExtWorkbenchWindowAdvisorHack::onIntro()
1136 QRegExp reg(
"(.*)<title>(\\n)*");
1137 QRegExp reg2(
"(\\n)*</title>(.*)");
1138 QFile file(
":/org.mitk.gui.qt.ext/index.html");
1139 file.open(QIODevice::ReadOnly | QIODevice::Text);
1141 QString text = QString(file.readAll());
1145 QString title = text;
1146 title.replace(reg,
"");
1147 title.replace(reg2,
"");
1149 std::cout << title.toStdString() << std::endl;
1151 QMessageBox::information(
nullptr, title,
1161 void QmitkExtWorkbenchWindowAdvisorHack::onHelp()
1163 ctkPluginContext* context = QmitkCommonExtPlugin::getContext();
1164 if (context ==
nullptr)
1166 MITK_WARN <<
"Plugin context not set, unable to open context help";
1171 QList<QSharedPointer<ctkPlugin> > plugins = context->getPlugins();
1174 if (p->getSymbolicName() ==
"org.blueberry.ui.qt.help")
1176 if (p->getState() != ctkPlugin::ACTIVE)
1181 p->start(ctkPlugin::START_TRANSIENT);
1183 catch (
const ctkPluginException& pe)
1185 MITK_ERROR <<
"Activating org.blueberry.ui.qt.help failed: " << pe.what();
1192 ctkServiceReference eventAdminRef = context->getServiceReference<ctkEventAdmin>();
1193 ctkEventAdmin* eventAdmin =
nullptr;
1196 eventAdmin = context->getService<ctkEventAdmin>(eventAdminRef);
1198 if (eventAdmin ==
nullptr)
1200 MITK_WARN <<
"ctkEventAdmin service not found. Unable to open context help";
1204 ctkEvent ev(
"org/blueberry/ui/help/CONTEXTHELP_REQUESTED");
1205 eventAdmin->postEvent(ev);
1209 void QmitkExtWorkbenchWindowAdvisorHack::onHelpOpenHelpPerspective()
1215 void QmitkExtWorkbenchWindowAdvisorHack::onAbout()
1217 auto aboutDialog =
new QmitkAboutDialog(QApplication::activeWindow(),
nullptr);
1218 aboutDialog->open();
1228 &QmitkExtWorkbenchWindowAdvisor::PropertyChange));
1244 configurer->GetWindow()->AddPerspectiveListener(titlePerspectiveListener.data());
1245 configurer->GetWindow()->GetPartService()->AddPartListener(titlePartListener.data());
1248 QString QmitkExtWorkbenchWindowAdvisor::ComputeTitle()
1255 activeEditor = lastActiveEditor.
Lock();
1262 title = product->GetName();
1264 if (title.isEmpty())
1267 title = productName;
1270 if(showMitkVersionInfo)
1274 if(mitkVersionInfo.isEmpty())
1277 title +=
" " + mitkVersionInfo;
1280 if (showVersionInfo)
1283 QString versions = QString(
" (ITK %1.%2.%3 | VTK %4.%5.%6 | Qt %7)")
1284 .arg(ITK_VERSION_MAJOR).arg(ITK_VERSION_MINOR).arg(ITK_VERSION_PATCH)
1285 .arg(VTK_MAJOR_VERSION).arg(VTK_MINOR_VERSION).arg(VTK_BUILD_VERSION)
1286 .arg(QT_VERSION_STR);
1295 lastEditorTitle = activeEditor->GetTitleToolTip();
1296 if (!lastEditorTitle.isEmpty())
1297 title = lastEditorTitle +
" - " + title;
1303 label = persp->GetLabel();
1308 label = currentPage->GetLabel();
1310 if (!label.isEmpty())
1312 title = label +
" - " + title;
1316 title +=
" (Not for use in diagnosis or treatment of patients)";
1321 void QmitkExtWorkbenchWindowAdvisor::RecomputeTitle()
1324 QString oldTitle = configurer->GetTitle();
1325 QString newTitle = ComputeTitle();
1326 if (newTitle != oldTitle)
1328 configurer->SetTitle(newTitle);
1332 void QmitkExtWorkbenchWindowAdvisor::UpdateTitle(
bool editorHidden)
1343 activeEditor = currentPage->GetActiveEditor();
1344 persp = currentPage->GetPerspective();
1345 input = currentPage->GetInput();
1350 activeEditor =
nullptr;
1354 if (activeEditor == lastActiveEditor.
Lock() && currentPage == lastActivePage.
Lock()
1355 && persp == lastPerspective.
Lock() && input == lastInput)
1360 if (!lastActiveEditor.
Expired())
1362 lastActiveEditor.
Lock()->RemovePropertyListener(editorPropertyListener.data());
1365 lastActiveEditor = activeEditor;
1366 lastActivePage = currentPage;
1367 lastPerspective = persp;
1372 activeEditor->AddPropertyListener(editorPropertyListener.data());
1382 if (!lastActiveEditor.
Expired())
1384 QString newTitle = lastActiveEditor.
Lock()->GetPartName();
1385 if (lastEditorTitle != newTitle)
1395 this->perspectiveExcludeList = v;
1400 return this->perspectiveExcludeList;
1405 this->viewExcludeList = v;
1410 return this->viewExcludeList;
1416 QMainWindow* mainWindow =
static_cast<QMainWindow*
> (window->GetShell()->GetControl());
1418 QSettings settings(GetQSettingsFile(), QSettings::IniFormat);
1419 settings.setValue(
"ToolbarPosition", mainWindow->saveState());
1422 QString QmitkExtWorkbenchWindowAdvisor::GetQSettingsFile()
const 1424 QFileInfo settingsInfo = QmitkCommonExtPlugin::getContext()->getDataFile(QT_SETTINGS_FILENAME);
1425 return settingsInfo.canonicalFilePath();
QWidget * CreateEmptyWindowContents(QWidget *parent) override
void ShowVersionInfo(bool show)
virtual void PartHidden(const IWorkbenchPartReference::Pointer &)
#define MITK_VERSION_STRING
void ShowPerspectiveToolbar(bool show)
void ShowViewMenuItem(bool show)
virtual void onHelpOpenHelpPerspective()
void PostWindowClose() override
berry::SmartPointer< berry::ActionBarAdvisor > CreateActionBarAdvisor(berry::SmartPointer< berry::IActionBarConfigurer > configurer) override
void ShowViewToolbar(bool show)
SmartPointer< Other > Cast() const
QmitkExtWorkbenchWindowAdvisor(berry::WorkbenchAdvisor *wbAdvisor, berry::IWorkbenchWindowConfigurer::Pointer configurer)
virtual IDataStorageReference::Pointer GetDataStorage() const =0
static QIcon ThemeIcon(const QByteArray &originalSVG)
virtual SmartPointer< ActionBarAdvisor > CreateActionBarAdvisor(SmartPointer< IActionBarConfigurer > configurer)
virtual IIntroManager * GetIntroManager() const =0
virtual QList< IPerspectiveDescriptor::Pointer > GetPerspectives()=0
static bool USE_EXPERIMENTAL_COMMAND_CONTRIBUTIONS
QT-Toolkit/GUI dependent class that provides the QT's ProgressBar.
static WorkbenchPlugin * GetDefault()
virtual void PostWindowOpen()
void PreWindowOpen() override
bool GetShowClosePerspectiveMenuItem()
SmartPointer< ObjectType > Lock() const
virtual void PartActivated(const IWorkbenchPartReference::Pointer &)
friend class PerspectiveListenerForTitle
virtual IIntroPart::Pointer ShowIntro(IWorkbenchWindow::Pointer preferredWindow, bool standby)=0
SmartPointer< IWorkbenchWindowConfigurer > GetWindowConfigurer()
void SetPerspectiveExcludeList(const QList< QString > &v)
virtual bool HasIntro() const =0
void ShowMitkVersionInfo(bool show)
virtual QList< IViewDescriptor::Pointer > GetViews() const =0
static const int PROP_TITLE
IPreferencesService * GetPreferencesService() const
QT-Toolkit/GUI dependent class that provides to send a Message to the QT's StatusBar.
virtual IWorkbenchWindow::Pointer OpenWorkbenchWindow(const QString &perspectiveId, IAdaptable *input)=0
void ShowClosePerspectiveMenuItem(bool show)
bool GetShowMemoryIndicator()
static const QString QT_STYLES_NODE
QList< QString > GetPerspectiveExcludeList()
friend class PartListenerForViewNavigator
virtual IWorkbenchWindow::Pointer GetActiveWorkbenchWindow() const =0
void ShowMemoryIndicator(bool show)
void SetProductName(const QString &product)
virtual IAdaptable * GetDefaultPageInput()
#define MITK_REVISION_DESC
friend class PartListenerForTitle
The custom viewer plugin implements simple viewer functionality presented in a customized look and feel It was developed to demonstrate extensibility and customizability of the blueberry application framework As an example for the GUI customization capabilities provided by the BlueBerry application the custom viewer plugin was developed It features simple viewer functionality presented in a customized look and feel The custom viewer consists of two i e a viewer perspective and a DICOM perspective As part of the viewer perspective
superclass for all UndoModels
A limited linear undo model providing GUI elements with stack status information. ...
virtual void PartClosed(const IWorkbenchPartReference::Pointer &)
friend class PerspectiveListenerForMenu
friend class PartListenerForImageNavigator
virtual void PartVisible(const IWorkbenchPartReference::Pointer &)
The custom viewer plugin implements simple viewer functionality presented in a customized look and feel It was developed to demonstrate extensibility and customizability of the blueberry application framework As an example for the GUI customization capabilities provided by the BlueBerry application the custom viewer plugin was developed It features simple viewer functionality presented in a customized look and feel The custom viewer consists of two perspectives
virtual void PartBroughtToTop(const IWorkbenchPartReference::Pointer &)
static const QString QT_SHOW_TOOLBAR_CATEGORY_NAMES
static UndoModel * GetCurrentUndoModel()
gives access to the currently used UndoModel Introduced to access special functions of more specific ...
virtual IViewRegistry * GetViewRegistry() const =0
void SetWindowIcon(const QString &wndIcon)
~QmitkExtWorkbenchWindowAdvisor() override
static berry::IEditorPart::Pointer OpenEditor(berry::IWorkbenchPage::Pointer page, berry::IEditorInput::Pointer input, const QString &editorId, bool activate=false)
void ShowNewWindowMenuItem(bool show)
void PostWindowOpen() override
virtual Events::Types GetPartEventTypes() const =0
std::vector< StackDescriptionItem > StackDescription
void PostWindowCreate() override
virtual SmartPointer< IWorkbenchPage > ShowPerspective(const QString &perspectiveId, IWorkbenchWindow::Pointer window)=0
void SetViewExcludeList(const QList< QString > &v)
QList< QString > GetViewExcludeList()
static void SafeHandleNavigatorView(QString view_query_name)