Skip to content

Commit 4cc5cd9

Browse files
committed
fix: clear DCi icon state when setting other icon types
Fixed an issue where DCi icon state was not properly cleared when setting other icon types (QIcon, QStyle::StandardPixmap, DStyle::StandardPixmap). This could cause incorrect icon rendering when switching between different icon types. The changes ensure that when setting a non-DCi icon, the DCi icon state is properly reset to avoid conflicts between different icon systems. When setting a DCi icon, the QAbstractButton icon is cleared to prevent interference. Log: Fixed icon display issues when switching between different icon types Influence: 1. Test switching between QIcon, standard pixmap icons, and DCi icons 2. Verify icons display correctly after type changes 3. Test button appearance in different states (normal, hover, pressed) 4. Check icon rendering consistency across different button types fix: 设置其他图标类型时正确清除 DCi 图标状态 修复了在设置其他图标类型(QIcon、QStyle::StandardPixmap、 DStyle::StandardPixmap)时未正确清除 DCi 图标状态的问题。这可能导致在不 同图标类型之间切换时出现错误的图标渲染。 这些更改确保在设置非 DCi 图标时,DCi 图标状态被正确重置,以避免不同图 标系统之间的冲突。当设置 DCi 图标时,QAbstractButton 图标被清除以防止 干扰。 Log: 修复在不同图标类型之间切换时的图标显示问题 Influence: 1. 测试在 QIcon、标准像素图标和 DCi 图标之间的切换 2. 验证类型更改后图标正确显示 3. 测试按钮在不同状态(正常、悬停、按下)下的外观 4. 检查不同按钮类型之间的图标渲染一致性 PMS: BUG-337027
1 parent 93b3065 commit 4cc5cd9

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/widgets/dbuttonbox.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ void DButtonBoxButton::setIcon(const QIcon &icon)
125125
D_D(DButtonBoxButton);
126126

127127
d->iconType = -1;
128+
d->dciIcon = DDciIcon();
128129
QAbstractButton::setIcon(icon);
129130
}
130131

@@ -140,6 +141,7 @@ void DButtonBoxButton::setIcon(QStyle::StandardPixmap iconType)
140141
D_D(DButtonBoxButton);
141142

142143
d->iconType = iconType;
144+
d->dciIcon = DDciIcon();
143145
QAbstractButton::setIcon(style()->standardIcon(iconType, nullptr, this));
144146
}
145147

@@ -154,6 +156,7 @@ void DButtonBoxButton::setIcon(DStyle::StandardPixmap iconType)
154156
{
155157
D_D(DButtonBoxButton);
156158

159+
d->dciIcon = DDciIcon();
157160
d->iconType = iconType;
158161
QAbstractButton::setIcon(DStyleHelper(style()).standardIcon(iconType, nullptr, this));
159162
}
@@ -163,6 +166,7 @@ void DButtonBoxButton::setIcon(const DDciIcon &icon)
163166
D_D(DButtonBoxButton);
164167

165168
d->dciIcon = icon;
169+
QAbstractButton::setIcon(QIcon());
166170
}
167171

168172
DDciIcon DButtonBoxButton::dciIcon() const

src/widgets/diconbutton.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ void DIconButton::setIcon(const QIcon &icon)
6969
{
7070
D_D(DIconButton);
7171

72+
d->dciIcon = DDciIcon();
7273
d->iconType = -1;
7374
QAbstractButton::setIcon(icon);
7475
}
@@ -82,6 +83,7 @@ void DIconButton::setIcon(QStyle::StandardPixmap iconType)
8283
{
8384
D_D(DIconButton);
8485

86+
d->dciIcon = DDciIcon();
8587
d->iconType = iconType;
8688
QAbstractButton::setIcon(style()->standardIcon(iconType, nullptr, this));
8789
}
@@ -95,6 +97,7 @@ void DIconButton::setIcon(DStyle::StandardPixmap iconType)
9597
{
9698
D_D(DIconButton);
9799

100+
d->dciIcon = DDciIcon();
98101
d->iconType = iconType;
99102
QAbstractButton::setIcon(DStyleHelper(style()).standardIcon(iconType, nullptr, this));
100103
}
@@ -105,6 +108,7 @@ void DIconButton::setIcon(const DDciIcon &icon)
105108

106109
d->iconType = -1;
107110
d->dciIcon = icon;
111+
QAbstractButton::setIcon(QIcon());
108112
this->update();
109113
this->updateGeometry();
110114
}

0 commit comments

Comments
 (0)