Skip to content

Commit dd06d84

Browse files
authored
Add option to always show all tabs (#102)
* Add option to always show tabs. * Disable "Detach" context menu option in tab if there is only one tab in the floating container.
1 parent d4c179c commit dd06d84

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

src/DockAreaWidget.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,11 @@ void CDockAreaWidget::updateTitleBarVisibility()
702702
return;
703703
}
704704

705+
if (CDockManager::configFlags().testFlag(CDockManager::AlwaysShowTabs))
706+
{
707+
return;
708+
}
709+
705710
if (d->TitleBar)
706711
{
707712
d->TitleBar->setVisible(!Container->isFloating() || !Container->hasTopLevelDockWidget());

src/DockContainerWidget.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,6 @@ class ADS_EXPORT CDockContainerWidget : public QFrame
130130
*/
131131
CDockAreaWidget* lastAddedDockAreaWidget(DockWidgetArea area) const;
132132

133-
/**
134-
* This function returns true if this dock area has only one single
135-
* visible dock widget.
136-
* A top level widget is a real floating widget. Only the isFloating()
137-
* function of top level widgets may returns true.
138-
*/
139-
bool hasTopLevelDockWidget() const;
140-
141133
/**
142134
* If hasSingleVisibleDockWidget() returns true, this function returns the
143135
* one and only visible dock widget. Otherwise it returns a nullptr.
@@ -214,6 +206,14 @@ class ADS_EXPORT CDockContainerWidget : public QFrame
214206
*/
215207
QList<CDockAreaWidget*> openedDockAreas() const;
216208

209+
/**
210+
* This function returns true if this dock area has only one single
211+
* visible dock widget.
212+
* A top level widget is a real floating widget. Only the isFloating()
213+
* function of top level widgets may returns true.
214+
*/
215+
bool hasTopLevelDockWidget() const;
216+
217217
/**
218218
* Returns the number of dock areas in this container
219219
*/

src/DockManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ class ADS_EXPORT CDockManager : public CDockContainerWidget
156156
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
157157
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
158158
DragPreviewHasWindowFrame = 0x1000,///< If opaque undocking is disabled, then this flag configures if the drag preview is frameless or looks like a real window
159+
AlwaysShowTabs = 0x2000,
159160
DefaultConfig = ActiveTabHasCloseButton
160161
| DockAreaHasCloseButton
161162
| OpaqueSplitterResize

src/DockWidgetTab.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,14 @@ void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev)
426426

427427
d->GlobalDragStartMousePosition = ev->globalPos();
428428
QMenu Menu(this);
429+
430+
const bool isFloatable = d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable);
431+
const bool isNotOnlyTabInContainer = !d->DockArea->dockContainer()->hasTopLevelDockWidget();
432+
433+
const bool isDetachable = isFloatable && isNotOnlyTabInContainer;
434+
429435
auto Action = Menu.addAction(tr("Detach"), this, SLOT(detachDockWidget()));
430-
Action->setEnabled(d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable));
436+
Action->setEnabled(isDetachable);
431437
Menu.addSeparator();
432438
Action = Menu.addAction(tr("Close"), this, SIGNAL(closeRequested()));
433439
Action->setEnabled(isClosable());

0 commit comments

Comments
 (0)