From 1103a4a3f5c85b09fbffb250f25595b39521062d Mon Sep 17 00:00:00 2001 From: Joseph Mirabel <jmirabel@laas.fr> Date: Wed, 14 Feb 2018 15:43:31 +0100 Subject: [PATCH] Show gepetto logo when no dock widget is visible. --- include/gepetto/gui/mainwindow.hh | 1 + include/gepetto/gui/ui/mainwindow.ui | 3 +++ src/gui/mainwindow.cc | 18 +++++++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/gepetto/gui/mainwindow.hh b/include/gepetto/gui/mainwindow.hh index 771294c..18d30af 100644 --- a/include/gepetto/gui/mainwindow.hh +++ b/include/gepetto/gui/mainwindow.hh @@ -219,6 +219,7 @@ signals: void openLoadRobotDialog (); void openLoadEnvironmentDialog (); void activateCollision(bool activate); + void dockVisibilityChanged(bool visible); void handleWorkerDone (int id); diff --git a/include/gepetto/gui/ui/mainwindow.ui b/include/gepetto/gui/ui/mainwindow.ui index 83bb24c..6ac572e 100644 --- a/include/gepetto/gui/ui/mainwindow.ui +++ b/include/gepetto/gui/ui/mainwindow.ui @@ -28,6 +28,9 @@ <verstretch>0</verstretch> </sizepolicy> </property> + <property name="contextMenuPolicy"> + <enum>Qt::NoContextMenu</enum> + </property> <property name="autoFillBackground"> <bool>false</bool> </property> diff --git a/src/gui/mainwindow.cc b/src/gui/mainwindow.cc index 495d9b8..690956f 100644 --- a/src/gui/mainwindow.cc +++ b/src/gui/mainwindow.cc @@ -115,11 +115,13 @@ namespace gepetto { dock->adjustSize(); ui_->menuWindow->addAction(dock->toggleViewAction ()); actionSearchBar_->addAction(dock->toggleViewAction ()); + connect(dock,SIGNAL(visibilityChanged(bool)),SLOT(dockVisibilityChanged(bool))); } void MainWindow::removeDockWidget(QDockWidget *dock) { ui_->menuWindow->removeAction(dock->toggleViewAction()); + disconnect(dock); QMainWindow::removeDockWidget(dock); } @@ -249,7 +251,6 @@ namespace gepetto { if (osgWindows_.empty()) { // This OSGWidget should be the central view centralWidget_ = osgWidget; - setCentralWidget(0); #if GEPETTO_GUI_HAS_PYTHONQT pythonWidget_->addToContext("osg", centralWidget_); #endif @@ -391,6 +392,21 @@ namespace gepetto { } } + void MainWindow::dockVisibilityChanged(bool visible) + { + QWidget* cw = QMainWindow::centralWidget(); + if (visible && cw->isVisible()) + cw->hide(); + else { + const QObjectList& objs = children(); + foreach(const QObject* obj, objs) { + const QDockWidget* dock = qobject_cast<const QDockWidget*>(obj); + if (dock != 0 && dock->isVisible()) return; + } + cw->show(); + } + } + void MainWindow::setupInterface() { // Menu "Window" -- GitLab