175 int width = dial->rect.width();
176 int height = dial->rect.height();
177 qreal r = qMin(width, height) / 2;
180 qreal xc = width / 2 + 0.5;
181 qreal yc = height / 2 + 0.5;
190 notches = (maximum + ns - 1 - dial
->minimum) / ns;
193 poly.resize(2 + 2 * notches);
194 int smallLineSize = bigLineSize / 2;
195 for (
int i = 0; i <= notches; ++i) {
196 qreal angle = dial->dialWrapping ? Q_PI * 3 / 2 - i * 2 * Q_PI / notches
197 : (Q_PI * 8 - i * 10 * Q_PI / notches) / 6;
198 qreal s = qSin(angle);
199 qreal c = qCos(angle);
201 poly[2 * i] = QPointF(xc + (r - bigLineSize) * c,
202 yc - (r - bigLineSize) * s);
203 poly[2 * i + 1] = QPointF(xc + r * c, yc - r * s);
205 poly[2 * i] = QPointF(xc + (r - 1 - smallLineSize) * c,
206 yc - (r - 1 - smallLineSize) * s);
207 poly[2 * i + 1] = QPointF(xc + (r - 1) * c, yc -(r - 1) * s);
218 QPalette pal = option->palette;
219 const int width = option->rect.width();
220 const int height = option->rect.height();
222 qreal r = qMin(width, height) / 2;
224 const qreal penSize = r/20.0;
227 painter->setRenderHint(QPainter::Antialiasing);
230 if (option->subControls & QStyle::SC_DialTickmarks) {
231 painter->setPen(option->palette.dark().color().darker(120));
232 painter->drawLines(QStyleHelper::calcLines(option));
237 QColor buttonColor = pal.button().color().toHsv();
238 buttonColor.setHsv(buttonColor .hue(),
239 qMin(140, buttonColor .saturation()),
240 qMax(180, buttonColor.value()));
244 p->setRenderHint(QPainter::Antialiasing);
246 const qreal d_ = r / 6;
247 const qreal dx = option->rect.x() + d_ + (width - 2 * r) / 2 + 1;
248 const qreal dy = option->rect.y() + d_ + (height - 2 * r) / 2 + 1;
250 QRectF br = QRectF(dx + 0.5, dy + 0.5,
251 int(r * 2 - 2 * d_ - 2),
252 int(r * 2 - 2 * d_ - 2));
256 qreal shadowSize = qMax(1.0, penSize/2.0);
257 QRectF shadowRect= br.adjusted(-2*shadowSize, -2*shadowSize,
258 2*shadowSize, 2*shadowSize);
259 QRadialGradient shadowGradient(shadowRect.center().x(),
260 shadowRect.center().y(), shadowRect.width()/2.0,
261 shadowRect.center().x(), shadowRect.center().y());
262 shadowGradient.setColorAt(qreal(0.91), QColor(0, 0, 0, 40));
263 shadowGradient.setColorAt(qreal(1.0), Qt::transparent);
264 p->setBrush(shadowGradient);
265 p->setPen(Qt::NoPen);
266 p->translate(shadowSize, shadowSize);
267 p->drawEllipse(shadowRect);
268 p->translate(-shadowSize, -shadowSize);
271 QRadialGradient gradient(br.center().x() - br.width()/3, dy,
272 br.width()*1.3, br.center().x(),
273 br.center().y() - br.height()/2);
274 gradient.setColorAt(0, buttonColor.lighter(110));
275 gradient.setColorAt(qreal(0.5), buttonColor);
276 gradient.setColorAt(qreal(0.501), buttonColor.darker(102));
277 gradient.setColorAt(1, buttonColor.darker(115));
278 p->setBrush(gradient);
280 p->setBrush(Qt::NoBrush);
283 p->setPen(QPen(buttonColor.darker(280)));
285 p->setBrush(Qt::NoBrush);
286 p->setPen(buttonColor.lighter(110));
287 p->drawEllipse(br.adjusted(1, 1, -1, -1));
290 QColor highlight = pal.highlight().color().toHsv();
291 highlight.setHsv(highlight.hue(),
292 qMin(160, highlight.saturation()),
293 qMax(230, highlight.value()));
294 highlight.setAlpha(127);
295 p->setPen(QPen(highlight, 2.0));
296 p->setBrush(Qt::NoBrush);
297 p->drawEllipse(br.adjusted(-1, -1, 1, 1));
302 QPointF dp = calcRadialPos(option, qreal(0.70));
303 buttonColor = buttonColor.lighter(104);
304 buttonColor.setAlphaF(0.8f);
305 const qreal ds = r/qreal(7.0);
306 QRectF dialRect(dp.x() - ds, dp.y() - ds, 2*ds, 2*ds);
307 QRadialGradient dialGradient(dialRect.center().x() + dialRect.width()/2,
308 dialRect.center().y() + dialRect.width(),
310 dialRect.center().x(), dialRect.center().y());
311 dialGradient.setColorAt(1, buttonColor.darker(140));
312 dialGradient.setColorAt(qreal(0.4), buttonColor.darker(120));
313 dialGradient.setColorAt(0, buttonColor.darker(110));
315 painter->setPen(QPen(QColor(0, 0, 0, 25), penSize));
316 painter->drawLine(calcRadialPos(option, qreal(0.90)), calcRadialPos(option, qreal(0.96)));
319 painter->setBrush(dialGradient);
320 painter->setPen(QColor(255, 255, 255, 150));
321 painter->drawEllipse(dialRect.adjusted(-1, -1, 1, 1));
322 painter->setPen(QColor(0, 0, 0, 80));
323 painter->drawEllipse(dialRect);
328 int left,
int top,
int right,
331 QSize size = pixmap.size();
336 painter->drawPixmap(QRect(rect.left() + left, rect.top(), rect.width() -right - left, top), pixmap,
337 QRect(left, 0, size.width() -right - left, top));
341 painter->drawPixmap(QRect(rect.left(), rect.top(), left, top), pixmap,
342 QRect(0, 0, left, top));
346 painter->drawPixmap(QRect(rect.left() + rect.width() - right, rect.top(), right, top), pixmap,
347 QRect(size.width() - right, 0, right, top));
352 painter->drawPixmap(QRect(rect.left(), rect.top()+top, left, rect.height() - top - bottom), pixmap,
353 QRect(0, top, left, size.height() - bottom - top));
356 painter->drawPixmap(QRect(rect.left() + left, rect.top()+top, rect.width() -right - left,
357 rect.height() - bottom - top), pixmap,
358 QRect(left, top, size.width() -right -left,
359 size.height() - bottom - top));
362 painter->drawPixmap(QRect(rect.left() +rect.width() - right, rect.top()+top, right, rect.height() - top - bottom), pixmap,
363 QRect(size.width() - right, top, right, size.height() - bottom - top));
367 painter->drawPixmap(QRect(rect.left() +left, rect.top() + rect.height() - bottom,
368 rect.width() - right - left, bottom), pixmap,
369 QRect(left, size.height() - bottom,
370 size.width() - right - left, bottom));
373 painter->drawPixmap(QRect(rect.left(), rect.top() + rect.height() - bottom, left, bottom), pixmap,
374 QRect(0, size.height() - bottom, left, bottom));
378 painter->drawPixmap(QRect(rect.left() + rect.width() - right, rect.top() + rect.height() - bottom, right, bottom), pixmap,
379 QRect(size.width() - right, size.height() - bottom, right, bottom));