Qt 4.8
Functions
QStyleHelper Namespace Reference

Functions

qreal angle (const QPointF &p1, const QPointF &p2)
 
int calcBigLineSize (int radius)
 
QPolygonF calcLines (const QStyleOptionSlider *dial)
 
static QPointF calcRadialPos (const QStyleOptionSlider *dial, qreal offset)
 
qreal dpiScaled (qreal value)
 
void drawBorderPixmap (const QPixmap &pixmap, QPainter *painter, const QRect &rect, int left, int top, int right, int bottom)
 
void drawDial (const QStyleOptionSlider *option, QPainter *painter)
 
QString uniqueName (const QString &key, const QStyleOption *option, const QSize &size)
 

Function Documentation

◆ angle()

qreal QStyleHelper::angle ( const QPointF p1,
const QPointF p2 
)

Definition at line 137 of file qstylehelper.cpp.

Referenced by adapted_angle_on_x(), calcLines(), QVectorPath::convertToPainterPath(), QDeclarativeParticlesPrivate::createParticle(), QCommonStyle::drawComplexControl(), QBBBpsEventFilter::handleNavigatorEvent(), QBBNavigatorEventHandler::handleOrientationChange(), QBBNavigatorEventHandler::handleOrientationCheck(), QStroker::joinPoints(), QGraphicsItem::moveBy(), operator<<(), operator>>(), pvrQwsSetRotation(), QLineF::QLineF(), QMatrix4x4::QMatrix4x4(), qt_fetch_conical_gradient(), qt_find_ellipse_coords(), qt_t_for_arc_angle(), QPinchGestureRecognizer::recognize(), QSwipeGestureRecognizer::recognize(), QAccessibleDial::rect(), QConicalGradient::setCenter(), QGraphicsItem::setRotation(), QGraphicsEllipseItem::setSpanAngle(), QGraphicsEllipseItem::setStartAngle(), QPainterPath::swap(), QGL2PaintEngineExPrivate::updateBrushUniforms(), QUIKitWindow::updateGeometryAndOrientation(), and QDeclarativePinchArea::updatePinch().

138 {
139  static const qreal rad_factor = 180 / Q_PI;
140  qreal _angle = 0;
141 
142  if (p1.x() == p2.x()) {
143  if (p1.y() < p2.y())
144  _angle = 270;
145  else
146  _angle = 90;
147  } else {
148  qreal x1, x2, y1, y2;
149 
150  if (p1.x() <= p2.x()) {
151  x1 = p1.x(); y1 = p1.y();
152  x2 = p2.x(); y2 = p2.y();
153  } else {
154  x2 = p1.x(); y2 = p1.y();
155  x1 = p2.x(); y1 = p2.y();
156  }
157 
158  qreal m = -(y2 - y1) / (x2 - x1);
159  _angle = qAtan(m) * rad_factor;
160 
161  if (p1.x() < p2.x())
162  _angle = 180 - _angle;
163  else
164  _angle = -_angle;
165  }
166  return _angle;
167 }
double qreal
Definition: qglobal.h:1193
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
qreal qAtan(qreal v)
Definition: qmath.h:173
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
static const qreal Q_PI
Definition: qmath_p.h:61

◆ calcBigLineSize()

int QStyleHelper::calcBigLineSize ( int  radius)

Definition at line 104 of file qstylehelper.cpp.

Referenced by calcArrow(), calcLines(), and calcRadialPos().

105 {
106  int bigLineSize = radius / 6;
107  if (bigLineSize < 4)
108  bigLineSize = 4;
109  if (bigLineSize > radius / 2)
110  bigLineSize = radius / 2;
111  return bigLineSize;
112 }

◆ calcLines()

QPolygonF QStyleHelper::calcLines ( const QStyleOptionSlider dial)

Definition at line 169 of file qstylehelper.cpp.

Referenced by QCommonStyle::drawComplexControl(), and drawDial().

