mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
reduce sensitivity of drag-event
Change-Id: Ic2d7c44adcb6b0c3fef27141c7b26d045a4a7c20
This commit is contained in:
parent
a009b4ef63
commit
a41c48040d
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: Thu, 15 Oct 2015 14:00:03 +0800 Reviewed-on: https://cr.deepin.io/7782 Project: dde/dde-dock Branch: refs/heads/master
@ -110,6 +110,8 @@ void AppItem::mousePressEvent(QMouseEvent *event)
|
||||
onMousePress(event);
|
||||
else
|
||||
QFrame::mousePressEvent(event);
|
||||
|
||||
m_lastPressPos = event->pos();
|
||||
}
|
||||
|
||||
void AppItem::mouseReleaseEvent(QMouseEvent *event)
|
||||
@ -122,30 +124,34 @@ void AppItem::mouseReleaseEvent(QMouseEvent *event)
|
||||
|
||||
void AppItem::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
//this event will only execp onec then handle by Drag
|
||||
emit dragStart();
|
||||
QRect moveRect(QPoint(m_lastPressPos.x() - INVALID_MOVE_RADIUS, m_lastPressPos.y() - INVALID_MOVE_RADIUS),
|
||||
QPoint(m_lastPressPos.x() + INVALID_MOVE_RADIUS, m_lastPressPos.y() + INVALID_MOVE_RADIUS));
|
||||
if (!moveRect.contains(event->pos())) {
|
||||
//this event will only execp onec then handle by Drag
|
||||
emit dragStart();
|
||||
|
||||
Qt::MouseButtons btn = event->buttons();
|
||||
if(btn == Qt::LeftButton)
|
||||
{
|
||||
//drag and mimeData object will delete automatically
|
||||
QDrag* drag = new QDrag(this);
|
||||
QMimeData* mimeData = new QMimeData();
|
||||
QImage dataImg = m_appIcon->grab().toImage();
|
||||
mimeData->setImageData(QVariant(dataImg));
|
||||
drag->setMimeData(mimeData);
|
||||
drag->setHotSpot(QPoint(15,15));
|
||||
Qt::MouseButtons btn = event->buttons();
|
||||
if(btn == Qt::LeftButton)
|
||||
{
|
||||
//drag and mimeData object will delete automatically
|
||||
QDrag* drag = new QDrag(this);
|
||||
QMimeData* mimeData = new QMimeData();
|
||||
QImage dataImg = m_appIcon->grab().toImage();
|
||||
mimeData->setImageData(QVariant(dataImg));
|
||||
drag->setMimeData(mimeData);
|
||||
drag->setHotSpot(QPoint(15,15));
|
||||
|
||||
if (m_dockModeData->getDockMode() == Dock::FashionMode){
|
||||
QPixmap pixmap = m_appIcon->grab();
|
||||
drag->setPixmap(pixmap.scaled(m_dockModeData->getAppIconSize(), m_dockModeData->getAppIconSize()));
|
||||
if (m_dockModeData->getDockMode() == Dock::FashionMode){
|
||||
QPixmap pixmap = m_appIcon->grab();
|
||||
drag->setPixmap(pixmap.scaled(m_dockModeData->getAppIconSize(), m_dockModeData->getAppIconSize()));
|
||||
}
|
||||
else{
|
||||
QPixmap pixmap = this->grab();
|
||||
drag->setPixmap(pixmap.scaled(this->size()));
|
||||
}
|
||||
|
||||
drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::MoveAction);
|
||||
}
|
||||
else{
|
||||
QPixmap pixmap = this->grab();
|
||||
drag->setPixmap(pixmap.scaled(this->size()));
|
||||
}
|
||||
|
||||
drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::MoveAction);
|
||||
}
|
||||
}
|
||||
|
||||
@ -295,6 +301,8 @@ void AppItem::onMousePress(QMouseEvent *event)
|
||||
emit mousePress(event);
|
||||
|
||||
hidePreview(true);
|
||||
|
||||
m_lastPressPos = event->pos();
|
||||
}
|
||||
|
||||
void AppItem::onMouseRelease(QMouseEvent *event)
|
||||
|
@ -100,7 +100,9 @@ private:
|
||||
AppPreviews *m_preview = NULL;
|
||||
AppIcon * m_appIcon = NULL;
|
||||
QLabel * m_appTitle = NULL;
|
||||
QPoint m_lastPressPos;
|
||||
|
||||
const int INVALID_MOVE_RADIUS = 10;
|
||||
const QEasingCurve MOVE_ANIMATION_CURVE = QEasingCurve::OutCubic;
|
||||
};
|
||||
|
||||
|
@ -21,7 +21,7 @@ void DockLayout::addItem(AbstractDockItem *item)
|
||||
insertItem(item, m_lastHoverIndex);
|
||||
}
|
||||
|
||||
void DockLayout::insertItem(AbstractDockItem *item, int index)
|
||||
void DockLayout::insertItem(AbstractDockItem *item, int index, bool delayShow)
|
||||
{
|
||||
QPointer<AbstractDockItem> pItem = item;
|
||||
if (pItem.isNull())
|
||||
@ -46,18 +46,20 @@ void DockLayout::insertItem(AbstractDockItem *item, int index)
|
||||
|
||||
m_ddam->Sort(itemsIdList());
|
||||
|
||||
//hide for delay show
|
||||
pItem->setVisible(false);
|
||||
//Qt5.3.* not support singleshot with lamda expressions
|
||||
QTimer *delayTimer = new QTimer(this);
|
||||
connect(delayTimer, &QTimer::timeout, [=] {
|
||||
delayTimer->stop();
|
||||
delayTimer->deleteLater();
|
||||
if (delayShow) {
|
||||
//hide for delay show
|
||||
pItem->setVisible(false);
|
||||
//Qt5.3.* not support singleshot with lamda expressions
|
||||
QTimer *delayTimer = new QTimer(this);
|
||||
connect(delayTimer, &QTimer::timeout, [=] {
|
||||
delayTimer->stop();
|
||||
delayTimer->deleteLater();
|
||||
|
||||
if (!pItem.isNull())
|
||||
item->setVisible(true);
|
||||
});
|
||||
delayTimer->start(m_addItemDelayInterval);
|
||||
if (!pItem.isNull())
|
||||
item->setVisible(true);
|
||||
});
|
||||
delayTimer->start(m_addItemDelayInterval);
|
||||
}
|
||||
|
||||
relayout();
|
||||
|
||||
@ -178,9 +180,9 @@ void DockLayout::restoreTmpItem()
|
||||
if (indexOf(tmpItem) == -1)
|
||||
{
|
||||
if (m_movingLeftward)
|
||||
insertItem(tmpItem,m_lastHoverIndex);
|
||||
insertItem(tmpItem,m_lastHoverIndex, false);
|
||||
else
|
||||
insertItem(tmpItem,m_lastHoverIndex + 1);
|
||||
insertItem(tmpItem,m_lastHoverIndex + 1, false);
|
||||
}
|
||||
|
||||
emit itemDropped();
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
explicit DockLayout(QWidget *parent = 0);
|
||||
|
||||
void addItem(AbstractDockItem *item);
|
||||
void insertItem(AbstractDockItem *item, int index);
|
||||
void insertItem(AbstractDockItem *item, int index, bool delayShow = true);
|
||||
void moveItem(int from, int to);
|
||||
void removeItem(int index);
|
||||
void removeItem(AbstractDockItem *item);
|
||||
|
Loading…
x
Reference in New Issue
Block a user