Commit 4d5a3658 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Don't update dock title bars several times on layout change

parent a6b0ac90
......@@ -35,13 +35,23 @@ void DockTitleBarManager::slotInstallRightClick()
connect(tab, &QWidget::customContextMenuRequested, this, &DockTitleBarManager::slotSwitchTitleBars);
}
connectDocks(true);
slotUpdateTitleBars();
}
void DockTitleBarManager::connectDocks(bool doConnect)
{
// connect
QList<QDockWidget *> docks = pCore->window()->findChildren<QDockWidget *>();
for (QDockWidget *dock : qAsConst(docks)) {
connect(dock, &QDockWidget::dockLocationChanged, this, &DockTitleBarManager::slotUpdateDockLocation);
connect(dock, &QDockWidget::topLevelChanged, this, &DockTitleBarManager::slotUpdateTitleBars);
if (doConnect) {
connect(dock, &QDockWidget::dockLocationChanged, this, &DockTitleBarManager::slotUpdateDockLocation);
connect(dock, &QDockWidget::topLevelChanged, this, &DockTitleBarManager::slotUpdateTitleBars);
} else {
disconnect(dock, &QDockWidget::dockLocationChanged, this, &DockTitleBarManager::slotUpdateDockLocation);
disconnect(dock, &QDockWidget::topLevelChanged, this, &DockTitleBarManager::slotUpdateTitleBars);
}
}
slotUpdateTitleBars();
}
void DockTitleBarManager::slotUpdateDockLocation(Qt::DockWidgetArea dockLocationArea)
......
......@@ -25,6 +25,8 @@ public:
public slots:
/** @brief Correctly hide/show dock widget title bars depending on position (floating, tabbed, docked) */
void slotUpdateTitleBars(bool isTopLevel = true);
/** @brief Connect/disconnect signals to update title bars on dock location changed */
void connectDocks(bool doConnect);
private:
QAction *m_switchAction;
......
......@@ -221,6 +221,7 @@ bool LayoutManagement::loadLayout(const QString &layoutId, bool selectButton)
// Error, layout not found
return false;
}
emit connectDocks(false);
QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toLatin1());
bool timelineVisible = true;
if (state.startsWith("NO-TL")) {
......@@ -230,6 +231,7 @@ bool LayoutManagement::loadLayout(const QString &layoutId, bool selectButton)
pCore->window()->centralWidget()->setHidden(!timelineVisible);
pCore->window()->processRestoreState(state);
pCore->window()->tabifyBins();
emit connectDocks(true);
if (selectButton) {
// Activate layout button
QList<QAbstractButton *>buttons = m_containerGrp->buttons();
......
......@@ -60,6 +60,8 @@ private:
signals:
/** @brief Layout changed, ensure title bars are correctly displayed. */
void updateTitleBars();
/** @brief Connect/disconnect stuff to update titlebars on dock location changed. */
void connectDocks(bool doConnect);
};
#endif
......@@ -509,6 +509,7 @@ void MainWindow::init(const QString &mltPath)
auto *titleBars = new DockTitleBarManager(this);
connect(layoutManager, &LayoutManagement::updateTitleBars, titleBars, [&] () { titleBars->slotUpdateTitleBars(); });
connect(layoutManager, &LayoutManagement::connectDocks, titleBars, &DockTitleBarManager::connectDocks);
m_extraFactory = new KXMLGUIClient(this);
buildDynamicActions();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment