MCPcopy Create free account
hub / github.com/Liniyous/ElaWidgetTools / setThemeColor

Method setThemeColor

ElaWidgetTools/ElaTheme.cpp:52–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50 Q_D(ElaTheme);
51 const QRect body = widgetRect.marginsRemoved(shadowMargins);
52 const int shadowBorderWidth = qMax(qMax(shadowMargins.left(), shadowMargins.right()), qMax(shadowMargins.top(), shadowMargins.bottom()));
53 if (!painter || !painter->isActive() || shadowBorderWidth <= 0 || body.isEmpty() || alphaRatio <= 0)
54 {
55 return;
56 }
57 const qreal ratio = painter->device()->devicePixelRatioF();
58 const int radius = qBound(0, borderRadius, qMin(body.width(), body.height()) / 2);
59 // 圆角和模糊过渡保持原尺寸 仅拉伸直边 避免窗口缩放或卡片动画反复生成阴影
60 const int edge = radius + shadowBorderWidth;
61 const QSize bodySize(qMin(body.width(), 2 * edge + 1), qMin(body.height(), 2 * edge + 1));
62 const QSize size = bodySize + QSize(shadowMargins.left() + shadowMargins.right(), shadowMargins.top() + shadowMargins.bottom());
63 QPainterPath path;
64 path.addRoundedRect(QRectF(QPointF(shadowMargins.left(), shadowMargins.top()), bodySize), radius, radius);
65 const QPixmap shadow = d->_getShadowPixmap(path, size, ratio, shadowBorderWidth, qMax(qreal(1), alphaRatio), shadowColor);
66 const int horizontalEdge = qMin(edge, bodySize.width() / 2);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected