feat: add trash file drop support#1238
Merged
Merged
Conversation
Reviewer's GuideThis PR adds drag-and-drop support to the trash icon in the task manager by detecting drops on the "dde-trash" item, moving dropped files to the system trash via a new moveFilesToTrash method, and including necessary Qt headers along with error and debug logging. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
18202781743
reviewed
Sep 4, 2025
18202781743
reviewed
Sep 4, 2025
18202781743
reviewed
Sep 4, 2025
18202781743
reviewed
Sep 4, 2025
c4176c0 to
10359c8
Compare
18202781743
reviewed
Sep 4, 2025
Added functionality to handle file drops on the trash icon in the task manager 1. Implemented moveFilesToTrash method that converts URL paths to local files and moves them to system trash 2. Added file drop detection for "dde-trash" item ID with proper debug logging 3. Included necessary Qt headers for file operations (QFile, QFileInfo, QProcess, QUrl) 4. Added error handling for empty file paths with warning messages feat: 添加回收站文件拖放支持 在任务管理器中添加了对回收站图标的文件拖放处理功能 1. 实现了moveFilesToTrash方法,将URL路径转换为本地文件并移动到系统回收站 2. 添加了对"dde-trash"项目ID的文件拖放检测,包含适当的调试日志 3. 包含了文件操作所需的Qt头文件(QFile、QFileInfo、QProcess、QUrl) 4. 为空的文件路径添加了错误处理,包含警告消息 Pms: BUG-271091
10359c8 to
8a1c266
Compare
deepin pr auto review代码审查报告总体评价这段代码为任务管理器添加了将文件拖放到回收站的功能,整体实现较为清晰,但有一些可以改进的地方。 具体分析1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
改进建议
void TaskManager::moveFilesToTrash(const QStringList& urls)
{
if (urls.isEmpty()) {
qCWarning(taskManagerLog) << "Empty URLs list provided";
return;
}
// 将文件路径转换为本地路径并移动到回收站
for (const QString& urlString : urls) {
if (urlString.isEmpty()) {
qCWarning(taskManagerLog) << "Empty URL encountered";
continue;
}
QUrl url(urlString);
if (!url.isValid()) {
qCWarning(taskManagerLog) << "Invalid URL format:" << urlString;
continue;
}
QString filePath = url.toLocalFile();
if (filePath.isEmpty()) {
qCWarning(taskManagerLog) << "Failed to convert URL to local file:" << urlString;
continue;
}
// 添加文件存在性检查
QFileInfo fileInfo(filePath);
if (!fileInfo.exists()) {
qCWarning(taskManagerLog) << "File does not exist:" << filePath;
continue;
}
if (!fileInfo.isReadable()) {
qCWarning(taskManagerLog) << "No read permission for file:" << filePath;
continue;
}
if (DTrashManager::instance()->moveToTrash(filePath)) {
qCDebug(taskManagerLog) << "Successfully moved to trash:" << filePath;
} else {
qCWarning(taskManagerLog) << "Failed to move to trash:" << filePath;
// 可以考虑在这里添加用户反馈
}
}
}
void TaskManager::moveFilesToTrash(const QStringList& urls)
{
// ... 参数验证代码 ...
int successCount = 0;
int totalCount = urls.size();
for (const QString& urlString : urls) {
// ... 验证代码 ...
if (DTrashManager::instance()->moveToTrash(filePath)) {
successCount++;
qCDebug(taskManagerLog) << "Successfully moved to trash:" << filePath;
} else {
qCWarning(taskManagerLog) << "Failed to move to trash:" << filePath;
}
}
// 可以在这里发送信号通知操作完成和成功率
emit trashOperationCompleted(successCount, totalCount);
}
Q_SIGNALS:
void dataModelChanged();
void windowSplitChanged();
void trashOperationCompleted(int successCount, int totalCount);
这些建议可以提高代码的健壮性、安全性和用户体验,同时保持代码的清晰和可维护性。 |
18202781743
approved these changes
Sep 4, 2025
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
wjyrich
added a commit
to wjyrich/dde-shell
that referenced
this pull request
Oct 24, 2025
文管采用了相关脚本处理,无需dde-shell特殊处理回收站,只需保持原有逻辑。 Logs:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added functionality to handle file drops on the trash icon in the task manager
feat: 添加回收站文件拖放支持
在任务管理器中添加了对回收站图标的文件拖放处理功能
Pms: BUG-271091
Summary by Sourcery
Add drag-and-drop handling for files on the trash icon by implementing moveFilesToTrash, incorporating debug logging and error handling.
New Features: