15 #include "boost/bind.hpp" 61 mFullScreenAction(NULL),
62 mStandard3DViewActions(new QActionGroup(this)),
67 this->setObjectName(
"main_window");
72 this->setCentralWidget(mServices->view()->createLayoutWidget(
this, 0));
76 this->createActions();
78 this->createToolBars();
79 this->setStatusBar(
new StatusBar(mServices->tracking(), mServices->view(), mServices->video()));
87 this->updateWindowTitle();
89 this->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
91 this->addAsDockWidget(
new PlaybackWidget(mServices->tracking(), mServices->video(), mServices->patient(),
this),
"Browsing");
93 this->addAsDockWidget(
new EraserWidget(mServices->patient(), mServices->view(),
this),
"Properties");
94 this->addAsDockWidget(
new MetricWidget(mServices,
this),
"Utility");
95 this->addAsDockWidget(
new SlicePropertiesWidget(mServices->patient(), mServices->view(),
this),
"Properties");
98 this->addAsDockWidget(
new StreamPropertiesWidget(mServices->patient(), mServices->view(),
this),
"Properties");
99 this->addAsDockWidget(
new TrackPadWidget(mServices->view(),
this),
"Utility");
101 this->addAsDockWidget(
new NavigationWidget(mServices->view(), mServices->tracking(),
this),
"Properties");
102 this->addAsDockWidget(
new ConsoleWidget(
this,
"console_widget",
"Console"),
"Utility");
103 this->addAsDockWidget(
new ConsoleWidget(
this,
"console_widget_2",
"Extra Console"),
"Utility");
105 this->addAsDockWidget(
new FrameTreeWidget(mServices->patient(),
this),
"Browsing");
106 this->addAsDockWidget(
new ToolManagerWidget(mServices->tracking(),
this),
"Debugging");
111 this->addAsDockWidget(
new BrowserWidget(
this, mServices),
"Browsing");
116 this->setupGUIExtenders();
120 popupMenu->setTitle(
"Window");
121 this->menuBar()->insertMenu(mHelpMenuAction, popupMenu);
122 this->menuBar()->setVisible(
settings()->value(
"Gui/showMenuBar").toBool());
132 if (restoreGeometry(
settings()->value(
"mainWindow/geometry").toByteArray()))
138 this->showMaximized();
141 if (
settings()->value(
"gui/fullscreen").toBool())
143 this->setWindowState(this->windowState() | Qt::WindowFullScreen);
149 QMainWindow::changeEvent(event);
151 if (event->type() == QEvent::WindowStateChange)
153 if (mFullScreenAction)
154 mFullScreenAction->setChecked(this->windowState() & Qt::WindowFullScreen);
158 void MainWindow::setupGUIExtenders()
166 mServiceListener->open();
171 std::vector<GUIExtenderService::CategorizedWidget> widgets = service->
createWidgets();
172 for (
unsigned j = 0; j < widgets.size(); ++j)
174 if(!widgets[j].mPlaceInSeparateWindow)
175 mDockWidgets->
addAsDockWidget(widgets[j].mWidget, widgets[j].mCategory, service);
177 this->createActionForWidgetInSeparateWindow(widgets[j].mWidget);
181 for(
unsigned j = 0; j < toolBars.size(); ++j)
199 this->focusInsideDockWidget(sender());
204 this->focusInsideDockWidget(now);
207 void MainWindow::focusInsideDockWidget(QObject *dockWidget)
220 QDockWidget* dw =
dynamic_cast<QDockWidget*
>(dockWidget);
223 if (dw->parent()!=
this)
225 QScrollArea* sa =
dynamic_cast<QScrollArea*
>(dw->widget());
236 QTimer::singleShot(0, sa->widget(), SLOT(setFocus()));
241 mServices->view()->deactivateLayout();
243 mServiceListener.reset();
251 void MainWindow::createActions()
255 mStandard3DViewActions = cameraControl->createStandard3DViewActions();
257 mShowContextSensitiveHelpAction =
new QAction(QIcon(
":/icons/open_icon_library/help-contents-5.png"),
258 "Context-sensitive help",
this);
261 mShowControlPanelAction =
new QAction(
"Show Control Panel",
this);
263 mSecondaryViewLayoutWindowAction =
new QAction(
"Show Secondary View Layout Window",
this);
267 mAboutAction =
new QAction(tr(
"About"),
this);
268 mAboutAction->setStatusTip(tr(
"Show the application's About box"));
269 mPreferencesAction =
new QAction(tr(
"Preferences"),
this);
270 mPreferencesAction->setShortcut(tr(
"Ctrl+,"));
271 mPreferencesAction->setStatusTip(tr(
"Show the preferences dialog"));
272 mPreferencesToolConfigAction =
new QAction(tr(
"Tool Config"),
this);
274 mFullScreenAction =
new QAction(tr(
"Fullscreen"),
this);
275 mFullScreenAction->setShortcut(tr(
"F11"));
276 mFullScreenAction->setStatusTip(tr(
"Toggle full screen"));
277 mFullScreenAction->setCheckable(
true);
278 mFullScreenAction->setChecked(this->windowState() & Qt::WindowFullScreen);
281 mQuitAction =
new QAction(tr(
"&Quit"),
this);
282 mQuitAction->setShortcut(tr(
"Ctrl+Q"));
283 mQuitAction->setStatusTip(tr(
"Exit the application"));
287 connect(mPreferencesToolConfigAction, &QAction::triggered,
this, [
this]{
preferencesSlot(5); });
288 connect(mQuitAction, &QAction::triggered, qApp, &QApplication::quit);
290 mSaveDesktopAction =
new QAction(QIcon(
":/icons/workflow_state_save.png"), tr(
"Save desktop"),
this);
291 mSaveDesktopAction->setToolTip(
"Save desktop for workflow step");
293 mResetDesktopAction =
new QAction(QIcon(
":/icons/workflow_state_revert.png"), tr(
"Reset desktop"),
this);
294 mResetDesktopAction->setToolTip(
"Reset desktop for workflow step");
297 mInteractorStyleActionGroup = mServices->view()->getInteractorStyleActionGroup();
306 this->updateWindowTitle();
309 void MainWindow::updateWindowTitle()
311 QString profileName = mServices->state()->getApplicationStateName();
312 QString versionName = mServices->state()->getVersionName();
314 QString activePatientFolder = mServices->patient()->getActivePatientFolder();
315 if (activePatientFolder.endsWith(
'/'))
316 activePatientFolder.chop(1);
319 if (!activePatientFolder.isEmpty())
321 QFileInfo info(activePatientFolder);
322 patientName = info.completeBaseName();
325 QString format(
"%1 %2 - %3 - %4 (not approved for medical use)");
326 QString title = format
327 .arg(qApp->applicationDisplayName())
331 this->setWindowTitle(title);
336 Desktop desktop = mServices->state()->getActiveDesktop();
339 mServices->view()->setActiveLayout(desktop.
mLayoutUid, 0);
341 mServices->patient()->autoSave();
365 desktop.
mLayoutUid = mServices->view()->getActiveLayout(0);
367 mServices->state()->saveDesktop(desktop);
377 mServices->state()->resetDesktop();
388 this->setWindowState(this->windowState() ^ Qt::WindowFullScreen);
390 settings()->
setValue(
"gui/fullscreen", (this->windowState() & Qt::WindowFullScreen)!=0);
393 void MainWindow::createActionForWidgetInSeparateWindow(QWidget* widget)
395 QString uid = widget->objectName();
396 if(mSecondaryMainWindows.find(uid) == mSecondaryMainWindows.end())
399 QAction* action =
new QAction(widget->windowTitle(),
this);
401 mSecondaryMainWindows[uid] = secondaryMainWindow;
402 mSecondaryMainWindowsActions[uid] = action;
404 connect(action, &QAction::triggered, secondaryMainWindow, &QWidget::show);
406 mFileMenu->addAction(action);
417 mControlPanel->show();
422 if (!mSecondaryViewLayoutWindow)
424 mSecondaryViewLayoutWindow->tryShowOnSecondaryScreen();
429 this->updateWindowTitle();
432 void MainWindow::createMenus()
440 this->menuBar()->setNativeMenuBar(
false);
442 mFileMenu =
new QMenu(tr(
"File"),
this);
443 mWorkflowMenu =
new QMenu(tr(
"Workflow"),
this);
444 mToolMenu =
new QMenu(tr(
"Tracking"),
this);
445 mLayoutMenu =
new QMenu(tr(
"Layouts"),
this);
446 mNavigationMenu =
new QMenu(tr(
"Navigation"),
this);
447 mHelpMenu =
new QMenu(tr(
"Help"),
this);
450 mFileMenu->addAction(mPreferencesAction);
451 this->menuBar()->addMenu(mFileMenu);
452 mFileMenu->addAction(mActions->
getAction(
"NewPatient"));
453 mFileMenu->addAction(mActions->
getAction(
"SaveFile"));
454 mFileMenu->addAction(mActions->
getAction(
"LoadFile"));
455 mFileMenu->addAction(mActions->
getAction(
"LoadFileCopy"));
456 mFileMenu->addAction(mActions->
getAction(
"ClearPatient"));
457 mFileMenu->addSeparator();
458 mFileMenu->addAction(mActions->
getAction(
"ExportPatient"));
459 mFileMenu->addAction(mActions->
getAction(
"AddFilesForImport"));
460 mFileMenu->addSeparator();
461 mFileMenu->addAction(mFullScreenAction);
462 mFileMenu->addAction(mActions->
getAction(
"StartLogConsole"));
463 mFileMenu->addAction(mActions->
getAction(
"ShootScreen"));
464 mFileMenu->addAction(mActions->
getAction(
"ShootWindow"));
465 mFileMenu->addAction(mActions->
getAction(
"RecordFullscreen"));
466 mFileMenu->addSeparator();
467 mFileMenu->addAction(mShowControlPanelAction);
468 mFileMenu->addAction(mSecondaryViewLayoutWindowAction);
470 mFileMenu->addAction(mQuitAction);
473 this->menuBar()->addMenu(mWorkflowMenu);
474 QList<QAction*> actions = mServices->state()->getWorkflowActions()->actions();
475 for (
int i=0; i<actions.size(); ++i)
477 mWorkflowMenu->addAction(actions[i]);
480 mWorkflowMenu->addSeparator();
481 mWorkflowMenu->addAction(mSaveDesktopAction);
482 mWorkflowMenu->addAction(mResetDesktopAction);
485 this->menuBar()->addMenu(mToolMenu);
486 mToolMenu->addAction(mPreferencesToolConfigAction);
487 mToolMenu->addAction(mActions->
getAction(
"TrackingTools"));
488 mToolMenu->addSeparator();
489 mToolMenu->addAction(mActions->
getAction(
"StartStreaming"));
490 mToolMenu->addSeparator();
493 this->menuBar()->addMenu(mLayoutMenu);
494 mLayoutInteractor->connectToMenu(mLayoutMenu);
496 this->menuBar()->addMenu(mNavigationMenu);
497 mNavigationMenu->addAction(mActions->
getAction(
"CenterToImageCenter"));
498 mNavigationMenu->addAction(mActions->
getAction(
"CenterToTooltip"));
499 mNavigationMenu->addAction(mActions->
getAction(
"ShowPointPicker"));
500 mNavigationMenu->addSeparator();
501 mNavigationMenu->addActions(mInteractorStyleActionGroup->actions());
503 mHelpMenuAction = this->menuBar()->addMenu(mHelpMenu);
504 mHelpMenu->addAction(mAboutAction);
505 mHelpMenu->addAction(mActions->
getAction(
"GotoDocumentation"));
506 mHelpMenu->addAction(mShowContextSensitiveHelpAction);
509 void MainWindow::createToolBars()
511 mWorkflowToolBar = this->registerToolBar(
"Workflow");
512 QList<QAction*> actions = mServices->state()->getWorkflowActions()->actions();
513 for (
int i=0; i<actions.size(); ++i)
514 mWorkflowToolBar->addAction(actions[i]);
516 mDataToolBar = this->registerToolBar(
"Data");
517 mDataToolBar->addAction(mActions->
getAction(
"NewPatient"));
518 mDataToolBar->addAction(mActions->
getAction(
"LoadFile"));
519 mDataToolBar->addAction(mActions->
getAction(
"SaveFile"));
520 mDataToolBar->addAction(mActions->
getAction(
"AddFilesForImport"));
522 mToolToolBar = this->registerToolBar(
"Tools");
523 mToolToolBar->addAction(mActions->
getAction(
"TrackingTools"));
524 mToolToolBar->addAction(mActions->
getAction(
"StartStreaming"));
526 mNavigationToolBar = this->registerToolBar(
"Navigation");
527 mNavigationToolBar->addAction(mActions->
getAction(
"CenterToImageCenter"));
528 mNavigationToolBar->addAction(mActions->
getAction(
"CenterToTooltip"));
529 mNavigationToolBar->addAction(mActions->
getAction(
"ShowPointPicker"));
531 mInteractorStyleToolBar = this->registerToolBar(
"InteractorStyle");
532 mInteractorStyleToolBar->addActions(mInteractorStyleActionGroup->actions());
534 mDesktopToolBar = this->registerToolBar(
"Desktop");
535 mDesktopToolBar->addAction(mSaveDesktopAction);
536 mDesktopToolBar->addAction(mResetDesktopAction);
538 mScreenshotToolBar = this->registerToolBar(
"Screenshot");
539 mScreenshotToolBar->addAction(mActions->
getAction(
"ShootScreen"));
540 mScreenshotToolBar->addAction(mActions->
getAction(
"RecordFullscreen"));
542 QToolBar* camera3DViewToolBar = this->registerToolBar(
"Camera 3D Views");
543 camera3DViewToolBar->addActions(mStandard3DViewActions->actions());
545 QToolBar* samplerWidgetToolBar = this->registerToolBar(
"Sampler");
546 samplerWidgetToolBar->addWidget(
new SamplerWidget(mServices->tracking(), mServices->patient(), mServices->spaceProvider(),
this));
548 QToolBar* toolOffsetToolBar = this->registerToolBar(
"Tool Offset");
552 toolOffsetToolBar->addWidget(offsetWidget);
554 QToolBar* helpToolBar = this->registerToolBar(
"Help");
555 helpToolBar->addAction(mShowContextSensitiveHelpAction);
558 QToolBar* MainWindow::registerToolBar(QString name, QString groupname)
560 QToolBar* toolbar =
new QToolBar(name);
561 toolbar->setObjectName(QString(name).
remove(
" ")+
"ToolBar");
569 QString appName = qApp->applicationDisplayName();
571 QString url_license = QString(
"file://%1/License.txt").arg(doc_path);
572 QString url_config = QString(
"file://%1/cxConfigDescription.txt").arg(doc_path);
577 "<p>A Research Platform for Image-Guided Therapy<p>" 578 "<p>%1 is NOT approved for medical use.<p>" 580 "<p><a href=%3> website </a><p>" 581 "<p><a href=%4> license </a><p>" 582 "<p><a href=%5> configuration </a><p>");
584 QMessageBox::about(
this, tr(
"About %1").arg(appName), text
586 .arg(CustusX_VERSION_STRING)
595 PreferencesDialog prefDialog(mServices->view(), mServices->patient(), mServices->state(), mServices->tracking(), currentTabIndex,
this);
599 void MainWindow::closeEvent(QCloseEvent *event)
601 QMainWindow::closeEvent(event);
605 QDockWidget* MainWindow::addAsDockWidget(QWidget* widget, QString groupname)
void registerToolBar(QToolBar *toolbar, QString groupname="Toolbars")
void dockWidgetVisibilityChanged(bool val)
virtual QMenu * createPopupMenu()
void changeEvent(QEvent *event)
boost::shared_ptr< class CameraControl > CameraControlPtr
Statusbar with extended functionality.
void applicationStateChanged()
void showSecondaryViewLayoutWindowActionSlot()
void focusChanged(QWidget *old, QWidget *now)
void restoreFrom(const Desktop &desktop)
void patientChangedSlot()
static VisServicesPtr create(ctkPluginContext *context)
Experimental class for IPad usage.This detached main window can be moved onto a secondary screen...
void onApplicationStateChangedSlot()
QMenu * createPopupMenu()
void setValue(const QString &key, const QVariant &value)
Experimental class for IPad usage.
void onGUIExtenderServiceAdded(GUIExtenderService *service)
void toggleFullScreenSlot()
void onGUIExtenderServiceRemoved(GUIExtenderService *service)
void preferencesSlot(int currentTabIndex=0)
static QString getWebsiteURL()
QByteArray mMainWindowState
static LogicManager * getInstance()
void showWidget(QString name)
void onGUIExtenderServiceModified(GUIExtenderService *service)
boost::shared_ptr< class DoublePropertyBase > DoublePropertyBasePtr
void onShowContextSentitiveHelp()
Settings * settings()
Shortcut for accessing the settings instance.
Helper class for listening to services being added, modified and removed.
LogicManager * logicManager()
void workflowStateChanged()
Data class for CustusX desktop.
void showControlPanelActionSlot()
QAction * getAction(QString uid)
void owningServiceRemoved(QObject *service)
virtual std::vector< QToolBar * > createToolBars() const
QString mSecondaryLayoutUid
virtual std::vector< CategorizedWidget > createWidgets() const =0
QDockWidget * addAsDockWidget(QWidget *widget, QString groupname, QObject *owningPlugin=NULL)
void onWorkflowStateChangedSlot()
static QString getDocPath()
return path to folder containing documentation files
Set application preferences.
boost::shared_ptr< Audio > AudioPtr
Namespace for all CustusX production code.