mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
fix: 修复拖拽托盘窗口图标至任务栏托盘区域经常失败的问题。
修复拖拽托盘窗口图标至任务栏托盘区域经常失败的问题。原因:现有实现只在任务栏托盘一小块区域实现,导致拖拽经常不能被捕获,已修改为托盘父窗口区域捕获传递给任务栏托盘区域处理,实现每次拖拽都能捕获。 Log: 修复拖拽托盘窗口图标至任务栏托盘区域经常失败的问题。 Bug: https://pms.uniontech.com/bug-view-147789.html Influence: 拖拽托盘窗口图标至任务栏托盘区域。 Change-Id: I310916160fe1dc0e05b134a45a018c81766fe8cf
This commit is contained in:
parent
16cb904058
commit
7502b87e06
@ -365,7 +365,7 @@ const QModelIndex TrayGridView::getIndexFromPos(QPoint currentPoint) const
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
void TrayGridView::dropEvent(QDropEvent *e)
|
||||
void TrayGridView::handleDropEvent(QDropEvent *e)
|
||||
{
|
||||
setState(DListView::NoState);
|
||||
clearDragModelIndex();
|
||||
@ -437,6 +437,10 @@ bool TrayGridView::beginDrag(Qt::DropActions supportedActions)
|
||||
drag->setPixmap(pixmap);
|
||||
drag->setHotSpot(pixmap.rect().center() / ratio);
|
||||
QMimeData *data = model()->mimeData(QModelIndexList() << modelIndex);
|
||||
if (!data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
data->setImageData(pixmap);
|
||||
drag->setMimeData(data);
|
||||
|
||||
@ -513,3 +517,8 @@ void TrayGridView::initUi()
|
||||
|
||||
connect(m_aniStartTime, &QTimer::timeout, this, &TrayGridView::moveAnimation);
|
||||
}
|
||||
|
||||
void TrayGridView::dropEvent(QDropEvent *e)
|
||||
{
|
||||
handleDropEvent(e);
|
||||
}
|
||||
|
@ -46,6 +46,8 @@ public:
|
||||
const QRect indexRect(const QModelIndex &index) const;
|
||||
void dropSwap();
|
||||
|
||||
void handleDropEvent(QDropEvent *e);
|
||||
|
||||
Q_SIGNALS:
|
||||
void requestRemove(const QString &);
|
||||
void dragLeaved();
|
||||
|
@ -445,16 +445,22 @@ void TrayManagerWindow::dragMoveEvent(QDragMoveEvent *e)
|
||||
|
||||
void TrayManagerWindow::dropEvent(QDropEvent *e)
|
||||
{
|
||||
const QuickPluginMimeData *mimeData = qobject_cast<const QuickPluginMimeData *>(e->mimeData());
|
||||
if (!mimeData)
|
||||
if (!e || !e->mimeData() || e->source() == this)
|
||||
return;
|
||||
|
||||
if (e->source() == this)
|
||||
return;
|
||||
if (qobject_cast<QuickPluginWindow *>(e->source())) {
|
||||
const QuickPluginMimeData *mimeData = qobject_cast<const QuickPluginMimeData *>(e->mimeData());
|
||||
if (!mimeData)
|
||||
return;
|
||||
|
||||
PluginsItemInterface *pluginItem = static_cast<PluginsItemInterface *>(mimeData->pluginItemInterface());
|
||||
if (pluginItem)
|
||||
m_quickIconWidget->dragPlugin(pluginItem);
|
||||
PluginsItemInterface *pluginItem = static_cast<PluginsItemInterface *>(mimeData->pluginItemInterface());
|
||||
if (pluginItem)
|
||||
m_quickIconWidget->dragPlugin(pluginItem);
|
||||
} else if (qobject_cast<TrayGridView *>(e->source())) {
|
||||
// 将trayView中的dropEvent扩大到整个区域(this),这样便于随意拖动到这个区域都可以捕获。
|
||||
// m_trayView中有e->accept不会导致事件重复处理。
|
||||
m_trayView->handleDropEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
void TrayManagerWindow::dragLeaveEvent(QDragLeaveEvent *event)
|
||||
|
Loading…
x
Reference in New Issue
Block a user