fix: threshold to emit drag event

https://tower.im/projects/e4ae1ad0b5d5497fb4b7c14fe2d2efbf/todos/d6bbed3e1c2bd8928a028c74b193d30a/

Change-Id: I190140f30336a595dbd9c0a23fa7a3bcf45c9c92
This commit is contained in:
listenerri 2018-12-11 16:41:11 +08:00
parent bb241369b3
commit 06ca6df205
Notes: gerrit 2018-12-12 14:40:18 +08:00
Verified+1: <jenkins@deepin.com>
Code-Review+2: listenerri <listenerri@gmail.com>
Submitted-by: listenerri <listenerri@gmail.com>
Submitted-at: Wed, 12 Dec 2018 14:40:16 +0800
Reviewed-on: https://cr.deepin.io/40471
Project: dde/dde-dock
Branch: refs/heads/master
3 changed files with 11 additions and 10 deletions

View File

@ -38,8 +38,13 @@ AbstractTrayWidget::~AbstractTrayWidget()
void AbstractTrayWidget::mousePressEvent(QMouseEvent *event)
{
// do not call Parent::mousePressEvent or the DockItem will catch this event
// and show dock-context-menu immediately when right button of mouse is pressed
event->accept();
// and show dock-context-menu immediately when right button of mouse is pressed in fashion mode
if (event->buttons() == Qt::RightButton) {
event->accept();
return;
}
QWidget::mousePressEvent(event);
}
void AbstractTrayWidget::mouseReleaseEvent(QMouseEvent *e)

View File

@ -100,8 +100,6 @@ bool FashionTrayWidgetWrapper::eventFilter(QObject *watched, QEvent *event)
mousePressEvent(static_cast<QMouseEvent *>(event));
} else if (event->type() == QEvent::Type::MouseButtonRelease) {
mouseReleaseEvent(static_cast<QMouseEvent *>(event));
} else if (event->type() == QEvent::Type::MouseMove) {
handleMouseMove(static_cast<QMouseEvent *>(event));
}
}
@ -122,7 +120,7 @@ void FashionTrayWidgetWrapper::mousePressEvent(QMouseEvent *event)
void FashionTrayWidgetWrapper::mouseMoveEvent(QMouseEvent *event)
{
return QWidget::mouseMoveEvent(event);
handleMouseMove(event);
}
void FashionTrayWidgetWrapper::mouseReleaseEvent(QMouseEvent *event)
@ -174,9 +172,9 @@ void FashionTrayWidgetWrapper::handleMouseMove(QMouseEvent *event)
return QWidget::mouseMoveEvent(event);
}
// if ((event->pos() - MousePressPoint).manhattanLength() < TRAY_ITEM_DRAG_THRESHOLD) {
// return QWidget::mouseMoveEvent(event);
// }
if ((event->pos() - MousePressPoint).manhattanLength() < TRAY_ITEM_DRAG_THRESHOLD) {
return;
}
event->accept();

View File

@ -40,8 +40,6 @@
static const qreal iconSize = 16;
#define DRAG_THRESHOLD 20
const QPoint rawXPosition(const QPoint &scaledPos)
{
QRect g = qApp->primaryScreen()->geometry();