Qt 6.x
The Qt SDK
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
25{
26}
27
32 : version(Version), type(Type), state(other.state),
35 control(other.control), window(other.window)
36{
37}
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
139 : QStyleOption(QStyleOptionButton::Version, SO_Button), features(None)
140{
141}
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
202{
203}
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
393 : QStyleOption(Version, SO_ViewItem),
394 displayAlignment(Qt::AlignLeft), decorationAlignment(Qt::AlignLeft),
395 textElideMode(Qt::ElideMiddle), decorationPosition(Left),
396 showDecorationSelected(false), features(None),
397 checkState(Qt::Unchecked), viewItemPosition(QStyleOptionViewItem::Invalid)
398{
399}
400
402 : QStyleOption(versionIn, SO_ViewItem),
403 displayAlignment(Qt::AlignLeft), decorationAlignment(Qt::AlignLeft),
404 textElideMode(Qt::ElideMiddle), decorationPosition(Left),
405 showDecorationSelected(false), features(None),
406 checkState(Qt::Unchecked), viewItemPosition(QStyleOptionViewItem::Invalid)
407{
408}
409
415 : QStyleOption(Version, SO_TabWidgetFrame), lineWidth(0), midLineWidth(0), shape(QStyleOptionTab::RoundedNorth)
416{
417}
418
420 : QStyleOption(versionIn, SO_TabWidgetFrame), lineWidth(0), midLineWidth(0)
421{
422}
423
429 : QStyleOption(Version, SO_TabBarBase), documentMode(false), shape(QStyleOptionTab::RoundedNorth)
430{
431}
432
434 : QStyleOption(versionIn, SO_TabBarBase), documentMode(false)
435{
436}
437
442 : QStyleOptionComplex(Version, Type), corner(Qt::BottomRightCorner)
443{
444}
445
447 : QStyleOptionComplex(versionIn, Type), corner(Qt::BottomRightCorner)
448{
449}
450
455 : QStyleOption(Version, Type), levelOfDetail(1)
456{
457}
458
460 : QStyleOption(versionIn, Type), levelOfDetail(1)
461{
462}
463
478{
479 if (worldTransform.type() <= QTransform::TxTranslate)
480 return 1; // Translation only? The LOD is 1.
481
482 // Two unit vectors.
483 QLineF v1(0, 0, 1, 0);
484 QLineF v2(0, 0, 0, 1);
485 // LOD is the transformed area of a 1x1 rectangle.
486 return qSqrt(worldTransform.map(v1).length() * worldTransform.map(v2).length());
487}
488
500 : version(versionIn), type(type)
501{
502}
503
509{
510}
511
517{
518}
519
521{
522}
523
529{
530}
531
533{
534}
535
536#if !defined(QT_NO_DEBUG_STREAM)
538{
539#if !defined(QT_NO_DEBUG)
540 switch (optionType) {
542 debug << "SO_Default"; break;
544 debug << "SO_FocusRect"; break;
546 debug << "SO_Button"; break;
548 debug << "SO_Tab"; break;
550 debug << "SO_MenuItem"; break;
552 debug << "SO_Frame"; break;
554 debug << "SO_ProgressBar"; break;
556 debug << "SO_ToolBox"; break;
558 debug << "SO_Header"; break;
560 debug << "SO_DockWidget"; break;
562 debug << "SO_ViewItem"; break;
564 debug << "SO_TabWidgetFrame"; break;
566 debug << "SO_TabBarBase"; break;
568 debug << "SO_RubberBand"; break;
570 debug << "SO_Complex"; break;
572 debug << "SO_Slider"; break;
574 debug << "SO_SpinBox"; break;
576 debug << "SO_ToolButton"; break;
578 debug << "SO_ComboBox"; break;
580 debug << "SO_TitleBar"; break;
582 debug << "SO_CustomBase"; break;
584 debug << "SO_GroupBox"; break;
586 debug << "SO_ToolBar"; break;
588 debug << "SO_ComplexCustomBase"; break;
590 debug << "SO_SizeGrip"; break;
592 debug << "SO_GraphicsItem"; break;
593 }
594#else
595 Q_UNUSED(optionType);
596#endif
597 return debug;
598}
599
601{
602#if !defined(QT_NO_DEBUG)
603 debug << "QStyleOption(";
605 debug << ',' << (option.direction == Qt::RightToLeft ? "RightToLeft" : "LeftToRight");
606 debug << ',' << option.state;
607 debug << ',' << option.rect;
608 debug << ',' << option.styleObject;
609 debug << ')';
610#else
612#endif
613 return debug;
614}
615#endif
616
617} // namespace QQC2
618
\inmodule QtCore
\reentrant
Definition qfont.h:20
\macro qGuiApp
\inmodule QtCore
Definition qline.h:182
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.
QStyleOptionViewItem()
Constructs a QStyleOptionViewItem, 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 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.
@ RightToLeft
qfloat16 qSqrt(qfloat16 f)
Definition qfloat16.h:243
@ 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:92
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:24