mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +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 <QTimer>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
#include <DGuiApplicationHelper>
|
#include <DGuiApplicationHelper>
|
||||||
#include <DWindowManagerHelper>
|
#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)
|
if (item->itemType() != DockItem::App && item->itemType() != DockItem::Plugins && item->itemType() != DockItem::FixedPlugin)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
const QPoint pos = mouseEvent->globalPos();
|
||||||
|
const QPoint distance = pos - m_mousePressPos;
|
||||||
|
if (distance.manhattanLength() < QApplication::startDragDistance())
|
||||||
|
return false;
|
||||||
|
|
||||||
startDrag(item);
|
startDrag(item);
|
||||||
|
|
||||||
return QWidget::eventFilter(watched, event);
|
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)
|
void MainPanelControl::startDrag(DockItem *item)
|
||||||
{
|
{
|
||||||
const QPixmap pixmap = item->grab();
|
const QPixmap pixmap = item->grab();
|
||||||
@ -660,7 +674,6 @@ DockItem *MainPanelControl::dropTargetItem(DockItem *sourceItem, QPoint point)
|
|||||||
targetItem = last;
|
targetItem = last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return targetItem;
|
return targetItem;
|
||||||
|
@ -78,6 +78,7 @@ private:
|
|||||||
void dragLeaveEvent(QDragLeaveEvent *e) override;
|
void dragLeaveEvent(QDragLeaveEvent *e) override;
|
||||||
void dropEvent(QDropEvent *) override;
|
void dropEvent(QDropEvent *) override;
|
||||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||||
|
void mousePressEvent(QMouseEvent *e) override;
|
||||||
|
|
||||||
void startDrag(DockItem *);
|
void startDrag(DockItem *);
|
||||||
DockItem *dropTargetItem(DockItem *sourceItem, QPoint point);
|
DockItem *dropTargetItem(DockItem *sourceItem, QPoint point);
|
||||||
@ -110,6 +111,7 @@ private:
|
|||||||
QLabel *m_fixedSpliter;
|
QLabel *m_fixedSpliter;
|
||||||
QLabel *m_appSpliter;
|
QLabel *m_appSpliter;
|
||||||
QLabel *m_traySpliter;
|
QLabel *m_traySpliter;
|
||||||
|
QPoint m_mousePressPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINPANELCONTROL_H
|
#endif // MAINPANELCONTROL_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user