Skip to content
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

menu item and slider style tweak #242

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions styleplugins/chameleon/chameleonstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2808,7 +2808,18 @@ void ChameleonStyle::drawMenuItemBackground(const QStyleOption *option, QPainter
}
}

painter->fillRect(option->rect, color);
painter->setBrush(color);
painter->setPen(Qt::NoPen);
painter->setRenderHint(QPainter::Antialiasing);

const int radius = DStyle::pixelMetric(PM_FrameRadius);
constexpr int margin = 6;

if (qobject_cast<QMenu *>(option->styleObject))
painter->drawRoundedRect(option->rect, radius, radius);
else
painter->drawRoundedRect(option->rect.marginsRemoved(QMargins(margin, 0, margin, 0)), radius, radius);

} else {
color = option->palette.window().color();

Expand All @@ -2833,8 +2844,6 @@ void ChameleonStyle::drawMenuItemBackground(const QStyleOption *option, QPainter
color = c;
}

painter->fillRect(option->rect, color);

if (type == QStyleOptionMenuItem::Separator) {
QColor colorSeparator;
DGuiApplicationHelper *guiAppHelp = DGuiApplicationHelper::instance();
Expand Down Expand Up @@ -3396,7 +3405,7 @@ void ChameleonStyle::drawComplexControl(QStyle::ComplexControl cc, const QStyleO
p->setPen(pen);
p->setRenderHint(QPainter::Antialiasing);

QColor color = getColor(opt, DPalette::ObviousBackground, w); //绘画的右侧/上侧的滑槽颜色一定是灰
QColor color = adjustColor(getColor(opt, DPalette::ObviousBackground, w), 0, 0, 0, 0, 0, 0, +15); //绘画的右侧/上侧的滑槽颜色一定是灰

// 属性启用灰色滑槽
QVariant prop = dslider ? const_cast<DSlider *>(dslider)->slider()->property("_d_dtk_sldier_across") : QVariant();
Expand Down Expand Up @@ -4196,7 +4205,7 @@ int ChameleonStyle::pixelMetric(QStyle::PixelMetric m, const QStyleOption *opt,
case PM_MenuVMargin:
return 8;
case PM_MenuHMargin:
return 0;
return 8;
Whale107 marked this conversation as resolved.
Show resolved Hide resolved
default:
break;
}
Expand Down
Loading