mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-26 08:01:32 +08:00
Fixed showing and hiding of dock widget title bar. If a dock widget is the one and only visible widget in a FloatingDockContainer, then this widget does not have a tile bar because the window already has a window frame that provides the same functionality
This commit is contained in:
parent
6ec38b48ef
commit
9f1b2c122a
@ -216,14 +216,7 @@ void DockAreaWidgetPrivate::updateTabBar()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Container->isFloating() && (Container->dockAreaCount() == 1) && (_this->dockWidgetsCount() == 1))
|
TitleBar->setVisible(!Container->isFloating() || !Container->hasSingleVisibleDockWidget());
|
||||||
{
|
|
||||||
TitleBar->setVisible(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
TitleBar->setVisible(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -360,27 +353,25 @@ void CDockAreaWidget::insertDockWidget(int index, CDockWidget* DockWidget,
|
|||||||
void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
|
void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
|
||||||
{
|
{
|
||||||
qDebug() << "CDockAreaWidget::removeDockWidget";
|
qDebug() << "CDockAreaWidget::removeDockWidget";
|
||||||
auto NextDockWidget = nextOpenDockWidget(DockWidget);
|
auto NextOpenDockWidget = nextOpenDockWidget(DockWidget);
|
||||||
|
|
||||||
d->ContentsLayout->removeWidget(DockWidget);
|
d->ContentsLayout->removeWidget(DockWidget);
|
||||||
auto TitleBar = DockWidget->tabWidget();
|
auto TabWidget = DockWidget->tabWidget();
|
||||||
TitleBar->hide();
|
TabWidget->hide();
|
||||||
d->TabsLayout->removeWidget(TitleBar);
|
d->TabsLayout->removeWidget(TabWidget);
|
||||||
disconnect(TitleBar, SIGNAL(clicked()), this, SLOT(onDockWidgetTitleClicked()));
|
disconnect(TabWidget, SIGNAL(clicked()), this, SLOT(onDockWidgetTitleClicked()));
|
||||||
if (NextDockWidget)
|
if (NextOpenDockWidget)
|
||||||
{
|
{
|
||||||
setCurrentDockWidget(NextDockWidget);
|
setCurrentDockWidget(NextOpenDockWidget);
|
||||||
d->markTabsMenuOutdated();
|
d->markTabsMenuOutdated();
|
||||||
}
|
}
|
||||||
|
else if (d->ContentsLayout->isEmpty())
|
||||||
CDockContainerWidget* DockContainer = dockContainer();
|
|
||||||
if (d->ContentsLayout->isEmpty())
|
|
||||||
{
|
{
|
||||||
qDebug() << "Dock Area empty";
|
qDebug() << "Dock Area empty";
|
||||||
dockContainer()->removeDockArea(this);
|
dockContainer()->removeDockArea(this);
|
||||||
this->deleteLater();;
|
this->deleteLater();
|
||||||
}
|
}
|
||||||
else if (!NextDockWidget)
|
else
|
||||||
{
|
{
|
||||||
// if contents layout is not empty but there are no more open dock
|
// if contents layout is not empty but there are no more open dock
|
||||||
// widgets, then we need to hide the dock area because it does not
|
// widgets, then we need to hide the dock area because it does not
|
||||||
@ -390,7 +381,11 @@ void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
|
|||||||
|
|
||||||
d->updateTabBar();
|
d->updateTabBar();
|
||||||
DockWidget->setDockArea(nullptr);
|
DockWidget->setDockArea(nullptr);
|
||||||
|
|
||||||
|
#if (ADS_DEBUG_LEVEL > 0)
|
||||||
|
CDockContainerWidget* DockContainer = dockContainer();
|
||||||
DockContainer->dumpLayout();
|
DockContainer->dumpLayout();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -656,6 +651,7 @@ void CDockAreaWidget::toggleDockWidgetView(CDockWidget* DockWidget, bool Open)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(DockWidget);
|
Q_UNUSED(DockWidget);
|
||||||
Q_UNUSED(Open);
|
Q_UNUSED(Open);
|
||||||
|
updateDockArea();
|
||||||
d->markTabsMenuOutdated();
|
d->markTabsMenuOutdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,8 +189,11 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float
|
|||||||
DockWidgetArea area)
|
DockWidgetArea area)
|
||||||
{
|
{
|
||||||
auto InsertParam = internal::dockAreaInsertParameters(area);
|
auto InsertParam = internal::dockAreaInsertParameters(area);
|
||||||
auto NewDockAreas = FloatingWidget->dockContainer()->findChildren<CDockAreaWidget*>(
|
CDockContainerWidget* FloatingDockContainer = FloatingWidget->dockContainer();
|
||||||
|
auto NewDockAreas = FloatingDockContainer->findChildren<CDockAreaWidget*>(
|
||||||
QString(), Qt::FindChildrenRecursively);
|
QString(), Qt::FindChildrenRecursively);
|
||||||
|
CDockWidget* SingleDoppedDockWidget = FloatingDockContainer->singleVisibleDockWidget();
|
||||||
|
CDockWidget* SingleDockWidget = _this->singleVisibleDockWidget();
|
||||||
QSplitter* Splitter = RootSplitter;
|
QSplitter* Splitter = RootSplitter;
|
||||||
|
|
||||||
if (DockAreas.count() <= 1)
|
if (DockAreas.count() <= 1)
|
||||||
@ -207,7 +210,7 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now we can insert the floating widget content into this container
|
// Now we can insert the floating widget content into this container
|
||||||
auto FloatingSplitter = FloatingWidget->dockContainer()->rootSplitter();
|
auto FloatingSplitter = FloatingDockContainer->rootSplitter();
|
||||||
if (FloatingSplitter->count() == 1)
|
if (FloatingSplitter->count() == 1)
|
||||||
{
|
{
|
||||||
insertWidgetIntoSplitter(Splitter, FloatingSplitter->widget(0), InsertParam.append());
|
insertWidgetIntoSplitter(Splitter, FloatingSplitter->widget(0), InsertParam.append());
|
||||||
@ -227,6 +230,15 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float
|
|||||||
RootSplitter = Splitter;
|
RootSplitter = Splitter;
|
||||||
addDockAreasToList(NewDockAreas);
|
addDockAreasToList(NewDockAreas);
|
||||||
FloatingWidget->deleteLater();
|
FloatingWidget->deleteLater();
|
||||||
|
if (SingleDoppedDockWidget)
|
||||||
|
{
|
||||||
|
SingleDoppedDockWidget->dockAreaWidget()->updateDockArea();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SingleDockWidget)
|
||||||
|
{
|
||||||
|
SingleDockWidget->dockAreaWidget()->updateDockArea();
|
||||||
|
}
|
||||||
// If we dropped the floating widget into the main dock container that does
|
// If we dropped the floating widget into the main dock container that does
|
||||||
// not contain any dock widgets, then splitter is invisible and we need to
|
// not contain any dock widgets, then splitter is invisible and we need to
|
||||||
// show it to display the docked widgets
|
// show it to display the docked widgets
|
||||||
@ -588,6 +600,7 @@ CDockAreaWidget* DockContainerWidgetPrivate::dockWidgetIntoContainer(DockWidgetA
|
|||||||
CDockAreaWidget* NewDockArea = new CDockAreaWidget(DockManager, _this);
|
CDockAreaWidget* NewDockArea = new CDockAreaWidget(DockManager, _this);
|
||||||
NewDockArea->addDockWidget(Dockwidget);
|
NewDockArea->addDockWidget(Dockwidget);
|
||||||
addDockArea(NewDockArea, area);
|
addDockArea(NewDockArea, area);
|
||||||
|
NewDockArea->updateDockArea();
|
||||||
LastAddedAreaCache[areaIdToIndex(area)] = NewDockArea;
|
LastAddedAreaCache[areaIdToIndex(area)] = NewDockArea;
|
||||||
return NewDockArea;
|
return NewDockArea;
|
||||||
}
|
}
|
||||||
@ -864,6 +877,12 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area)
|
|||||||
delete Splitter;
|
delete Splitter;
|
||||||
|
|
||||||
emitAndExit:
|
emitAndExit:
|
||||||
|
// Updated the title bar visibility of the dock widget if there is only
|
||||||
|
// one single visible dock widget
|
||||||
|
if (hasSingleVisibleDockWidget())
|
||||||
|
{
|
||||||
|
openedDockAreas()[0]->updateDockArea();
|
||||||
|
}
|
||||||
dumpLayout();
|
dumpLayout();
|
||||||
emit dockAreasRemoved();
|
emit dockAreasRemoved();
|
||||||
}
|
}
|
||||||
@ -974,7 +993,7 @@ QList<CDockAreaWidget*> CDockContainerWidget::openedDockAreas() const
|
|||||||
QList<CDockAreaWidget*> Result;
|
QList<CDockAreaWidget*> Result;
|
||||||
for (auto DockArea : d->DockAreas)
|
for (auto DockArea : d->DockAreas)
|
||||||
{
|
{
|
||||||
if (DockArea->isVisible())
|
if (DockArea->isVisibleTo(this))
|
||||||
{
|
{
|
||||||
Result.append(DockArea);
|
Result.append(DockArea);
|
||||||
}
|
}
|
||||||
@ -1088,6 +1107,45 @@ CDockAreaWidget* CDockContainerWidget::lastAddedDockAreaWidget(DockWidgetArea ar
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
bool CDockContainerWidget::hasSingleVisibleDockWidget() const
|
||||||
|
{
|
||||||
|
auto DockAreas = openedDockAreas();
|
||||||
|
if (DockAreas.count() != 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DockAreas[0]->openDockWidgetsCount() == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
CDockWidget* CDockContainerWidget::firstVisibleDockWidget() const
|
||||||
|
{
|
||||||
|
return openedDockAreas()[0]->openedDockWidgets()[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
CDockWidget* CDockContainerWidget::singleVisibleDockWidget() const
|
||||||
|
{
|
||||||
|
auto DockAreas = openedDockAreas();
|
||||||
|
if (DockAreas.count() != 1)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto DockWidgets = DockAreas[0]->openedDockWidgets();
|
||||||
|
if (DockWidgets.count() != 1)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DockWidgets[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -61,8 +61,10 @@ private:
|
|||||||
friend class CDockManager;
|
friend class CDockManager;
|
||||||
friend struct DockManagerPrivate;
|
friend struct DockManagerPrivate;
|
||||||
friend class CDockAreaWidget;
|
friend class CDockAreaWidget;
|
||||||
|
friend struct DockAreaWidgetPrivate;
|
||||||
friend class CFloatingDockContainer;
|
friend class CFloatingDockContainer;
|
||||||
friend struct FloatingDockContainerPrivate;
|
friend struct FloatingDockContainerPrivate;
|
||||||
|
friend class CDockWidget;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
@ -110,6 +112,25 @@ protected:
|
|||||||
*/
|
*/
|
||||||
CDockAreaWidget* lastAddedDockAreaWidget(DockWidgetArea area) const;
|
CDockAreaWidget* lastAddedDockAreaWidget(DockWidgetArea area) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function returns true if this dock area has only one single
|
||||||
|
* visible dock widget.
|
||||||
|
*/
|
||||||
|
bool hasSingleVisibleDockWidget() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If hasSingleVisibleDockWidget() returns true, this function returns the
|
||||||
|
* one and only visible dock widget. Otherwise it returns a nullptr.
|
||||||
|
*/
|
||||||
|
CDockWidget* singleVisibleDockWidget() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the first visible dock widget.
|
||||||
|
* If the function hasSingleVisibleDockWidget() returns true, then this
|
||||||
|
* function returns the one and only visible dock widget
|
||||||
|
*/
|
||||||
|
CDockWidget* firstVisibleDockWidget() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
|
@ -328,7 +328,7 @@ CDockContainerWidget* CDockWidget::dockContainer() const
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
CDockAreaWidget* CDockWidget::dockAreaWidget() const
|
CDockAreaWidget* CDockWidget::dockAreaWidget() const
|
||||||
{
|
{
|
||||||
return internal::findParent<CDockAreaWidget*>(this);
|
return d->DockArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -345,7 +345,7 @@ bool CDockWidget::isFloating() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dockContainer()->dockArea(0)->dockWidgetsCount() != 1)
|
if (d->DockArea->openDockWidgetsCount() != 1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -357,12 +357,13 @@ bool CDockWidget::isFloating() const
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
bool CDockWidget::isInFloatingContainer() const
|
bool CDockWidget::isInFloatingContainer() const
|
||||||
{
|
{
|
||||||
if (!dockContainer())
|
auto Container = dockContainer();
|
||||||
|
if (!Container)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dockContainer()->isFloating())
|
if (!Container->isFloating())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -405,6 +406,13 @@ void CDockWidget::setToggleViewActionMode(eToggleViewActionMode Mode)
|
|||||||
void CDockWidget::toggleView(bool Open)
|
void CDockWidget::toggleView(bool Open)
|
||||||
{
|
{
|
||||||
QAction* Sender = qobject_cast<QAction*>(sender());
|
QAction* Sender = qobject_cast<QAction*>(sender());
|
||||||
|
CDockContainerWidget* DockContainer = dockContainer();
|
||||||
|
CDockWidget* SingleDockWidget = nullptr;;
|
||||||
|
if (Open)
|
||||||
|
{
|
||||||
|
SingleDockWidget = DockContainer->singleVisibleDockWidget();
|
||||||
|
}
|
||||||
|
|
||||||
if (Sender == d->ToggleViewAction && !d->ToggleViewAction->isCheckable())
|
if (Sender == d->ToggleViewAction && !d->ToggleViewAction->isCheckable())
|
||||||
{
|
{
|
||||||
Open = true;
|
Open = true;
|
||||||
@ -424,6 +432,16 @@ void CDockWidget::toggleView(bool Open)
|
|||||||
d->ToggleViewAction->blockSignals(false);
|
d->ToggleViewAction->blockSignals(false);
|
||||||
d->DockArea->toggleDockWidgetView(this, Open);
|
d->DockArea->toggleDockWidgetView(this, Open);
|
||||||
|
|
||||||
|
if (!Open)
|
||||||
|
{
|
||||||
|
SingleDockWidget = DockContainer->singleVisibleDockWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SingleDockWidget)
|
||||||
|
{
|
||||||
|
SingleDockWidget->dockAreaWidget()->updateDockArea();
|
||||||
|
}
|
||||||
|
|
||||||
if (!Open)
|
if (!Open)
|
||||||
{
|
{
|
||||||
emit closed();
|
emit closed();
|
||||||
|
@ -162,14 +162,15 @@ void DockWidgetTabPrivate::moveTab(QMouseEvent* ev)
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
bool DockWidgetTabPrivate::startFloating()
|
bool DockWidgetTabPrivate::startFloating()
|
||||||
{
|
{
|
||||||
qDebug() << "isFloating " << DockWidget->dockContainer()->isFloating();
|
auto dockContainer = DockWidget->dockContainer();
|
||||||
qDebug() << "areaCount " << DockWidget->dockContainer()->dockAreaCount();
|
qDebug() << "isFloating " << dockContainer->isFloating();
|
||||||
|
qDebug() << "areaCount " << dockContainer->dockAreaCount();
|
||||||
qDebug() << "widgetCount " << DockWidget->dockAreaWidget()->dockWidgetsCount();
|
qDebug() << "widgetCount " << DockWidget->dockAreaWidget()->dockWidgetsCount();
|
||||||
// if this is the last dock widget inside of this floating widget,
|
// if this is the last dock widget inside of this floating widget,
|
||||||
// then it does not make any sense, to make it floating because
|
// then it does not make any sense, to make it floating because
|
||||||
// it is already floating
|
// it is already floating
|
||||||
if (DockWidget->dockContainer()->isFloating()
|
if (dockContainer->isFloating()
|
||||||
&& (DockWidget->dockContainer()->visibleDockAreaCount() == 1)
|
&& (dockContainer->visibleDockAreaCount() == 1)
|
||||||
&& (DockWidget->dockAreaWidget()->dockWidgetsCount() == 1))
|
&& (DockWidget->dockAreaWidget()->dockWidgetsCount() == 1))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -399,6 +400,17 @@ void CDockWidgetTab::mouseDoubleClickEvent(QMouseEvent *event)
|
|||||||
Super::mouseDoubleClickEvent(event);
|
Super::mouseDoubleClickEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockWidgetTab::setVisible(bool visible)
|
||||||
|
{
|
||||||
|
if (!visible)
|
||||||
|
{
|
||||||
|
qDebug() << "CDockWidgetTab::setVisible " << visible;
|
||||||
|
}
|
||||||
|
Super::setVisible(visible);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -116,6 +116,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
const QIcon& icon() const;
|
const QIcon& icon() const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
virtual void setVisible(bool visible);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void activeTabChanged();
|
void activeTabChanged();
|
||||||
void clicked();
|
void clicked();
|
||||||
|
Loading…
Reference in New Issue
Block a user