mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
feat(dock): click app item is easy to drag app
This commit is contained in:
parent
cd405aee3e
commit
9a72d823f0
@ -30,6 +30,7 @@
|
||||
#include <QTimer>
|
||||
#include <QStandardPaths>
|
||||
#include <QString>
|
||||
#include <QApplication>
|
||||
|
||||
#include <DGuiApplicationHelper>
|
||||
#include <DWindowManagerHelper>
|
||||
@ -535,11 +536,24 @@ bool MainPanelControl::eventFilter(QObject *watched, QEvent *event)
|
||||
if (item->itemType() != DockItem::App && item->itemType() != DockItem::Plugins && item->itemType() != DockItem::FixedPlugin)
|
||||
return false;
|
||||
|
||||
const QPoint pos = mouseEvent->globalPos();
|
||||
const QPoint distance = pos - m_mousePressPos;
|
||||
if (distance.manhattanLength() < QApplication::startDragDistance())
|
||||
return false;
|
||||
|
||||
startDrag(item);
|
||||
|
||||
return QWidget::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void MainPanelControl::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->button() == Qt::LeftButton)
|
||||
m_mousePressPos = e->globalPos();
|
||||
|
||||
QWidget::mousePressEvent(e);
|
||||
}
|
||||
|
||||
void MainPanelControl::startDrag(DockItem *item)
|
||||
{
|
||||
const QPixmap pixmap = item->grab();
|
||||
@ -660,7 +674,6 @@ DockItem *MainPanelControl::dropTargetItem(DockItem *sourceItem, QPoint point)
|
||||
targetItem = last;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return targetItem;
|
||||
|
@ -78,6 +78,7 @@ private:
|
||||
void dragLeaveEvent(QDragLeaveEvent *e) override;
|
||||
void dropEvent(QDropEvent *) override;
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *e) override;
|
||||
|
||||
void startDrag(DockItem *);
|
||||
DockItem *dropTargetItem(DockItem *sourceItem, QPoint point);
|
||||
@ -110,6 +111,7 @@ private:
|
||||
QLabel *m_fixedSpliter;
|
||||
QLabel *m_appSpliter;
|
||||
QLabel *m_traySpliter;
|
||||
QPoint m_mousePressPos;
|
||||
};
|
||||
|
||||
#endif // MAINPANELCONTROL_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user