mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix: 修复任务栏中拖拽图标到桌面区域图标消失的问题
在拖拽图标结束后,自动调用TrayView的onUpdateEditorView方法来重新生成图标 Log: Influence: 将托盘图标从任务栏快速向上拖动,观察任务栏托盘的图标是否还存在 Bug: https://pms.uniontech.com/bug-view-171539.html Change-Id: Ib2dc99742349f06ee27726073916464e7a5769b2
This commit is contained in:
parent
47f8581788
commit
1236ae5b87
@ -149,7 +149,7 @@ void TrayDelegate::setEditorData(QWidget *editor, const QModelIndex &index) cons
|
|||||||
{
|
{
|
||||||
BaseTrayWidget *widget = static_cast<BaseTrayWidget *>(editor);
|
BaseTrayWidget *widget = static_cast<BaseTrayWidget *>(editor);
|
||||||
if (widget) {
|
if (widget) {
|
||||||
widget->setNeedShow(!index.data(TrayModel::Blank).toBool());
|
widget->setNeedShow(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,10 +457,12 @@ bool TrayGridView::beginDrag(Qt::DropActions supportedActions)
|
|||||||
if (!widget)
|
if (!widget)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
QMimeData *data = model()->mimeData(QModelIndexList() << modelIndex);
|
||||||
|
if (!data)
|
||||||
|
return false;
|
||||||
|
|
||||||
auto pixmap = widget->icon();
|
auto pixmap = widget->icon();
|
||||||
|
|
||||||
QString text = modelIndex.data(Qt::DisplayRole).toString();
|
|
||||||
QString itemKey = modelIndex.data(TrayModel::Role::KeyRole).toString();
|
|
||||||
qreal ratio = qApp->devicePixelRatio();
|
qreal ratio = qApp->devicePixelRatio();
|
||||||
// 创建拖拽释放时的应用图标
|
// 创建拖拽释放时的应用图标
|
||||||
QLabel *pixLabel = new QLabel(this);
|
QLabel *pixLabel = new QLabel(this);
|
||||||
@ -472,17 +474,13 @@ bool TrayGridView::beginDrag(Qt::DropActions supportedActions)
|
|||||||
pixmap.setDevicePixelRatio(ratio);
|
pixmap.setDevicePixelRatio(ratio);
|
||||||
drag->setPixmap(pixmap);
|
drag->setPixmap(pixmap);
|
||||||
drag->setHotSpot(pixmap.rect().center() / ratio);
|
drag->setHotSpot(pixmap.rect().center() / ratio);
|
||||||
QMimeData *data = model()->mimeData(QModelIndexList() << modelIndex);
|
|
||||||
if (!data) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
data->setImageData(pixmap);
|
data->setImageData(pixmap);
|
||||||
drag->setMimeData(data);
|
drag->setMimeData(data);
|
||||||
|
|
||||||
setState(DraggingState);
|
setState(DraggingState);
|
||||||
|
|
||||||
listModel->setDragKey(itemKey);
|
listModel->setDragKey(modelIndex.data(TrayModel::Role::KeyRole).toString());
|
||||||
listModel->setDragingIndex(modelIndex);
|
listModel->setDragingIndex(modelIndex);
|
||||||
// 删除当前的图标
|
// 删除当前的图标
|
||||||
WinInfo winInfo = listModel->takeIndex(modelIndex);
|
WinInfo winInfo = listModel->takeIndex(modelIndex);
|
||||||
@ -506,6 +504,7 @@ bool TrayGridView::beginDrag(Qt::DropActions supportedActions)
|
|||||||
m_dropPos = QPoint();
|
m_dropPos = QPoint();
|
||||||
m_dragPos = QPoint();
|
m_dragPos = QPoint();
|
||||||
|
|
||||||
|
onUpdateEditorView();
|
||||||
Q_EMIT dragFinished();
|
Q_EMIT dragFinished();
|
||||||
});
|
});
|
||||||
posAni->setEasingCurve(QEasingCurve::Linear);
|
posAni->setEasingCurve(QEasingCurve::Linear);
|
||||||
@ -520,6 +519,7 @@ bool TrayGridView::beginDrag(Qt::DropActions supportedActions)
|
|||||||
|
|
||||||
m_dropPos = QPoint();
|
m_dropPos = QPoint();
|
||||||
m_dragPos = QPoint();
|
m_dragPos = QPoint();
|
||||||
|
Q_EMIT dragFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -49,6 +49,9 @@ TrayModel *TrayModel::getDockModel()
|
|||||||
connect(iconModel, &TrayModel::rowsInserted, model, [ = ] {
|
connect(iconModel, &TrayModel::rowsInserted, model, [ = ] {
|
||||||
model->setExpandVisible(iconModel->rowCount() > 0);
|
model->setExpandVisible(iconModel->rowCount() > 0);
|
||||||
});
|
});
|
||||||
|
connect(iconModel, &TrayModel::rowCountChanged, model, [ = ] {
|
||||||
|
model->setExpandVisible(iconModel->rowCount() > 0);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user