feat: add wallpaper fill style configuration - #4025
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Kakueeen 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 |
Reviewer's GuideAdds configurable wallpaper fill styles via a new DConfig key and updates the background manager/bridge to interpret per-screen style values, load original images for non-Fill styles, and render wallpapers using different scaling/tiling strategies while clearing cache on configuration changes. Sequence diagram for wallpaper style change and renderingsequenceDiagram
participant DConfigManager
participant BackgroundManager
participant BackgroundBridge
participant WallpaperCache
DConfigManager->>BackgroundManager: valueChanged(kConfName, KwallpaperFillStyle)
BackgroundManager->>BackgroundManager: onConfigChanged(cfg, key)
BackgroundManager->>BackgroundManager: QPixmapCache_clear()
BackgroundManager->>BackgroundManager: onBackgroundChanged()
BackgroundManager->>BackgroundBridge: runUpdate(self, reqs)
loop per Requestion
BackgroundBridge->>DConfigManager: value(kConfName, KwallpaperFillStyle, QString())
BackgroundBridge->>BackgroundBridge: getValueFromJson(styleConfig, req.screen)
alt WallpaperStyle_Fill
BackgroundBridge->>WallpaperCache: getScaledPathFromCache(wallpaperPath, trueSize)
opt pix_isNull
BackgroundBridge->>BackgroundBridge: getPixmap(req.path, trueSize)
end
else Non_Fill_styles
BackgroundBridge->>BackgroundBridge: getPixmap(req.path)
BackgroundBridge->>BackgroundBridge: processPixmap(backgroundPixmap, wallpaperStyle, trueSize)
end
end
BackgroundBridge-->>BackgroundManager: onFinished(pRecorder)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Johnson-zs
left a comment
There was a problem hiding this comment.
commit message的两个TASK换下行
Add support for configuring desktop wallpaper fill styles (Fill, Fit,
Stretch, Flatten, Center). This allows users to choose how the wallpaper
is displayed on the screen. A new DConfig key `wallpaperFillStyle` has
been added to `org.deepin.dde.file-manager.desktop.json`. The background
manager now listens for changes to this config, clears the pixmap cache,
and re-renders the wallpaper accordingly. The background bridge selects
the appropriate rendering strategy: for Fill style it uses the existing
WallpaperCache service or scaled cropping; for other styles it calls a
new `processPixmap` function that handles scaling, tiling, centering,
etc. A JSON parsing utility `getValueFromJson` extracts per-screen style
values from the config (expected format: `{"screenName": styleNumber}
`). Added a new overload of `getPixmap` to load original images without
scaling for non-Fill styles.
Log: Added wallpaper fill style configuration feature
Influence:
1. Test setting each fill style (Fill, Fit, Stretch, Flatten, Center)
via dconfig and verify wallpaper display
2. Test changing style dynamically and ensure wallpaper updates
immediately without restart
3. Test with multi-monitor setups, verify per-screen style if config
supports it
4. Test with different image sizes and aspect ratios
5. Test with corrupted or unsupported image formats (e.g., .png
with .jpg content)
6. Verify that the wallpaper cache is cleared when style changes
7. Test default behavior when config value is empty or invalid
8. Test performance with large images and screen resolutions
feat: 添加桌面壁纸填充方式配置
支持配置桌面壁纸的填充方式(填充、适应、拉伸、平铺、居中)。新增 DConfig
键 `wallpaperFillStyle` 到 `org.deepin.dde.file-manager.desktop.json`。
背景管理器监听该配置变化,清除缓存并重新渲染壁纸。背景桥根据配置选
择渲染策略:填充模式使用原有的 WallpaperCache 服务或裁剪缩放;其他
模式调用新的 `processPixmap` 函数处理缩放、平铺、居中等操作。新增
`getValueFromJson` 工具函数从 JSON 格式的配置值解析每个屏幕的样式值(预
期格式:`{"screenName": styleNumber}`)。新增 `getPixmap` 重载函数以加载
原始图片(不缩放)用于非填充模式。
Log: 新增桌面壁纸填充方式配置功能
Influence:
1. 测试通过 dconfig 设置每种填充方式(填充/适应/拉伸/平铺/居中),验证壁
纸显示效果
2. 测试动态修改样式,确保壁纸立即更新,无需重启
3. 测试多屏环境,如果配置支持按屏幕设置则验证每个屏幕的样式
4. 测试不同尺寸和宽高比的图片
5. 测试损坏或不支持的图片格式(如 .png 后缀但内容为 .jpg)
6. 验证修改样式时壁纸缓存被清除
7. 测试配置值为空或无效时的默认行为
8. 测试大尺寸图片和高分辨率屏幕下的性能
TASK: https://pms.uniontech.com/task-view-393123.html
TASK: https://pms.uniontech.com/task-view-371829.html
deepin pr auto review★ 总体评分:85分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 1. 修复 Flatten 模式下 Pixmap 未初始化问题
// 2. 优化 runUpdate 中的配置读取位置
// 3. 修复命名规范
diff --git a/src/plugins/desktop/ddplugin-background/backgroundmanager.cpp b/src/plugins/desktop/ddplugin-background/backgroundmanager.cpp
index 9a5335695d..e1daa4d17a 100644
--- a/src/plugins/desktop/ddplugin-background/backgroundmanager.cpp
+++ b/src/plugins/desktop/ddplugin-background/backgroundmanager.cpp
@@ -29,7 +29,7 @@ DDP_BACKGROUND_USE_NAMESPACE
#define CanvasCoreUnsubscribe(topic, func) \
dpfSignalDispatcher->unsubscribe("ddplugin_core", QT_STRINGIFY2(topic), this, func);
-static constexpr char kConfName[] { "org.deepin.dde.file-manager.desktop" };
-static constexpr char KwallpaperFillStyle[] { "wallpaperFillStyle" };
+static constexpr char kWallpaperFillStyle[] { "wallpaperFillStyle" };
// Generate cache key for wallpaper: wallpaper:path@widthxheight
static QString generateCacheKey(const QString &path, const QSize &size)
@@ -640,8 +640,11 @@ void BackgroundBridge::runUpdate(BackgroundBridge *self, QList<Requestion> reqs)
QSize trueSize = req.size;
QString wallpaperPath = req.path.startsWith("file:") ? QUrl(req.path).toLocalFile() : req.path;
- // Read wallpaper fill style from dconfig
- QString styleConfig = DConfigManager::instance()->value(kConfName, KwallpaperFillStyle, QString()).toString();
- int style = getValueFromJson(styleConfig, req.screen);
- auto wallpaperStyle = static_cast<WallpaperStyle>(style);
+ // Read wallpaper fill style from dconfig outside the loop (if not already)
+ // Note: Assuming this block is inside the loop, we should move it out.
+ // For the sake of diff, showing the concept:
+ // QString styleConfig = DConfigManager::instance()->value(kConfName, kWallpaperFillStyle, QString()).toString();
+ // int style = getValueFromJson(styleConfig, req.screen);
+ // auto wallpaperStyle = static_cast<WallpaperStyle>(style);
QPixmap pix;
@@ -730,6 +733,7 @@ QPixmap BackgroundBridge::processPixmap(const QPixmap &originalPixmap, Wallpaper
case WallpaperStyle::Flatten: {
QPixmap flattenPixmap(targetSize);
+ flattenPixmap.fill(Qt::transparent); // 添加初始化填充
QPainter painter(&flattenPixmap);
int tileWidth = originalPixmap.width();
int tileHeight = originalPixmap.height();
@@ -766,7 +770,7 @@ int BackgroundBridge::getValueFromJson(QString json, const QString &screenName)
{
// The string in dconfig contains extra characters
if (json.startsWith('"')) {
json.remove(0, 1);
}
if (json.endsWith('"')) {
json.chop(1);
}
QJsonDocument jsonDoc = QJsonDocument::fromJson(json.toUtf8());
if (!jsonDoc.isObject())
return 0;
QJsonObject jsonObj = jsonDoc.object();
if (jsonObj.contains(screenName))
return jsonObj[screenName].toInt();
return 0;
} |
Add support for configuring desktop wallpaper fill styles (Fill, Fit,
Stretch, Flatten, Center). This allows users to choose how the wallpaper
is displayed on the screen. A new DConfig key
wallpaperFillStylehasbeen added to
org.deepin.dde.file-manager.desktop.json. The backgroundmanager now listens for changes to this config, clears the pixmap cache,
and re-renders the wallpaper accordingly. The background bridge selects
the appropriate rendering strategy: for Fill style it uses the existing
WallpaperCache service or scaled cropping; for other styles it calls a
new
processPixmapfunction that handles scaling, tiling, centering,etc. A JSON parsing utility
getValueFromJsonextracts per-screen stylevalues from the config (expected format:
{"screenName": styleNumber}). Added a new overload ofgetPixmapto load original images withoutscaling for non-Fill styles.
Log: Added wallpaper fill style configuration feature
Influence:
via dconfig and verify wallpaper display
immediately without restart
supports it
with .jpg content)
feat: 添加桌面壁纸填充方式配置
支持配置桌面壁纸的填充方式(填充、适应、拉伸、平铺、居中)。新增 DConfig
键
wallpaperFillStyle到org.deepin.dde.file-manager.desktop.json。背景管理器监听该配置变化,清除缓存并重新渲染壁纸。背景桥根据配置选
择渲染策略:填充模式使用原有的 WallpaperCache 服务或裁剪缩放;其他
模式调用新的
processPixmap函数处理缩放、平铺、居中等操作。新增getValueFromJson工具函数从 JSON 格式的配置值解析每个屏幕的样式值(预期格式:
{"screenName": styleNumber})。新增getPixmap重载函数以加载原始图片(不缩放)用于非填充模式。
Log: 新增桌面壁纸填充方式配置功能
Influence:
纸显示效果
TASK: https://pms.uniontech.com/task-view-393123.html
TASK: https://pms.uniontech.com/task-view-371829.html
Summary by Sourcery
Add configurable wallpaper fill styles and hook them into the desktop background rendering pipeline.
New Features:
Enhancements: