Add ability to remember which workbench is active for each tab of the viewport

Can be enabled/disabled through preferences => Connected to 'SaveWBbyTab' parameter
Workbench is saved when it is changed or when a new subwindow is created
It is restored when subwindow is activated if one was previously saved
This commit is contained in:
0penBrain
2020-02-17 20:54:19 +01:00
committed by Yorik van Havre
parent e122b44351
commit 6c8eb7e047
3 changed files with 42 additions and 0 deletions

View File

@@ -40,6 +40,25 @@ lower right corner within opened files</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="CheckBox_WbByTab">
<property name="toolTip">
<string>If checked, application will remember which workbench is active for each tab of the viewport</string>
</property>
<property name="text">
<string>Remember active workbench by tab</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>SaveWBbyTab</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="CheckBox_ShowFPS">
<property name="toolTip">

View File

@@ -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();

View File

@@ -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<MDIView*>(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.