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