-
Notifications
You must be signed in to change notification settings - Fork 55
feat: add trash file drop support #1238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c4176c0 to
10359c8
Compare
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);
这些建议可以提高代码的健壮性、安全性和用户体验,同时保持代码的清晰和可维护性。 |
|
[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 |
文管采用了相关脚本处理,无需dde-shell特殊处理回收站,只需保持原有逻辑。 Logs:
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: