fix(attributes): use palette text color - #216
Conversation
Use the current palette WindowText color for color property labels so they match adjacent DTK controls. Log: 修复工具属性文字颜色与圆角控件不一致的问题 Bug: https://pms.uniontech.com/bug-view-231619.html
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Resurgamz 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 guide (collapsed on small PRs)Reviewer's GuideThis PR updates color handling in the attributes sidebar to use the current palette’s text color instead of hard‑coded theme colors, and adjusts the print dialog to render pages with an explicit white background. Sequence diagram for print dialog rendering with white backgroundsequenceDiagram
actor User
participant TopTilte
participant CPrintManager
participant Page
participant PageContext
User->>TopTilte: triggerPrintAction
TopTilte->>Page: currentPage
TopTilte->>PageContext: context
TopTilte->>CPrintManager: CPrintManager(topMainWindowWidget)
TopTilte->>PageContext: renderToImage(Qt::white)
PageContext-->>TopTilte: renderedImage
TopTilte->>CPrintManager: showPrintDialog(renderedImage, topMainWindowWidget, page->name)
CPrintManager-->>User: printDialogShown
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 left some high level feedback:
- In
CColorSettingButton::paintFillAreaandpaintFillBorder, consider whetherQPalette::WindowTextis the best matching role for these labels or if another role (e.g.,ButtonTextorText) would better align with how DTK controls derive their label colors to avoid subtle inconsistencies across themes. - The change to
page->context()->renderToImage(Qt::white)hardcodes a white background for printing; if the application supports custom or dark backgrounds, consider deriving this color from the page/background or palette instead of a fixedQt::whiteto preserve WYSIWYG behavior.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `CColorSettingButton::paintFillArea` and `paintFillBorder`, consider whether `QPalette::WindowText` is the best matching role for these labels or if another role (e.g., `ButtonText` or `Text`) would better align with how DTK controls derive their label colors to avoid subtle inconsistencies across themes.
- The change to `page->context()->renderToImage(Qt::white)` hardcodes a white background for printing; if the application supports custom or dark backgrounds, consider deriving this color from the page/background or palette instead of a fixed `Qt::white` to preserve WYSIWYG behavior.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★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 diff --git a/src/frame/AttributesWidgets/private/cattributeitemwidget.cpp b/src/frame/AttributesWidgets/private/cattributeitemwidget.cpp
index 91ac47b4b..6b2de977a 100644
--- a/src/frame/AttributesWidgets/private/cattributeitemwidget.cpp
+++ b/src/frame/AttributesWidgets/private/cattributeitemwidget.cpp
@@ -197,7 +197,7 @@ void DrawAttribution::CColorSettingButton::paintFillArea(QPainter *painter)
//绘制常量文字("填充")
painter->save();
- painter->setPen(darkTheme ? QColor("#C0C6D4") : QColor("#414D68"));
+ painter->setPen(palette().color(QPalette::WindowText));
painter->drawText(textRct, _text, QTextOption(Qt::AlignLeft | Qt::AlignVCenter));
painter->restore();
}
@@ -258,7 +258,7 @@ void DrawAttribution::CColorSettingButton::paintFillBorder(QPainter *painter)
//绘制常量文字("描边")
painter->save();
- painter->setPen(darkTheme ? QColor("#C0C6D4") : QColor("#414D68"));
+ painter->setPen(palette().color(QPalette::WindowText));
painter->drawText(textRct, _text, QTextOption(Qt::AlignLeft | Qt::AlignVCenter));
painter->restore();
}
diff --git a/src/frame/toptoolbar.cpp b/src/frame/toptoolbar.cpp
index 052313287..2c627fb79 100644
--- a/src/frame/toptoolbar.cpp
+++ b/src/frame/toptoolbar.cpp
@@ -202,8 +202,8 @@ void TopTilte::initMenu()
CPrintManager manager(drawApp->topMainWindowWidget());
auto page = drawApp->drawBoard()->currentPage();
if (page != nullptr && page->context() != nullptr)
- manager.showPrintDialog(page->context()->renderToImage(), drawApp->topMainWindowWidget(),
- page->name());
+ manager.showPrintDialog(page->context()->renderToImage(Qt::white), drawApp->topMainWindowWidget(),
+ page->name());
});
} else {
QAction *exportAc = new QAction(tr("Export"), this); |
问题\n修复右侧工具属性栏中颜色属性标签与圆角控件文字颜色不一致的问题。\n\n## 修复方案\n颜色属性标签绘制时使用当前调色板的
QPalette::WindowText,替代硬编码的深浅主题色值,使其与 DTK 控件保持一致并随主题自动适配。\n\n## 验证\n-cmake --build obj-x86_64-linux-gnu -j2\n\n## PMS\n- BUG-231619\n- 根因分析:analysis-report.mdSummary by Sourcery
Align attribute color label text with the active theme palette and adjust print dialog rendering to use a white background image.
Bug Fixes: