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);
146 if (restoreGeometry(
settings()->value(
"mainWindow/geometry").toByteArray()))
152 this->showMaximized();
155 if (
settings()->value(
"gui/fullscreen").toBool())
156 this->setWindowState(this->windowState() | Qt::WindowFullScreen);
161 QMainWindow::changeEvent(event);
163 if (event->type() == QEvent::WindowStateChange)
165 if (mFullScreenAction)
166 mFullScreenAction->setChecked(this->windowState() & Qt::WindowFullScreen);
170 void MainWindow::setupGUIExtenders()
178 mServiceListener->open();
183 std::vector<GUIExtenderService::CategorizedWidget> widgets = service->
createWidgets();
184 for (
unsigned j = 0; j < widgets.size(); ++j)
186 mDockWidgets->
addAsDockWidget(widgets[j].mWidget, widgets[j].mCategory, service);
190 for(
unsigned j = 0; j < toolBars.size(); ++j)
208 this->focusInsideDockWidget(sender());
213 this->focusInsideDockWidget(now);
216 void MainWindow::focusInsideDockWidget(QObject *dockWidget)
229 QDockWidget* dw =
dynamic_cast<QDockWidget*
>(dockWidget);
232 if (dw->parent()!=
this)
234 QScrollArea* sa =
dynamic_cast<QScrollArea*
>(dw->widget());
245 QTimer::singleShot(0, sa->widget(), SLOT(setFocus()));
252 mServiceListener.reset();
260 void MainWindow::createActions()
264 mStandard3DViewActions = cameraControl->createStandard3DViewActions();
266 mShowContextSensitiveHelpAction =
new QAction(QIcon(
":/icons/open_icon_library/help-contents-5.png"),
267 "Context-sensitive help",
this);
270 mShowControlPanelAction =
new QAction(
"Show Control Panel",
this);
272 mSecondaryViewLayoutWindowAction =
new QAction(
"Show Secondary View Layout Window",
this);
276 mAboutAction =
new QAction(tr(
"About"),
this);
277 mAboutAction->setStatusTip(tr(
"Show the application's About box"));
278 mPreferencesAction =
new QAction(tr(
"Preferences"),
this);
279 mPreferencesAction->setShortcut(tr(
"Ctrl+,"));
280 mPreferencesAction->setStatusTip(tr(
"Show the preferences dialog"));
282 mFullScreenAction =
new QAction(tr(
"Fullscreen"),
this);
283 mFullScreenAction->setShortcut(tr(
"F11"));
284 mFullScreenAction->setStatusTip(tr(
"Toggle full screen"));
285 mFullScreenAction->setCheckable(
true);
286 mFullScreenAction->setChecked(this->windowState() & Qt::WindowFullScreen);
289 mQuitAction =
new QAction(tr(
"&Quit"),
this);
290 mQuitAction->setShortcut(tr(
"Ctrl+Q"));
291 mQuitAction->setStatusTip(tr(
"Exit the application"));
295 connect(mQuitAction, &QAction::triggered, qApp, &QApplication::quit);
297 mSaveDesktopAction =
new QAction(QIcon(
":/icons/workflow_state_save.png"), tr(
"Save desktop"),
this);
298 mSaveDesktopAction->setToolTip(
"Save desktop for workflow step");
300 mResetDesktopAction =
new QAction(QIcon(
":/icons/workflow_state_revert.png"), tr(
"Reset desktop"),
this);
301 mResetDesktopAction->setToolTip(
"Reset desktop for workflow step");
304 mInteractorStyleActionGroup =
viewService()->getInteractorStyleActionGroup();
313 this->updateWindowTitle();
316 void MainWindow::updateWindowTitle()
318 QString profileName =
stateService()->getApplicationStateName();
321 QString activePatientFolder =
patientService()->getActivePatientFolder();
322 if (activePatientFolder.endsWith(
'/'))
323 activePatientFolder.chop(1);
326 if (!activePatientFolder.isEmpty())
328 QFileInfo info(activePatientFolder);
329 patientName = info.completeBaseName();
332 QString format(
"%1 %2 - %3 - %4 (not approved for medical use)");
333 QString title = format
334 .arg(qApp->applicationDisplayName())
338 this->setWindowTitle(title);
394 this->setWindowState(this->windowState() ^ Qt::WindowFullScreen);
396 settings()->
setValue(
"gui/fullscreen", (this->windowState() & Qt::WindowFullScreen)!=0);
403 mControlPanel->show();
408 if (!mSecondaryViewLayoutWindow)
410 mSecondaryViewLayoutWindow->tryShowOnSecondaryScreen();
415 this->updateWindowTitle();
418 void MainWindow::createMenus()
426 this->menuBar()->setNativeMenuBar(
false);
428 mFileMenu =
new QMenu(tr(
"File"),
this);
429 mWorkflowMenu =
new QMenu(tr(
"Workflow"),
this);
430 mToolMenu =
new QMenu(tr(
"Tracking"),
this);
431 mLayoutMenu =
new QMenu(tr(
"Layouts"),
this);
432 mNavigationMenu =
new QMenu(tr(
"Navigation"),
this);
433 mHelpMenu =
new QMenu(tr(
"Help"),
this);
436 mFileMenu->addAction(mPreferencesAction);
437 this->menuBar()->addMenu(mFileMenu);
438 mFileMenu->addAction(mActions->
getAction(
"NewPatient"));
439 mFileMenu->addAction(mActions->
getAction(
"SaveFile"));
440 mFileMenu->addAction(mActions->
getAction(
"LoadFile"));
441 mFileMenu->addAction(mActions->
getAction(
"ClearPatient"));
442 mFileMenu->addSeparator();
443 mFileMenu->addAction(mActions->
getAction(
"ExportPatient"));
444 mFileMenu->addAction(mActions->
getAction(
"ImportData"));
445 mFileMenu->addSeparator();
446 mFileMenu->addAction(mFullScreenAction);
447 mFileMenu->addAction(mActions->
getAction(
"StartLogConsole"));
448 mFileMenu->addAction(mActions->
getAction(
"ShootScreen"));
449 mFileMenu->addAction(mActions->
getAction(
"ShootWindow"));
450 mFileMenu->addAction(mActions->
getAction(
"RecordFullscreen"));
451 mFileMenu->addSeparator();
452 mFileMenu->addAction(mShowControlPanelAction);
453 mFileMenu->addAction(mSecondaryViewLayoutWindowAction);
455 mFileMenu->addAction(mQuitAction);
458 this->menuBar()->addMenu(mWorkflowMenu);
459 QList<QAction*> actions =
stateService()->getWorkflowActions()->actions();
460 for (
int i=0; i<actions.size(); ++i)
462 mWorkflowMenu->addAction(actions[i]);
465 mWorkflowMenu->addSeparator();
466 mWorkflowMenu->addAction(mSaveDesktopAction);
467 mWorkflowMenu->addAction(mResetDesktopAction);
470 this->menuBar()->addMenu(mToolMenu);
471 mToolMenu->addAction(mActions->
getAction(
"ConfigureTools"));
472 mToolMenu->addAction(mActions->
getAction(
"InitializeTools"));
473 mToolMenu->addAction(mActions->
getAction(
"TrackingTools"));
474 mToolMenu->addSeparator();
475 mToolMenu->addAction(mActions->
getAction(
"StartStreaming"));
476 mToolMenu->addSeparator();
479 this->menuBar()->addMenu(mLayoutMenu);
480 mLayoutInteractor->connectToMenu(mLayoutMenu);
482 this->menuBar()->addMenu(mNavigationMenu);
483 mNavigationMenu->addAction(mActions->
getAction(
"CenterToImageCenter"));
484 mNavigationMenu->addAction(mActions->
getAction(
"CenterToTooltip"));
485 mNavigationMenu->addAction(mActions->
getAction(
"ShowPointPicker"));
486 mNavigationMenu->addSeparator();
487 mNavigationMenu->addActions(mInteractorStyleActionGroup->actions());
489 mHelpMenuAction = this->menuBar()->addMenu(mHelpMenu);
490 mHelpMenu->addAction(mAboutAction);
491 mHelpMenu->addAction(mActions->
getAction(
"GotoDocumentation"));
492 mHelpMenu->addAction(mShowContextSensitiveHelpAction);
495 void MainWindow::createToolBars()
497 mWorkflowToolBar = this->registerToolBar(
"Workflow");
498 QList<QAction*> actions =
stateService()->getWorkflowActions()->actions();
499 for (
int i=0; i<actions.size(); ++i)
500 mWorkflowToolBar->addAction(actions[i]);
502 mDataToolBar = this->registerToolBar(
"Data");
503 mDataToolBar->addAction(mActions->
getAction(
"NewPatient"));
504 mDataToolBar->addAction(mActions->
getAction(
"LoadFile"));
505 mDataToolBar->addAction(mActions->
getAction(
"SaveFile"));
506 mDataToolBar->addAction(mActions->
getAction(
"ImportData"));
508 mToolToolBar = this->registerToolBar(
"Tools");
509 mToolToolBar->addAction(mActions->
getAction(
"TrackingTools"));
510 mToolToolBar->addAction(mActions->
getAction(
"StartStreaming"));
512 mNavigationToolBar = this->registerToolBar(
"Navigation");
513 mNavigationToolBar->addAction(mActions->
getAction(
"CenterToImageCenter"));
514 mNavigationToolBar->addAction(mActions->
getAction(
"CenterToTooltip"));
515 mNavigationToolBar->addAction(mActions->
getAction(
"ShowPointPicker"));
517 mInteractorStyleToolBar = this->registerToolBar(
"InteractorStyle");
518 mInteractorStyleToolBar->addActions(mInteractorStyleActionGroup->actions());
520 mDesktopToolBar = this->registerToolBar(
"Desktop");
521 mDesktopToolBar->addAction(mSaveDesktopAction);
522 mDesktopToolBar->addAction(mResetDesktopAction);
524 mScreenshotToolBar = this->registerToolBar(
"Screenshot");
525 mScreenshotToolBar->addAction(mActions->
getAction(
"ShootScreen"));
526 mScreenshotToolBar->addAction(mActions->
getAction(
"RecordFullscreen"));
528 QToolBar* camera3DViewToolBar = this->registerToolBar(
"Camera 3D Views");
529 camera3DViewToolBar->addActions(mStandard3DViewActions->actions());
531 QToolBar* samplerWidgetToolBar = this->registerToolBar(
"Sampler");
532 samplerWidgetToolBar->addWidget(
new SamplerWidget(
this));
534 QToolBar* toolOffsetToolBar = this->registerToolBar(
"Tool Offset");
536 SpinBoxAndSliderGroupWidget* offsetWidget =
new SpinBoxAndSliderGroupWidget(
this, offset);
537 offsetWidget->showLabel(
false);
538 toolOffsetToolBar->addWidget(offsetWidget);
540 QToolBar* helpToolBar = this->registerToolBar(
"Help");
541 helpToolBar->addAction(mShowContextSensitiveHelpAction);
544 QToolBar* MainWindow::registerToolBar(QString name, QString groupname)
546 QToolBar* toolbar =
new QToolBar(name);
547 toolbar->setObjectName(QString(name).
remove(
" ")+
"ToolBar");
555 QString appName = qApp->applicationDisplayName();
557 QString url_license = QString(
"file://%1/License.txt").arg(doc_path);
558 QString url_config = QString(
"file://%1/cxConfigDescription.txt").arg(doc_path);
563 "<p>A Research Platform for Image-Guided Therapy<p>"
564 "<p>%1 is NOT approved for medical use.<p>"
566 "<p><a href=%3> website </a><p>"
567 "<p><a href=%4> license </a><p>"
568 "<p><a href=%5> configuration </a><p>");
570 QMessageBox::about(
this, tr(
"About %1").arg(appName), text
572 .arg(CustusX_VERSION_STRING)
585 void MainWindow::closeEvent(QCloseEvent *event)
587 QMainWindow::closeEvent(event);
591 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