Skip to content

Commit

Permalink
Added new config flag DoubleClickUndocksWidget to configure if double…
Browse files Browse the repository at this point in the history
… clicking a DockWidget tab or titlebar undocks the widget
  • Loading branch information
githubuser0xFFFF committed Dec 12, 2024
1 parent e2f611e commit 7245dce
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/emptydockarea/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ CMainWindow::CMainWindow(QWidget *parent)
ads::CDockManager::setConfigFlag( ads::CDockManager::DockAreaHasUndockButton, false );
ads::CDockManager::setConfigFlag( ads::CDockManager::DockAreaDynamicTabsMenuButtonVisibility, true );
ads::CDockManager::setConfigFlag( ads::CDockManager::DisableTabTextEliding, true );
ads::CDockManager::setConfigFlag( ads::CDockManager::DoubleClickUndocksWidget, false );
DockManager = new CDockManager(this);

// Set central widget
Expand Down
5 changes: 5 additions & 0 deletions src/DockAreaTitleBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,11 @@ void CDockAreaTitleBar::mouseDoubleClickEvent(QMouseEvent *event)
return;
}

if (!CDockManager::testConfigFlag(CDockManager::DoubleClickUndocksWidget))
{
return;
}

d->makeAreaFloating(event->pos(), DraggingInactive);
}

Expand Down
5 changes: 4 additions & 1 deletion src/DockManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ public Q_SLOTS:
MiddleMouseButtonClosesTab = 0x2000000, //! If the flag is set, the user can use the mouse middle button to close the tab under the mouse
DisableTabTextEliding = 0x4000000, //! Set this flag to disable eliding of tab texts in dock area tabs
ShowTabTextOnlyForActiveTab =0x8000000, //! Set this flag to show label texts in dock area tabs only for active tabs
DoubleClickUndocksWidget = 0x10000000, //!< If the flag is set, a double click on a tab undocks the widget


DefaultDockAreaButtons = DockAreaHasCloseButton
| DockAreaHasUndockButton
Expand All @@ -223,7 +225,8 @@ public Q_SLOTS:
DefaultBaseConfig = DefaultDockAreaButtons
| ActiveTabHasCloseButton
| XmlCompressionEnabled
| FloatingContainerHasWidgetTitle, ///< default base configuration settings
| FloatingContainerHasWidgetTitle
| DoubleClickUndocksWidget, ///< default base configuration settings

DefaultOpaqueConfig = DefaultBaseConfig
| OpaqueSplitterResize
Expand Down
2 changes: 1 addition & 1 deletion src/DockWidgetTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ QString CDockWidgetTab::text() const
//============================================================================
void CDockWidgetTab::mouseDoubleClickEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
if (event->button() == Qt::LeftButton && CDockManager::testConfigFlag(CDockManager::DoubleClickUndocksWidget))
{
// If this is the last dock area in a dock container it does not make
// sense to move it to a new floating widget and leave this one
Expand Down

0 comments on commit 7245dce

Please sign in to comment.