Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickstyleitemdial.cpp
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
7
12
26
28{
29 QStyleOptionSlider styleOption;
30 initStyleOption(styleOption);
31
32 StyleItemGeometry geometry;
33 geometry.minimumSize = style()->sizeFromContents(QStyle::CT_Dial, &styleOption, QSize(0, 0));
34 geometry.implicitSize = geometry.minimumSize;
35 geometry.layoutRect = style()->subElementRect(QStyle::SE_SliderLayoutItem, &styleOption);
36 geometry.ninePatchMargins = style()->ninePatchMargins(QStyle::CC_Dial, &styleOption, geometry.minimumSize);
37 geometry.focusFrameRadius = style()->pixelMetric(QStyle::PM_DialFocusFrameRadius, &styleOption);
38
39 return geometry;
40}
41
43{
44 QStyleOptionSlider styleOption;
45 initStyleOption(styleOption);
46 style()->drawComplexControl(QStyle::CC_Dial, &styleOption, painter);
47}
48
49void QQuickStyleItemDial::initStyleOption(QStyleOptionSlider &styleOption) const
50{
51 initStyleOptionBase(styleOption);
52 auto dial = control<QQuickDial>();
53
56 styleOption.tickInterval = dial->stepSize();
57 styleOption.dialWrapping = dial->wrap();
58 styleOption.upsideDown = true;
59 styleOption.startAngle = dial->startAngle();
60 styleOption.endAngle = dial->endAngle();
61
62 if (dial->isPressed())
63 styleOption.state |= QStyle::State_Sunken;
64
65 if (dial->stepSize() == 0) {
66 styleOption.minimum = 0;
67 styleOption.maximum = 10000;
68 styleOption.sliderPosition = dial->position() * styleOption.maximum;
69 } else {
70 styleOption.minimum = dial->from();
71 styleOption.maximum = dial->to();
72 styleOption.sliderPosition = dial->value();
73 }
74
75 // TODO: add proper API for tickmarks
76 const int index = dial->metaObject()->indexOfProperty("qqc2_style_tickPosition");
77 if (index != -1) {
78 const int tickPosition = dial->metaObject()->property(index).read(dial).toInt();
79 styleOption.tickPosition = QStyleOptionSlider::TickPosition(tickPosition);
82 }
83
84}
85
87
88#include "moc_qquickstyleitemdial.cpp"
\reentrant
Definition qfont.h:22
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
QStyle::SubControls subControls
QStyle::SubControls activeSubControls
void valueChanged()
void stepSizeChanged()
void positionChanged()
void pressedChanged()
void toChanged()
void fromChanged()
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
StyleItemGeometry calculateGeometry() override
QFont styleFont(QQuickItem *control) const override
void paintEvent(QPainter *painter) const override
void connectToControl() const override
virtual void connectToControl() const
static QStyle::State controlSize(QQuickItem *item)
void initStyleOptionBase(QStyleOption &styleOption) const
QQuickItem * control
static QStyle * style()
\inmodule QtCore
Definition qsize.h:25
@ State_Sunken
Definition qstyle.h:69
@ CE_ProgressBarLabel
Definition qstyle.h:188
@ CC_Dial
Definition qstyle.h:338
@ SE_SliderLayoutItem
Definition qstyle.h:296
@ SC_SliderGroove
Definition qstyle.h:369
@ SC_DialTickmarks
Definition qstyle.h:388
@ SC_None
Definition qstyle.h:348
@ SC_SliderHandle
Definition qstyle.h:370
Combined button and popup list for selecting options.
GLuint index
[2]
QPainter painter(this)
[7]