diff --git a/src/DockAreaTitleBar.cpp b/src/DockAreaTitleBar.cpp index e86b12e..16c690d 100644 --- a/src/DockAreaTitleBar.cpp +++ b/src/DockAreaTitleBar.cpp @@ -188,7 +188,7 @@ void DockAreaTitleBarPrivate::createButtons() AutoHideButton->setAutoRaise(true); AutoHideButton->setCheckable(true); AutoHideButton->setChecked(false); - internal::setToolTip(AutoHideButton, QObject::tr("Toggle Auto Hide Group")); + internal::setToolTip(AutoHideButton, QObject::tr("Toggle Auto Hide")); internal::setButtonIcon(AutoHideButton, QStyle::SP_DialogOkButton, ads::AutoHideIcon); AutoHideButton->setSizePolicy(ButtonSizePolicy); Layout->addWidget(AutoHideButton, 0); @@ -199,14 +199,7 @@ void DockAreaTitleBarPrivate::createButtons() CloseButton->setObjectName("dockAreaCloseButton"); CloseButton->setAutoRaise(true); internal::setButtonIcon(CloseButton, QStyle::SP_TitleBarCloseButton, ads::DockAreaCloseIcon); - if (testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab)) - { - internal::setToolTip(CloseButton, QObject::tr("Close Active Tab")); - } - else - { - internal::setToolTip(CloseButton, QObject::tr("Close Group")); - } + internal::setToolTip(CloseButton, _this->closeGroupToolTip()); CloseButton->setSizePolicy(ButtonSizePolicy); CloseButton->setIconSize(QSize(16, 16)); Layout->addWidget(CloseButton, 0); @@ -664,6 +657,22 @@ int CDockAreaTitleBar::indexOf(QWidget *widget) const return d->Layout->indexOf(widget); } +//============================================================================ +QString CDockAreaTitleBar::closeGroupToolTip() const +{ + if (d->DockArea->isOverlayed()) + { + return QObject::tr("Close Overlay"); + + } + if (CDockManager::testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab)) + { + return QObject::tr("Close Active Tab"); + } + + return QObject::tr("Close Group") ; +} + //============================================================================ CTitleBarButton::CTitleBarButton(bool visible, QWidget* parent) : tTitleBarButton(parent), diff --git a/src/DockAreaTitleBar.h b/src/DockAreaTitleBar.h index b3af047..63d6749 100644 --- a/src/DockAreaTitleBar.h +++ b/src/DockAreaTitleBar.h @@ -155,6 +155,12 @@ public: */ int indexOf(QWidget *widget) const; + /** + * Close group tool tip based on the current state + * Overlayed widgets can only have one dock widget so it does not make sense for the tooltip to show close group + */ + QString closeGroupToolTip() const; + Q_SIGNALS: /** * This signal is emitted if a tab in the tab bar is clicked by the user diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index e471eb0..598ac78 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -832,7 +832,7 @@ void CDockAreaWidget::markTitleBarMenuOutdated() //============================================================================ -void CDockAreaWidget::updateAutoHidebuttonCheckState() +void CDockAreaWidget::updateAutoHideButtonCheckState() { auto autoHideButton = titleBarButton(TitleBarButtonAutoHide); autoHideButton->blockSignals(true); @@ -840,12 +840,21 @@ void CDockAreaWidget::updateAutoHidebuttonCheckState() autoHideButton->blockSignals(false); } + +//============================================================================ void CDockAreaWidget::updateTitleBarButtonVisibility(bool IsTopLevel) const { d->updateTitleBarButtonVisibility(IsTopLevel); } +//============================================================================ +void CDockAreaWidget::updateTitleBarButtonToolTip() +{ + internal::setToolTip(titleBarButton(TitleBarButtonClose), titleBar()->closeGroupToolTip()); +} + + //============================================================================ void CDockAreaWidget::saveState(QXmlStreamWriter& s) const { diff --git a/src/DockAreaWidget.h b/src/DockAreaWidget.h index 503df45..f94fc34 100644 --- a/src/DockAreaWidget.h +++ b/src/DockAreaWidget.h @@ -154,13 +154,18 @@ protected: /* * Update the auto hide button checked state based on if it's overlayed or not */ - void updateAutoHidebuttonCheckState(); + void updateAutoHideButtonCheckState(); /* * Update the title bar button visibility based on if it's top level or not */ void updateTitleBarButtonVisibility(bool IsTopLevel) const; + /* + * Update the title bar button tooltips + */ + void updateTitleBarButtonToolTip(); + protected Q_SLOTS: void toggleView(bool Open); diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index fb72c92..312d726 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -1058,7 +1058,8 @@ bool DockContainerWidgetPrivate::restoreOverlayDockArea(CDockingStateReader& s, dockContainer->hide(); DockArea = dockContainer->dockAreaWidget(); - DockArea->updateAutoHidebuttonCheckState(); + DockArea->updateAutoHideButtonCheckState(); + DockArea->updateTitleBarButtonToolTip(); } while (s.readNextStartElement()) @@ -1653,7 +1654,8 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area) dumpLayout(); d->emitDockAreasRemoved(); area->setOverlayDockContainer(nullptr); - area->updateAutoHidebuttonCheckState(); + area->updateAutoHideButtonCheckState(); + area->updateTitleBarButtonToolTip(); return; } diff --git a/src/OverlayDockContainer.cpp b/src/OverlayDockContainer.cpp index 28be352..d908dcd 100644 --- a/src/OverlayDockContainer.cpp +++ b/src/OverlayDockContainer.cpp @@ -83,7 +83,8 @@ COverlayDockContainer::COverlayDockContainer(CDockManager* DockManager, CDockWid d->DockArea = new CDockAreaWidget(DockManager, parent); d->DockArea->setObjectName("OverlayDockArea"); d->DockArea->setOverlayDockContainer(this); - d->DockArea->updateAutoHidebuttonCheckState(); + d->DockArea->updateAutoHideButtonCheckState(); + d->DockArea->updateTitleBarButtonToolTip(); QBoxLayout* l = new QBoxLayout(QBoxLayout::LeftToRight); d->Splitter = new QSplitter(Qt::Orientation::Horizontal);