Skip to content

Commit

Permalink
allow hiding of docks (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunderme committed May 13, 2024
1 parent 6da4cc7 commit 01d4e7d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
49 changes: 48 additions & 1 deletion src/texstudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,23 @@ void Texstudio::setupMenus()
act->setCheckable(true);
act->setChecked(configManager.getOption("View/ShowStatusbar").toBool());
newManagedAction(submenu, "resetdocks", tr("Reset Sidepanel/docks"), SLOT(resetDocks()));
submenu->addSeparator();
// toggle visibiliyt of all docks
QList<QDockWidget*> dockWidgets = findChildren<QDockWidget*>(); // get all dock widgets
QStringList hiddenDocks=hiddenLeftPanelWidgets.split("|");
int i=0;
foreach (QDockWidget* dockWidget, dockWidgets) {
if (dockWidget->toggleViewAction()) {
auto *act=newManagedAction(submenu, QString("dockview_%1").arg(i),dockWidget->objectName(),SLOT(toggleDockVisibility()));
act->setData(dockWidget->objectName());
QLabel *lbl=qobject_cast<QLabel*>(dockWidget->titleBarWidget());
act->setText(lbl->text());
act->setCheckable(true);
bool hide=hiddenDocks.contains(dockWidget->objectName());
act->setChecked(!hide);
++i;
}
}

newManagedAction(menu, "enlargePDF", tr("Show embedded PDF large"), SLOT(enlargeEmbeddedPDFViewer()));
newManagedAction(menu, "shrinkPDF", tr("Show embedded PDF small"), SLOT(shrinkEmbeddedPDFViewer()));
Expand Down Expand Up @@ -4458,7 +4475,12 @@ void Texstudio::readSettings(bool reread)
symbolListModel = new SymbolListModel(config->value("Symbols/UsageCount").toMap(),
config->value("Symbols/FavoriteIDs").toStringList());
symbolListModel->setDarkmode(darkMode);
hiddenLeftPanelWidgets = config->value("Symbols/hiddenlists", "").toString(); // TODO: still needed?
#ifdef Q_OS_MAC
// hide some docks by default as OSX dockwidget handle larger number badly
hiddenLeftPanelWidgets = config->value("Symbols/hiddenlists", "brackets|pstricks|metapost|tikz|asymptote|beamer|xymatrix").toString();
#else
hiddenLeftPanelWidgets = config->value("Symbols/hiddenlists", "").toString();
#endif

configManager.editorKeys = QEditor::getEditOperations(false); //this will also initialize the default keys
configManager.editorAvailableOperations = QEditor::getAvailableOperations();
Expand Down Expand Up @@ -11554,6 +11576,31 @@ void Texstudio::resetDocks()
}
m_firstDockWidget->raise();
}
/*!
* \brief toggle visibility of dock
* search for dock with name and toggle visibility
*/
void Texstudio::toggleDockVisibility()
{
QAction *act = qobject_cast<QAction *>(sender());
bool visible=act->isChecked();
QString name=act->data().toString();
QList<QDockWidget*>lst=this->findChildren<QDockWidget*>(QString(),Qt::FindDirectChildrenOnly);
QStringList hiddenDocks=hiddenLeftPanelWidgets.split("|");
foreach(QDockWidget* dw,lst){
if(name != dw->objectName()) continue;
dw->setVisible(visible);
// update hiddenDocks
if(visible){
hiddenDocks.removeAll(name);
}else{
hiddenDocks.append(name);
}
hiddenLeftPanelWidgets=hiddenDocks.join("|");
break;
}

}
/*!
\brief call updateTOC & updateStructureLocally as only one call works with a signal
*/
Expand Down
1 change: 1 addition & 0 deletions src/texstudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,7 @@ public slots:
void addDock(const QString &name, const QString &iconName, const QString &title, QWidget *wgt);
void toggleDocks(bool visible);
void resetDocks();
void toggleDockVisibility();

signals:
void infoNewFile(); ///< signal that a new file has been generated. Used for scritps as trigger.
Expand Down

4 comments on commit 01d4e7d

@octaeder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sunderme I still see the old context menu (for toolbar selection). Is selection done differently?

@sunderme
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

view/show/... all docks are listed at the bottom of the submenu

@octaeder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hint: The manual needs an update here: configuration.html#toolbars

@octaeder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uups, this is a different part.

Please sign in to comment.