33void QQuickFusionDial::paint(QPainter *painter)
35 const int width = QQuickItem::width();
36 const int height = QQuickItem::height();
37 if (width <= 0 || height <= 0 || !isVisible())
40 const bool enabled = isEnabled();
41 qreal r = qMin(width, height) / 2.0;
43 const qreal penSize = r/20.0;
45 painter->setRenderHint(QPainter::Antialiasing);
47 const qreal d_ = r / 6;
48 const qreal dx = d_ + (width - 2 * r) / 2 + 1;
49 const qreal dy = d_ + (height - 2 * r) / 2 + 1;
51 QRectF br = QRectF(dx + 0.5, dy + 0.5,
52 int(r * 2 - 2 * d_ - 2),
53 int(r * 2 - 2 * d_ - 2));
54 QColor buttonColor = QQuickItemPrivate::get(
this)->palette()->button().toHsv();
55 buttonColor.setHsv(buttonColor .hue(),
56 qMin(140, buttonColor .saturation()),
57 qMax(180, buttonColor.value()));
61 qreal shadowSize = qMax(1.0, penSize/2.0);
62 QRectF shadowRect= br.adjusted(-2*shadowSize, -2*shadowSize,
63 2*shadowSize, 2*shadowSize);
64 QRadialGradient shadowGradient(shadowRect.center().x(),
65 shadowRect.center().y(), shadowRect.width()/2.0,
66 shadowRect.center().x(), shadowRect.center().y());
67 shadowGradient.setColorAt(qreal(0.91), QColor(0, 0, 0, 40));
68 shadowGradient.setColorAt(qreal(1.0), Qt::transparent);
69 painter->setBrush(shadowGradient);
70 painter->setPen(Qt::NoPen);
71 painter->translate(shadowSize, shadowSize);
72 painter->drawEllipse(shadowRect);
73 painter->translate(-shadowSize, -shadowSize);
76 QRadialGradient gradient(br.center().x() - br.width()/3, dy,
77 br.width()*1.3, br.center().x(),
78 br.center().y() - br.height()/2);
79 gradient.setColorAt(0, buttonColor.lighter(110));
80 gradient.setColorAt(qreal(0.5), buttonColor);
81 gradient.setColorAt(qreal(0.501), buttonColor.darker(102));
82 gradient.setColorAt(1, buttonColor.darker(115));
83 painter->setBrush(gradient);
85 painter->setBrush(Qt::NoBrush);
88 painter->setPen(QPen(buttonColor.darker(280)));
89 painter->drawEllipse(br);
90 painter->setBrush(Qt::NoBrush);
91 painter->setPen(buttonColor.lighter(110));
92 painter->drawEllipse(br.adjusted(1, 1, -1, -1));
95 QColor highlight = QQuickItemPrivate::get(
this)->palette()->highlight().toHsv();
96 highlight.setHsv(highlight.hue(),
97 qMin(160, highlight.saturation()),
98 qMax(230, highlight.value()));
99 highlight.setAlpha(127);
100 painter->setPen(QPen(highlight, 2.0));
101 painter->setBrush(Qt::NoBrush);
102 painter->drawEllipse(br.adjusted(-1, -1, 1, 1));