updateTitleBarVisibility after deserializing
Fixes floating window having two title bars
This commit is contained in:
@@ -336,6 +336,9 @@ void FloatingWindow::updateTitleBarVisibility()
|
||||
visible = !frames().first()->hasTabsVisible();
|
||||
}
|
||||
}
|
||||
|
||||
for (Frame *frame : frames())
|
||||
frame->updateTitleBarVisibility();
|
||||
}
|
||||
|
||||
m_titleBar->setVisible(visible);
|
||||
@@ -390,6 +393,7 @@ void FloatingWindow::onCloseEvent(QCloseEvent *e)
|
||||
bool FloatingWindow::deserialize(const LayoutSaver::FloatingWindow &fw)
|
||||
{
|
||||
if (dropArea()->multiSplitterLayout()->deserialize(fw.multiSplitterLayout)) {
|
||||
updateTitleBarVisibility();
|
||||
show();
|
||||
return true;
|
||||
} else {
|
||||
|
||||
@@ -201,6 +201,13 @@ void Frame::onCurrentTabChanged(int index)
|
||||
|
||||
void Frame::updateTitleBarVisibility()
|
||||
{
|
||||
if (m_updatingTitleBar) {
|
||||
// To break a cyclic dependency
|
||||
return;
|
||||
}
|
||||
|
||||
QScopedValueRollback<bool> guard(m_updatingTitleBar, true);
|
||||
|
||||
bool visible = false;
|
||||
if (isCentralFrame()) {
|
||||
visible = false;
|
||||
@@ -214,8 +221,11 @@ void Frame::updateTitleBarVisibility()
|
||||
}
|
||||
|
||||
m_titleBar->setVisible(visible);
|
||||
if (auto fw = floatingWindow())
|
||||
if (auto fw = floatingWindow()) {
|
||||
// Update the floating window which might be using Flag_HideTitleBarWhenTabsVisible
|
||||
// In that case it might not show title bar depending on the number of tabs that the frame has
|
||||
fw->updateTitleBarVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
bool Frame::containsMouse(QPoint globalPos) const
|
||||
|
||||
@@ -223,6 +223,7 @@ private:
|
||||
DropArea *m_dropArea = nullptr;
|
||||
const FrameOptions m_options;
|
||||
QPointer<Layouting::Item> m_layoutItem;
|
||||
bool m_updatingTitleBar = false;
|
||||
bool m_beingDeleted = false;
|
||||
QMetaObject::Connection m_visibleWidgetCountChangedConnection;
|
||||
};
|
||||
|
||||
@@ -5301,6 +5301,32 @@ void TestDocks::tst_moreTitleBarCornerCases()
|
||||
delete fw1;
|
||||
delete fw2;
|
||||
}
|
||||
|
||||
{
|
||||
// Tests that restoring a single floating dock widget doesn't make it show two title-bars
|
||||
// As reproduced myself... and fixed in this commit
|
||||
|
||||
EnsureTopLevelsDeleted e;
|
||||
auto dock1 = createDockWidget("dock1", new QPushButton("foo1"));
|
||||
dock1->show();
|
||||
|
||||
auto fw1 = qobject_cast<FloatingWindow*>(dock1->window());
|
||||
QVERIFY(!dock1->frame()->titleBar()->isVisible());
|
||||
QVERIFY(fw1->titleBar()->isVisible());
|
||||
|
||||
LayoutSaver saver;
|
||||
const QByteArray saved = saver.serializeLayout();
|
||||
saver.restoreLayout(saved);
|
||||
|
||||
delete fw1; // the old window
|
||||
|
||||
fw1 = qobject_cast<FloatingWindow*>(dock1->window());
|
||||
QVERIFY(dock1->isVisible());
|
||||
QVERIFY(!dock1->frame()->titleBar()->isVisible());
|
||||
QVERIFY(fw1->titleBar()->isVisible());
|
||||
delete dock1->window();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
Reference in New Issue
Block a user