170 {
171  QPolygonF poly;
172  int width = dial->rect.width();
173  int height = dial->rect.height();
174  qreal r = qMin(width, height) / 2;
175  int bigLineSize = calcBigLineSize(int(r));
176 
177  qreal xc = width / 2 + 0.5;
178  qreal yc = height / 2 + 0.5;
179  const int ns = dial->tickInterval;
180  if (!ns) // Invalid values may be set by Qt Designer.
181  return poly;
182  int notches = (dial->maximum + ns - 1 - dial->minimum) / ns;
183  if (notches <= 0)
184  return poly;
185  if (dial->maximum < dial->minimum || dial->maximum - dial->minimum > 1000) {
186  int maximum = dial->minimum + 1000;
187  notches = (maximum + ns - 1 - dial->minimum) / ns;
188  }
189 
190  poly.resize(2 + 2 * notches);
191  int smallLineSize = bigLineSize / 2;
192  for (int i = 0; i <= notches; ++i) {
193  qreal angle = dial->dialWrapping ? Q_PI * 3 / 2 - i * 2 * Q_PI / notches
194  : (Q_PI * 8 - i * 10 * Q_PI / notches) / 6;
195  qreal s = qSin(angle);
196  qreal c = qCos(angle);
197  if (i == 0 || (((ns * i) % (dial->pageStep ? dial->pageStep : 1)) == 0)) {
198  poly[2 * i] = QPointF(xc + (r - bigLineSize) * c,
199  yc - (r - bigLineSize) * s);
200  poly[2 * i + 1] = QPointF(xc + r * c, yc - r * s);
201  } else {
202  poly[2 * i] = QPointF(xc + (r - 1 - smallLineSize) * c,
203  yc - (r - 1 - smallLineSize) * s);
204  poly[2 * i + 1] = QPointF(xc + (r - 1) * c, yc -(r - 1) * s);
205  }
206  }
207  return poly;
208 }
double qreal
Definition: qglobal.h:1193
unsigned char c[8]
Definition: qnumeric_p.h:62
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
int tickInterval
the interval that should be drawn between tick marks
Definition: qstyleoption.h:711
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
bool dialWrapping
whether the dial should wrap or not
Definition: qstyleoption.h:718
int calcBigLineSize(int radius)
qreal qSin(qreal v)
Definition: qmath.h:93
The QPolygonF class provides a vector of points using floating point precision.
Definition: qpolygon.h:134
qreal angle(const QPointF &p1, const QPointF &p2)
int maximum
the maximum value for the slider
Definition: qstyleoption.h:709
int minimum
the minimum value for the slider
Definition: qstyleoption.h:708
int pageStep
the size of the page step of the slider
Definition: qstyleoption.h:716
qreal qCos(qreal v)
Definition: qmath.h:109
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
static const qreal Q_PI
Definition: qmath_p.h:61

◆ calcRadialPos()

static QPointF QStyleHelper::calcRadialPos ( const QStyleOptionSlider dial,
qreal  offset 
)
static

Definition at line 114 of file qstylehelper.cpp.

Referenced by drawDial().

115 {
116  const int width = dial->rect.width();
117  const int height = dial->rect.height();
118  const int r = qMin(width, height) / 2;
119  const int currentSliderPosition = dial->upsideDown ? dial->sliderPosition : (dial->maximum - dial->sliderPosition);
120  qreal a = 0;
121  if (dial->maximum == dial->minimum)
122  a = Q_PI / 2;
123  else if (dial->dialWrapping)
124  a = Q_PI * 3 / 2 - (currentSliderPosition - dial->minimum) * 2 * Q_PI
125  / (dial->maximum - dial->minimum);
126  else
127  a = (Q_PI * 8 - (currentSliderPosition - dial->minimum) * 10 * Q_PI
128  / (dial->maximum - dial->minimum)) / 6;
129  qreal xc = width / 2.0;
130  qreal yc = height / 2.0;
131  qreal len = r - QStyleHelper::calcBigLineSize(r) - 3;
132  qreal back = offset * len;
133  QPointF pos(QPointF(xc + back * qCos(a), yc - back * qSin(a)));
134  return pos;
135 }
double qreal
Definition: qglobal.h:1193
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
long ASN1_INTEGER_get ASN1_INTEGER * a
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
bool dialWrapping
whether the dial should wrap or not
Definition: qstyleoption.h:718
bool upsideDown
the slider control orientation
Definition: qstyleoption.h:712
int calcBigLineSize(int radius)
qreal qSin(qreal v)
Definition: qmath.h:93
int sliderPosition
the position of the slider handle
Definition: qstyleoption.h:713
int maximum
the maximum value for the slider
Definition: qstyleoption.h:709
int minimum
the minimum value for the slider
Definition: qstyleoption.h:708
qreal qCos(qreal v)
Definition: qmath.h:109
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
static const qreal Q_PI
Definition: qmath_p.h:61

◆ dpiScaled()

qreal QStyleHelper::dpiScaled ( qreal  value)

Definition at line 82 of file qstylehelper.cpp.

