Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickstyleoption.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// Qt-Security score:significant reason:default
4
6
7#include <QtGui/private/qguiapplication_p.h>
8#include <QtCore/qdebug.h>
9#include <QtCore/qmath.h>
10
12
13namespace QQC2 {
14
15QStyleOption::QStyleOption(int version, int type)
16 : version(version), type(type), state(QStyle::State_None),
18 styleObject(nullptr), control(nullptr), window(nullptr)
19{
20}
21
22/*!
23 Destroys this style option object.
24*/
28
29/*!
30 Constructs a copy of \a other.
31*/
39
40/*!
41 Assign \a other to this QStyleOption.
42*/
44{
45 control = other.control;
46 window = other.window;
47 state = other.state;
48 direction = other.direction;
49 rect = other.rect;
50 fontMetrics = other.fontMetrics;
51 palette = other.palette;
52 styleObject = other.styleObject;
53 return *this;
54}
55
56/*!
57 Constructs a QStyleOptionFocusRect, initializing the members
58 variables to their default values.
59*/
62{
63 state |= QStyle::State_KeyboardFocusChange; // assume we had one, will be corrected in initFrom()
64}
65
66/*!
67 \internal
68*/
71{
72 state |= QStyle::State_KeyboardFocusChange; // assume we had one, will be corrected in initFrom()
73}
74
75/*!
76 Constructs a QStyleOptionFrame, initializing the members
77 variables to their default values.
78*/
84
85/*!
86 \internal
87*/
93
94/*!
95 Constructs a QStyleOptionGroupBox, initializing the members
96 variables to their default values.
97*/
103
109
110/*!
111 Constructs a QStyleOptionHeader, initializing the members
112 variables to their default values.
113*/
122
123/*!
124 \internal
125*/
134
135/*!
136 Constructs a QStyleOptionButton, initializing the members
137 variables to their default values.
138*/
143
144/*!
145 \internal
146*/
151
152/*!
153 Constructs a QStyleOptionToolBar, initializing the members
154 variables to their default values.
155*/
161
162/*!
163 \fn QStyleOptionToolBar::QStyleOptionToolBar(const QStyleOptionToolBar &other)
164
165 Constructs a copy of the \a other style option.
166*/
173
174/*!
175 Constructs a QStyleOptionTab object, initializing the members
176 variables to their default values.
177*/
187
197
198/*!
199 Constructs a QStyleOptionTabV4 object, initializing the members
200 variables to their default values.
201 */
205
206/*!
207 Constructs a QStyleOptionProgressBar, initializing the members
208 variables to their default values.
209*/
216
223
224/*!
225 Constructs a QStyleOptionMenuItem, initializing the members
226 variables to their default values.
227*/
233
234/*!
235 \internal
236*/
242
243/*!
244 Constructs a QStyleOptionComplex of the specified \a type and \a
245 version, initializing the member variables to their default
246 values. This constructor is usually called by subclasses.
247*/
248QStyleOptionComplex::QStyleOptionComplex(int versionIn, int typeIn)
250{
251}
252
253
254/*!
255 Constructs a QStyleOptionSlider, initializing the members
256 variables to their default values.
257*/
265
266/*!
267 \internal
268*/
276
277/*!
278 Constructs a QStyleOptionSpinBox, initializing the members
279 variables to their default values.
280*/
286
287/*!
288 \internal
289*/
295
296/*!
297 Constructs a QStyleOptionDockWidget, initializing the member
298 variables to their default values.
299*/
305
306/*!
307 \internal
308*/
314
315/*!
316 Constructs a QStyleOptionToolButton, initializing the members
317 variables to their default values.
318*/
324
331
332/*!
333 Creates a QStyleOptionComboBox, initializing the members variables
334 to their default values.
335*/
340
342 : QStyleOptionComplex(versionIn, SO_ComboBox), editable(false), frame(true)
343{
344}
345
346/*!
347 Creates a QStyleOptionSearchField, initializing the members variables
348 to their default values.
349*/
354
359
360/*!
361 Creates a QStyleOptionToolBox, initializing the members variables
362 to their default values.
363*/
368
373
374
375/*!
376 Creates a QStyleOptionRubberBand, initializing the members
377 variables to their default values.
378*/
383
388
389/*!
390 Constructs a QStyleOptionTitleBar, initializing the members
391 variables to their default values.
392*/
397
402
403#if QT_CONFIG(quick_itemview)
404/*!
405 Constructs a QStyleOptionViewItem, initializing the members
406 variables to their default values.
407*/
414{
415}
416
423{
424}
425#endif // QT_CONFIG(quick_itemview)
426
427/*!
428 Constructs a QStyleOptionTabWidgetFrame, initializing the members
429 variables to their default values.
430*/
435
440
441/*!
442 Construct a QStyleOptionTabBarBase, initializing the members
443 vaiables to their default values.
444*/
449
454
455/*!
456 Constructs a QStyleOptionSizeGrip.
457*/
462
467
468/*!
469 Constructs a QStyleOptionGraphicsItem.
470*/
475
480
481/*!
482 \since 4.6
483
484 Returns the level of detail from the \a worldTransform.
485
486 Its value represents the maximum value of the height and
487 width of a unity rectangle, mapped using the \a worldTransform
488 of the painter used to draw the item. By default, if no
489 transformations are applied, its value is 1. If zoomed out 1:2, the level
490 of detail will be 0.5, and if zoomed in 2:1, its value is 2.
491
492 \sa QGraphicsScene::minimumRenderSize()
493*/
494qreal QStyleOptionGraphicsItem::levelOfDetailFromTransform(const QTransform &worldTransform)
495{
496 if (worldTransform.type() <= QTransform::TxTranslate)
497 return 1; // Translation only? The LOD is 1.
498
499 // Two unit vectors.
500 QLineF v1(0, 0, 1, 0);
501 QLineF v2(0, 0, 0, 1);
502 // LOD is the transformed area of a 1x1 rectangle.
503 return qSqrt(worldTransform.map(v1).length() * worldTransform.map(v2).length());
504}
505
506/*!
507 Constructs a QStyleHintReturn with version \a version and type \a
508 type.
509
510 The version has no special meaning for QStyleHintReturn; it can be
511 used by subclasses to distinguish between different version of
512 the same hint type.
513
514 \sa QStyleOption::version, QStyleOption::type
515*/
516QStyleHintReturn::QStyleHintReturn(int versionIn, int type)
517 : version(versionIn), type(type)
518{
519}
520
521/*!
522 \internal
523*/
524
528
529/*!
530 Constructs a QStyleHintReturnMask. The member variables are
531 initialized to default values.
532*/
536
540
541/*!
542 Constructs a QStyleHintReturnVariant. The member variables are
543 initialized to default values.
544*/
548
552
553#if !defined(QT_NO_DEBUG_STREAM)
554QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType)
555{
556#if !defined(QT_NO_DEBUG)
557 switch (optionType) {
559 debug << "SO_Default"; break;
561 debug << "SO_FocusRect"; break;
563 debug << "SO_Button"; break;
565 debug << "SO_Tab"; break;
567 debug << "SO_MenuItem"; break;
569 debug << "SO_Frame"; break;
571 debug << "SO_ProgressBar"; break;
573 debug << "SO_ToolBox"; break;
575 debug << "SO_Header"; break;
577 debug << "SO_DockWidget"; break;
579 debug << "SO_ViewItem"; break;
581 debug << "SO_TabWidgetFrame"; break;
583 debug << "SO_TabBarBase"; break;
585 debug << "SO_RubberBand"; break;
587 debug << "SO_Complex"; break;
589 debug << "SO_SearchField"; break;
591 debug << "SO_Slider"; break;
593 debug << "SO_SpinBox"; break;
595 debug << "SO_ToolButton"; break;
597 debug << "SO_ComboBox"; break;
599 debug << "SO_TitleBar"; break;
601 debug << "SO_CustomBase"; break;
603 debug << "SO_GroupBox"; break;
605 debug << "SO_ToolBar"; break;
607 debug << "SO_ComplexCustomBase"; break;
609 debug << "SO_SizeGrip"; break;
611 debug << "SO_GraphicsItem"; break;
612 }
613#else
614 Q_UNUSED(optionType);
615#endif
616 return debug;
617}
618
619QDebug operator<<(QDebug debug, const QStyleOption &option)
620{
621#if !defined(QT_NO_DEBUG)
622 debug << "QStyleOption(";
623 debug << QStyleOption::OptionType(option.type);
624 debug << ',' << (option.direction == Qt::RightToLeft ? "RightToLeft" : "LeftToRight");
625 debug << ',' << option.state;
626 debug << ',' << option.rect;
627 debug << ',' << option.styleObject;
628 debug << ')';
629#else
630 Q_UNUSED(option);
631#endif
632 return debug;
633}
634#endif
635
636} // namespace QQC2
637
638QT_END_NAMESPACE
QStyleHintReturnMask()
Constructs a QStyleHintReturnMask.
QStyleHintReturnVariant()
Constructs a QStyleHintReturnVariant.
QStyleHintReturn(int version=QStyleOption::Version, int type=SH_Default)
Constructs a QStyleHintReturn with version version and type type.
QStyleOptionButton()
Constructs a QStyleOptionButton, initializing the members variables to their default values.
QStyleOptionComboBox()
Creates a QStyleOptionComboBox, initializing the members variables to their default values.
QStyleOptionComplex(int version=QStyleOptionComplex::Version, int type=SO_Complex)
Constructs a QStyleOptionComplex of the specified type and version, initializing the member variables...
QStyleOptionFocusRect()
Constructs a QStyleOptionFocusRect, initializing the members variables to their default values.
QStyleOptionGraphicsItem()
Constructs a QStyleOptionGraphicsItem.
QStyleOptionGroupBox()
Constructs a QStyleOptionGroupBox, initializing the members variables to their default values.
SelectedPosition selectedPosition
QStyleOptionHeader()
Constructs a QStyleOptionHeader, initializing the members variables to their default values.
QStyleOptionMenuItem()
Constructs a QStyleOptionMenuItem, initializing the members variables to their default values.
QStyleOptionProgressBar()
Constructs a QStyleOptionProgressBar, initializing the members variables to their default values.
QStyleOptionRubberBand()
Creates a QStyleOptionRubberBand, initializing the members variables to their default values.
QStyleOptionSearchField()
Creates a QStyleOptionSearchField, initializing the members variables to their default values.
QStyleOptionSizeGrip()
Constructs a QStyleOptionSizeGrip.
QStyleOptionSlider()
Constructs a QStyleOptionSlider, initializing the members variables to their default values.
QStyleOptionSpinBox()
Constructs a QStyleOptionSpinBox, initializing the members variables to their default values.
QStyleOptionTabBarBase()
Construct a QStyleOptionTabBarBase, initializing the members vaiables to their default values.
QStyleOptionTabV4()
Constructs a QStyleOptionTabV4 object, initializing the members variables to their default values.
QStyleOptionTitleBar()
Constructs a QStyleOptionTitleBar, initializing the members variables to their default values.
QStyleOptionToolBar()
Constructs a QStyleOptionToolBar, initializing the members variables to their default values.
QStyleOptionToolButton()
Constructs a QStyleOptionToolButton, initializing the members variables to their default values.
QStyleOption(int version=QStyleOption::Version, int type=SO_Default)
~QStyleOption()
Destroys this style option object.
QStyleOption(const QStyleOption &other)
Constructs a copy of other.
QStyleOption & operator=(const QStyleOption &other)
Assign other to this QStyleOption.