#include "flagpainter.h" #include #include void FlagPainter::draw(QPainter* p, uint8_t flags, int x, int y, int sz) { if (!flags) return; int cx = x; if (flags & MEMBER_FLAG_SUPERNODE) { drawLightning(p, cx, y, sz); cx += sz + 2; } if (flags & MEMBER_FLAG_ADMIN) { drawStar(p, cx, y, sz); cx += sz + 2; } if (flags & MEMBER_FLAG_MODER) { drawShield(p, cx, y, sz); cx += sz + 2; } } void FlagPainter::drawLightning(QPainter* p, int x, int y, int sz) { p->save(); p->setRenderHint(QPainter::Antialiasing); QPainterPath path; qreal cx = x + sz / 2.0, t = y + 1.0, b = y + sz - 1.0; path.moveTo(cx, t); path.lineTo(cx - sz * 0.3, t + sz * 0.55); path.lineTo(cx - sz * 0.05, t + sz * 0.5); path.lineTo(cx + sz * 0.15, b); path.lineTo(cx + sz * 0.1, t + sz * 0.55); path.lineTo(cx + sz * 0.35, t + sz * 0.4); path.closeSubpath(); p->setPen(Qt::NoPen); p->setBrush(QColor("#FFC107")); p->drawPath(path); p->restore(); } void FlagPainter::drawStar(QPainter* p, int x, int y, int sz) { p->save(); p->setRenderHint(QPainter::Antialiasing); QPainterPath path; qreal cx = x + sz / 2.0, cy = y + sz / 2.0, r = sz / 2.0 - 1.0; for (int i = 0; i < 10; i++) { qreal a = (i * 36.0 - 90.0) * 3.14159265 / 180.0; qreal rr = (i & 1) ? r * 0.42 : r; qreal px = cx + rr * cos(a), py = cy + rr * sin(a); if (i == 0) path.moveTo(px, py); else path.lineTo(px, py); } path.closeSubpath(); p->setPen(QPen(QColor("#E65100"), 0.5)); p->setBrush(QColor("#FFD700")); p->drawPath(path); p->restore(); } void FlagPainter::drawShield(QPainter* p, int x, int y, int sz) { p->save(); p->setRenderHint(QPainter::Antialiasing); QPainterPath path; qreal cx = x + sz / 2.0, t = y + 1.0, b = y + sz - 1.0; qreal w = sz * 0.38; qreal notch = sz * 0.22; path.moveTo(cx - w, t); path.lineTo(cx - w, t + notch); path.lineTo(cx - w * 0.3, t + notch + 1); path.lineTo(cx, b); path.lineTo(cx + w * 0.3, t + notch + 1); path.lineTo(cx + w, t + notch); path.lineTo(cx + w, t); path.closeSubpath(); p->setPen(QPen(QColor("#1565C0"), 0.8)); p->setBrush(QColor("#2196F3")); p->drawPath(path); p->restore(); } void FlagPainter::drawStorage(QPainter* p, int x, int y, int sz) { p->save(); p->setRenderHint(QPainter::Antialiasing); qreal cx = x + sz / 2.0, t = y + 1.0, b = y + sz - 1.0; qreal w = sz * 0.36, gap = sz * 0.20; QPainterPath path; path.moveTo(cx - w, t); path.lineTo(cx + w, t); path.lineTo(cx + w, b); path.lineTo(cx - w, b); path.closeSubpath(); p->setPen(QPen(QColor("#37474F"), 0.8)); p->setBrush(QColor("#78909C")); p->drawPath(path); p->setBrush(QColor("#ECEFF1")); p->drawEllipse(QPointF(cx, t), w, gap); p->drawEllipse(QPointF(cx, b), w, gap); p->restore(); }