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
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
4#include "qquickstyleoption.h"
5
6#include <QtGui/private/qguiapplication_p.h>
7#include <QtCore/qdebug.h>
8#include <QtCore/qmath.h>
9
11
12namespace QQC2 {
13
15 : version(version), type(type), state(QStyle::State_None),
16 direction(QGuiApplication::layoutDirection()), fontMetrics(QFont()),
18{
19}
20
27
38
43{
44 control = other.control;
45 window = other.window;
46 state = other.state;
47 direction = other.direction;
48 rect = other.rect;
49 fontMetrics = other.fontMetrics;
50 palette = other.palette;
51 styleObject = other.styleObject;
52 return *this;
53}
54
60 : QStyleOption(Version, SO_FocusRect)
61{
62 state |= QStyle::State_KeyboardFocusChange; // assume we had one, will be corrected in initFrom()
63}
64
69 : QStyleOption(versionIn, SO_FocusRect)
70{
71 state |= QStyle::State_KeyboardFocusChange; // assume we had one, will be corrected in initFrom()
72}
73
79 : QStyleOption(Version, SO_Frame), lineWidth(0), midLineWidth(0),
80 features(None), frameShape(NoFrame)
81{
82}
83
88 : QStyleOption(versionIn, SO_Frame), lineWidth(0), midLineWidth(0),
89 features(None)
90{
91}
92
99 textAlignment(Qt::AlignLeft), lineWidth(0), midLineWidth(0)
100{
101}
102
104 : QStyleOptionComplex(versionIn, Type), features(QStyleOptionFrame::None),
105 textAlignment(Qt::AlignLeft), lineWidth(0), midLineWidth(0)
106{
107}
108
115 section(0), textAlignment(Qt::AlignLeft), iconAlignment(Qt::AlignLeft),
116 position(QStyleOptionHeader::Beginning),
117 selectedPosition(QStyleOptionHeader::NotAdjacent), sortIndicator(None),
118 orientation(Qt::Horizontal)
119{
120}
121
126 : QStyleOption(versionIn, SO_Header),
127 section(0), textAlignment(Qt::AlignLeft), iconAlignment(Qt::AlignLeft),
128 position(QStyleOptionHeader::Beginning),
129 selectedPosition(QStyleOptionHeader::NotAdjacent), sortIndicator(None),
130 orientation(Qt::Horizontal)
131{
132}
133
142
147 : QStyleOption(versionIn, SO_Button), features(None)
148{
149}
150
156 : QStyleOption(Version, SO_ToolBar), positionOfLine(OnlyOne), positionWithinLine(OnlyOne),
157 toolBarArea(Qt::TopToolBarArea), features(None), lineWidth(0), midLineWidth(0)
158{
159}
160
167: QStyleOption(versionIn, SO_ToolBar), positionOfLine(OnlyOne), positionWithinLine(OnlyOne),
168 toolBarArea(Qt::TopToolBarArea), features(None), lineWidth(0), midLineWidth(0)
169{
170
171}
172
179 row(0),
180 position(Beginning),
181 selectedPosition(NotAdjacent), cornerWidgets(QStyleOptionTab::NoCornerWidgets),
182 documentMode(false),
183 features(QStyleOptionTab::None)
184{
185}
186
188 : QStyleOption(versionIn, SO_Tab),
189 row(0),
190 position(Beginning),
191 selectedPosition(NotAdjacent), cornerWidgets(QStyleOptionTab::NoCornerWidgets),
192 documentMode(false),
193 features(QStyleOptionTab::None)
194{
195}
196
204
210 : QStyleOption(QStyleOptionProgressBar::Version, SO_ProgressBar),
211 minimum(0), maximum(0), progress(0), textAlignment(Qt::AlignLeft), textVisible(false),
212 invertedAppearance(false), bottomToTop(false)
213{
214}
215
217 : QStyleOption(versionIn, SO_ProgressBar),
218 minimum(0), maximum(0), progress(0), textAlignment(Qt::AlignLeft), textVisible(false),
219 invertedAppearance(false), bottomToTop(false)
220{
221}
222
228 : QStyleOption(QStyleOptionMenuItem::Version, SO_MenuItem), menuItemType(Normal),
229 checkType(NotCheckable), checked(false), menuHasCheckableItems(true), maxIconWidth(0), tabWidth(0)
230{
231}
232
237 : QStyleOption(versionIn, SO_MenuItem), menuItemType(Normal),
238 checkType(NotCheckable), checked(false), menuHasCheckableItems(true), maxIconWidth(0), tabWidth(0)
239{
240}
241
248 : QStyleOption(versionIn, typeIn), subControls(QStyle::SC_All), activeSubControls(QStyle::SC_None)
249{
250}
251
252
258 : QStyleOptionComplex(Version, SO_Slider), orientation(Qt::Horizontal), minimum(0), maximum(0),
259 tickPosition(NoTicks), tickInterval(0), upsideDown(false),
260 sliderPosition(0), sliderValue(0), singleStep(0), pageStep(0), notchTarget(0.0),
261 dialWrapping(false)
262{
263}
264
269 : QStyleOptionComplex(versionIn, SO_Slider), orientation(Qt::Horizontal), minimum(0), maximum(0),
270 tickPosition(NoTicks), tickInterval(0), upsideDown(false),
271 sliderPosition(0), sliderValue(0), singleStep(0), pageStep(0), notchTarget(0.0),
272 dialWrapping(false)
273{
274}
275
281 : QStyleOptionComplex(Version, SO_SpinBox), buttonSymbols(UpDownArrows),
282 stepEnabled(StepNone), frame(false)
283{
284}
285
290 : QStyleOptionComplex(versionIn, SO_SpinBox), buttonSymbols(UpDownArrows),
291 stepEnabled(StepNone), frame(false)
292{
293}
294
300 : QStyleOption(Version, SO_DockWidget), closable(false),
301 movable(false), floatable(false), verticalTitleBar(false)
302{
303}
304
309 : QStyleOption(versionIn, SO_DockWidget), closable(false),
310 movable(false), floatable(false), verticalTitleBar(false)
311{
312}
313
319 : QStyleOptionComplex(Version, SO_ToolButton), features(None), arrowType(Qt::DownArrow)
320 , toolButtonStyle(Qt::ToolButtonIconOnly)
321{
322}
323
325 : QStyleOptionComplex(versionIn, SO_ToolButton), features(None), arrowType(Qt::DownArrow)
326 , toolButtonStyle(Qt::ToolButtonIconOnly)
327
328{
329}
330
336 : QStyleOptionComplex(Version, SO_ComboBox), editable(false), frame(true)
337{
338}
339
341 : QStyleOptionComplex(versionIn, SO_ComboBox), editable(false), frame(true)
342{
343}
344
350 : QStyleOption(Version, SO_ToolBox), position(Beginning), selectedPosition(NotAdjacent)
351{
352}
353
355 : QStyleOption(versionIn, SO_ToolBox), position(Beginning), selectedPosition(NotAdjacent)
356{
357}
358
359
365 : QStyleOption(Version, SO_RubberBand), opaque(false), shape(Line)
366{
367}
368
370 : QStyleOption(versionIn, SO_RubberBand), opaque(false)
371{
372}
373
379 : QStyleOptionComplex(Version, SO_TitleBar), titleBarState(0)
380{
381}
382
384 : QStyleOptionComplex(versionIn, SO_TitleBar), titleBarState(0)
385{
386}
387
388#if QT_CONFIG(quick_itemview)
393QStyleOptionViewItem::QStyleOptionViewItem()
394 : QStyleOption(Version, SO_ViewItem),
395 displayAlignment(Qt::AlignLeft), decorationAlignment(Qt::AlignLeft),
396 textElideMode(Qt::ElideMiddle), decorationPosition(Left),
397 showDecorationSelected(false), features(None),
398 checkState(Qt::Unchecked), viewItemPosition(QStyleOptionViewItem::Invalid)
399{
400}
401
402QStyleOptionViewItem::QStyleOptionViewItem(int versionIn)
403 : QStyleOption(versionIn, SO_ViewItem),
404 displayAlignment(Qt::AlignLeft), decorationAlignment(Qt::AlignLeft),
405 textElideMode(Qt::ElideMiddle), decorationPosition(Left),
406 showDecorationSelected(false), features(None),
407 checkState(Qt::Unchecked), viewItemPosition(QStyleOptionViewItem::Invalid)
408{
409}
410#endif // QT_CONFIG(quick_itemview)
411
417 : QStyleOption(Version, SO_TabWidgetFrame), lineWidth(0), midLineWidth(0), shape(QStyleOptionTab::RoundedNorth)
418{
419}
420
422 : QStyleOption(versionIn, SO_TabWidgetFrame), lineWidth(0), midLineWidth(0)
423{
424}
425
431 : QStyleOption(Version, SO_TabBarBase), documentMode(false), shape(QStyleOptionTab::RoundedNorth)
432{
433}
434
436 : QStyleOption(versionIn, SO_TabBarBase), documentMode(false)
437{
438}
439
444 : QStyleOptionComplex(Version, Type), corner(Qt::BottomRightCorner)
445{
446}
447
449 : QStyleOptionComplex(versionIn, Type), corner(Qt::BottomRightCorner)
450{
451}
452
460
462 : QStyleOption(versionIn, Type), levelOfDetail(1)
463{
464}
465
480{
481 if (worldTransform.type() <= QTransform::TxTranslate)
482 return 1; // Translation only? The LOD is 1.
483
484 // Two unit vectors.
485 QLineF v1(0, 0, 1, 0);
486 QLineF v2(0, 0, 0, 1);
487 // LOD is the transformed area of a 1x1 rectangle.
488 return qSqrt(worldTransform.map(v1).length() * worldTransform.map(v2).length());
489}
490
502 : version(versionIn), type(type)
503{
504}
505
513
521
525
533
537
538#if !defined(QT_NO_DEBUG_STREAM)
540{
541#if !defined(QT_NO_DEBUG)
542 switch (optionType) {
544 debug << "SO_Default"; break;
546 debug << "SO_FocusRect"; break;
548 debug << "SO_Button"; break;
550 debug << "SO_Tab"; break;
552 debug << "SO_MenuItem"; break;
554 debug << "SO_Frame"; break;
556 debug << "SO_ProgressBar"; break;
558 debug << "SO_ToolBox"; break;
560 debug << "SO_Header"; break;
562 debug << "SO_DockWidget"; break;
564 debug << "SO_ViewItem"; break;
566 debug << "SO_TabWidgetFrame"; break;
568 debug << "SO_TabBarBase"; break;
570 debug << "SO_RubberBand"; break;
572 debug << "SO_Complex"; break;
574 debug << "SO_Slider"; break;
576 debug << "SO_SpinBox"; break;
578 debug << "SO_ToolButton"; break;
580 debug << "SO_ComboBox"; break;
582 debug << "SO_TitleBar"; break;
584 debug << "SO_CustomBase"; break;
586 debug << "SO_GroupBox"; break;
588 debug << "SO_ToolBar"; break;
590 debug << "SO_ComplexCustomBase"; break;
592 debug << "SO_SizeGrip"; break;
594 debug << "SO_GraphicsItem"; break;
595 }
596#else
597 Q_UNUSED(optionType);
598#endif
599 return debug;
600}
601
603{
604#if !defined(QT_NO_DEBUG)
605 debug << "QStyleOption(";
607 debug << ',' << (option.direction == Qt::RightToLeft ? "RightToLeft" : "LeftToRight");
608 debug << ',' << option.state;
609 debug << ',' << option.rect;
610 debug << ',' << option.styleObject;
611 debug << ')';
612#else
614#endif
615 return debug;
616}
617#endif
618
619} // namespace QQC2
620
\inmodule QtCore
\reentrant
Definition qfont.h:22
\macro qGuiApp
\inmodule QtCore\compares equality \compareswith equality QLine \endcompareswith
Definition qline.h:192
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...
QStyleOptionDockWidget()
Constructs a QStyleOptionDockWidget, initializing the member variables to their default values.
QStyleOptionFocusRect()
Constructs a QStyleOptionFocusRect, initializing the members variables to their default values.
QStyleOptionFrame()
Constructs a QStyleOptionFrame, initializing the members variables to their default values.
static qreal levelOfDetailFromTransform(const QTransform &worldTransform)
QStyleOptionGraphicsItem()
Constructs a QStyleOptionGraphicsItem.
QStyleOptionGroupBox()
Constructs a QStyleOptionGroupBox, initializing the members variables to their default values.
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.
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.
QStyleOptionTabWidgetFrame()
Constructs a QStyleOptionTabWidgetFrame, initializing the members variables to their default values.
QStyleOptionTab()
Constructs a QStyleOptionTab 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.
QStyleOptionToolBox()
Creates a QStyleOptionToolBox, initializing the members variables to their default values.
QStyleOptionToolButton()
Constructs a QStyleOptionToolButton, initializing the members variables to their default values.
Qt::LayoutDirection direction
QStyleOption(int version=QStyleOption::Version, int type=SO_Default)
~QStyleOption()
Destroys this style option object.
QStyleOption & operator=(const QStyleOption &other)
Assign other to this QStyleOption.
@ State_KeyboardFocusChange
Definition qquickstyle.h:65
The QStyleOption class stores the parameters used by QStyle functions.
The QTransform class specifies 2D transformations of a coordinate system.
Definition qtransform.h:20
QPoint map(const QPoint &p) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
TransformationType type() const
Returns the transformation type of this matrix.
rect
[4]
direction
fontMetrics
else opt state
[0]
QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType)
Combined button and popup list for selecting options.
Definition qcompare.h:63
@ RightToLeft
qfloat16 qSqrt(qfloat16 f)
Definition qfloat16.h:289
@ None
Definition qhash.cpp:531
@ Invalid
GLint GLfloat GLfloat GLfloat v2
GLenum type
GLint GLfloat GLfloat v1
GLenum GLenum GLsizei void * row
GLuint GLenum option
@ Left
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define v1
#define Q_UNUSED(x)
double qreal
Definition qtypes.h:187
QObject * styleObject(const QStyleOption *option)
QObject::connect nullptr
QSharedPointer< T > other(t)
[5]
aWidget window() -> setWindowTitle("New Window Title")
[2]
QFrame frame
[0]
Definition moc.h:23