Skip to content

Commit b7c8c5f

Browse files
fix(text): Sync text color with theme highlight color in pressed state
When ToolButton is in pressed (isSunken) state, the icon already changes to the theme highlight color, but the text remains unchanged. This causes inconsistent visual feedback between the icon and text. Now both icon and text use palette().highlight().color() in pressed state, providing a unified user experience across all theme modes. bug: https://pms.uniontech.com/bug-view-356023.html
1 parent 36d3c2b commit b7c8c5f

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ AI config
1010
.cursor/
1111
.cursorindexingignore
1212
.specstory/
13-
.vscode/
13+
.vscode/
14+
.npm-cache/
15+
.claude/

src/widgets/toolbutton.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,14 @@ void ToolButton::paintEvent(QPaintEvent *event)
272272
ip.setCompositionMode(QPainter::CompositionMode_SourceIn);
273273
ip.fillRect(tinted.rect(), palette().highlight().color());
274274
ip.end();
275-
275+
276276
opt.icon = QIcon(tinted);
277277
}
278+
// 设置文字为主题色
279+
opt.palette.setColor(QPalette::ButtonText, palette().highlight().color());
280+
opt.palette.setColor(QPalette::WindowText, palette().highlight().color());
281+
opt.palette.setColor(QPalette::Text, palette().highlight().color());
282+
278283
opt.state &= ~QStyle::State_MouseOver;
279284
opt.state &= ~QStyle::State_Sunken;
280285
style()->drawControl(QStyle::CE_ToolButtonLabel, &opt, &p, this);

0 commit comments

Comments
 (0)