Repository navigation
fix: correct Xft/DPI property name in XSettings update - #40
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts how DPI settings are synchronized between DConfig and XSettings by correcting the Xft/DPI property name used over D-Bus, ensuring proper scaling of the DPI value before persisting and broadcasting it, and enabling logging via QLoggingCategory. Sequence diagram for updated DPI synchronization via XSettingssequenceDiagram
actor User
participant DisplaySettingsUI
participant XSettingsManager
participant DConfig
participant XSettingsDBus
User->>DisplaySettingsUI: change display scale
DisplaySettingsUI->>XSettingsManager: setScale(scale)
XSettingsManager->>XSettingsManager: updateDPI()
XSettingsManager->>DConfig: read dcKeyXftDpi
DConfig-->>XSettingsManager: tempXftDpi
XSettingsManager->>XSettingsManager: compute scaledDpi = (DPI_FALLBACK * 1024) * scale
alt DPI changed
XSettingsManager->>DConfig: setValue dcKeyXftDpi, scaledDpi
XSettingsManager->>XSettingsManager: create XsSetting(prop = Xft/DPI, value = scaledDpi, type = HeadTypeInteger)
XSettingsManager->>XSettingsDBus: update XSettings with prop Xft/DPI
XSettingsDBus-->>Applications: broadcast updated XSettings
else DPI unchanged
XSettingsManager->>XSettingsManager: do nothing
end
Updated class diagram for XSettingsManager DPI update logicclassDiagram
class XSettingsManager {
- DConfig* m_settingDconfig
- int DPI_FALLBACK
- double scale
+ updateDPI() void
}
class DConfig {
+ value(key QString) int
+ setValue(key QString, value int) void
}
class XsSetting {
+ QString prop
+ int value
+ int type
}
class QLoggingCategory {
+ QLoggingCategory(name const char*)
}
XSettingsManager --> DConfig : uses
XSettingsManager --> XsSetting : creates
XSettingsManager --> QLoggingCategory : logging
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
1. Fixed incorrect property name used when updating Xft/DPI setting via D-Bus 2. Changed property from internal DConfig key "xft.dpi" to actual XSettings property "Xft/DPI" 3. Added missing QLoggingCategory include for proper logging functionality 4. Added proper scaling calculation for DPI value before comparison Log: Fixed incorrect XSettings property name when updating display DPI settings Influence: 1. Test display scaling changes to ensure DPI settings are properly applied 2. Verify XSettings D-Bus interface receives correct property name "Xft/ DPI" 3. Check that DConfig values are correctly synchronized with XSettings 4. Test with different display scaling factors to ensure DPI calculation works correctly 5. Verify that DPI changes are properly reflected in applications using XSettings fix: 修正XSettings更新中Xft/DPI属性名称错误 1. 修复通过D-Bus更新Xft/DPI设置时使用的错误属性名称 2. 将属性从内部DConfig键"xft.dpi"更改为实际的XSettings属性"Xft/DPI" 3. 添加缺失的QLoggingCategory包含以支持正确的日志功能 4. 在比较前添加了DPI值的正确缩放计算 Log: 修复更新显示DPI设置时XSettings属性名称错误的问题 Influence: 1. 测试显示缩放更改以确保DPI设置正确应用 2. 验证XSettings D-Bus接口接收到正确的属性名称"Xft/DPI" 3. 检查DConfig值是否正确与XSettings同步 4. 使用不同的显示缩放因子测试以确保DPI计算正常工作 5. 验证DPI更改是否正确反映在使用XSettings的应用程序中 pms: BUG-343127
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- The new
#include <qlogging.h>looks mismatched with the description mentioningQLoggingCategory; consider including the specific header you actually need (e.g.<QLoggingCategory>or the project’s logging header) to avoid pulling in broader/incorrect Qt logging APIs. - The literal "Xft/DPI" is now embedded directly in
XsSetting; if this value is used elsewhere or tied to a protocol spec, consider centralizing it as a named constant (e.g. inxsdatainfo.h) to avoid typos and keep it consistent with other XSettings keys.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `#include <qlogging.h>` looks mismatched with the description mentioning `QLoggingCategory`; consider including the specific header you actually need (e.g. `<QLoggingCategory>` or the project’s logging header) to avoid pulling in broader/incorrect Qt logging APIs.
- The literal "Xft/DPI" is now embedded directly in `XsSetting`; if this value is used elsewhere or tied to a protocol spec, consider centralizing it as a named constant (e.g. in `xsdatainfo.h`) to avoid typos and keep it consistent with other XSettings keys.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
deepin pr auto review我来对这段代码进行审查和分析:
改进建议:
setting.prop = dcKeyXftDpi; // 而不是 "Xft/DPI"
// DPI 缩放因子,用于提高精度
constexpr int DPI_SCALE_FACTOR = 1024;
scaledDpi = static_cast<int>((DPI_FALLBACK * DPI_SCALE_FACTOR) * scale);
scaledDpi = static_cast<int>((DPI_FALLBACK * DPI_SCALE_FACTOR) * scale);
// 确保 scaledDpi 在合理范围内
if (scaledDpi < DPI_MIN || scaledDpi > DPI_MAX) {
qWarning() << "Calculated DPI out of range:" << scaledDpi;
scaledDpi = qBound(DPI_MIN, scaledDpi, DPI_MAX);
}
if (tempXftDpi != scaledDpi) {
qDebug() << "Updating DPI from" << tempXftDpi << "to" << scaledDpi;
m_settingDconfig->setValue(dcKeyXftDpi, scaledDpi);
// ...
}这些改进将使代码更加健壮、可维护和安全。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: caixr23, 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 |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Log: Fixed incorrect XSettings property name when updating display DPI settings
Influence:
fix: 修正XSettings更新中Xft/DPI属性名称错误
Log: 修复更新显示DPI设置时XSettings属性名称错误的问题
Influence:
pms: BUG-343127
Summary by Sourcery
Correct XSettings DPI updates and align them with the expected Xft/DPI property.
Bug Fixes:
Enhancements: