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
qqc2qstyleoption.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 <private/qguiapplication_p.h>
8
9#include <QtCore/qdebug.h>
10#include <QtCore/qmath.h>
11
13
14namespace QQC2 {
15
16QStyleOption::QStyleOption(int version, int type)
17 : version(version), type(type), state(QStyle::State_None),
19 styleObject(nullptr), control(nullptr), window(nullptr)
20{
21}
22
23/*!
24 \internal
25 Destroys this style option object.
26*/
30
31/*!
32 \internal
33 Constructs a copy of \a other.
34*/
42
43/*!
44 \internal
45 Assign \a other to this QStyleOption.
46*/
48{
49 control = other.control;
50 window = other.window;
51 state = other.state;
52 direction = other.direction;
53 rect = other.rect;
54 fontMetrics = other.fontMetrics;
55 palette = other.palette;
56 styleObject = other.styleObject;
57 return *this;
58}
59
60/*!
61 \internal
62 Constructs a QStyleOptionFocusRect, initializing the members
63 variables to their default values.
64*/
67{
68 state |= QStyle::State_KeyboardFocusChange; // assume we had one, will be corrected in initFrom()
69}
70
71/*!
72 \internal
73*/
76{
77 state |= QStyle::State_KeyboardFocusChange; // assume we had one, will be corrected in initFrom()
78}
79
80/*!
81 \internal
82 Constructs a QStyleOptionFrame, initializing the members
83 variables to their default values.
84*/
90
91/*!
92 \internal
93*/
99
100/*!
101 \internal
102 Constructs a QStyleOptionGroupBox, initializing the members
103 variables to their default values.
104*/
110
116
117/*!
118 \internal
119 Constructs a QStyleOptionHeader, initializing the members
120 variables to their default values.
121*/
130
131/*!
132 \internal
133*/
142
143/*!
144 \internal
145 Constructs a QStyleOptionButton, initializing the members
146 variables to their default values.
147*/
152
153/*!
154 \internal
155*/
160
161/*!
162 \internal
163 Constructs a QStyleOptionToolBar, initializing the members
164 variables to their default values.
165*/
171
172/*!
173 \internal
174
175 Constructs a copy of the \a other style option.
176*/
183
184/*!
185 \internal
186 Constructs a QStyleOptionTab object, initializing the members
187 variables to their default values.
188*/
198
208
209/*!
210 \internal
211 Constructs a QStyleOptionTabV4 object, initializing the members
212 variables to their default values.
213 */
217
218/*!
219 \internal
220 Constructs a QStyleOptionProgressBar, initializing the members
221 variables to their default values.
222*/
229
236
237/*!
238 \internal
239 Constructs a QStyleOptionMenuItem, initializing the members
240 variables to their default values.
241*/
247
248/*!
249 \internal
250*/
256
257/*!
258 \internal
259 Constructs a QStyleOptionComplex of the specified \a type and \a
260 version, initializing the member variables to their default
261 values. This constructor is usually called by subclasses.
262*/
263QStyleOptionComplex::QStyleOptionComplex(int versionIn, int typeIn)
265{
266}
267
268
269/*!
270 \internal
271 Constructs a QStyleOptionSlider, initializing the members
272 variables to their default values.
273*/
281
282/*!
283 \internal
284*/
292
293/*!
294 \internal
295 Constructs a QStyleOptionSpinBox, initializing the members
296 variables to their default values.
297*/
303
304/*!
305 \internal
306*/
312
313/*!
314 \internal
315 Constructs a QStyleOptionDockWidget, initializing the member
316 variables to their default values.
317*/
323
324/*!
325 \internal
326*/
332
333/*!
334 \internal
335 Constructs a QStyleOptionToolButton, initializing the members
336 variables to their default values.
337*/
343
350
351/*!
352 \internal
353 Creates a QStyleOptionComboBox, initializing the members variables
354 to their default values.
355*/
360
362 : QStyleOptionComplex(versionIn, SO_ComboBox), editable(false), frame(true)
363{
364}
365
366/*!
367 \internal
368 Creates a QStyleOptionSearchField, initializing the members variables
369 to their default values.
370*/
375
380
381/*!
382 \internal
383 Creates a QStyleOptionToolBox, initializing the members variables
384 to their default values.
385*/
390
395
396
397/*!
398 \internal
399 Creates a QStyleOptionRubberBand, initializing the members
400 variables to their default values.
401*/
406
411
412/*!
413 \internal
414 Constructs a QStyleOptionTitleBar, initializing the members
415 variables to their default values.
416*/
421
426
427#if QT_CONFIG(quick_itemview)
428/*!
429 \internal
430 Constructs a QStyleOptionViewItem, initializing the members
431 variables to their default values.
432*/
439{
440}
441
448{
449}
450#endif // QT_CONFIG(quick_itemview)
451
452/*!
453 \internal
454 Constructs a QStyleOptionTabWidgetFrame, initializing the members
455 variables to their default values.
456*/
461
466
467/*!
468 \internal
469 Construct a QStyleOptionTabBarBase, initializing the members
470 vaiables to their default values.
471*/
476
481
482/*!
483 \internal
484 Constructs a QStyleOptionSizeGrip.
485*/
490
495
496/*!
497 \internal
498 Constructs a QStyleOptionGraphicsItem.
499*/
504
509
510/*!
511 \internal
512
513 Returns the level of detail from the \a worldTransform.
514
515 Its value represents the maximum value of the height and
516 width of a unity rectangle, mapped using the \a worldTransform
517 of the painter used to draw the item. By default, if no
518 transformations are applied, its value is 1. If zoomed out 1:2, the level
519 of detail will be 0.5, and if zoomed in 2:1, its value is 2.
520
521 \sa QGraphicsScene::minimumRenderSize()
522*/
523qreal QStyleOptionGraphicsItem::levelOfDetailFromTransform(const QTransform &worldTransform)
524{
525 if (worldTransform.type() <= QTransform::TxTranslate)
526 return 1; // Translation only? The LOD is 1.
527
528 // Two unit vectors.
529 QLineF v1(0, 0, 1, 0);
530 QLineF v2(0, 0, 0, 1);
531 // LOD is the transformed area of a 1x1 rectangle.
532 return qSqrt(worldTransform.map(v1).length() * worldTransform.map(v2).length());
533}
534
535/*!
536 \internal
537 Constructs a QStyleHintReturn with version \a version and type \a
538 type.
539
540 The version has no special meaning for QStyleHintReturn; it can be
541 used by subclasses to distinguish between different version of
542 the same hint type.
543
544 \sa QStyleOption::version, QStyleOption::type
545*/
546QStyleHintReturn::QStyleHintReturn(int versionIn, int type)
547 : version(versionIn), type(type)
548{
549}
550
551/*!
552 \internal
553*/
554
558
559/*!
560 \internal
561 Constructs a QStyleHintReturnMask. The member variables are
562 initialized to default values.
563*/
567
571
572/*!
573 \internal
574 Constructs a QStyleHintReturnVariant. The member variables are
575 initialized to default values.
576*/
580
584
585#if !defined(QT_NO_DEBUG_STREAM)
586QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType)
587{
588#if !defined(QT_NO_DEBUG)
589 switch (optionType) {
591 debug << "SO_Default"; break;
593 debug << "SO_FocusRect"; break;
595 debug << "SO_Button"; break;
597 debug << "SO_Tab"; break;
599 debug << "SO_MenuItem"; break;
601 debug << "SO_Frame"; break;
603 debug << "SO_ProgressBar"; break;
605 debug << "SO_ToolBox"; break;
607 debug << "SO_Header"; break;
609 debug << "SO_DockWidget"; break;
611 debug << "SO_ViewItem"; break;
613 debug << "SO_TabWidgetFrame"; break;
615 debug << "SO_TabBarBase"; break;
617 debug << "SO_RubberBand"; break;
619 debug << "SO_Complex"; break;
621 debug << "SO_SearchField"; break;
623 debug << "SO_Slider"; break;
625 debug << "SO_SpinBox"; break;
627 debug << "SO_ToolButton"; break;
629 debug << "SO_ComboBox"; break;
631 debug << "SO_TitleBar"; break;
633 debug << "SO_CustomBase"; break;
635 debug << "SO_GroupBox"; break;
637 debug << "SO_ToolBar"; break;
639 debug << "SO_ComplexCustomBase"; break;
641 debug << "SO_SizeGrip"; break;
643 debug << "SO_GraphicsItem"; break;
644 }
645#else
646 Q_UNUSED(optionType);
647#endif
648 return debug;
649}
650
651QDebug operator<<(QDebug debug, const QStyleOption &option)
652{
653#if !defined(QT_NO_DEBUG)
654 debug << "QStyleOption(";
655 debug << QStyleOption::OptionType(option.type);
656 debug << ',' << (option.direction == Qt::RightToLeft ? "RightToLeft" : "LeftToRight");
657 debug << ',' << option.state;
658 debug << ',' << option.rect;
659 debug << ',' << option.styleObject;
660 debug << ')';
661#else
662 Q_UNUSED(option);
663#endif
664 return debug;
665}
666#endif
667
668} // namespace QQC2
669
670QT_END_NAMESPACE
QStyleHintReturn(int version=QStyleOption::Version, int type=SH_Default)
QStyleOptionComplex(int version=QStyleOptionComplex::Version, int type=SO_Complex)
SelectedPosition selectedPosition
QStyleOption(int version=QStyleOption::Version, int type=SO_Default)
QStyleOption(const QStyleOption &other)
QStyleOption & operator=(const QStyleOption &other)
QDebug operator<<(QDebug debug, const QStyleOption &option)
QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType)
Combined button and popup list for selecting options.