mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-04-01 02:42:39 +08:00
Add dockwidget tab order
This commit is contained in:
parent
0bfee09b17
commit
9e9d166542
@ -43,6 +43,7 @@ CMainWindow::CMainWindow(QWidget *parent)
|
||||
table->setColumnCount(3);
|
||||
table->setRowCount(10);
|
||||
CDockWidget* TableDockWidget = new CDockWidget("Table 1");
|
||||
//TableDockWidget->setAutoHideTabOrder(1.0); // Uncomment if you would like the table dock widget to always be pinned before the second table dock widget
|
||||
TableDockWidget->setWidget(table);
|
||||
TableDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget);
|
||||
TableDockWidget->setMinimumSize(200,150);
|
||||
@ -54,6 +55,7 @@ CMainWindow::CMainWindow(QWidget *parent)
|
||||
table->setColumnCount(5);
|
||||
table->setRowCount(1020);
|
||||
TableDockWidget = new CDockWidget("Table 2");
|
||||
//TableDockWidget->setAutoHideTabOrder(2.0); // Uncomment if you would like the table dock widget to always be pinned after the first table dock widget
|
||||
TableDockWidget->setWidget(table);
|
||||
TableDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget);
|
||||
TableDockWidget->resize(250, 150);
|
||||
|
@ -241,6 +241,41 @@ CAutoHideDockContainer* CAutoHideSideBar::insertDockWidget(int Index, CDockWidge
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CAutoHideDockContainer* CAutoHideSideBar::insertDockWidgetByOrder(CDockWidget* DockWidget)
|
||||
{
|
||||
auto AutoHideContainer = new CAutoHideDockContainer(DockWidget, d->SideTabArea, d->ContainerWidget);
|
||||
DockWidget->dockManager()->dockFocusController()->clearDockWidgetFocus(DockWidget);
|
||||
auto Tab = AutoHideContainer->autoHideTab();
|
||||
DockWidget->setSideTabWidget(Tab);
|
||||
|
||||
const auto insertDockOrder = DockWidget->autoHideTabOrder();
|
||||
for (auto i = 0; i < d->TabsLayout->count(); i++)
|
||||
{
|
||||
const auto autoHideTab = qobject_cast<CAutoHideTab*>(d->TabsLayout->itemAt(i)->widget());
|
||||
if (autoHideTab == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto order = autoHideTab->dockWidget()->autoHideTabOrder();
|
||||
if (order < 0) // less than 0 means that a preferred order was not set
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (order > insertDockOrder)
|
||||
{
|
||||
insertTab(i, Tab);
|
||||
return AutoHideContainer;
|
||||
}
|
||||
}
|
||||
|
||||
insertTab(-1, Tab);
|
||||
return AutoHideContainer;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CAutoHideSideBar::removeAutoHideWidget(CAutoHideDockContainer* AutoHideWidget)
|
||||
{
|
||||
|
@ -107,6 +107,13 @@ public:
|
||||
*/
|
||||
CAutoHideDockContainer* insertDockWidget(int Index, CDockWidget* DockWidget);
|
||||
|
||||
/**
|
||||
* Insert dock widget into the side bar, following auto hide tab order preferences from the dock widget.
|
||||
* The function creates the auto hide dock container, inserts the
|
||||
* auto hide tab
|
||||
*/
|
||||
CAutoHideDockContainer* insertDockWidgetByOrder(CDockWidget* DockWidget);
|
||||
|
||||
/**
|
||||
* Removes the auto hide widget from this side bar
|
||||
*/
|
||||
|
@ -1417,6 +1417,11 @@ CAutoHideDockContainer* CDockContainerWidget::createAndSetupAutoHideContainer(
|
||||
DockWidget->setDockManager(d->DockManager); // Auto hide Dock Container needs a valid dock manager
|
||||
}
|
||||
|
||||
if (DockWidget->autoHideTabOrder() > 0)
|
||||
{
|
||||
return sideTabBar(area)->insertDockWidgetByOrder(DockWidget);
|
||||
}
|
||||
|
||||
return sideTabBar(area)->insertDockWidget(-1, DockWidget);
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,8 @@ struct DockWidgetPrivate
|
||||
CDockWidget::eMinimumSizeHintMode MinimumSizeHintMode = CDockWidget::MinimumSizeHintFromDockWidget;
|
||||
WidgetFactory* Factory = nullptr;
|
||||
QPointer<CAutoHideTab> SideTabWidget;
|
||||
|
||||
float AutoHideTabOrder = -1.0;
|
||||
|
||||
/**
|
||||
* Private data constructor
|
||||
*/
|
||||
@ -1228,6 +1229,18 @@ void CDockWidget::toggleAutoHide(SideBarLocation Location)
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockWidget::setAutoHideTabOrder(float order)
|
||||
{
|
||||
d->AutoHideTabOrder = order;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
float CDockWidget::autoHideTabOrder() const
|
||||
{
|
||||
return d->AutoHideTabOrder;
|
||||
}
|
||||
} // namespace ads
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -536,6 +536,19 @@ public:
|
||||
*/
|
||||
bool isCurrentTab() const;
|
||||
|
||||
/*
|
||||
* Sets the relative order preference for auto hide tabs.
|
||||
* Lower numbers will be closer to the start, higher numbers will be closer to the end.
|
||||
* Set to < 0 to ignore this setting (default is -1)
|
||||
* This is relevant when pinning and unpinning via the auto hide button (not programmatically)
|
||||
*/
|
||||
void setAutoHideTabOrder(float order);
|
||||
|
||||
/*
|
||||
* Get the relative order preference for auto hide tabs.
|
||||
*/
|
||||
float autoHideTabOrder() const;
|
||||
|
||||
public: // reimplements QFrame -----------------------------------------------
|
||||
/**
|
||||
* Emits titleChanged signal if title change event occurs
|
||||
@ -614,7 +627,6 @@ public Q_SLOTS:
|
||||
*/
|
||||
void toggleAutoHide(SideBarLocation Location = SideBarNone);
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal is emitted if the dock widget is opened or closed
|
||||
|
Loading…
Reference in New Issue
Block a user