Fix side tab widget ordering

Now is fixed based on the side tab widget
This commit is contained in:
Syarif Fakhri 2022-09-14 17:39:57 +08:00
parent 06bcf2cd48
commit 4d3328e468
5 changed files with 49 additions and 7 deletions

View File

@ -899,14 +899,19 @@ void DockContainerWidgetPrivate::saveChildNodesState(QXmlStreamWriter& s, QWidge
void DockContainerWidgetPrivate::saveOverlayWidgetsState(QXmlStreamWriter& Stream)
{
for (const auto dockAreaWidget : _this->findChildren<CDockAreaWidget*>())
for (const auto sideTabBar : SideTabBarWidgets.values())
{
if (!dockAreaWidget->isOverlayed())
{
continue;
}
for (auto itemIndex = 0; itemIndex < sideTabBar->tabCount(); itemIndex++)
{
const auto sideTab = sideTabBar->tabAt(itemIndex);
if (sideTab == nullptr)
{
continue;
}
dockAreaWidget->saveState(Stream);
const auto dockArea = sideTab->dockWidget()->dockAreaWidget();
dockArea->saveState(Stream);
}
}
}
@ -1096,7 +1101,7 @@ bool DockContainerWidgetPrivate::restoreOverlayDockArea(CDockingStateReader& s,
DockWidget->setClosedState(Closed);
DockWidget->setProperty(internal::ClosedProperty, Closed);
DockWidget->setProperty(internal::DirtyProperty, false);
_this->sideTabBar(area)->insertSideTab(0, DockWidget->sideTabWidget());
_this->sideTabBar(area)->insertSideTab(-1, DockWidget->sideTabWidget());
DockArea->overlayDockContainer()->addDockWidget(DockWidget);
DockWidget->sideTabWidget()->updateStyle(); // Needed as the side tab widget get it's left/right property from the overlay dock container which was just added
DockArea->overlayDockContainer()->toggleView(!Closed);

View File

@ -314,6 +314,13 @@ void CDockWidgetSideTab::updateOrientationAndSpacing(SideTabBarArea area)
d->TitleLabel->show();
}
//============================================================================
CDockWidget* CDockWidgetSideTab::dockWidget() const
{
return d->DockWidget;
}
/**
* Private data class of SideTabIcon class (pimpl)
*/

View File

@ -136,6 +136,12 @@ public:
*/
void updateOrientationAndSpacing(SideTabBarArea area);
/**
* returns the dock widget this belongs to
*/
CDockWidget* dockWidget() const;
Q_SIGNALS:
void elidedChanged(bool elided);
void clicked();

View File

@ -123,4 +123,18 @@ Qt::Orientation CSideTabBar::orientation() const
{
return d->Orientation;
}
//============================================================================
CDockWidgetSideTab* CSideTabBar::tabAt(int index) const
{
return qobject_cast<CDockWidgetSideTab*>(d->TabsLayout->itemAt(index)->widget());
}
//============================================================================
int CSideTabBar::tabCount() const
{
return d->TabsLayout->count();
}
}

View File

@ -84,6 +84,16 @@ public:
*/
Qt::Orientation orientation() const;
/*
* get the side tab widget at position, returns nullptr if it's out of bounds
*/
CDockWidgetSideTab* tabAt(int index) const;
/*
* Gets the count of the tab widgets
*/
int tabCount() const;
Q_SIGNALS:
void sideTabAutoHideToggleRequested();
};