fix(personalization): handle custom wallpapers#3319
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy 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 |
bf2fdd5 to
b656fff
Compare
|
TAG Bot New tag: 6.1.97 |
|
TAG Bot New tag: 6.1.98 |
Reviewer's GuideAdjusts wallpaper installation to use the actual wallpaper type from the item, improves wallpaper lookup to support cross-type and custom wallpapers, and refactors custom wallpaper handling to support non-auto-set usage in Treeland while ensuring wallpapers remain accessible even if original resources are missing or unreadable. Sequence diagram for Treeland custom wallpaper handlingsequenceDiagram
actor User
participant TreeLandWorker
participant WallpaperProvider
participant PersonalizationWorker
User->>TreeLandWorker: setWallpaper(monitorName, url, type)
TreeLandWorker->>TreeLandWorker: QFile::exists(url)
TreeLandWorker->>TreeLandWorker: QUrl::fromLocalFile / QUrl::fromUserInput
alt type is wallpaper_source_type_image
TreeLandWorker->>WallpaperProvider: findWallpaperItem(dest, Wallpaper_all)
WallpaperProvider-->>TreeLandWorker: std::optional<WallpaperItemPtr>
opt [no wallpaper item found]
TreeLandWorker->>PersonalizationWorker: addCustomWallpaper(destUrl.toString(), false)
PersonalizationWorker-->>TreeLandWorker: lastHashPath
TreeLandWorker->>TreeLandWorker: dest = lastHashPath
end
end
TreeLandWorker->>TreeLandWorker: [continue applying wallpaper with dest]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/plugin-personalization/operation/treelandworker.cpp" line_range="358-361" />
<code_context>
dest = destUrl.toLocalFile();
}
+ if (type == WallpaperContext::wallpaper_source_type_image && Q_LIKELY(m_wallpaperWorker)) {
+ if (m_wallpaperWorker->findWallpaperItem(dest, WallpaperEnums::Wallpaper_all) == std::nullopt) {
+ qInfo(DdcPersonnalizationTreelandWorker) << "cannot find wallpaper item for url:" << dest << ", adding as custom wallpaper.";
+ dest = addCustomWallpaper(destUrl.toString(), false);
+ qInfo(DdcPersonnalizationTreelandWorker) << "added custom wallpaper, new path:" << dest;
+ }
</code_context>
<issue_to_address>
**issue (bug_risk):** Matching on `dest` (local path) against `wallpaperItem->url` may fail and cause duplicate custom wallpapers.
`findWallpaperItem` is passed `dest` (a local file path from `toLocalFile()`), but internally it compares the argument to `wallpaperItem->url`. If stored items use `file://` URLs or remote URIs rather than plain paths, this lookup will always fail and a new custom wallpaper will be added each time. Please normalize the identifier used for matching (e.g., always canonical URL or always local path) consistently when storing and searching wallpaper items.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| if (type == WallpaperContext::wallpaper_source_type_image && Q_LIKELY(m_wallpaperWorker)) { | ||
| if (m_wallpaperWorker->findWallpaperItem(dest, WallpaperEnums::Wallpaper_all) == std::nullopt) { | ||
| qInfo(DdcPersonnalizationTreelandWorker) << "cannot find wallpaper item for url:" << dest << ", adding as custom wallpaper."; | ||
| dest = addCustomWallpaper(destUrl.toString(), false); |
There was a problem hiding this comment.
issue (bug_risk): Matching on dest (local path) against wallpaperItem->url may fail and cause duplicate custom wallpapers.
findWallpaperItem is passed dest (a local file path from toLocalFile()), but internally it compares the argument to wallpaperItem->url. If stored items use file:// URLs or remote URIs rather than plain paths, this lookup will always fail and a new custom wallpaper will be added each time. Please normalize the identifier used for matching (e.g., always canonical URL or always local path) consistently when storing and searching wallpaper items.
1. Return the saved path when adding custom wallpapers. 2. Allow custom wallpapers to be added without applying them immediately. 3. Register unknown Treeland image wallpapers before setting them. 4. Find wallpapers across all types and install packages with the matched type. Log: Handle custom wallpaper paths correctly when setting Treeland wallpapers. fix(personalization): 处理自定义壁纸 1. 添加自定义壁纸时返回保存后的路径。 2. 支持添加自定义壁纸但不立即应用。 3. 在设置 Treeland 图片壁纸前注册未知壁纸。 4. 跨全部类型查找壁纸,并使用匹配到的类型安装包。 Log: 修正 Treeland 设置壁纸时自定义壁纸路径的处理。
deepin pr auto review★ 总体评分:75分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 diff --git a/src/plugin-personalization/operation/treelandworker.cpp b/src/plugin-personalization/operation/treelandworker.cpp
index c79e7e0b96..corrected_hash 100644
--- a/src/plugin-personalization/operation/treelandworker.cpp
+++ b/src/plugin-personalization/operation/treelandworker.cpp
@@ -414,7 +414,7 @@ bool TreeLandWorker::setWallpaper(const QString &monitorName, const QString &url
if (type == WallpaperContext::wallpaper_source_type_image && Q_LIKELY(m_wallpaperWorker)) {
- if (m_wallpaperWorker->findWallpaperItem(destUrl.toString(), WallpaperEnums::Wallpaper_all) == std::nullopt) {
+ if (m_wallpaperWorker->findWallpaperItem(dest, WallpaperEnums::Wallpaper_all) == std::nullopt) {
qInfo(DdcPersonnalizationTreelandWorker) << "cannot find wallpaper item for url:" << dest << ", adding as custom wallpaper.";
- dest = addCustomWallpaper(destUrl.toString(), false);
+ dest = addCustomWallpaper(dest, false);
qInfo(DdcPersonnalizationTreelandWorker) << "added custom wallpaper, new path:" << dest;
}
} |
|
TAG Bot New tag: 6.1.99 |
|
TAG Bot New tag: 6.1.100 |
修复Treeland设置自定义壁纸的时候,Treeland 可能没有权限去读, 以及原始资源如果删除,则Treeland会找不到壁纸资源的问题
Summary by Sourcery
Improve handling of custom wallpapers and wallpaper lookup, ensuring Treeland can set and track wallpapers even when using arbitrary image paths or previously unknown resources.
New Features:
Bug Fixes:
Enhancements: