Skip to content

Commit 7245dce

Browse files
Added new config flag DoubleClickUndocksWidget to configure if double clicking a DockWidget tab or titlebar undocks the widget
1 parent e2f611e commit 7245dce

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

examples/emptydockarea/mainwindow.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ CMainWindow::CMainWindow(QWidget *parent)
3737
ads::CDockManager::setConfigFlag( ads::CDockManager::DockAreaHasUndockButton, false );
3838
ads::CDockManager::setConfigFlag( ads::CDockManager::DockAreaDynamicTabsMenuButtonVisibility, true );
3939
ads::CDockManager::setConfigFlag( ads::CDockManager::DisableTabTextEliding, true );
40+
ads::CDockManager::setConfigFlag( ads::CDockManager::DoubleClickUndocksWidget, false );
4041
DockManager = new CDockManager(this);
4142

4243
// Set central widget

src/DockAreaTitleBar.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,11 @@ void CDockAreaTitleBar::mouseDoubleClickEvent(QMouseEvent *event)
733733
return;
734734
}
735735

736+
if (!CDockManager::testConfigFlag(CDockManager::DoubleClickUndocksWidget))
737+
{
738+
return;
739+
}
740+
736741
d->makeAreaFloating(event->pos(), DraggingInactive);
737742
}
738743

src/DockManager.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ public Q_SLOTS:
215215
MiddleMouseButtonClosesTab = 0x2000000, //! If the flag is set, the user can use the mouse middle button to close the tab under the mouse
216216
DisableTabTextEliding = 0x4000000, //! Set this flag to disable eliding of tab texts in dock area tabs
217217
ShowTabTextOnlyForActiveTab =0x8000000, //! Set this flag to show label texts in dock area tabs only for active tabs
218+
DoubleClickUndocksWidget = 0x10000000, //!< If the flag is set, a double click on a tab undocks the widget
219+
218220

219221
DefaultDockAreaButtons = DockAreaHasCloseButton
220222
| DockAreaHasUndockButton
@@ -223,7 +225,8 @@ public Q_SLOTS:
223225
DefaultBaseConfig = DefaultDockAreaButtons
224226
| ActiveTabHasCloseButton
225227
| XmlCompressionEnabled
226-
| FloatingContainerHasWidgetTitle, ///< default base configuration settings
228+
| FloatingContainerHasWidgetTitle
229+
| DoubleClickUndocksWidget, ///< default base configuration settings
227230

228231
DefaultOpaqueConfig = DefaultBaseConfig
229232
| OpaqueSplitterResize

src/DockWidgetTab.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ QString CDockWidgetTab::text() const
699699
//============================================================================
700700
void CDockWidgetTab::mouseDoubleClickEvent(QMouseEvent *event)
701701
{
702-
if (event->button() == Qt::LeftButton)
702+
if (event->button() == Qt::LeftButton && CDockManager::testConfigFlag(CDockManager::DoubleClickUndocksWidget))
703703
{
704704
// If this is the last dock area in a dock container it does not make
705705
// sense to move it to a new floating widget and leave this one

0 commit comments

Comments
 (0)