mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-24 23:31:32 +08:00
Fix bug after saving-restoring a empty container with no SectionWidget.
SectionTitleWidget::mousePressEvent call 'grabMouse' to ensure the floaing widget can always follow the mouse after floated. SectionTitleWidget::mouseMoveEvent check Qt::LeftButton.
This commit is contained in:
parent
d2d2467101
commit
f2f5de707c
@ -489,25 +489,28 @@ bool ContainerWidget::restoreState(const QByteArray& data)
|
|||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
in >> cnt;
|
in >> cnt;
|
||||||
|
|
||||||
// Create dummy section, required to call hideSectionContent() later.
|
if(cnt > 0)
|
||||||
SectionWidget* sw = new SectionWidget(this);
|
|
||||||
sections.append(sw);
|
|
||||||
|
|
||||||
for (int i = 0; i < cnt; ++i)
|
|
||||||
{
|
{
|
||||||
QString uname;
|
// Create dummy section, required to call hideSectionContent() later.
|
||||||
in >> uname;
|
SectionWidget* sw = new SectionWidget(this);
|
||||||
|
sections.append(sw);
|
||||||
|
|
||||||
const SectionContent::RefPtr sc = SCLookupMapByName(this).value(uname);
|
for (int i = 0; i < cnt; ++i)
|
||||||
if (!sc)
|
{
|
||||||
continue;
|
QString uname;
|
||||||
|
in >> uname;
|
||||||
|
|
||||||
InternalContentData data;
|
const SectionContent::RefPtr sc = SCLookupMapByName(this).value(uname);
|
||||||
if (!takeContent(sc, data))
|
if (!sc)
|
||||||
qFatal("This should never happen!!!");
|
continue;
|
||||||
|
|
||||||
sw->addContent(data, false);
|
InternalContentData data;
|
||||||
contentsToHide.append(sc);
|
if (!takeContent(sc, data))
|
||||||
|
qFatal("This should never happen!!!");
|
||||||
|
|
||||||
|
sw->addContent(data, false);
|
||||||
|
contentsToHide.append(sc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mode == 1)
|
else if (mode == 1)
|
||||||
|
@ -68,6 +68,7 @@ void SectionTitleWidget::setActiveTab(bool active)
|
|||||||
void SectionTitleWidget::mousePressEvent(QMouseEvent* ev)
|
void SectionTitleWidget::mousePressEvent(QMouseEvent* ev)
|
||||||
{
|
{
|
||||||
// qDebug() << Q_FUNC_INFO << ev->pos();
|
// qDebug() << Q_FUNC_INFO << ev->pos();
|
||||||
|
this->grabMouse();
|
||||||
if (ev->button() == Qt::LeftButton)
|
if (ev->button() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
_dragStartPos = ev->pos();
|
_dragStartPos = ev->pos();
|
||||||
@ -80,6 +81,8 @@ void SectionTitleWidget::mousePressEvent(QMouseEvent* ev)
|
|||||||
void SectionTitleWidget::mouseReleaseEvent(QMouseEvent* ev)
|
void SectionTitleWidget::mouseReleaseEvent(QMouseEvent* ev)
|
||||||
{
|
{
|
||||||
// qDebug() << Q_FUNC_INFO << ev->pos();
|
// qDebug() << Q_FUNC_INFO << ev->pos();
|
||||||
|
if(QWidget::mouseGrabber() == this)
|
||||||
|
this->releaseMouse();
|
||||||
SectionWidget* section = NULL;
|
SectionWidget* section = NULL;
|
||||||
|
|
||||||
// Drop contents of FloatingWidget into SectionWidget.
|
// Drop contents of FloatingWidget into SectionWidget.
|
||||||
@ -189,7 +192,7 @@ void SectionTitleWidget::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
SectionWidget* section = NULL;
|
SectionWidget* section = NULL;
|
||||||
|
|
||||||
// Move already existing FloatingWidget
|
// Move already existing FloatingWidget
|
||||||
if (_fw)
|
if (_fw && (ev->buttons() & Qt::LeftButton))
|
||||||
{
|
{
|
||||||
const QPoint moveToPos = ev->globalPos() - (_dragStartPos + QPoint(ADS_WINDOW_FRAME_BORDER_WIDTH, ADS_WINDOW_FRAME_BORDER_WIDTH));
|
const QPoint moveToPos = ev->globalPos() - (_dragStartPos + QPoint(ADS_WINDOW_FRAME_BORDER_WIDTH, ADS_WINDOW_FRAME_BORDER_WIDTH));
|
||||||
_fw->move(moveToPos);
|
_fw->move(moveToPos);
|
||||||
|
Loading…
Reference in New Issue
Block a user