diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index 3192971..b26b0bd 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -702,6 +702,11 @@ void CDockAreaWidget::updateTitleBarVisibility() return; } + if (CDockManager::configFlags().testFlag(CDockManager::AlwaysShowTabs)) + { + return; + } + if (d->TitleBar) { d->TitleBar->setVisible(!Container->isFloating() || !Container->hasTopLevelDockWidget()); diff --git a/src/DockContainerWidget.h b/src/DockContainerWidget.h index 1ac037d..c5c674b 100644 --- a/src/DockContainerWidget.h +++ b/src/DockContainerWidget.h @@ -130,14 +130,6 @@ protected: */ CDockAreaWidget* lastAddedDockAreaWidget(DockWidgetArea area) const; - /** - * This function returns true if this dock area has only one single - * visible dock widget. - * A top level widget is a real floating widget. Only the isFloating() - * function of top level widgets may returns true. - */ - bool hasTopLevelDockWidget() const; - /** * If hasSingleVisibleDockWidget() returns true, this function returns the * one and only visible dock widget. Otherwise it returns a nullptr. @@ -214,6 +206,14 @@ public: */ QList openedDockAreas() const; + /** + * This function returns true if this dock area has only one single + * visible dock widget. + * A top level widget is a real floating widget. Only the isFloating() + * function of top level widgets may returns true. + */ + bool hasTopLevelDockWidget() const; + /** * Returns the number of dock areas in this container */ diff --git a/src/DockManager.h b/src/DockManager.h index b948cef..1b455ae 100644 --- a/src/DockManager.h +++ b/src/DockManager.h @@ -156,6 +156,7 @@ public: DragPreviewIsDynamic = 0x0400,///< If opaque undocking is disabled, this flag defines the behavior of the drag preview window, if this flag is enabled, the preview will be adjusted dynamically to the drop area DragPreviewShowsContentPixmap = 0x0800,///< If opaque undocking is disabled, the created drag preview window shows a copy of the content of the dock widget / dock are that is dragged DragPreviewHasWindowFrame = 0x1000,///< If opaque undocking is disabled, then this flag configures if the drag preview is frameless or looks like a real window + AlwaysShowTabs = 0x2000, DefaultConfig = ActiveTabHasCloseButton | DockAreaHasCloseButton | OpaqueSplitterResize diff --git a/src/DockWidgetTab.cpp b/src/DockWidgetTab.cpp index ace86b8..ca5450b 100644 --- a/src/DockWidgetTab.cpp +++ b/src/DockWidgetTab.cpp @@ -426,8 +426,14 @@ void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev) d->GlobalDragStartMousePosition = ev->globalPos(); QMenu Menu(this); + + const bool isFloatable = d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable); + const bool isNotOnlyTabInContainer = !d->DockArea->dockContainer()->hasTopLevelDockWidget(); + + const bool isDetachable = isFloatable && isNotOnlyTabInContainer; + auto Action = Menu.addAction(tr("Detach"), this, SLOT(detachDockWidget())); - Action->setEnabled(d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable)); + Action->setEnabled(isDetachable); Menu.addSeparator(); Action = Menu.addAction(tr("Close"), this, SIGNAL(closeRequested())); Action->setEnabled(isClosable());