mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-24 23:31:32 +08:00
Add insert order for overlayed widget to the side tab bar
- Set the default insert order to append
This commit is contained in:
parent
5df2467592
commit
06bcf2cd48
@ -1097,7 +1097,7 @@ void CDockAreaWidget::onAutoHideToggleRequested(CDockWidget* DockWidget, bool En
|
||||
{
|
||||
if (Enable)
|
||||
{
|
||||
dockContainer()->createAndInitializeDockWidgetOverlayContainer(area, DockWidget);
|
||||
dockContainer()->createAndInitializeDockWidgetOverlayContainer(area, DockWidget, DockWidget->overlayInsertOrder());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1485,7 +1485,7 @@ CDockAreaWidget* CDockContainerWidget::addDockWidget(DockWidgetArea area, CDockW
|
||||
|
||||
|
||||
//============================================================================
|
||||
COverlayDockContainer* CDockContainerWidget::createAndInitializeDockWidgetOverlayContainer(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* DockWidget)
|
||||
COverlayDockContainer* CDockContainerWidget::createAndInitializeDockWidgetOverlayContainer(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* DockWidget, CDockWidget::eOverlayInsertOrder insertOrder)
|
||||
{
|
||||
if (d->DockManager != DockWidget->dockManager())
|
||||
{
|
||||
@ -1498,7 +1498,7 @@ COverlayDockContainer* CDockContainerWidget::createAndInitializeDockWidgetOverla
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sideTabBar(area)->insertSideTab(0, DockWidget->sideTabWidget());
|
||||
sideTabBar(area)->insertSideTab(insertOrder == CDockWidget::First ? 0 : -1, DockWidget->sideTabWidget());
|
||||
DockWidget->sideTabWidget()->show();
|
||||
|
||||
const auto dockContainer = new COverlayDockContainer(DockWidget, area, this);
|
||||
@ -1800,7 +1800,7 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi
|
||||
auto overlayWidgets = FloatingWidget->dockContainer()->overlayWidgets();
|
||||
for (const auto overlayWidget : overlayWidgets)
|
||||
{
|
||||
createAndInitializeDockWidgetOverlayContainer(overlayWidget->sideTabBarArea(), overlayWidget->dockWidget());
|
||||
createAndInitializeDockWidgetOverlayContainer(overlayWidget->sideTabBarArea(), overlayWidget->dockWidget(), overlayWidget->dockWidget()->overlayInsertOrder());
|
||||
}
|
||||
|
||||
if (DockArea)
|
||||
|
@ -95,13 +95,12 @@ protected:
|
||||
*/
|
||||
QSplitter* rootSplitter() const;
|
||||
|
||||
|
||||
/**
|
||||
* Creates and initializes a dockwidget overlay container into the given area.
|
||||
* Initializing inserts the tabs into the side tab widget and hides it
|
||||
* Returns nullptr if you try and insert into an area where the configuration is not enabled
|
||||
*/
|
||||
COverlayDockContainer* createAndInitializeDockWidgetOverlayContainer(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* DockWidget);
|
||||
COverlayDockContainer* createAndInitializeDockWidgetOverlayContainer(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* DockWidget, CDockWidget::eOverlayInsertOrder insertOrder);
|
||||
|
||||
/**
|
||||
* Helper function for creation of the root splitter
|
||||
@ -198,7 +197,6 @@ protected:
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
|
@ -864,16 +864,16 @@ CDockAreaWidget* CDockManager::addDockWidgetToContainer(DockWidgetArea area,
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
COverlayDockContainer* CDockManager::addOverlayDockWidget(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* Dockwidget)
|
||||
COverlayDockContainer* CDockManager::addOverlayDockWidget(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* Dockwidget, CDockWidget::eOverlayInsertOrder insertOrder)
|
||||
{
|
||||
return addOverlayDockWidgetToContainer(area, Dockwidget, this);
|
||||
return addOverlayDockWidgetToContainer(area, Dockwidget, this, insertOrder);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
COverlayDockContainer* CDockManager::addOverlayDockWidgetToContainer(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* Dockwidget, CDockContainerWidget* DockContainerWidget)
|
||||
COverlayDockContainer* CDockManager::addOverlayDockWidgetToContainer(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* Dockwidget, CDockContainerWidget* DockContainerWidget, CDockWidget::eOverlayInsertOrder insertOrder)
|
||||
{
|
||||
d->DockWidgetsMap.insert(Dockwidget->objectName(), Dockwidget);
|
||||
auto container = DockContainerWidget->createAndInitializeDockWidgetOverlayContainer(area, Dockwidget);
|
||||
auto container = DockContainerWidget->createAndInitializeDockWidgetOverlayContainer(area, Dockwidget, insertOrder);
|
||||
container->collapseView(true);
|
||||
|
||||
Q_EMIT dockWidgetAdded(Dockwidget);
|
||||
|
@ -341,14 +341,14 @@ public:
|
||||
* An overlay widget is used for auto hide functionality
|
||||
* \return Returns the COverlayDockContainer that contains the new DockWidget
|
||||
*/
|
||||
COverlayDockContainer* addOverlayDockWidget(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* Dockwidget);
|
||||
COverlayDockContainer* addOverlayDockWidget(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* Dockwidget, CDockWidget::eOverlayInsertOrder insertOrder = CDockWidget::Last);
|
||||
|
||||
/**
|
||||
* Adds dock widget overlayed into the given container based on the CDockWidgetSideTab::SideTabBarArea.
|
||||
* An overlay widget is used for auto hide functionality
|
||||
* \return Returns the COverlayDockContainer that contains the new DockWidget
|
||||
*/
|
||||
COverlayDockContainer* addOverlayDockWidgetToContainer(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* Dockwidget, CDockContainerWidget* DockContainerWidget);
|
||||
COverlayDockContainer* addOverlayDockWidgetToContainer(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* Dockwidget, CDockContainerWidget* DockContainerWidget, CDockWidget::eOverlayInsertOrder = CDockWidget::Last);
|
||||
|
||||
/**
|
||||
* This function will add the given Dockwidget to the given dock area as
|
||||
|
@ -96,6 +96,7 @@ struct DockWidgetPrivate
|
||||
CDockWidget::eMinimumSizeHintMode MinimumSizeHintMode = CDockWidget::MinimumSizeHintFromDockWidget;
|
||||
WidgetFactory* Factory = nullptr;
|
||||
double DefaultOverlayDockProportion = 0.25;
|
||||
CDockWidget::eOverlayInsertOrder OverlayInsertOrder = CDockWidget::Last;
|
||||
|
||||
/**
|
||||
* Private data constructor
|
||||
@ -1149,6 +1150,18 @@ double CDockWidget::DefaultOverlayDockProportion() const
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockWidget::setOverlayInsertOrder(eOverlayInsertOrder insertOrder)
|
||||
{
|
||||
d->OverlayInsertOrder = insertOrder;
|
||||
}
|
||||
|
||||
CDockWidget::eOverlayInsertOrder CDockWidget::overlayInsertOrder() const
|
||||
{
|
||||
return d->OverlayInsertOrder;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockWidget::raise()
|
||||
{
|
||||
|
@ -229,6 +229,17 @@ public:
|
||||
ActionModeShow //!< ActionModeShow
|
||||
};
|
||||
|
||||
/**
|
||||
* This mode configures the order of pinning and unpinning overlayed widgets
|
||||
* First will add it to the top of the SideTabBar, while last will append it to the end
|
||||
*/
|
||||
enum eOverlayInsertOrder
|
||||
{
|
||||
First,
|
||||
Last
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This constructor creates a dock widget with the given title.
|
||||
@ -524,6 +535,16 @@ public:
|
||||
*/
|
||||
double DefaultOverlayDockProportion() const;
|
||||
|
||||
/*
|
||||
* Set overlay insertion mode
|
||||
*/
|
||||
void setOverlayInsertOrder(eOverlayInsertOrder insertOrder);
|
||||
|
||||
/*
|
||||
* Get overlay insertion mode
|
||||
*/
|
||||
eOverlayInsertOrder overlayInsertOrder() const;
|
||||
|
||||
public: // reimplements QFrame -----------------------------------------------
|
||||
/**
|
||||
* Emits titleChanged signal if title change event occurs
|
||||
|
@ -71,12 +71,17 @@ CSideTabBar::CSideTabBar(CDockContainerWidget* parent, Qt::Orientation orientati
|
||||
d->ContainerWidget = parent;
|
||||
d->Orientation = orientation;
|
||||
|
||||
auto mainLayout = new QBoxLayout(d->Orientation == Qt::Vertical ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight);
|
||||
|
||||
d->TabsLayout = new QBoxLayout(d->Orientation == Qt::Vertical ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight);
|
||||
d->TabsLayout->setContentsMargins(0, 0, 0, 0);
|
||||
d->TabsLayout->setSpacing(0);
|
||||
d->TabsLayout->addStretch(1);
|
||||
setLayout(d->TabsLayout);
|
||||
mainLayout->addLayout(d->TabsLayout);
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
mainLayout->setSpacing(0);
|
||||
mainLayout->addStretch(1);
|
||||
|
||||
setLayout(mainLayout);
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user