Skip to content

Commit a5a62ab

Browse files
committed
feat: enhance trash functionality with file count and drag hints
1. Add file count display to trash tooltip showing number of files in trash 2. Implement drag-and-drop hint "Move to Trash" when dragging files over trash icon 3. Add new dragToolTip component that appears during file drag operations 4. Update translation files for multiple languages to support new features feat: 增强回收站功能,添加文件计数和拖拽提示 1. 在回收站工具提示中添加文件数量显示,显示回收站中的文件数量 2. 实现拖拽文件到回收站图标时显示"移动到回收站"提示 3. 添加新的拖拽工具提示组件,在文件拖拽操作期间显示 4. 更新多语言翻译文件以支持新功能 PMS: BUG-336327 BUG-336329
1 parent a5466cd commit a5a62ab

26 files changed

+454
-57
lines changed

panels/dock/taskmanager/package/AppItem.qml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,19 @@ Item {
369369

370370
PanelToolTip {
371371
id: toolTip
372-
text: root.name
372+
text: root.itemId === "dde-trash" ? root.name + "-" + taskmanager.Applet.getTrashTipText() : root.name
373373
toolTipX: DockPanelPositioner.x
374374
toolTipY: DockPanelPositioner.y
375375
}
376376

377+
PanelToolTip {
378+
id: dragToolTip
379+
text: qsTr("Move to Trash")
380+
toolTipX: DockPanelPositioner.x
381+
toolTipY: DockPanelPositioner.y
382+
visible: false
383+
}
384+
377385
Timer {
378386
id: toolTipShowTimer
379387
interval: 50
@@ -397,6 +405,20 @@ Item {
397405
anchors.fill: parent
398406
keys: ["dfm_app_type_for_drag"]
399407

408+
onEntered: function (drag) {
409+
if (root.itemId === "dde-trash") {
410+
var point = root.mapToItem(null, root.width / 2, root.height / 2)
411+
dragToolTip.DockPanelPositioner.bounding = Qt.rect(point.x, point.y, dragToolTip.width, dragToolTip.height)
412+
dragToolTip.open()
413+
}
414+
}
415+
416+
onExited: function (drag) {
417+
if (root.itemId === "dde-trash") {
418+
dragToolTip.close()
419+
}
420+
}
421+
400422
onDropped: function (drop){
401423
root.dropFilesOnItem(root.itemId, drop.urls)
402424
}

panels/dock/taskmanager/taskmanager.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <QGuiApplication>
2525
#include <QStringLiteral>
2626
#include <QUrl>
27+
#include <QDir>
28+
#include <QStandardPaths>
2729
#include <DTrashManager>
2830

2931
#include <appletbridge.h>
@@ -425,6 +427,20 @@ void TaskManager::saveDockElementsOrder(const QStringList &appIds)
425427
TaskManagerSettings::instance()->setDockedElements(newDockedElements);
426428
}
427429

430+
QString TaskManager::getTrashTipText()
431+
{
432+
int fileCount = 0;
433+
QString trashPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/Trash/files";
434+
QDir trashDir(trashPath);
435+
436+
if (trashDir.exists()) {
437+
QStringList entries = trashDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
438+
fileCount = entries.size();
439+
}
440+
441+
return tr("%1 files").arg(fileCount);
442+
}
443+
428444
void TaskManager::modifyOpacityChanged()
429445
{
430446
DS_NAMESPACE::DAppletBridge appearanceBridge("org.deepin.ds.dde-appearance");

panels/dock/taskmanager/taskmanager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class TaskManager : public DS_NAMESPACE::DContainment, public AbstractTaskManage
9595

9696
Q_INVOKABLE void activateWindow(uint32_t windowID);
9797
Q_INVOKABLE void saveDockElementsOrder(const QStringList &appIds);
98+
Q_INVOKABLE QString getTrashTipText();
9899

99100
private:
100101
void moveFilesToTrash(const QStringList& urls);

panels/dock/taskmanager/translations/org.deepin.ds.dock.taskmanager.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!DOCTYPE TS>
33
<TS version="2.1">
4+
<context>
5+
<name>AppItem</name>
6+
<message>
7+
<source>Move to Trash</source>
8+
<translation type="unfinished"></translation>
9+
</message>
10+
</context>
411
<context>
512
<name>dock::AppItem</name>
613
<message>
@@ -47,4 +54,11 @@
4754
<translation type="unfinished"></translation>
4855
</message>
4956
</context>
57+
<context>
58+
<name>dock::TaskManager</name>
59+
<message>
60+
<source>%1 files</source>
61+
<translation type="unfinished"></translation>
62+
</message>
63+
</context>
5064
</TS>

panels/dock/taskmanager/translations/org.deepin.ds.dock.taskmanager_ar.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
<?xml version="1.0" ?><!DOCTYPE TS><TS version="2.1" language="ar">
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!DOCTYPE TS>
3+
<TS version="2.1" language="ar">
4+
<context>
5+
<name>AppItem</name>
6+
<message>
7+
<source>Move to Trash</source>
8+
<translation type="unfinished"></translation>
9+
</message>
10+
</context>
211
<context>
312
<name>dock::AppItem</name>
413
<message>
@@ -26,23 +35,30 @@
2635
<name>dock::DockGlobalElementModel</name>
2736
<message>
2837
<source>Open</source>
29-
<translation type="unfinished"/>
38+
<translation type="unfinished">افتح</translation>
3039
</message>
3140
<message>
3241
<source>Undock</source>
33-
<translation type="unfinished"/>
42+
<translation type="unfinished">فك الربط</translation>
3443
</message>
3544
<message>
3645
<source>Dock</source>
37-
<translation type="unfinished"/>
46+
<translation type="unfinished">الرسو</translation>
3847
</message>
3948
<message>
4049
<source>Force Quit</source>
41-
<translation type="unfinished"/>
50+
<translation type="unfinished">إنهاء قسري</translation>
4251
</message>
4352
<message>
4453
<source>Close All</source>
45-
<translation type="unfinished"/>
54+
<translation type="unfinished">إغلاق الكل</translation>
55+
</message>
56+
</context>
57+
<context>
58+
<name>dock::TaskManager</name>
59+
<message>
60+
<source>%1 files</source>
61+
<translation type="unfinished"></translation>
4662
</message>
4763
</context>
48-
</TS>
64+
</TS>

panels/dock/taskmanager/translations/org.deepin.ds.dock.taskmanager_az.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
<?xml version="1.0" ?><!DOCTYPE TS><TS version="2.1" language="az">
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!DOCTYPE TS>
3+
<TS version="2.1" language="az">
4+
<context>
5+
<name>AppItem</name>
6+
<message>
7+
<source>Move to Trash</source>
8+
<translation type="unfinished"></translation>
9+
</message>
10+
</context>
211
<context>
312
<name>dock::AppItem</name>
413
<message>
@@ -26,23 +35,30 @@
2635
<name>dock::DockGlobalElementModel</name>
2736
<message>
2837
<source>Open</source>
29-
<translation type="unfinished"/>
38+
<translation type="unfinished">Aç</translation>
3039
</message>
3140
<message>
3241
<source>Undock</source>
33-
<translation type="unfinished"/>
42+
<translation type="unfinished">Undock</translation>
3443
</message>
3544
<message>
3645
<source>Dock</source>
37-
<translation type="unfinished"/>
46+
<translation type="unfinished">Dock</translation>
3847
</message>
3948
<message>
4049
<source>Force Quit</source>
41-
<translation type="unfinished"/>
50+
<translation type="unfinished">Zəmanətli Çıxış</translation>
4251
</message>
4352
<message>
4453
<source>Close All</source>
45-
<translation type="unfinished"/>
54+
<translation type="unfinished">Hər Birı Kapat</translation>
55+
</message>
56+
</context>
57+
<context>
58+
<name>dock::TaskManager</name>
59+
<message>
60+
<source>%1 files</source>
61+
<translation type="unfinished"></translation>
4662
</message>
4763
</context>
48-
</TS>
64+
</TS>

panels/dock/taskmanager/translations/org.deepin.ds.dock.taskmanager_bo.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!DOCTYPE TS>
33
<TS version="2.1">
4+
<context>
5+
<name>AppItem</name>
6+
<message>
7+
<source>Move to Trash</source>
8+
<translation type="unfinished"></translation>
9+
</message>
10+
</context>
411
<context>
512
<name>dock::AppItem</name>
613
<message>
@@ -47,4 +54,11 @@
4754
<translation type="unfinished"></translation>
4855
</message>
4956
</context>
57+
<context>
58+
<name>dock::TaskManager</name>
59+
<message>
60+
<source>%1 files</source>
61+
<translation type="unfinished"></translation>
62+
</message>
63+
</context>
5064
</TS>

panels/dock/taskmanager/translations/org.deepin.ds.dock.taskmanager_ca.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
<?xml version="1.0" ?><!DOCTYPE TS><TS version="2.1" language="ca">
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!DOCTYPE TS>
3+
<TS version="2.1" language="ca">
4+
<context>
5+
<name>AppItem</name>
6+
<message>
7+
<source>Move to Trash</source>
8+
<translation type="unfinished"></translation>
9+
</message>
10+
</context>
211
<context>
312
<name>dock::AppItem</name>
413
<message>
@@ -45,4 +54,11 @@
4554
<translation>Tanca-ho tot</translation>
4655
</message>
4756
</context>
48-
</TS>
57+
<context>
58+
<name>dock::TaskManager</name>
59+
<message>
60+
<source>%1 files</source>
61+
<translation type="unfinished"></translation>
62+
</message>
63+
</context>
64+
</TS>

panels/dock/taskmanager/translations/org.deepin.ds.dock.taskmanager_de.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
<?xml version="1.0" ?><!DOCTYPE TS><TS version="2.1" language="de">
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!DOCTYPE TS>
3+
<TS version="2.1" language="de">
4+
<context>
5+
<name>AppItem</name>
6+
<message>
7+
<source>Move to Trash</source>
8+
<translation type="unfinished"></translation>
9+
</message>
10+
</context>
211
<context>
312
<name>dock::AppItem</name>
413
<message>
@@ -26,23 +35,30 @@
2635
<name>dock::DockGlobalElementModel</name>
2736
<message>
2837
<source>Open</source>
29-
<translation type="unfinished"/>
38+
<translation type="unfinished">Öffnen</translation>
3039
</message>
3140
<message>
3241
<source>Undock</source>
33-
<translation type="unfinished"/>
42+
<translation type="unfinished">Abdocken</translation>
3443
</message>
3544
<message>
3645
<source>Dock</source>
37-
<translation type="unfinished"/>
46+
<translation type="unfinished">Dock</translation>
3847
</message>
3948
<message>
4049
<source>Force Quit</source>
41-
<translation type="unfinished"/>
50+
<translation type="unfinished">Beenden erzwingen</translation>
4251
</message>
4352
<message>
4453
<source>Close All</source>
45-
<translation type="unfinished"/>
54+
<translation type="unfinished">Alle schließen</translation>
55+
</message>
56+
</context>
57+
<context>
58+
<name>dock::TaskManager</name>
59+
<message>
60+
<source>%1 files</source>
61+
<translation type="unfinished"></translation>
4662
</message>
4763
</context>
48-
</TS>
64+
</TS>

panels/dock/taskmanager/translations/org.deepin.ds.dock.taskmanager_es.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
<?xml version="1.0" ?><!DOCTYPE TS><TS version="2.1" language="es">
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!DOCTYPE TS>
3+
<TS version="2.1" language="es">
4+
<context>
5+
<name>AppItem</name>
6+
<message>
7+
<source>Move to Trash</source>
8+
<translation type="unfinished"></translation>
9+
</message>
10+
</context>
211
<context>
312
<name>dock::AppItem</name>
413
<message>
@@ -45,4 +54,11 @@
4554
<translation>Cerrar todo</translation>
4655
</message>
4756
</context>
48-
</TS>
57+
<context>
58+
<name>dock::TaskManager</name>
59+
<message>
60+
<source>%1 files</source>
61+
<translation type="unfinished"></translation>
62+
</message>
63+
</context>
64+
</TS>

0 commit comments

Comments
 (0)