diff --git a/src/Gui/DlgSettings3DView.ui b/src/Gui/DlgSettings3DView.ui
index a4bd3e0b5f..5ac9ed0186 100644
--- a/src/Gui/DlgSettings3DView.ui
+++ b/src/Gui/DlgSettings3DView.ui
@@ -40,6 +40,25 @@ lower right corner within opened files
+ -
+
+
+ If checked, application will remember which workbench is active for each tab of the viewport
+
+
+ Remember active workbench by tab
+
+
+ false
+
+
+ SaveWBbyTab
+
+
+ View
+
+
+
-
diff --git a/src/Gui/DlgSettings3DViewImp.cpp b/src/Gui/DlgSettings3DViewImp.cpp
index 7b79f8adae..7c4872014c 100644
--- a/src/Gui/DlgSettings3DViewImp.cpp
+++ b/src/Gui/DlgSettings3DViewImp.cpp
@@ -102,6 +102,7 @@ void DlgSettings3DViewImp::saveSettings()
ui->spinBoxZoomStep->onSave();
ui->checkBoxDragAtCursor->onSave();
ui->CheckBox_CornerCoordSystem->onSave();
+ ui->CheckBox_WbByTab->onSave();
ui->CheckBox_ShowFPS->onSave();
ui->CheckBox_useVBO->onSave();
ui->CheckBox_NaviCube->onSave();
@@ -134,6 +135,7 @@ void DlgSettings3DViewImp::loadSettings()
ui->spinBoxZoomStep->onRestore();
ui->checkBoxDragAtCursor->onRestore();
ui->CheckBox_CornerCoordSystem->onRestore();
+ ui->CheckBox_WbByTab->onRestore();
ui->CheckBox_ShowFPS->onRestore();
ui->CheckBox_useVBO->onRestore();
ui->CheckBox_NaviCube->onRestore();
diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp
index c58d20f9eb..f7f60d55f6 100644
--- a/src/Gui/MainWindow.cpp
+++ b/src/Gui/MainWindow.cpp
@@ -700,6 +700,15 @@ void MainWindow::activatePreviousWindow ()
void MainWindow::activateWorkbench(const QString& name)
{
+ ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
+ bool saveWB = hGrp->GetBool("SaveWBbyTab", false);
+ QMdiSubWindow* subWin = d->mdiArea->activeSubWindow();
+ if (subWin /*!= nullptr*/ && saveWB) {
+ QString currWb = subWin->property("ownWB").toString();
+ if (currWb.isEmpty() || currWb != name) {
+ subWin->setProperty("ownWB", name);
+ }
+ }
// emit this signal
workbenchActivated(name);
updateActions(true);
@@ -1020,6 +1029,18 @@ void MainWindow::onWindowActivated(QMdiSubWindow* w)
if (!w) return;
MDIView* view = dynamic_cast(w->widget());
+ ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
+ bool saveWB = hGrp->GetBool("SaveWBbyTab", false);
+ if (saveWB) {
+ QString currWb = w->property("ownWB").toString();
+ if (! currWb.isEmpty()) {
+ this->activateWorkbench(currWb);
+ }
+ else {
+ w->setProperty("ownWB", QString::fromStdString(WorkbenchManager::instance()->active()->name()));
+ }
+ }
+
// Even if windowActivated() signal is emitted mdi doesn't need to be a top-level window.
// This happens e.g. if two windows are top-level and one of them gets docked again.
// QWorkspace emits the signal then even though the other window is in front.