mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-26 14:29:02 +08:00
Moved creation of SideTabWidget into AutoHideDockContainer.cpp
This commit is contained in:
parent
af4a3ef2a8
commit
8d670577a9
@ -107,7 +107,7 @@ struct AutoHideDockContainerPrivate
|
|||||||
QBoxLayout* Layout;
|
QBoxLayout* Layout;
|
||||||
CResizeHandle* ResizeHandle = nullptr;
|
CResizeHandle* ResizeHandle = nullptr;
|
||||||
QSize Size; // creates invalid size
|
QSize Size; // creates invalid size
|
||||||
CDockWidgetSideTab* SideTab = nullptr;
|
QPointer<CDockWidgetSideTab> SideTab;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private data constructor
|
* Private data constructor
|
||||||
@ -174,6 +174,8 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockManager* DockManager, SideBa
|
|||||||
d(new AutoHideDockContainerPrivate(this))
|
d(new AutoHideDockContainerPrivate(this))
|
||||||
{
|
{
|
||||||
d->SideTabBarArea = area;
|
d->SideTabBarArea = area;
|
||||||
|
d->SideTab = new CDockWidgetSideTab();
|
||||||
|
connect(d->SideTab, &CDockWidgetSideTab::pressed, this, &CAutoHideDockContainer::toggleCollapseState);
|
||||||
d->DockArea = new CDockAreaWidget(DockManager, parent);
|
d->DockArea = new CDockAreaWidget(DockManager, parent);
|
||||||
d->DockArea->setObjectName("autoHideDockArea");
|
d->DockArea->setObjectName("autoHideDockArea");
|
||||||
d->DockArea->setAutoHideDockContainer(this);
|
d->DockArea->setAutoHideDockContainer(this);
|
||||||
@ -194,7 +196,6 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockManager* DockManager, SideBa
|
|||||||
d->Layout->insertWidget(resizeHandleLayoutPosition(area), d->ResizeHandle);
|
d->Layout->insertWidget(resizeHandleLayoutPosition(area), d->ResizeHandle);
|
||||||
d->Size = d->DockArea->size();
|
d->Size = d->DockArea->size();
|
||||||
|
|
||||||
|
|
||||||
updateSize();
|
updateSize();
|
||||||
parent->registerAutoHideWidget(this);
|
parent->registerAutoHideWidget(this);
|
||||||
}
|
}
|
||||||
@ -205,6 +206,7 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockWidget* DockWidget, SideBarL
|
|||||||
CAutoHideDockContainer(DockWidget->dockManager(), area, parent)
|
CAutoHideDockContainer(DockWidget->dockManager(), area, parent)
|
||||||
{
|
{
|
||||||
addDockWidget(DockWidget);
|
addDockWidget(DockWidget);
|
||||||
|
hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -292,7 +294,14 @@ void CAutoHideDockContainer::addDockWidget(CDockWidget* DockWidget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
d->DockWidget = DockWidget;
|
d->DockWidget = DockWidget;
|
||||||
|
if (!d->SideTab)
|
||||||
|
{
|
||||||
d->SideTab = DockWidget->sideTabWidget();
|
d->SideTab = DockWidget->sideTabWidget();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d->SideTab->setDockWidget(DockWidget);
|
||||||
|
}
|
||||||
CDockAreaWidget* OldDockArea = DockWidget->dockAreaWidget();
|
CDockAreaWidget* OldDockArea = DockWidget->dockAreaWidget();
|
||||||
if (OldDockArea)
|
if (OldDockArea)
|
||||||
{
|
{
|
||||||
@ -446,6 +455,8 @@ void CAutoHideDockContainer::toggleCollapseState()
|
|||||||
collapseView(isVisible());
|
collapseView(isVisible());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
void CAutoHideDockContainer::setSize(int width, int height)
|
void CAutoHideDockContainer::setSize(int width, int height)
|
||||||
{
|
{
|
||||||
d->Size = QSize(width, height);
|
d->Size = QSize(width, height);
|
||||||
|
@ -1535,25 +1535,26 @@ CDockAreaWidget* CDockContainerWidget::addDockWidget(DockWidgetArea area, CDockW
|
|||||||
CAutoHideDockContainer* CDockContainerWidget::createAndSetupAutoHideContainer(
|
CAutoHideDockContainer* CDockContainerWidget::createAndSetupAutoHideContainer(
|
||||||
SideBarLocation area, CDockWidget* DockWidget, CDockWidget::eAutoHideInsertOrder insertOrder)
|
SideBarLocation area, CDockWidget* DockWidget, CDockWidget::eAutoHideInsertOrder insertOrder)
|
||||||
{
|
{
|
||||||
if (d->DockManager != DockWidget->dockManager())
|
|
||||||
{
|
|
||||||
DockWidget->setDockManager(d->DockManager); // Auto hide Dock Container needs a valid dock manager
|
|
||||||
}
|
|
||||||
if (!CDockManager::testConfigFlag(CDockManager::AutoHideFeatureEnabled))
|
if (!CDockManager::testConfigFlag(CDockManager::AutoHideFeatureEnabled))
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(false, "CDockContainerWidget::createAndInitializeDockWidgetOverlayContainer",
|
Q_ASSERT_X(false, "CDockContainerWidget::createAndInitializeDockWidgetOverlayContainer",
|
||||||
"Requested area does not exist in config");
|
"Requested area does not exist in config");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
if (d->DockManager != DockWidget->dockManager())
|
||||||
|
{
|
||||||
|
DockWidget->setDockManager(d->DockManager); // Auto hide Dock Container needs a valid dock manager
|
||||||
|
}
|
||||||
|
|
||||||
sideTabBar(area)->insertSideTab(insertOrder == CDockWidget::First ? 0 : -1, DockWidget->sideTabWidget());
|
/*sideTabBar(area)->insertSideTab(insertOrder == CDockWidget::First ? 0 : -1, DockWidget->sideTabWidget());
|
||||||
DockWidget->sideTabWidget()->show();
|
DockWidget->sideTabWidget()->show();
|
||||||
|
|
||||||
const auto AutoHideContainer = new CAutoHideDockContainer(DockWidget, area, this);
|
const auto AutoHideContainer = new CAutoHideDockContainer(DockWidget, area, this);
|
||||||
AutoHideContainer->hide();
|
AutoHideContainer->hide();
|
||||||
d->DockManager->dockFocusController()->clearDockWidgetFocus(DockWidget);
|
d->DockManager->dockFocusController()->clearDockWidgetFocus(DockWidget);
|
||||||
|
return AutoHideContainer;*/
|
||||||
|
|
||||||
return AutoHideContainer;
|
return sideTabBar(area)->insertDockWidget(insertOrder == CDockWidget::First ? 0 : -1, DockWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -325,7 +325,8 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) :
|
|||||||
setObjectName(title);
|
setObjectName(title);
|
||||||
|
|
||||||
d->TabWidget = componentsFactory()->createDockWidgetTab(this);
|
d->TabWidget = componentsFactory()->createDockWidgetTab(this);
|
||||||
d->SideTabWidget = componentsFactory()->createDockWidgetSideTab(this);
|
d->SideTabWidget = componentsFactory()->createDockWidgetSideTab(nullptr);
|
||||||
|
d->SideTabWidget->hide();
|
||||||
|
|
||||||
connect(d->SideTabWidget, &CDockWidgetSideTab::pressed, this, &CDockWidget::onDockWidgetSideTabClicked);
|
connect(d->SideTabWidget, &CDockWidgetSideTab::pressed, this, &CDockWidget::onDockWidgetSideTabClicked);
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ namespace ads
|
|||||||
struct DockWidgetSideTabPrivate
|
struct DockWidgetSideTabPrivate
|
||||||
{
|
{
|
||||||
CDockWidgetSideTab* _this;
|
CDockWidgetSideTab* _this;
|
||||||
CDockWidget* DockWidget;
|
CDockWidget* DockWidget = nullptr;
|
||||||
CSideTabBar* SideTabBar = nullptr;
|
CSideTabBar* SideTabBar = nullptr;
|
||||||
Qt::Orientation Orientation{Qt::Vertical};
|
Qt::Orientation Orientation{Qt::Vertical};
|
||||||
|
|
||||||
@ -84,13 +84,11 @@ void CDockWidgetSideTab::removeFromSideTabBar()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockWidgetSideTab::CDockWidgetSideTab(CDockWidget* DockWidget, QWidget* parent) :
|
CDockWidgetSideTab::CDockWidgetSideTab(QWidget* parent) :
|
||||||
Super(parent),
|
Super(parent),
|
||||||
d(new DockWidgetSideTabPrivate(this))
|
d(new DockWidgetSideTabPrivate(this))
|
||||||
{
|
{
|
||||||
setAttribute(Qt::WA_NoMousePropagation);
|
setAttribute(Qt::WA_NoMousePropagation);
|
||||||
d->DockWidget = DockWidget;
|
|
||||||
setText(DockWidget->windowTitle());
|
|
||||||
setFocusPolicy(Qt::NoFocus);
|
setFocusPolicy(Qt::NoFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +180,7 @@ void CDockWidgetSideTab::updateOrientationForArea(SideBarLocation area)
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
bool CDockWidgetSideTab::isActiveTab() const
|
bool CDockWidgetSideTab::isActiveTab() const
|
||||||
{
|
{
|
||||||
if (d->DockWidget->autoHideDockContainer())
|
if (d->DockWidget && d->DockWidget->autoHideDockContainer())
|
||||||
{
|
{
|
||||||
return d->DockWidget->autoHideDockContainer()->isVisible();
|
return d->DockWidget->autoHideDockContainer()->isVisible();
|
||||||
}
|
}
|
||||||
@ -197,4 +195,16 @@ CDockWidget* CDockWidgetSideTab::dockWidget() const
|
|||||||
return d->DockWidget;
|
return d->DockWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockWidgetSideTab::setDockWidget(CDockWidget* DockWidget)
|
||||||
|
{
|
||||||
|
if (!DockWidget)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
d->DockWidget = DockWidget;
|
||||||
|
setText(DockWidget->windowTitle());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ public:
|
|||||||
* param[in] DockWidget The dock widget this title bar belongs to
|
* param[in] DockWidget The dock widget this title bar belongs to
|
||||||
* param[in] parent The parent widget of this title bar
|
* param[in] parent The parent widget of this title bar
|
||||||
*/
|
*/
|
||||||
CDockWidgetSideTab(CDockWidget* DockWidget, QWidget* parent = nullptr);
|
CDockWidgetSideTab(QWidget* parent = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Virtual Destructor
|
* Virtual Destructor
|
||||||
@ -117,6 +117,11 @@ public:
|
|||||||
* returns the dock widget this belongs to
|
* returns the dock widget this belongs to
|
||||||
*/
|
*/
|
||||||
CDockWidget* dockWidget() const;
|
CDockWidget* dockWidget() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the dock widget that is controlled by this tab
|
||||||
|
*/
|
||||||
|
void setDockWidget(CDockWidget* DockWidget);
|
||||||
}; // class DockWidgetSideTab
|
}; // class DockWidgetSideTab
|
||||||
}
|
}
|
||||||
// namespace ads
|
// namespace ads
|
||||||
|
@ -139,21 +139,19 @@ void CSideTabBar::insertSideTab(int Index, CDockWidgetSideTab* SideTab)
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
CAutoHideDockContainer* CSideTabBar::insertDockWidget(int Index, CDockWidget* DockWidget)
|
CAutoHideDockContainer* CSideTabBar::insertDockWidget(int Index, CDockWidget* DockWidget)
|
||||||
{
|
{
|
||||||
CDockWidgetSideTab* Tab = new CDockWidgetSideTab(DockWidget);
|
/*
|
||||||
auto area = sideTabBarArea();
|
* sideTabBar(area)->insertSideTab(insertOrder == CDockWidget::First ? 0 : -1, DockWidget->sideTabWidget());
|
||||||
qDebug() << "area " << area;
|
DockWidget->sideTabWidget()->show();
|
||||||
Tab->setSideTabBar(this);
|
|
||||||
Tab->updateOrientationForArea(area);
|
|
||||||
d->TabsLayout->insertWidget(Index, Tab);
|
|
||||||
Tab->show();
|
|
||||||
|
|
||||||
auto AutoHideContainer = new CAutoHideDockContainer(DockWidget, area, d->ContainerWidget);
|
const auto AutoHideContainer = new CAutoHideDockContainer(DockWidget, area, this);
|
||||||
AutoHideContainer->hide();
|
AutoHideContainer->hide();
|
||||||
DockWidget->dockManager()->dockFocusController()->clearDockWidgetFocus(DockWidget);
|
d->DockManager->dockFocusController()->clearDockWidgetFocus(DockWidget);
|
||||||
Tab->updateStyle();
|
return AutoHideContainer;*/
|
||||||
|
|
||||||
connect(Tab, &CDockWidgetSideTab::pressed, AutoHideContainer, &CAutoHideDockContainer::toggleCollapseState);
|
auto AutoHideContainer = new CAutoHideDockContainer(DockWidget, d->SideTabArea, d->ContainerWidget);
|
||||||
show();
|
DockWidget->dockManager()->dockFocusController()->clearDockWidgetFocus(DockWidget);
|
||||||
|
auto Tab = AutoHideContainer->sideTab();
|
||||||
|
insertSideTab(Index, Tab);
|
||||||
return AutoHideContainer;
|
return AutoHideContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user