Skip to content

Commit

Permalink
sync: from linuxdeepin/qt5integration
Browse files Browse the repository at this point in the history
Synchronize source files from linuxdeepin/qt5integration.

Source-pull-request: linuxdeepin/qt5integration#215
  • Loading branch information
deepin-ci-robot committed Mar 20, 2024
1 parent 287e168 commit 31f2084
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions styleplugins/chameleon/chameleonstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,41 +864,50 @@ void ChameleonStyle::drawControl(QStyle::ControlElement element, const QStyleOpt
scrollBarRectCenter.setX((scrollBar->rect.x() + scrollBar->rect.width()) / 2);
scrollBarRectCenter.setY(scrollBar->rect.y() + scrollBar->rect.height() / 2);
rect.moveCenter(scrollBarRectCenter);
rect.moveRight(scrollBar->rect.right() - 2);
rect.moveRight(scrollBar->rect.right() - 1);
}

QColor lineColor(opt->palette.color(QPalette::Base));
if (DGuiApplicationHelper::toColorType(lineColor) == DGuiApplicationHelper::LightType) {
// 外侧拓展一个像素的outside border
p->setPen(QPen(QColor(255, 255, 255, 0.1 * 255), Metrics::Painter_PenWidth));
p->setBrush(Qt::NoBrush);
p->drawRoundedRect(rect.adjusted(-1, -1, 1, 1),
realRadius, realRadius);
// 内侧绘制一个像素的inside border
p->setPen(QPen(QColor(0, 0, 0, 0.05 * 255), Metrics::Painter_PenWidth));
p->setPen(QPen(QColor(0, 0, 0, 0.1 * 255), Metrics::Painter_PenWidth));
p->drawRoundedRect(rect.adjusted(1, 1, -1, -1),
realRadius, realRadius);
// normal状态
p->setBrush(QColor(0, 0, 0, 0.3 * 255));
p->setBrush(QColor(0, 0, 0, 0.5 * 255));

if (scrollBar->state & QStyle::State_MouseOver)
// hover 状态
p->setBrush(QColor(0, 0, 0, 0.6 * 255));
p->setBrush(QColor(0, 0, 0, 0.7 * 255));
if (scrollBar->state & QStyle::State_Sunken)
// active状态
p->setBrush(QColor(0, 0, 0, 0.5 * 255));
p->setBrush(QColor(0, 0, 0, 0.6 * 255));
} else {
// 外侧拓展一个像素的outside border
p->setPen(QPen(QColor(0, 0, 0, 0.2 * 255), Metrics::Painter_PenWidth));
p->setPen(QPen(QColor(0, 0, 0, 0.1 * 255), Metrics::Painter_PenWidth));
p->setBrush(Qt::NoBrush);
p->drawRoundedRect(rect.adjusted(-1, -1, 1, 1),
realRadius, realRadius);
// 内侧绘制一个像素的inside border
p->setPen(QPen(QColor(255, 255, 255, 0.05 * 255), Metrics::Painter_PenWidth));
p->setPen(QPen(QColor(255, 255, 255, 0.1 * 255), Metrics::Painter_PenWidth));
p->drawRoundedRect(rect.adjusted(1, 1, -1, -1),
realRadius, realRadius);
// normal状态
p->setBrush(QColor(96, 96, 96, 0.7 * 255));
p->setBrush(QColor(255, 255, 255, 0.2 * 255));

if (scrollBar->state & QStyle::State_MouseOver)
// hover 状态
p->setBrush(QColor(96, 96, 96, 0.8 * 255));
p->setBrush(QColor(255, 255, 255, 0.5 * 255));
if (scrollBar->state & QStyle::State_Sunken)
// active状态
p->setBrush(QColor(112, 112, 112, 0.8 * 255));
p->setBrush(QColor(255, 255, 255, 0.4 * 255));
}

p->setPen(Qt::NoPen);
p->drawRoundedRect(rect, realRadius, realRadius);
p->restore();
}
Expand Down Expand Up @@ -2954,8 +2963,8 @@ bool ChameleonStyle::drawMenuItem(const QStyleOptionMenuItem *option, QPainter *

if (checkable) {
checkRect.setLeft(frameRadius);
checkRect.setWidth(smallIconSize);
checkRect.setHeight(smallIconSize);
checkRect.setWidth(smallIconSize - 2);
checkRect.setHeight(smallIconSize - 4);
checkRect.moveCenter(QPoint(checkRect.left() + smallIconSize / 2, menuItem->rect.center().y()));
painter->setRenderHint(QPainter::Antialiasing);

Expand Down Expand Up @@ -4358,7 +4367,8 @@ void ChameleonStyle::polish(QWidget *w)
handle.setEnableBlurWindow(true);

DPlatformTheme *theme = DGuiApplicationHelper::instance()->applicationTheme();
setWindowRadius(w, qMax(0, qMin(theme->windowRadius(), 18)));
if (theme->isValid())
setWindowRadius(w, qMax(0, qMin(theme->windowRadius(), 18)));

connect(theme, &DPlatformTheme::windowRadiusChanged, w, [w](int r){
setWindowRadius(w, qMax(0, qMin(r, 18)));
Expand Down

0 comments on commit 31f2084

Please sign in to comment.