diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp index 2ebf0522..36094610 100644 --- a/demo/MainWindow.cpp +++ b/demo/MainWindow.cpp @@ -527,6 +527,7 @@ void MainWindowPrivate::createContent() // Tests CustomCloseHandling without DeleteOnClose LabelDockWidget->setFeature(ads::CDockWidget::CustomCloseHandling, true); + LabelDockWidget->setWindowTitle(LabelDockWidget->windowTitle() + " [Custom Close]"); QObject::connect(LabelDockWidget, &ads::CDockWidget::closeRequested, [LabelDockWidget, this]() { int Result = QMessageBox::question(_this, "Custom Close Request", diff --git a/src/DockAreaTitleBar.cpp b/src/DockAreaTitleBar.cpp index 919b130a..e8c39917 100644 --- a/src/DockAreaTitleBar.cpp +++ b/src/DockAreaTitleBar.cpp @@ -431,6 +431,24 @@ void CDockAreaTitleBar::onCloseButtonClicked() } +//============================================================================ +void CDockAreaTitleBar::onAutoHideCloseActionTriggered() +{ + d->DockArea->closeArea(); +} + + +//============================================================================ +void CDockAreaTitleBar::onAutoHideMinimizeActionTriggered() +{ + auto AutoHideContainer = d->DockArea->autoHideDockContainer(); + if (AutoHideContainer) + { + AutoHideContainer->collapseView(true); + } +} + + //============================================================================ void CDockAreaTitleBar::onUndockButtonClicked() { @@ -735,7 +753,17 @@ void CDockAreaTitleBar::contextMenuEvent(QContextMenuEvent* ev) } Menu.addSeparator(); } - Action = Menu.addAction(isAutoHide ? tr("Close") : tr("Close Group"), this, SLOT(onCloseButtonClicked())); + + if (isAutoHide) + { + Action = Menu.addAction(tr("Minimize"), this, SLOT(onAutoHideMinimizeActionTriggered())); + Action = Menu.addAction(tr("Close"), this, SLOT(onAutoHideCloseActionTriggered())); + } + else + { + Action = Menu.addAction(isAutoHide ? tr("Close") : tr("Close Group"), this, SLOT(onCloseButtonClicked())); + } + Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable)); if (!isAutoHide && !isTopLevelArea) { @@ -782,7 +810,8 @@ QString CDockAreaTitleBar::titleBarButtonToolTip(TitleBarButton Button) const case TitleBarButtonClose: if (d->DockArea->isAutoHide()) { - return tr("Close"); + bool Minimize = CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideCloseButtonCollapsesDock); + return Minimize ? tr("Minimize") : tr("Close"); } if (CDockManager::testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab)) diff --git a/src/DockAreaTitleBar.h b/src/DockAreaTitleBar.h index 46ac2317..2de2ed68 100644 --- a/src/DockAreaTitleBar.h +++ b/src/DockAreaTitleBar.h @@ -97,6 +97,8 @@ class ADS_EXPORT CDockAreaTitleBar : public QFrame private Q_SLOTS: void onTabsMenuAboutToShow(); void onCloseButtonClicked(); + void onAutoHideCloseActionTriggered(); + void onAutoHideMinimizeActionTriggered(); void onUndockButtonClicked(); void onTabsMenuActionTriggered(QAction* Action); void onCurrentTabChanged(int Index);