MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / setStrokeStyle

Method setStrokeStyle

app/src/UI/Widgets/PainterContext.cpp:583–613  ·  view source on GitHub ↗

* @brief Updates the stroke style. Accepts a CSS color string OR a gradient/pattern object. */

Source from the content-addressed store, hash-verified

581 * @brief Updates the stroke style. Accepts a CSS color string OR a gradient/pattern object.
582 */
583void Widgets::PainterContext::setStrokeStyle(const QJSValue& value)
584{
585 if (value.isString()) {
586 const QString spec = value.toString();
587 const QColor c = parseColor(spec);
588 if (!c.isValid())
589 return;
590
591 m_state.strokeSpec = spec;
592 m_state.strokeStyleValue = value;
593 m_state.strokePen.setColor(c);
594 m_state.strokePen.setBrush(QBrush(c));
595 rebindStrokeBrush();
596 return;
597 }
598
599 if (value.isQObject()) {
600 if (auto* g = qobject_cast<PainterGradient*>(value.toQObject())) {
601 m_state.strokePen.setBrush(g->brush());
602 m_state.strokeStyleValue = value;
603 rebindStrokeBrush();
604 return;
605 }
606 if (auto* p = qobject_cast<PainterPattern*>(value.toQObject())) {
607 m_state.strokePen.setBrush(p->brush());
608 m_state.strokeStyleValue = value;
609 rebindStrokeBrush();
610 return;
611 }
612 }
613}
614
615/**
616 * @brief Updates the line width.

Callers

nothing calls this directly

Calls 3

brushMethod · 0.80
isValidMethod · 0.45
setColorMethod · 0.45

Tested by

no test coverage detected