Skip to content

Commit 8113bf6

Browse files
Added spacer widget to handle mouse events properly in CDockAreaTitleBar, added missing updateGeometry calls to CDockAreaTabBar
1 parent c4872c6 commit 8113bf6

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

src/DockAreaTabBar.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,15 @@ bool CDockAreaTabBar::eventFilter(QObject *watched, QEvent *event)
445445
switch (event->type())
446446
{
447447
case QEvent::Hide:
448-
emit tabClosed(d->TabsLayout->indexOf(Tab)); break;
448+
emit tabClosed(d->TabsLayout->indexOf(Tab));
449+
updateGeometry();
450+
break;
451+
449452
case QEvent::Show:
450-
emit tabOpened(d->TabsLayout->indexOf(Tab)); break;
453+
emit tabOpened(d->TabsLayout->indexOf(Tab));
454+
updateGeometry();
455+
break;
456+
451457
default:
452458
break;
453459
}

src/DockAreaTitleBar.cpp

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,30 @@ class CTitleBarButton : public tTitleBarButton
185185
};
186186

187187

188+
/**
189+
* This spacer widget is here because of the following problem.
190+
* The dock area title bar handles mouse dragging and moving the floating widget.
191+
* The problem is, that if the title bar becomes invisible, i.e. if the dock
192+
* area contains only one single dock widget and the dock area is moved
193+
* into a floating widget, then mouse events are not handled anymore and dragging
194+
* of the floating widget stops.
195+
*/
196+
class CSpacerWidget : public QWidget
197+
{
198+
Q_OBJECT
199+
public:
200+
using Super = QWidget;
201+
CSpacerWidget(QWidget* Parent = 0)
202+
: Super(Parent)
203+
{
204+
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
205+
setStyleSheet("border: none; background: none;");
206+
}
207+
virtual QSize sizeHint() const override {return QSize(0, 0);}
208+
virtual QSize minimumSizeHint() const override {return QSize(0, 0);}
209+
};
210+
211+
188212
//============================================================================
189213
DockAreaTitleBarPrivate::DockAreaTitleBarPrivate(CDockAreaTitleBar* _public) :
190214
_this(_public)
@@ -322,8 +346,7 @@ CDockAreaTitleBar::CDockAreaTitleBar(CDockAreaWidget* parent) :
322346
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
323347

324348
d->createTabBar();
325-
auto horizontalSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
326-
d->Layout->addSpacerItem(horizontalSpacer);
349+
d->Layout->addWidget(new CSpacerWidget(this));
327350
d->createButtons();
328351
}
329352

0 commit comments

Comments
 (0)