36 #include "boost/bind.hpp"
82 mFullScreenAction(NULL),
83 mStandard3DViewActions(new QActionGroup(this)),
88 this->setObjectName(
"MainWindow");
93 this->setCentralWidget(
viewService()->createLayoutWidget(
this, 0));
97 this->createActions();
99 this->createToolBars();
108 this->updateWindowTitle();
110 this->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
114 this->addAsDockWidget(
new EraserWidget(mServices->patient(), mServices->view(),
this),
"Properties");
115 this->addAsDockWidget(
new MetricWidget(mServices->view(), mServices->patient(),
this),
"Utility");
116 this->addAsDockWidget(
new SlicePropertiesWidget(mServices->patient(), mServices->view(),
this),
"Properties");
119 this->addAsDockWidget(
new StreamPropertiesWidget(mServices->patient(), mServices->view(),
this),
"Properties");
123 this->addAsDockWidget(
new ConsoleWidget(
this,
"ConsoleWidget",
"Console"),
"Utility");
124 this->addAsDockWidget(
new ConsoleWidget(
this,
"ConsoleWidget2",
"Extra Console"),
"Utility");
126 this->addAsDockWidget(
new FrameTreeWidget(mServices->patient(),
this),
"Browsing");
132 this->addAsDockWidget(
new BrowserWidget(
this, mServices),
"Browsing");
137 this->setupGUIExtenders();
141 popupMenu->setTitle(
"Window");
142 this->menuBar()->insertMenu(mHelpMenuAction, popupMenu);
152 if (restoreGeometry(
settings()->value(
"mainWindow/geometry").toByteArray()))
158 this->showMaximized();
161 if (
settings()->value(
"gui/fullscreen").toBool())
163 this->setWindowState(this->windowState() | Qt::WindowFullScreen);
169 QMainWindow::changeEvent(event);
171 if (event->type() == QEvent::WindowStateChange)
173 if (mFullScreenAction)
174 mFullScreenAction->setChecked(this->windowState() & Qt::WindowFullScreen);
178 void MainWindow::setupGUIExtenders()
186 mServiceListener->open();
191 std::vector<GUIExtenderService::CategorizedWidget> widgets = service->
createWidgets();
192 for (
unsigned j = 0; j < widgets.size(); ++j)
194 mDockWidgets->
addAsDockWidget(widgets[j].mWidget, widgets[j].mCategory, service);
198 for(
unsigned j = 0; j < toolBars.size(); ++j)
216 this->focusInsideDockWidget(sender());
221 this->focusInsideDockWidget(now);
224 void MainWindow::focusInsideDockWidget(QObject *dockWidget)
237 QDockWidget* dw =
dynamic_cast<QDockWidget*
>(dockWidget);
240 if (dw->parent()!=
this)
242 QScrollArea* sa =
dynamic_cast<QScrollArea*
>(dw->widget());
253 QTimer::singleShot(0, sa->widget(), SLOT(setFocus()));
260 mServiceListener.reset();
268 void MainWindow::createActions()
272 mStandard3DViewActions = cameraControl->createStandard3DViewActions();
274 mShowContextSensitiveHelpAction =
new QAction(QIcon(
":/icons/open_icon_library/help-contents-5.png"),
275 "Context-sensitive help",
this);
278 mShowControlPanelAction =
new QAction(
"Show Control Panel",
this);
280 mSecondaryViewLayoutWindowAction =
new QAction(
"Show Secondary View Layout Window",
this);
284 mAboutAction =
new QAction(tr(
"About"),
this);
285 mAboutAction->setStatusTip(tr(
"Show the application's About box"));
286 mPreferencesAction =
new QAction(tr(
"Preferences"),
this);
287 mPreferencesAction->setShortcut(tr(
"Ctrl+,"));
288 mPreferencesAction->setStatusTip(tr(
"Show the preferences dialog"));
290 mFullScreenAction =
new QAction(tr(
"Fullscreen"),
this);
291 mFullScreenAction->setShortcut(tr(
"F11"));
292 mFullScreenAction->setStatusTip(tr(
"Toggle full screen"));
293 mFullScreenAction->setCheckable(
true);
294 mFullScreenAction->setChecked(this->windowState() & Qt::WindowFullScreen);
297 mQuitAction =
new QAction(tr(
"&Quit"),
this);
298 mQuitAction->setShortcut(tr(
"Ctrl+Q"));
299 mQuitAction->setStatusTip(tr(
"Exit the application"));
303 connect(mQuitAction, &QAction::triggered, qApp, &QApplication::quit);
305 mSaveDesktopAction =
new QAction(QIcon(
":/icons/workflow_state_save.png"), tr(
"Save desktop"),
this);
306 mSaveDesktopAction->setToolTip(
"Save desktop for workflow step");
308 mResetDesktopAction =
new QAction(QIcon(
":/icons/workflow_state_revert.png"), tr(
"Reset desktop"),
this);
309 mResetDesktopAction->setToolTip(
"Reset desktop for workflow step");
312 mInteractorStyleActionGroup =
viewService()->getInteractorStyleActionGroup();
321 this->updateWindowTitle();
324 void MainWindow::updateWindowTitle()
326 QString profileName =
stateService()->getApplicationStateName();
329 QString activePatientFolder =
patientService()->getActivePatientFolder();
330 if (activePatientFolder.endsWith(
'/'))
331 activePatientFolder.chop(1);
334 if (!activePatientFolder.isEmpty())
336 QFileInfo info(activePatientFolder);
337 patientName = info.completeBaseName();
340 QString format(
"%1 %2 - %3 - %4 (not approved for medical use)");
341 QString title = format
342 .arg(qApp->applicationDisplayName())
346 this->setWindowTitle(title);
402 this->setWindowState(this->windowState() ^ Qt::WindowFullScreen);
404 settings()->
setValue(
"gui/fullscreen", (this->windowState() & Qt::WindowFullScreen)!=0);
411 mControlPanel->show();
416 if (!mSecondaryViewLayoutWindow)
418 mSecondaryViewLayoutWindow->tryShowOnSecondaryScreen();
423 this->updateWindowTitle();
426 void MainWindow::createMenus()
434 this->menuBar()->setNativeMenuBar(
false);
436 mFileMenu =
new QMenu(tr(
"File"),
this);
437 mWorkflowMenu =
new QMenu(tr(
"Workflow"),
this);
438 mToolMenu =
new QMenu(tr(
"Tracking"),
this);
439 mLayoutMenu =
new QMenu(tr(
"Layouts"),
this);
440 mNavigationMenu =
new QMenu(tr(
"Navigation"),
this);
441 mHelpMenu =
new QMenu(tr(
"Help"),
this);
444 mFileMenu->addAction(mPreferencesAction);
445 this->menuBar()->addMenu(mFileMenu);
446 mFileMenu->addAction(mActions->
getAction(
"NewPatient"));
447 mFileMenu->addAction(mActions->
getAction(
"SaveFile"));
448 mFileMenu->addAction(mActions->
getAction(
"LoadFile"));
449 mFileMenu->addAction(mActions->
getAction(
"ClearPatient"));
450 mFileMenu->addSeparator();
451 mFileMenu->addAction(mActions->
getAction(
"ExportPatient"));
452 mFileMenu->addAction(mActions->
getAction(
"ImportData"));
453 mFileMenu->addSeparator();
454 mFileMenu->addAction(mFullScreenAction);
455 mFileMenu->addAction(mActions->
getAction(
"StartLogConsole"));
456 mFileMenu->addAction(mActions->
getAction(
"ShootScreen"));
457 mFileMenu->addAction(mActions->
getAction(
"ShootWindow"));
458 mFileMenu->addAction(mActions->
getAction(
"RecordFullscreen"));
459 mFileMenu->addSeparator();
460 mFileMenu->addAction(mShowControlPanelAction);
461 mFileMenu->addAction(mSecondaryViewLayoutWindowAction);
463 mFileMenu->addAction(mQuitAction);
466 this->menuBar()->addMenu(mWorkflowMenu);
467 QList<QAction*> actions =
stateService()->getWorkflowActions()->actions();
468 for (
int i=0; i<actions.size(); ++i)
470 mWorkflowMenu->addAction(actions[i]);
473 mWorkflowMenu->addSeparator();
474 mWorkflowMenu->addAction(mSaveDesktopAction);
475 mWorkflowMenu->addAction(mResetDesktopAction);
478 this->menuBar()->addMenu(mToolMenu);
479 mToolMenu->addAction(mActions->
getAction(
"ConfigureTools"));
480 mToolMenu->addAction(mActions->
getAction(
"InitializeTools"));
481 mToolMenu->addAction(mActions->
getAction(
"TrackingTools"));
482 mToolMenu->addSeparator();
483 mToolMenu->addAction(mActions->
getAction(
"StartStreaming"));
484 mToolMenu->addSeparator();
487 this->menuBar()->addMenu(mLayoutMenu);
488 mLayoutInteractor->connectToMenu(mLayoutMenu);
490 this->menuBar()->addMenu(mNavigationMenu);
491 mNavigationMenu->addAction(mActions->
getAction(
"CenterToImageCenter"));
492 mNavigationMenu->addAction(mActions->
getAction(
"CenterToTooltip"));
493 mNavigationMenu->addAction(mActions->
getAction(
"ShowPointPicker"));
494 mNavigationMenu->addSeparator();
495 mNavigationMenu->addActions(mInteractorStyleActionGroup->actions());
497 mHelpMenuAction = this->menuBar()->addMenu(mHelpMenu);
498 mHelpMenu->addAction(mAboutAction);
499 mHelpMenu->addAction(mActions->
getAction(
"GotoDocumentation"));
500 mHelpMenu->addAction(mShowContextSensitiveHelpAction);
503 void MainWindow::createToolBars()
505 mWorkflowToolBar = this->registerToolBar(
"Workflow");
506 QList<QAction*> actions =
stateService()->getWorkflowActions()->actions();
507 for (
int i=0; i<actions.size(); ++i)
508 mWorkflowToolBar->addAction(actions[i]);
510 mDataToolBar = this->registerToolBar(
"Data");
511 mDataToolBar->addAction(mActions->
getAction(
"NewPatient"));
512 mDataToolBar->addAction(mActions->
getAction(
"LoadFile"));
513 mDataToolBar->addAction(mActions->
getAction(
"SaveFile"));
514 mDataToolBar->addAction(mActions->
getAction(
"ImportData"));
516 mToolToolBar = this->registerToolBar(
"Tools");
517 mToolToolBar->addAction(mActions->
getAction(
"TrackingTools"));
518 mToolToolBar->addAction(mActions->
getAction(
"StartStreaming"));
520 mNavigationToolBar = this->registerToolBar(
"Navigation");
521 mNavigationToolBar->addAction(mActions->
getAction(
"CenterToImageCenter"));
522 mNavigationToolBar->addAction(mActions->
getAction(
"CenterToTooltip"));
523 mNavigationToolBar->addAction(mActions->
getAction(
"ShowPointPicker"));
525 mInteractorStyleToolBar = this->registerToolBar(
"InteractorStyle");
526 mInteractorStyleToolBar->addActions(mInteractorStyleActionGroup->actions());
528 mDesktopToolBar = this->registerToolBar(
"Desktop");
529 mDesktopToolBar->addAction(mSaveDesktopAction);
530 mDesktopToolBar->addAction(mResetDesktopAction);
532 mScreenshotToolBar = this->registerToolBar(
"Screenshot");
533 mScreenshotToolBar->addAction(mActions->
getAction(
"ShootScreen"));
534 mScreenshotToolBar->addAction(mActions->
getAction(
"RecordFullscreen"));
536 QToolBar* camera3DViewToolBar = this->registerToolBar(
"Camera 3D Views");
537 camera3DViewToolBar->addActions(mStandard3DViewActions->actions());
539 QToolBar* samplerWidgetToolBar = this->registerToolBar(
"Sampler");
540 samplerWidgetToolBar->addWidget(
new SamplerWidget(
this));
542 QToolBar* toolOffsetToolBar = this->registerToolBar(
"Tool Offset");
544 SpinBoxAndSliderGroupWidget* offsetWidget =
new SpinBoxAndSliderGroupWidget(
this, offset);
545 offsetWidget->showLabel(
false);
546 toolOffsetToolBar->addWidget(offsetWidget);
548 QToolBar* helpToolBar = this->registerToolBar(
"Help");
549 helpToolBar->addAction(mShowContextSensitiveHelpAction);
552 QToolBar* MainWindow::registerToolBar(QString name, QString groupname)
554 QToolBar* toolbar =
new QToolBar(name);
555 toolbar->setObjectName(QString(name).
remove(
" ")+
"ToolBar");
563 QString appName = qApp->applicationDisplayName();
565 QString url_license = QString(
"file://%1/License.txt").arg(doc_path);
566 QString url_config = QString(
"file://%1/cxConfigDescription.txt").arg(doc_path);
571 "<p>A Research Platform for Image-Guided Therapy<p>"
572 "<p>%1 is NOT approved for medical use.<p>"
574 "<p><a href=%3> website </a><p>"
575 "<p><a href=%4> license </a><p>"
576 "<p><a href=%5> configuration </a><p>");
578 QMessageBox::about(
this, tr(
"About %1").arg(appName), text
580 .arg(CustusX_VERSION_STRING)
593 void MainWindow::closeEvent(QCloseEvent *event)
595 QMainWindow::closeEvent(event);
599 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)
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)
cxLogicManager_EXPORT StateServicePtr stateService()
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 workflowStateAboutToChange()
void onGUIExtenderServiceAdded(GUIExtenderService *service)
void toggleFullScreenSlot()
void onGUIExtenderServiceRemoved(GUIExtenderService *service)
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)
boost::shared_ptr< class CameraControl > CameraControlPtr
cxLogicManager_EXPORT ViewServicePtr viewService()
void owningServiceRemoved(QObject *service)
virtual std::vector< QToolBar * > createToolBars() const
cxLogicManager_EXPORT PatientModelServicePtr patientService()
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
void isSaving(QDomElement &root)
xml storage is available