Skip to content

Conversation

@wjyrich
Copy link
Contributor

@wjyrich wjyrich commented Oct 9, 2025

  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

Summary by Sourcery

Enhance trash interactions in the dock by showing the number of items in trash and providing a drag‐and‐drop hint, and update translations to support the new UI strings.

New Features:

  • Display the current file count in the trash tooltip
  • Show a “Move to Trash” drag hint when files are dragged over the trash icon
  • Introduce a dedicated dragToolTip component for file drag operations

Documentation:

  • Add and update translation entries across multiple language TS files for the new features

@sourcery-ai
Copy link

sourcery-ai bot commented Oct 9, 2025

Reviewer's Guide

This PR enhances the dock’s trash icon by computing and displaying the number of items in the trash, adding an interactive drag‐and‐drop hint when dragging files over the trash icon, and updating the translation files to include the new UI strings.

Sequence diagram for drag-and-drop hint on trash icon

sequenceDiagram
    actor User
    participant "AppItem.qml"
    participant "dragToolTip"
    User->>"AppItem.qml": Drag file over trash icon
    "AppItem.qml"->>"dragToolTip": Show 'Move to Trash' hint
    User-->>"AppItem.qml": Drag file away from trash icon
    "AppItem.qml"->>"dragToolTip": Hide hint
Loading

File-Level Changes

Change Details Files
Compute and expose dynamic trash file count
  • Imported QDir and QStandardPaths for locating the trash directory
  • Implemented TaskManager::getTrashTipText() to count files and return a translated "-N files" string
  • Declared getTrashTipText() as Q_INVOKABLE in the header
panels/dock/taskmanager/taskmanager.cpp
panels/dock/taskmanager/taskmanager.h
Add drag‐and‐drop tooltip hint in QML
  • Modified the existing PanelToolTip to append the trash file count for the trash icon
  • Introduced a new dragToolTip PanelToolTip with text "Move to Trash"
  • Handled onEntered/onExited events to open and close the dragToolTip over the trash icon
panels/dock/taskmanager/package/AppItem.qml
Update translation files with new contexts and messages
  • Added encoding and blocks for 'Move to Trash' in AppItem TS files
  • Inserted entries for '-%1 files' under dock::TaskManager
  • Standardized XML headers and wrapping across all language TS files
panels/dock/taskmanager/translations/org.deepin.ds.dock.taskmanager_*.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • Replace manual trash path construction with a standard API (e.g. QStandardPaths::TrashLocation or DTrashManager) to ensure the correct folder on all platforms.
  • Switch to Qt pluralization (tr("%n file(s)", "", count)) rather than a fixed "-%1 files" so translations can properly handle singular vs. plural forms.
  • Consider caching or watching the trash directory instead of rescanning it on every tooltip display to avoid UI jank when the trash contains many items.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Replace manual trash path construction with a standard API (e.g. QStandardPaths::TrashLocation or DTrashManager) to ensure the correct folder on all platforms.
- Switch to Qt pluralization (tr("%n file(s)", "", count)) rather than a fixed "-%1 files" so translations can properly handle singular vs. plural forms.
- Consider caching or watching the trash directory instead of rescanning it on every tooltip display to avoid UI jank when the trash contains many items.

## Individual Comments

### Comment 1
<location> `panels/dock/taskmanager/package/AppItem.qml:372` </location>
<code_context>
         PanelToolTip {
             id: toolTip
-            text: root.name
+            text: root.itemId === "dde-trash" ? root.name + taskmanager.Applet.getTrashTipText() : root.name
             toolTipX: DockPanelPositioner.x
             toolTipY: DockPanelPositioner.y
</code_context>

<issue_to_address>
**suggestion:** Consider separating the tooltip text with a space or punctuation for clarity.

The tooltip currently joins root.name and the trash tip text without a separator, which can make the message unclear. Please add a space or punctuation between them for better readability.

```suggestion
            text: root.itemId === "dde-trash" ? root.name + " - " + taskmanager.Applet.getTrashTipText() : root.name
```
</issue_to_address>

### Comment 2
<location> `panels/dock/taskmanager/taskmanager.cpp:437` </location>
<code_context>
+    QDir trashDir(trashPath);
+    
+    if (trashDir.exists()) {
+        QStringList entries = trashDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
+        fileCount = entries.size();
+    }
</code_context>

<issue_to_address>
**suggestion:** Including directories in the Trash file count may be misleading.

entryList currently counts both files and directories. If you want to display only the number of files, use QDir::Files instead.
</issue_to_address>

### Comment 3
<location> `panels/dock/taskmanager/taskmanager.cpp:441` </location>
<code_context>
+        fileCount = entries.size();
+    }
+
+    return tr("-%1 files").arg(fileCount);
+}
+
</code_context>

<issue_to_address>
**suggestion:** Negative sign in tooltip string may be confusing.

Consider removing the leading dash or clarifying its meaning to avoid confusion about negative file counts.

```suggestion
    return tr("%1 files in Trash").arg(fileCount);
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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
PanelToolTip {
id: toolTip
text: root.name
text: root.itemId === "dde-trash" ? root.name + "-" + taskmanager.Applet.getTrashTipText() : root.name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是不是加载cpp里比较好,AppItem里直接区分dde-trash后返回需要的name,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不太好加, 因为 从AM获取的数据,如果在name那边加,意义差不多,性能方面也一样。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, wjyrich

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@wjyrich
Copy link
Contributor Author

wjyrich commented Oct 10, 2025

/forcemerge

@deepin-bot
Copy link

deepin-bot bot commented Oct 10, 2025

This pr force merged! (status: behind)

@deepin-bot deepin-bot bot merged commit 2a6eecf into linuxdeepin:master Oct 10, 2025
8 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants