diff --git a/src/DockAreaTitleBar.cpp b/src/DockAreaTitleBar.cpp index 8b67a5d..9c994a7 100644 --- a/src/DockAreaTitleBar.cpp +++ b/src/DockAreaTitleBar.cpp @@ -49,10 +49,10 @@ #include "DockWidget.h" #include "DockWidgetTab.h" #include "DockAreaTabBar.h" -#include "IconProvider.h" #include "DockComponentsFactory.h" #include "DockFocusController.h" #include "OverlayDockContainer.h" +#include "ElidingLabel.h" #include @@ -72,6 +72,7 @@ struct DockAreaTitleBarPrivate QBoxLayout* Layout; CDockAreaWidget* DockArea; CDockAreaTabBar* TabBar; + CElidingLabel* OverlayTitleLabel; bool MenuOutdated = true; QMenu* TabsMenu; QList DockWidgetActionsButtons; @@ -91,7 +92,13 @@ struct DockAreaTitleBarPrivate */ void createButtons(); + /** + * Creates the overlay title label, only displayed when the dock area is overlayed + */ + void createOverlayTitleLabel(); + + /** * Creates the internal TabBar */ void createTabBar(); @@ -207,6 +214,15 @@ void DockAreaTitleBarPrivate::createButtons() } +//============================================================================ +void DockAreaTitleBarPrivate::createOverlayTitleLabel() +{ + OverlayTitleLabel = new CElidingLabel(""); + OverlayTitleLabel->setObjectName("overlayTitleLabel"); + Layout->addWidget(OverlayTitleLabel); +} + + //============================================================================ void DockAreaTitleBarPrivate::createTabBar() { @@ -287,6 +303,8 @@ CDockAreaTitleBar::CDockAreaTitleBar(CDockAreaWidget* parent) : setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); d->createTabBar(); + d->createOverlayTitleLabel(); + d->OverlayTitleLabel->setVisible(false); // Default hidden d->Layout->addWidget(new CSpacerWidget(this)); d->createButtons(); @@ -480,6 +498,13 @@ QAbstractButton* CDockAreaTitleBar::button(TitleBarButton which) const } +//============================================================================ +CElidingLabel* CDockAreaTitleBar::overlayTitleLabel() const +{ + return d->OverlayTitleLabel; +} + + //============================================================================ void CDockAreaTitleBar::setVisible(bool Visible) { diff --git a/src/DockAreaTitleBar.h b/src/DockAreaTitleBar.h index 70010a4..b3af047 100644 --- a/src/DockAreaTitleBar.h +++ b/src/DockAreaTitleBar.h @@ -41,6 +41,7 @@ namespace ads class CDockAreaTabBar; class CDockAreaWidget; struct DockAreaTitleBarPrivate; +class CElidingLabel; /** * Title bar of a dock area. @@ -120,6 +121,11 @@ public: */ QAbstractButton* button(TitleBarButton which) const; + /** + * Returns the overlay title label, used when the dock area is overlayed + */ + CElidingLabel* overlayTitleLabel() const; + /** * Updates the visibility of the dock widget actions in the title bar */ diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index 502c8b3..be27e6d 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -32,18 +32,15 @@ #include #include -#include #include #include #include #include #include -#include #include -#include #include - +#include "ElidingLabel.h" #include "DockContainerWidget.h" #include "DockWidget.h" #include "FloatingDockContainer.h" @@ -54,7 +51,6 @@ #include "DockAreaTitleBar.h" #include "DockComponentsFactory.h" #include "DockWidgetTab.h" -#include "SideTabBar.h" #include "DockWidgetSideTab.h" #include "OverlayDockContainer.h" @@ -451,6 +447,7 @@ void CDockAreaWidget::insertDockWidget(int index, CDockWidget* DockWidget, d->tabBar()->insertTab(index, TabWidget); d->tabBar()->blockSignals(false); TabWidget->setVisible(!DockWidget->isClosed()); + d->TitleBar->overlayTitleLabel()->setText(DockWidget->windowTitle()); DockWidget->setProperty(INDEX_PROPERTY, index); d->MinSizeHint.setHeight(qMax(d->MinSizeHint.height(), DockWidget->minimumSizeHint().height())); d->MinSizeHint.setWidth(qMax(d->MinSizeHint.width(), DockWidget->minimumSizeHint().width())); @@ -787,7 +784,9 @@ void CDockAreaWidget::updateTitleBarVisibility() || CDockManager::testConfigFlag(CDockManager::HideSingleCentralWidgetTitleBar)); Hidden |= (d->Flags.testFlag(HideSingleWidgetTitleBar) && openDockWidgetsCount() == 1); d->TitleBar->setVisible(isOverlayed() ? true : !Hidden); // Titlebar must always be visible when overlayed so it can be dragged - d->TitleBar->tabBar()->setVisible(isOverlayed() ? false : !Hidden); // Never show tab bar when overlayed + auto tabBar = d->TitleBar->tabBar(); + tabBar->setVisible(isOverlayed() ? false : !Hidden); // Never show tab bar when overlayed + d->TitleBar->overlayTitleLabel()->setVisible(isOverlayed()); // Always show when overlayed, never otherwise } }