mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
feat: 回收站拖拽行为增加tips
回收站拖拽行为增加'移动到回收站'tips Log: 新增回收站拖拽行为tips功能 Task: https://pms.uniontech.com/zentao/task-view-84320.html Change-Id: I4f0a8ee2bc0e6fbcced0bd5084be7c9625d69acb
This commit is contained in:
parent
8c31301505
commit
055d122657
@ -90,6 +90,11 @@ QWidget *TrashPlugin::itemTipsWidget(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
|
||||
if (m_trashWidget->getDragging()) {
|
||||
m_tipsLabel->setText(tr("Move to trash"));
|
||||
return m_tipsLabel.data();
|
||||
}
|
||||
|
||||
const int count = m_trashWidget->trashItemCount();
|
||||
if (count < 2)
|
||||
m_tipsLabel->setText(tr("Trash - %1 file").arg(count));
|
||||
|
@ -42,6 +42,7 @@ TrashWidget::TrashWidget(QWidget *parent)
|
||||
"/org/freedesktop/FileManager1",
|
||||
QDBusConnection::sessionBus(),
|
||||
this))
|
||||
, m_dragging(false)
|
||||
{
|
||||
m_popupApplet->setVisible(false);
|
||||
|
||||
@ -126,6 +127,9 @@ void TrashWidget::dragEnterEvent(QDragEnterEvent *e)
|
||||
if (e->dropAction() != Qt::MoveAction) {
|
||||
e->ignore();
|
||||
} else {
|
||||
// 设置item是否拖入回收站的状态,给DockItem发送鼠标进入事件
|
||||
setDragging(true);
|
||||
qApp->postEvent(this->parent(), new QEnterEvent(e->pos(), mapToParent(e->pos()), mapToGlobal(e->pos())));
|
||||
e->accept();
|
||||
}
|
||||
}
|
||||
@ -144,6 +148,15 @@ void TrashWidget::dragMoveEvent(QDragMoveEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
void TrashWidget::dragLeaveEvent(QDragLeaveEvent *e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
|
||||
// 设置item是否拖入回收站的状态,给DockItem发送鼠标离开事件
|
||||
setDragging(false);
|
||||
qApp->postEvent(this->parent(), new QEvent(QEvent::Leave));
|
||||
}
|
||||
|
||||
void TrashWidget::dropEvent(QDropEvent *e)
|
||||
{
|
||||
if (e->mimeData()->hasFormat("RequestDock"))
|
||||
@ -159,6 +172,10 @@ void TrashWidget::dropEvent(QDropEvent *e)
|
||||
return e->ignore();
|
||||
}
|
||||
|
||||
// 设置item是否拖入回收站的状态,给DockItem发送鼠标离开事件
|
||||
setDragging(false);
|
||||
qApp->postEvent(this->parent(), new QEvent(QEvent::Leave));
|
||||
|
||||
const QMimeData *mime = e->mimeData();
|
||||
for (auto url : mime->urls())
|
||||
moveToTrash(url);
|
||||
@ -210,6 +227,16 @@ void TrashWidget::updateIconAndRefresh()
|
||||
update();
|
||||
}
|
||||
|
||||
bool TrashWidget::getDragging() const
|
||||
{
|
||||
return m_dragging;
|
||||
}
|
||||
|
||||
void TrashWidget::setDragging(bool state)
|
||||
{
|
||||
m_dragging = state;
|
||||
}
|
||||
|
||||
void TrashWidget::removeApp(const QString &appKey)
|
||||
{
|
||||
const QString cmd("dbus-send --print-reply --dest=com.deepin.dde.Launcher /com/deepin/dde/Launcher com.deepin.dde.Launcher.UninstallApp string:\"" + appKey + "\"");
|
||||
|
@ -52,6 +52,8 @@ public:
|
||||
void invokeMenuItem(const QString &menuId, const bool checked);
|
||||
void updateIcon();
|
||||
void updateIconAndRefresh();
|
||||
bool getDragging() const;
|
||||
void setDragging(bool state);
|
||||
|
||||
signals:
|
||||
void requestContextMenu() const;
|
||||
@ -59,6 +61,7 @@ signals:
|
||||
protected:
|
||||
void dragEnterEvent(QDragEnterEvent *e) override;
|
||||
void dragMoveEvent(QDragMoveEvent *e) override;
|
||||
void dragLeaveEvent(QDragLeaveEvent *e) override;
|
||||
void dropEvent(QDropEvent *e) override;
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
@ -70,6 +73,8 @@ private:
|
||||
PopupControlWidget *m_popupApplet;
|
||||
DBusFileManager1 *m_fileManagerInter;
|
||||
|
||||
bool m_dragging; // item是否被拖入回收站
|
||||
|
||||
QPixmap m_icon;
|
||||
QIcon m_defaulticon;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user