mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-04-16 10:24:45 +08:00
Added spacer widget to handle mouse events properly in CDockAreaTitleBar, added missing updateGeometry calls to CDockAreaTabBar
This commit is contained in:
parent
c4872c6b10
commit
8113bf63ba
@ -445,9 +445,15 @@ bool CDockAreaTabBar::eventFilter(QObject *watched, QEvent *event)
|
|||||||
switch (event->type())
|
switch (event->type())
|
||||||
{
|
{
|
||||||
case QEvent::Hide:
|
case QEvent::Hide:
|
||||||
emit tabClosed(d->TabsLayout->indexOf(Tab)); break;
|
emit tabClosed(d->TabsLayout->indexOf(Tab));
|
||||||
|
updateGeometry();
|
||||||
|
break;
|
||||||
|
|
||||||
case QEvent::Show:
|
case QEvent::Show:
|
||||||
emit tabOpened(d->TabsLayout->indexOf(Tab)); break;
|
emit tabOpened(d->TabsLayout->indexOf(Tab));
|
||||||
|
updateGeometry();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -185,6 +185,30 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This spacer widget is here because of the following problem.
|
||||||
|
* The dock area title bar handles mouse dragging and moving the floating widget.
|
||||||
|
* The problem is, that if the title bar becomes invisible, i.e. if the dock
|
||||||
|
* area contains only one single dock widget and the dock area is moved
|
||||||
|
* into a floating widget, then mouse events are not handled anymore and dragging
|
||||||
|
* of the floating widget stops.
|
||||||
|
*/
|
||||||
|
class CSpacerWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
using Super = QWidget;
|
||||||
|
CSpacerWidget(QWidget* Parent = 0)
|
||||||
|
: Super(Parent)
|
||||||
|
{
|
||||||
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
setStyleSheet("border: none; background: none;");
|
||||||
|
}
|
||||||
|
virtual QSize sizeHint() const override {return QSize(0, 0);}
|
||||||
|
virtual QSize minimumSizeHint() const override {return QSize(0, 0);}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
DockAreaTitleBarPrivate::DockAreaTitleBarPrivate(CDockAreaTitleBar* _public) :
|
DockAreaTitleBarPrivate::DockAreaTitleBarPrivate(CDockAreaTitleBar* _public) :
|
||||||
_this(_public)
|
_this(_public)
|
||||||
@ -322,8 +346,7 @@ CDockAreaTitleBar::CDockAreaTitleBar(CDockAreaWidget* parent) :
|
|||||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||||
|
|
||||||
d->createTabBar();
|
d->createTabBar();
|
||||||
auto horizontalSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
d->Layout->addWidget(new CSpacerWidget(this));
|
||||||
d->Layout->addSpacerItem(horizontalSpacer);
|
|
||||||
d->createButtons();
|
d->createButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user