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

This commit is contained in:
Uwe Kindler 2018-08-24 14:04:21 +02:00
parent 6b93ae9c39
commit 3f40c997e5
3 changed files with 23 additions and 27 deletions

View File

@ -18,9 +18,9 @@ class CDockAreaWidget;
struct DockAreaTabBarPrivate;
/**
* Custom scroll bar implementation for dock area tab bar
* This scroll area enables floating of a whole dock area including all
* dock widgets
* Custom tabbar implementation for tab area that is shown on top of a
* dock area widget.
* The tabbar displays the tab widgets of the contained dock widgets.
*/
class CDockAreaTabBar : public QScrollArea
{

View File

@ -45,7 +45,7 @@ class CDockWidget;
/**
* DockAreaWidget manages multiple instances of DckWidgets.
* DockAreaWidget manages multiple instances of DockWidgets.
* It displays a title tab, which is clickable and will switch to
* the contents associated to the title when clicked.
*/

View File

@ -240,7 +240,6 @@ void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev)
// End of tab moving, change order now
if (d->isDraggingState(DraggingTab) && d->DockArea)
{
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
// Find tab under mouse
QPoint pos = d->DockArea->mapFromGlobal(ev->globalPos());
int fromIndex = d->DockArea->tabIndex(d->DockWidget);
@ -253,8 +252,6 @@ void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev)
d->DockArea->reorderDockWidget(fromIndex, toIndex);
}
}
if (!d->DragStartMousePosition.isNull())
{
emit clicked();
@ -276,11 +273,10 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
return;
}
// move floating winwdow
if (d->isDraggingState(DraggingFloatingWidget))
{
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
d->FloatingWidget->moveFloating();
}
QFrame::mouseMoveEvent(ev);
return;
}
@ -288,15 +284,17 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
// move tab
if (d->isDraggingState(DraggingTab))
{
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
// Moving the tab is always allowed because it does not mean moving the
// dock widget around
d->moveTab(ev);
}
}
bool MouseInsideTitleArea = d->titleAreaGeometryContains(ev->globalPos());
if (!MouseInsideTitleArea)
{
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
// Floating is only allowed for widgets that are movable
if (d->DockWidget->features().testFlag(CDockWidget::DockWidgetMovable))
{
d->startFloating();
}
return;
@ -304,9 +302,7 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
else if (d->DockArea->count() > 1
&& (ev->pos() - d->DragStartMousePosition).manhattanLength() >= QApplication::startDragDistance()) // Wait a few pixels before start moving
{
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
d->DragState = DraggingTab;
}
return;
}