mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-04-16 02:14:45 +08:00
clean handling of QEvent::accept()
This commit is contained in:
parent
fffc84374a
commit
823028c6aa
@ -65,8 +65,8 @@ void SectionTitleWidget::mousePressEvent(QMouseEvent* ev)
|
|||||||
{
|
{
|
||||||
if (ev->button() == Qt::LeftButton)
|
if (ev->button() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
_dragStartPos = ev->pos();
|
|
||||||
ev->accept();
|
ev->accept();
|
||||||
|
_dragStartPos = ev->pos();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QFrame::mousePressEvent(ev);
|
QFrame::mousePressEvent(ev);
|
||||||
@ -182,6 +182,8 @@ void SectionTitleWidget::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
// Move already existing FloatingWidget
|
// Move already existing FloatingWidget
|
||||||
if (_fw && (ev->buttons() & Qt::LeftButton))
|
if (_fw && (ev->buttons() & Qt::LeftButton))
|
||||||
{
|
{
|
||||||
|
ev->accept();
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
@ -217,8 +219,6 @@ void SectionTitleWidget::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
hideDropOverlay();
|
hideDropOverlay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ev->accept();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Begin to drag/float the SectionContent.
|
// Begin to drag/float the SectionContent.
|
||||||
@ -226,6 +226,8 @@ void SectionTitleWidget::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
&& (section = findParentSectionWidget(this)) != NULL
|
&& (section = findParentSectionWidget(this)) != NULL
|
||||||
&& !section->titleAreaGeometry().contains(section->mapFromGlobal(ev->globalPos())))
|
&& !section->titleAreaGeometry().contains(section->mapFromGlobal(ev->globalPos())))
|
||||||
{
|
{
|
||||||
|
ev->accept();
|
||||||
|
|
||||||
// Create floating widget.
|
// Create floating widget.
|
||||||
InternalContentData data;
|
InternalContentData data;
|
||||||
if (!section->takeContent(_content->uid(), data))
|
if (!section->takeContent(_content->uid(), data))
|
||||||
@ -237,7 +239,6 @@ void SectionTitleWidget::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
_fw = new FloatingWidget(cw, data.content, data.titleWidget, data.contentWidget, cw);
|
_fw = new FloatingWidget(cw, data.content, data.titleWidget, data.contentWidget, cw);
|
||||||
_fw->resize(section->size());
|
_fw->resize(section->size());
|
||||||
cw->_floatings.append(_fw); // Note: I don't like this...
|
cw->_floatings.append(_fw); // Note: I don't like this...
|
||||||
//setActiveTab(false);
|
|
||||||
|
|
||||||
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);
|
||||||
@ -249,23 +250,22 @@ void SectionTitleWidget::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
delete section;
|
delete section;
|
||||||
section = NULL;
|
section = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete old splitter, if it is empty now
|
|
||||||
deleteEmptySplitter(cw);
|
deleteEmptySplitter(cw);
|
||||||
|
|
||||||
ev->accept();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Handle movement of this tab
|
// Handle movement of this tab
|
||||||
else if (_tabMoving
|
else if (_tabMoving
|
||||||
&& (section = findParentSectionWidget(this)) != NULL)
|
&& (section = findParentSectionWidget(this)) != NULL)
|
||||||
{
|
{
|
||||||
|
ev->accept();
|
||||||
|
|
||||||
int left, top, right, bottom;
|
int left, top, right, bottom;
|
||||||
getContentsMargins(&left, &top, &right, &bottom);
|
getContentsMargins(&left, &top, &right, &bottom);
|
||||||
QPoint moveToPos = mapToParent(ev->pos()) - _dragStartPos;
|
QPoint moveToPos = mapToParent(ev->pos()) - _dragStartPos;
|
||||||
moveToPos.setY(0/* + top*/);
|
moveToPos.setY(0/* + top*/);
|
||||||
move(moveToPos);
|
move(moveToPos);
|
||||||
ev->accept();
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
// Begin to drag title inside the title area to switch its position inside the SectionWidget.
|
// Begin to drag title inside the title area to switch its position inside the SectionWidget.
|
||||||
else if (!_dragStartPos.isNull() && (ev->buttons() & Qt::LeftButton)
|
else if (!_dragStartPos.isNull() && (ev->buttons() & Qt::LeftButton)
|
||||||
@ -273,10 +273,12 @@ void SectionTitleWidget::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
&& (section = findParentSectionWidget(this)) != NULL
|
&& (section = findParentSectionWidget(this)) != NULL
|
||||||
&& section->titleAreaGeometry().contains(section->mapFromGlobal(ev->globalPos())))
|
&& section->titleAreaGeometry().contains(section->mapFromGlobal(ev->globalPos())))
|
||||||
{
|
{
|
||||||
// Raise current title-widget above other tabs
|
|
||||||
_tabMoving = true;
|
|
||||||
raise();
|
|
||||||
ev->accept();
|
ev->accept();
|
||||||
|
|
||||||
|
_tabMoving = true;
|
||||||
|
raise(); // Raise current title-widget above other tabs
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
QFrame::mouseMoveEvent(ev);
|
QFrame::mouseMoveEvent(ev);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user