Skip to content

Commit 3f40c99

Browse files
author
Uwe Kindler
committed
Improved and fixed handling of CDockWidget::DockWidgetMovable - moving the tab in the tabbar is always allowed, only moving the complete dock widget can be blocked by clearing this flag
1 parent 6b93ae9 commit 3f40c99

File tree

3 files changed

+23
-27
lines changed

3 files changed

+23
-27
lines changed

src/DockAreaTabBar.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class CDockAreaWidget;
1818
struct DockAreaTabBarPrivate;
1919

2020
/**
21-
* Custom scroll bar implementation for dock area tab bar
22-
* This scroll area enables floating of a whole dock area including all
23-
* dock widgets
21+
* Custom tabbar implementation for tab area that is shown on top of a
22+
* dock area widget.
23+
* The tabbar displays the tab widgets of the contained dock widgets.
2424
*/
2525
class CDockAreaTabBar : public QScrollArea
2626
{

src/DockAreaWidget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class CDockWidget;
4545

4646

4747
/**
48-
* DockAreaWidget manages multiple instances of DckWidgets.
48+
* DockAreaWidget manages multiple instances of DockWidgets.
4949
* It displays a title tab, which is clickable and will switch to
5050
* the contents associated to the title when clicked.
5151
*/

src/DockWidgetTab.cpp

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -240,19 +240,16 @@ void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev)
240240
// End of tab moving, change order now
241241
if (d->isDraggingState(DraggingTab) && d->DockArea)
242242
{
243-
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
244-
// Find tab under mouse
245-
QPoint pos = d->DockArea->mapFromGlobal(ev->globalPos());
246-
int fromIndex = d->DockArea->tabIndex(d->DockWidget);
247-
int toIndex = d->DockArea->indexOfContentByTitlePos(pos, this);
248-
if (-1 == toIndex)
249-
{
250-
toIndex = d->DockArea->count() - 1;
251-
}
252-
qDebug() << "Move tab from " << fromIndex << " to " << toIndex;
253-
d->DockArea->reorderDockWidget(fromIndex, toIndex);
254-
}
255-
243+
// Find tab under mouse
244+
QPoint pos = d->DockArea->mapFromGlobal(ev->globalPos());
245+
int fromIndex = d->DockArea->tabIndex(d->DockWidget);
246+
int toIndex = d->DockArea->indexOfContentByTitlePos(pos, this);
247+
if (-1 == toIndex)
248+
{
249+
toIndex = d->DockArea->count() - 1;
250+
}
251+
qDebug() << "Move tab from " << fromIndex << " to " << toIndex;
252+
d->DockArea->reorderDockWidget(fromIndex, toIndex);
256253
}
257254

258255
if (!d->DragStartMousePosition.isNull())
@@ -276,37 +273,36 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
276273
return;
277274
}
278275

276+
// move floating winwdow
279277
if (d->isDraggingState(DraggingFloatingWidget))
280278
{
281-
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
282-
d->FloatingWidget->moveFloating();
283-
}
279+
d->FloatingWidget->moveFloating();
284280
QFrame::mouseMoveEvent(ev);
285281
return;
286282
}
287283

288284
// move tab
289285
if (d->isDraggingState(DraggingTab))
290286
{
291-
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
292-
d->moveTab(ev);
293-
}
287+
// Moving the tab is always allowed because it does not mean moving the
288+
// dock widget around
289+
d->moveTab(ev);
294290
}
295291

296292
bool MouseInsideTitleArea = d->titleAreaGeometryContains(ev->globalPos());
297293
if (!MouseInsideTitleArea)
298294
{
299-
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
295+
// Floating is only allowed for widgets that are movable
296+
if (d->DockWidget->features().testFlag(CDockWidget::DockWidgetMovable))
297+
{
300298
d->startFloating();
301299
}
302300
return;
303301
}
304302
else if (d->DockArea->count() > 1
305303
&& (ev->pos() - d->DragStartMousePosition).manhattanLength() >= QApplication::startDragDistance()) // Wait a few pixels before start moving
306304
{
307-
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
308-
d->DragState = DraggingTab;
309-
}
305+
d->DragState = DraggingTab;
310306
return;
311307
}
312308

0 commit comments

Comments
 (0)