-
Notifications
You must be signed in to change notification settings - Fork 55
fix: scale task manager preview icons for high DPI displays #1347
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
1. Added device pixel ratio scaling to icon size calculation 2. This ensures icons appear sharp and properly sized on high DPI screens 3. Previously used fixed PREVIEW_TITLE_HEIGHT resulted in blurry icons on high DPI displays 4. Now scales the icon pixmap according to the device's pixel ratio fix: 为高DPI显示器缩放任务管理器预览图标 1. 在图标尺寸计算中添加设备像素比缩放 2. 确保在高DPI屏幕上图标显示清晰且尺寸正确 3. 之前使用的固定PREVIEW_TITLE_HEIGHT在高DPI显示器上会导致图标模糊 4. 现在根据设备的像素比缩放图标像素图 PMS: BUG-336089
Reviewer's guide (collapsed on small PRs)Reviewer's GuideIntroduces DPI-aware scaling when generating task manager preview icons by computing and applying a scaled size based on the device pixel ratio, replacing the previous fixed-height approach to ensure sharp rendering on high-DPI displays. Sequence diagram for DPI-aware icon rendering in task manager previewsequenceDiagram
participant "X11WindowPreviewContainer"
participant "QIcon"
participant "QApplication"
participant "Device"
"X11WindowPreviewContainer"->>"QApplication": get devicePixelRatio()
"QApplication"->>"Device": query pixel ratio
"Device"-->>"QApplication": return pixel ratio
"QApplication"-->>"X11WindowPreviewContainer": return pixel ratio
"X11WindowPreviewContainer"->>"QIcon": request icon pixmap with scaled size
"QIcon"-->>"X11WindowPreviewContainer": return scaled pixmap
Class diagram for updated icon scaling in X11WindowPreviewContainerclassDiagram
class X11WindowPreviewContainer {
+void updatePreviewIconFromString(QString stringData)
}
class QApplication {
+double devicePixelRatio()
}
class QIcon {
+QPixmap pixmap(int width, int height)
}
X11WindowPreviewContainer --> QApplication : uses
X11WindowPreviewContainer --> QIcon : uses
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.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `panels/dock/taskmanager/x11preview.cpp:773-774` </location>
<code_context>
} else {
// is (likely) icon name from theme
- pix = QIcon::fromTheme(stringData).pixmap(PREVIEW_TITLE_HEIGHT, PREVIEW_TITLE_HEIGHT);
+ const int scaledSize = PREVIEW_TITLE_HEIGHT * qApp->devicePixelRatio();
+ pix = QIcon::fromTheme(stringData).pixmap(scaledSize, scaledSize);
}
</code_context>
<issue_to_address>
**suggestion:** Consider using qRound or qCeil for scaledSize to avoid fractional pixel values.
Multiplying by devicePixelRatio() can produce non-integer values, which may cause issues with pixmap(). Applying qRound or qCeil will ensure scaledSize is always an integer, leading to more reliable rendering.
```suggestion
#include <QtMath>
const int scaledSize = qRound(PREVIEW_TITLE_HEIGHT * qApp->devicePixelRatio());
pix = QIcon::fromTheme(stringData).pixmap(scaledSize, scaledSize);
```
</issue_to_address>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这是一个关于窗口预览图标显示的改进,主要涉及高DPI显示的适配。让我来分析这个改动:
建议:
总的来说,这是一个很好的改进,主要解决了在高DPI显示器上图标模糊的问题,代码质量也有所提升。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, 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 |
fix: 为高DPI显示器缩放任务管理器预览图标
PMS: BUG-336089
Summary by Sourcery
Bug Fixes: