mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
NewLayout: append widget at the end of layout if it was droped to the layout's open area
tower: https://hk.tower.im/projects/e3fe3ffacd89401fbd2cf9805d0d2dcf/todos/348a1597bbb0487ea062da3238a57640/ Change-Id: I309bccdef50a2729049326faa63aa2e2560f12f0
This commit is contained in:
parent
e9f3d7a32d
commit
a2900404e8
Notes:
Deepin Code Review
2016-06-14 07:19:47 +00:00
Verified+1: Anonymous Coward #1000004 Code-Review+2: <yangwanqing@linuxdeepin.com> Submitted-by: <yangwanqing@linuxdeepin.com> Submitted-at: Fri, 22 Jan 2016 10:45:14 +0800 Reviewed-on: https://cr.deepin.io/10545 Project: dde/dde-dock Branch: refs/heads/master
@ -341,6 +341,37 @@ void MovableLayout::dragMoveEvent(QDragMoveEvent *event)
|
||||
void MovableLayout::dropEvent(QDropEvent *event)
|
||||
{
|
||||
if (m_draginItem && event->source() == this) {
|
||||
//判断拖动对象是否在layout的空旷区域中drop,如果是,则把拖拽中的widget插入末尾(layout的前部总是会被填满)
|
||||
QWidget *lw = m_widgetList.last();
|
||||
switch (direction()) {
|
||||
case QBoxLayout::TopToBottom:
|
||||
if (event->pos().y() > (lw->pos().y() + lw->height())) {
|
||||
m_lastHoverIndex = m_widgetList.length() - 1;
|
||||
m_vMoveDirection = MoveBottomToTop;
|
||||
}
|
||||
break;
|
||||
case QBoxLayout::LeftToRight:
|
||||
if (event->pos().x() > (lw->pos().x() + lw->width())) {
|
||||
m_lastHoverIndex = m_widgetList.length() - 1;
|
||||
m_hMoveDirection = MoveRightToLeft;
|
||||
}
|
||||
break;
|
||||
case QBoxLayout::BottomToTop:
|
||||
if (event->pos().y() < (lw->pos().y() - lw->height())) {
|
||||
m_lastHoverIndex = m_widgetList.length() - 1;
|
||||
m_vMoveDirection = MoveTopToBottom;
|
||||
}
|
||||
break;
|
||||
case QBoxLayout::RightToLeft:
|
||||
if (event->pos().x() < (lw->pos().x() - lw->width())) {
|
||||
m_lastHoverIndex = m_widgetList.length() - 1;
|
||||
m_hMoveDirection = MoveLeftToRight;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
restoreDragingWidget();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user