Referenced by QVistaHelper::backButtonSize(), QCommonStyle::pixelMetric(), QWindowsVistaStyle::pixelMetric(), QWindowsXPStyle::pixelMetric(), QWindowsStyle::pixelMetric(), QVistaHelper::QVistaHelper(), QWindowsMobileStyle::sizeFromContents(), QWindowsStyle::sizeFromContents(), QVistaBackButton::sizeHint(), QVistaHelper::topOffset(), and QVistaHelper::topPadding().

83 {
84  static qreal scale = -1;
85  if (scale < 0) {
86  scale = 1.0;
87 #if defined(Q_WS_WIN)
88  {
89  HDC hdcScreen = GetDC(0);
90  int dpi = GetDeviceCaps(hdcScreen, LOGPIXELSX);
91  ReleaseDC(0, hdcScreen);
92  scale = dpi/96.0;
93  }
94 #elif defined(Q_WS_MAC)
95  scale = qt_mac_get_scalefactor();
96 #endif
97  }
98  return value * scale;
99 }
double qreal
Definition: qglobal.h:1193
CGFloat qt_mac_get_scalefactor()

◆ drawBorderPixmap()

void QStyleHelper::drawBorderPixmap ( const QPixmap pixmap,
QPainter painter,
const QRect rect,
int  left,
int  top,
int  right,
int  bottom 
)

Definition at line 323 of file qstylehelper.cpp.

Referenced by QMacStyle::drawComplexControl(), and QMacStyle::drawControl().

326 {
327  QSize size = pixmap.size();
328  //painter->setRenderHint(QPainter::SmoothPixmapTransform);
329 
330  //top
331  if (top > 0) {
332  painter->drawPixmap(QRect(rect.left() + left, rect.top(), rect.width() -right - left, top), pixmap,
333  QRect(left, 0, size.width() -right - left, top));
334 
335  //top-left
336  if(left > 0)
337  painter->drawPixmap(QRect(rect.left(), rect.top(), left, top), pixmap,
338  QRect(0, 0, left, top));
339 
340  //top-right
341  if (right > 0)
342  painter->drawPixmap(QRect(rect.left() + rect.width() - right, rect.top(), right, top), pixmap,
343  QRect(size.width() - right, 0, right, top));
344  }
345 
346  //left
347  if (left > 0)
348  painter->drawPixmap(QRect(rect.left(), rect.top()+top, left, rect.height() - top - bottom), pixmap,
349  QRect(0, top, left, size.height() - bottom - top));
350 
351  //center
352  painter->drawPixmap(QRect(rect.left() + left, rect.top()+top, rect.width() -right - left,
353  rect.height() - bottom - top), pixmap,
354  QRect(left, top, size.width() -right -left,
355  size.height() - bottom - top));
356  //right
357  if (right > 0)
358  painter->drawPixmap(QRect(rect.left() +rect.width() - right, rect.top()+top, right, rect.height() - top - bottom), pixmap,
359  QRect(size.width() - right, top, right, size.height() - bottom - top));
360 
361  //bottom
362  if (bottom > 0) {
363  painter->drawPixmap(QRect(rect.left() +left, rect.top() + rect.height() - bottom,
364  rect.width() - right - left, bottom), pixmap,
365  QRect(left, size.height() - bottom,
366  size.width() - right - left, bottom));
367  //bottom-left
368  if (left > 0)
369  painter->drawPixmap(QRect(rect.left(), rect.top() + rect.height() - bottom, left, bottom), pixmap,
370  QRect(0, size.height() - bottom, left, bottom));
371 
372  //bottom-right
373  if (right > 0)
374  painter->drawPixmap(QRect(rect.left() + rect.width() - right, rect.top() + rect.height() - bottom, right, bottom), pixmap,
375  QRect(size.width() - right, size.height() - bottom, right, bottom));
376 
377  }
378 }
QSize size() const
Returns the size of the pixmap.
Definition: qpixmap.cpp:661
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int width() const
Returns the width.
Definition: qsize.h:126
QTextStream & right(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignRight) on stream and returns stream...
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
Definition: qpainter.cpp:5619
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QTextStream & left(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignLeft) on stream and returns stream...

◆ drawDial()

void QStyleHelper::drawDial ( const QStyleOptionSlider option,
QPainter painter 
)

Definition at line 213 of file qstylehelper.cpp.

Referenced by QPlastiqueStyle::drawComplexControl(), QCleanlooksStyle::drawComplexControl(), QWindowsXPStyle::drawComplexControl(), and QMacStyle::drawComplexControl().

214 {
215  QPalette pal = option->palette;
216  QColor buttonColor = pal.button().color();
217  const int width = option->rect.width();
218  const int height = option->rect.height();
219  const bool enabled = option->state & QStyle::State_Enabled;
220  qreal r = qMin(width, height) / 2;
221  r -= r/50;
222  const qreal penSize = r/20.0;
223 
224  painter->save();
226 
227  // Draw notches
228  if (option->subControls & QStyle::SC_DialTickmarks) {
229  painter->setPen(option->palette.dark().color().darker(120));
230  painter->drawLines(QStyleHelper::calcLines(option));
231  }
232 
233  // Cache dial background
235  p->setRenderHint(QPainter::Antialiasing);
236 
237  const qreal d_ = r / 6;
238  const qreal dx = option->rect.x() + d_ + (width - 2 * r) / 2 + 1;
239  const qreal dy = option->rect.y() + d_ + (height - 2 * r) / 2 + 1;
240 
241  QRectF br = QRectF(dx + 0.5, dy + 0.5,
242  int(r * 2 - 2 * d_ - 2),
243  int(r * 2 - 2 * d_ - 2));
244  buttonColor.setHsv(buttonColor .hue(),
245  qMin(140, buttonColor .saturation()),
246  qMax(180, buttonColor.value()));
247  QColor shadowColor(0, 0, 0, 20);
248 
249  if (enabled) {
250  // Drop shadow
251  qreal shadowSize = qMax(1.0, penSize/2.0);
252  QRectF shadowRect= br.adjusted(-2*shadowSize, -2*shadowSize,
253  2*shadowSize, 2*shadowSize);
254  QRadialGradient shadowGradient(shadowRect.center().x(),
255  shadowRect.center().y(), shadowRect.width()/2.0,
256  shadowRect.center().x(), shadowRect.center().y());
257  shadowGradient.setColorAt(qreal(0.91), QColor(0, 0, 0, 40));
258  shadowGradient.setColorAt(qreal(1.0), Qt::transparent);
259  p->setBrush(shadowGradient);
260  p->setPen(Qt::NoPen);
261  p->translate(shadowSize, shadowSize);
262  p->drawEllipse(shadowRect);
263  p->translate(-shadowSize, -shadowSize);
264 
265  // Main gradient
266  QRadialGradient gradient(br.center().x() - br.width()/3, dy,
267  br.width()*1.3, br.center().x(),
268  br.center().y() - br.height()/2);
269  gradient.setColorAt(0, buttonColor.lighter(110));
270  gradient.setColorAt(qreal(0.5), buttonColor);
271  gradient.setColorAt(qreal(0.501), buttonColor.darker(102));
272  gradient.setColorAt(1, buttonColor.darker(115));
273  p->setBrush(gradient);
274  } else {
275  p->setBrush(Qt::NoBrush);
276  }
277 
278  p->setPen(QPen(buttonColor.darker(280)));
279  p->drawEllipse(br);
280  p->setBrush(Qt::NoBrush);
281  p->setPen(buttonColor.lighter(110));
282  p->drawEllipse(br.adjusted(1, 1, -1, -1));
283 
284  if (option->state & QStyle::State_HasFocus) {
285  QColor highlight = pal.highlight().color();
286  highlight.setHsv(highlight.hue(),
287  qMin(160, highlight.saturation()),
288  qMax(230, highlight.value()));
289  highlight.setAlpha(127);
290  p->setPen(QPen(highlight, 2.0));
291  p->setBrush(Qt::NoBrush);
292  p->drawEllipse(br.adjusted(-1, -1, 1, 1));
293  }
294 
296 
297  QPointF dp = calcRadialPos(option, qreal(0.70));
298  buttonColor = buttonColor.lighter(104);
299  buttonColor.setAlphaF(qreal(0.8));
300  const qreal ds = r/qreal(7.0);
301  QRectF dialRect(dp.x() - ds, dp.y() - ds, 2*ds, 2*ds);
302  QRadialGradient dialGradient(dialRect.center().x() + dialRect.width()/2,
303  dialRect.center().y() + dialRect.width(),
304  dialRect.width()*2,
305  dialRect.center().x(), dialRect.center().y());
306  dialGradient.setColorAt(1, buttonColor.darker(140));
307  dialGradient.setColorAt(qreal(0.4), buttonColor.darker(120));
308  dialGradient.setColorAt(0, buttonColor.darker(110));
309  if (penSize > 3.0) {
310  painter->setPen(QPen(QColor(0, 0, 0, 25), penSize));
311  painter->drawLine(calcRadialPos(option, qreal(0.90)), calcRadialPos(option, qreal(0.96)));
312  }
313 
314  painter->setBrush(dialGradient);
315  painter->setPen(QColor(255, 255, 255, 150));
316  painter->drawEllipse(dialRect.adjusted(-1, -1, 1, 1));
317  painter->setPen(QColor(0, 0, 0, 80));
318  painter->drawEllipse(dialRect);
319  painter->restore();
320 }
#define BEGIN_STYLE_PIXMAPCACHE(a)
Definition: qstyle_p.h:76
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
const QBrush & highlight() const
Returns the highlight brush of the current color group.
Definition: qpalette.h:140
double qreal
Definition: qglobal.h:1193
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
void setColorAt(qreal pos, const QColor &color)
Creates a stop point at the given position with the given color.
Definition: qbrush.cpp:1475
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
ushort hue
Returns the hue color component of this color.
Definition: qcolor.h:250
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
static QPointF calcRadialPos(const QStyleOptionSlider *dial, qreal offset)
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
#define END_STYLE_PIXMAPCACHE
Definition: qstyle_p.h:96
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QRadialGradient class is used in combination with QBrush to specify a radial gradient brush...
Definition: qbrush.h:297
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
void setHsv(int h, int s, int v, int a=255)
Sets a HSV color value; h is the hue, s is the saturation, v is the value and a is the alpha componen...
Definition: qcolor.cpp:734
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
void drawEllipse(const QRectF &r)
Draws the ellipse defined by the given rectangle.
Definition: qpainter.cpp:4464
ushort value
Returns the value color component of this color.
Definition: qcolor.h:252
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
Definition: qpainter.cpp:4873
ushort saturation
Returns the saturation color component of this color.
Definition: qcolor.h:251
qreal width() const
Returns the width of the rectangle.
Definition: qrect.h:707
QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:781
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
QPolygonF calcLines(const QStyleOptionSlider *dial)
void setAlphaF(qreal alpha)
Sets the alpha of this color to alpha.
Definition: qcolor.cpp:1117
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
void setAlpha(int alpha)
Sets the alpha of this color to alpha.
Definition: qcolor.cpp:1094
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
QColor lighter(int f=150) const
Returns a lighter (or darker) color, but does not change this object.
Definition: qcolor.h:298
const QBrush & button() const
Returns the button brush of the current color group.
Definition: qpalette.h:125
QPointF center() const
Returns the center point of the rectangle.
Definition: qrect.h:686
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693
#define enabled
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ uniqueName()

QString QStyleHelper::uniqueName ( const QString key,
const QStyleOption option,
const QSize size 
)

Definition at line 62 of file qstylehelper.cpp.

Referenced by QPlastiqueStyle::drawComplexControl(), QCleanlooksStyle::drawComplexControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QPlastiqueStyle::drawPrimitive(), and QWindowsStyle::drawPrimitive().

63 {
64  const QStyleOptionComplex *complexOption = qstyleoption_cast<const QStyleOptionComplex *>(option);
65  QString tmp = key % HexString<uint>(option->state)
66  % HexString<uint>(option->direction)
67  % HexString<uint>(complexOption ? uint(complexOption->activeSubControls) : 0u)
68  % HexString<quint64>(option->palette.cacheKey())
69  % HexString<uint>(size.width())
70  % HexString<uint>(size.height());
71 
72 #ifndef QT_NO_SPINBOX
73  if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
74  tmp = tmp % HexString<uint>(spinBox->buttonSymbols)
75  % HexString<uint>(spinBox->stepEnabled)
76  % QLatin1Char(spinBox->frame ? '1' : '0'); ;
77  }
78 #endif // QT_NO_SPINBOX
79  return tmp;
80 }
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
quint16 u
QStyle::SubControls activeSubControls
This variable holds a bitwise OR of the sub-controls that are active for the complex control...
Definition: qstyleoption.h:694
The QString class provides a Unicode character string.
Definition: qstring.h:83
T qstyleoption_cast(const QStyleOption *option)
Definition: qstyleoption.h:885
unsigned __int64 quint64
Definition: qglobal.h:943
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
Definition: qstyleoption.h:729
unsigned int uint
Definition: qglobal.h:996
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
The QStyleOptionComplex class is used to hold parameters that are common to all complex controls...
Definition: qstyleoption.h:687
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55