diff --git a/include/gepetto/gui/mainwindow.hh b/include/gepetto/gui/mainwindow.hh index 771294cd8fbdd5b48dfc4ab10823aebb2006d483..18d30af5c83ed64a40d380f3cd1fe7ea0d66726b 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 83bb24ce95acabe7d84c4bb3b2101c2079fa6b59..6ac572e4806309e7e1f1eddbb6c90b365e1f5328 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 495d9b8c5698652736f4bcc8062c729ae6e12713..690956ffbabe7e88d69f2d876ec8dc24c45c1aa1 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"