@@ -3076,12 +3076,14 @@ bool ChameleonStyle::drawMenuBarItem(const QStyleOptionMenuItem *option, QRect &
3076
3076
ChameleonMovementAnimation *ChameleonStyle::drawMenuItemBackground (const QStyleOption *option, QPainter *painter, QStyleOptionMenuItem::MenuItemType type) const
3077
3077
{
3078
3078
QBrush color;
3079
+ constexpr int margin = 6 ; // margin of MenuItem's bounding.
3080
+ const auto rect = option->rect .marginsRemoved (QMargins (margin, 0 , margin, 0 ));
3079
3081
bool selected = (option->state & QStyle::State_Enabled) && option->state & QStyle::State_Selected;
3080
3082
if (selected && (DGuiApplicationHelper::isTabletEnvironment () ||
3081
3083
!DGuiApplicationHelper::isSpecialEffectsEnvironment ())) {
3082
3084
painter->setPen (Qt::NoPen);
3083
3085
painter->setBrush (getColor (option, QPalette::Highlight));
3084
- painter->drawRect (option-> rect );
3086
+ painter->drawRect (rect);
3085
3087
return nullptr ;
3086
3088
}
3087
3089
@@ -3117,7 +3119,7 @@ ChameleonMovementAnimation *ChameleonStyle::drawMenuItemBackground(const QStyleO
3117
3119
colorSeparator = QColor (255 , 255 , 255 , 255 * 0.05 );
3118
3120
else
3119
3121
colorSeparator = QColor (0 , 0 , 0 , 255 * 0.1 );
3120
- painter->fillRect (option-> rect , colorSeparator);
3122
+ painter->fillRect (rect, colorSeparator);
3121
3123
}
3122
3124
3123
3125
if (!option->styleObject )
@@ -3143,7 +3145,7 @@ ChameleonMovementAnimation *ChameleonStyle::drawMenuItemBackground(const QStyleO
3143
3145
}
3144
3146
3145
3147
if (selected)
3146
- animation->setTargetRect (option-> rect );
3148
+ animation->setTargetRect (rect);
3147
3149
}
3148
3150
const int round = 6 ;
3149
3151
if (animation && animation->isRuning ()) {
@@ -3153,6 +3155,7 @@ ChameleonMovementAnimation *ChameleonStyle::drawMenuItemBackground(const QStyleO
3153
3155
painter->setOpacity (1.0 );
3154
3156
painter->setBrush (color);
3155
3157
painter->setPen (Qt::NoPen);
3158
+ painter->setRenderHint (QPainter::Antialiasing);
3156
3159
painter->drawRoundedRect (animation->currentRect (), round, round);
3157
3160
painter->setOpacity (opacity);
3158
3161
painter->restore ();
@@ -3162,7 +3165,8 @@ ChameleonMovementAnimation *ChameleonStyle::drawMenuItemBackground(const QStyleO
3162
3165
painter->save ();
3163
3166
painter->setBrush (color);
3164
3167
painter->setPen (Qt::NoPen);
3165
- painter->drawRoundedRect (option->rect , round, round);
3168
+ painter->setRenderHint (QPainter::Antialiasing);
3169
+ painter->drawRoundedRect (rect, round, round);
3166
3170
painter->restore ();
3167
3171
}
3168
3172
}
@@ -4496,7 +4500,7 @@ int ChameleonStyle::pixelMetric(QStyle::PixelMetric m, const QStyleOption *opt,
4496
4500
case PM_MenuVMargin:
4497
4501
return 8 ;
4498
4502
case PM_MenuHMargin:
4499
- return 6 ;
4503
+ return 0 ;
4500
4504
default :
4501
4505
break ;
4502
4506
}
0 commit comments