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
qqstylekitcontrolproperties_p.h
Go to the documentation of this file.
1// Copyright (C) 2025 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
5#ifndef QQSTYLEKITCONTROLPROPERTIES_P_H
6#define QQSTYLEKITCONTROLPROPERTIES_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtQml/QtQml>
20#include <QtGui/QColor>
21#include <QtQuick/private/qquickrectangle_p.h>
22#include <QtQuick/private/qquickimage_p.h>
23#include <QtQuick/private/qquicktransition_p.h>
24
27#include <QtLabsStyleKit/qtlabsstylekitexports.h>
28
30
31using namespace Qt::StringLiterals;
32
33class QQStyleKitStyle;
34class QQStyleKitControl;
35class QQStyleKitControlState;
36class QQStyleKitReader;
37class QQStyleKitControlProperties;
38class QQStyleKitDelegateProperties;
39
41{
43
44public:
45 enum class EmitFlag {
48 };
49 Q_DECLARE_FLAGS(EmitFlags, EmitFlag)
51
53
54 template<typename T>
55 inline T styleProperty(
58 {
59 return qvariant_cast<T>(QQStyleKitPropertyResolver::readStyleProperty(this, property, alternative));
60 }
61
62 template<typename T>
64 {
65 const QVariant value = QQStyleKitPropertyResolver::readStyleProperty(this, property);
66 return value.isValid() ? qvariant_cast<T>(value) : defaultValue;
67 }
68
69 template<typename T>
71 {
72 // This function will return true if the new value differes from the old one
73 return QQStyleKitPropertyResolver::writeStyleProperty(this, property, QVariant::fromValue(value));
74 }
75
76 inline bool isDefined(QQSK::Property property) const
77 {
78 return QQStyleKitPropertyResolver::readStyleProperty(this, property).isValid();
79 }
80
81 template<typename SUBCLASS>
82 inline void handleStylePropertyChanged(void (SUBCLASS::*changedSignal)());
83
84 template <typename SUBCLASS, typename... CHANGED_SIGNALS>
85 inline void handleStylePropertiesChanged(CHANGED_SIGNALS... changedSignals);
86
87 template <typename T>
88 T *lazyCreateGroup(T *const &ptr, QQSK::PropertyGroup group) const;
89
90 inline bool isControlProperties() const
91 {
92 /* Only QQStyleKitControlProperties (as opposed to the nested delegates) have properties
93 * with an ID at the bottom of the available space. The exception is the global flag, which
94 * inherits the groupSpace from the control. */
95 return m_groupSpace.start == 0 && m_pathFlags != QQSK::PropertyPathFlag::Global;
96 }
97
98 QQStyleKitControlProperties *controlProperties() const;
99 inline QQSK::PropertyPathFlags pathFlags() const { return m_pathFlags; }
102
103protected:
104 virtual void forEachExistingNestedGroup(
105 const std::function<void (QQStyleKitPropertyGroup *)> &f) const;
106
108 const QQStyleKitControl *control, const std::function<void (QQStyleKitReader *reader)> &f) const;
109
112
113private:
114 bool shouldEmitLocally();
115 bool shouldEmitGlobally();
116};
117
118// ************* QQStyleKitImageProperties ****************
119
120class Q_LABSSTYLEKIT_EXPORT QQStyleKitImageProperties : public QQStyleKitPropertyGroup
121{
122 Q_OBJECT
123 Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged FINAL)
124 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
125 Q_PROPERTY(QQuickImage::FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged FINAL)
126 QML_UNCREATABLE("This component can only be instantiated by StyleKit")
127 QML_NAMED_ELEMENT(ImageStyle)
128
129public:
130 QQStyleKitImageProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent = nullptr);
131
132 template <typename... CHANGED_SIGNALS>
133 void emitGlobally(CHANGED_SIGNALS... changedSignals) const;
134
135 QUrl source() const;
136 void setSource(const QUrl &source);
137
138 QColor color() const;
139 void setColor(const QColor &color);
140
141 QQuickImage::FillMode fillMode() const;
142 void setFillMode(QQuickImage::FillMode fillMode);
143
144signals:
145 void sourceChanged();
146 void colorChanged();
147 void fillModeChanged();
148};
149
150// ************* QQStyleKitBorderProperties ****************
151
152class Q_LABSSTYLEKIT_EXPORT QQStyleKitBorderProperties : public QQStyleKitPropertyGroup
153{
154 Q_OBJECT
155 Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged FINAL)
156 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
157 QML_UNCREATABLE("This component can only be instantiated by StyleKit")
158 QML_NAMED_ELEMENT(BorderStyle)
159
160public:
161 QQStyleKitBorderProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent = nullptr);
162
163 template <typename... CHANGED_SIGNALS>
164 void emitGlobally(CHANGED_SIGNALS... changedSignals) const;
165
166 qreal width() const;
167 void setWidth(qreal width);
168
169 QColor color() const;
170 void setColor(const QColor &color);
171
172signals:
173 void widthChanged();
174 void colorChanged();
175};
176
177// ************* QQStyleKitShadowProperties ****************
178
179class Q_LABSSTYLEKIT_EXPORT QQStyleKitShadowProperties : public QQStyleKitPropertyGroup
180{
181 Q_OBJECT
182 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
183 Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged FINAL)
184 Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged FINAL)
185 Q_PROPERTY(qreal verticalOffset READ verticalOffset WRITE setVerticalOffset NOTIFY verticalOffsetChanged FINAL)
186 Q_PROPERTY(qreal horizontalOffset READ horizontalOffset WRITE setHorizontalOffset NOTIFY horizontalOffsetChanged FINAL)
187 Q_PROPERTY(qreal blur READ blur WRITE setBlur NOTIFY blurChanged FINAL)
188 Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged FINAL)
189 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
190 QML_UNCREATABLE("This component can only be instantiated by StyleKit")
191 QML_NAMED_ELEMENT(ShadowStyle)
192
193public:
194 QQStyleKitShadowProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent = nullptr);
195
196 template <typename... CHANGED_SIGNALS>
197 void emitGlobally(CHANGED_SIGNALS... changedSignals) const;
198
199 QColor color() const;
200 void setColor(QColor color);
201
202 qreal opacity() const;
203 void setOpacity(qreal opacity);
204
205 qreal scale() const;
206 void setScale(qreal scale);
207
208 qreal verticalOffset() const;
209 void setVerticalOffset(qreal verticalOffset);
210
211 qreal horizontalOffset() const;
212 void setHorizontalOffset(qreal horizontalOffset);
213
214 qreal blur() const;
215 void setBlur(qreal blur);
216
217 bool visible() const;
218 void setVisible(bool visible);
219
220 QQmlComponent *delegate() const;
221 void setDelegate(QQmlComponent *delegate);
222
223signals:
224 void colorChanged();
225 void opacityChanged();
226 void scaleChanged();
227 void verticalOffsetChanged();
228 void horizontalOffsetChanged();
229 void blurChanged();
230 void visibleChanged();
231 void delegateChanged();
232};
233
234// ************* QQStyleKitDelegateProperties ****************
235
236class Q_LABSSTYLEKIT_EXPORT QQStyleKitDelegateProperties : public QQStyleKitPropertyGroup
237{
238 Q_OBJECT
239 Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged FINAL)
240 Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged FINAL)
241 Q_PROPERTY(qreal minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged FINAL)
242 Q_PROPERTY(qreal minimumHeight READ minimumHeight WRITE setMinimumHeight NOTIFY minimumHeightChanged FINAL)
243 Q_PROPERTY(bool fillWidth READ fillWidth WRITE setFillWidth NOTIFY fillWidthChanged FINAL)
244 Q_PROPERTY(bool fillHeight READ fillHeight WRITE setFillHeight NOTIFY fillHeightChanged FINAL)
245 Q_PROPERTY(qreal margins READ margins WRITE setMargins NOTIFY marginsChanged FINAL)
246 Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged FINAL)
247 Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged FINAL)
248 Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged FINAL)
249 Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged FINAL)
250 Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged FINAL)
251 Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged FINAL)
252 Q_PROPERTY(qreal topLeftRadius READ topLeftRadius WRITE setTopLeftRadius NOTIFY topLeftRadiusChanged FINAL)
253 Q_PROPERTY(qreal topRightRadius READ topRightRadius WRITE setTopRightRadius NOTIFY topRightRadiusChanged FINAL)
254 Q_PROPERTY(qreal bottomLeftRadius READ bottomLeftRadius WRITE setBottomLeftRadius NOTIFY bottomLeftRadiusChanged FINAL)
255 Q_PROPERTY(qreal bottomRightRadius READ bottomRightRadius WRITE setBottomRightRadius NOTIFY bottomRightRadiusChanged FINAL)
256 Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged FINAL)
257 Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged FINAL)
258 Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged FINAL)
259 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
260 Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged FINAL)
261 Q_PROPERTY(bool clip READ clip WRITE setClip NOTIFY clipChanged FINAL)
262 Q_PROPERTY(QQuickGradient *gradient READ gradient WRITE setGradient NOTIFY gradientChanged FINAL)
263 Q_PROPERTY(QQStyleKitImageProperties *image READ image NOTIFY imageChanged FINAL)
264 Q_PROPERTY(QQStyleKitBorderProperties *border READ border NOTIFY borderChanged FINAL)
265 Q_PROPERTY(QQStyleKitShadowProperties *shadow READ shadow NOTIFY shadowChanged FINAL)
266 Q_PROPERTY(QObject *data READ data WRITE setData NOTIFY dataChanged FINAL)
267 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
268 QML_UNCREATABLE("This component can only be instantiated by StyleKit")
269 QML_NAMED_ELEMENT(DelegateStyle)
270
271public:
272 QQStyleKitDelegateProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent = nullptr);
273
274 template <typename... CHANGED_SIGNALS>
275 void emitGlobally(CHANGED_SIGNALS... changedSignals) const;
276
277 qreal radius() const;
278 void setRadius(qreal radius);
279
280 qreal topLeftRadius() const;
281 void setTopLeftRadius(qreal radius);
282
283 qreal topRightRadius() const;
284 void setTopRightRadius(qreal radius);
285
286 qreal bottomLeftRadius() const;
287 void setBottomLeftRadius(qreal radius);
288
289 qreal bottomRightRadius() const;
290 void setBottomRightRadius(qreal radius);
291
292 qreal scale() const;
293 void setScale(qreal scale);
294
295 qreal rotation() const;
296 void setRotation(qreal rotation);
297
298 qreal width() const;
299 void setWidth(qreal width);
300
301 qreal height() const;
302 void setHeight(qreal height);
303
304 qreal minimumWidth() const;
305 void setMinimumWidth(qreal width);
306
307 qreal minimumHeight() const;
308 void setMinimumHeight(qreal height);
309
310 bool fillWidth() const;
311 void setFillWidth(bool fill);
312
313 bool fillHeight() const;
314 void setFillHeight(bool fill);
315
316 qreal margins() const;
317 void setMargins(qreal margins);
318
319 qreal leftMargin() const;
320 void setLeftMargin(qreal margin);
321
322 qreal rightMargin() const;
323 void setRightMargin(qreal margin);
324
325 qreal topMargin() const;
326 void setTopMargin(qreal margin);
327
328 qreal bottomMargin() const;
329 void setBottomMargin(qreal margin);
330
331 Qt::Alignment alignment() const;
332 void setAlignment(Qt::Alignment alignment);
333
334 qreal opacity() const;
335 void setOpacity(qreal opacity);
336
337 QColor color() const;
338 void setColor(const QColor &color);
339
340 bool visible() const;
341 void setVisible(bool visible);
342
343 bool clip() const;
344 void setClip(bool clip);
345
346 QQuickGradient *gradient() const;
347 void setGradient(QQuickGradient *gradient);
348
349 QObject *data() const;
350 void setData(QObject *data);
351
352 QQmlComponent *delegate() const;
353 void setDelegate(QQmlComponent *delegate);
354
355 QQStyleKitImageProperties *image() const;
356 QQStyleKitBorderProperties *border() const;
357 QQStyleKitShadowProperties *shadow() const;
358
359signals:
360 void colorChanged();
361 void radiusChanged();
362 void topLeftRadiusChanged();
363 void topRightRadiusChanged();
364 void bottomLeftRadiusChanged();
365 void bottomRightRadiusChanged();
366 void scaleChanged();
367 void rotationChanged();
368 void visibleChanged();
369 void clipChanged();
370 void borderChanged();
371 void shadowChanged();
372 void imageChanged();
373 void gradientChanged();
374 void colorImageChanged();
375 void widthChanged();
376 void heightChanged();
377 void minimumWidthChanged();
378 void minimumHeightChanged();
379 void marginsChanged();
380 void leftMarginChanged();
381 void rightMarginChanged();
382 void topMarginChanged();
383 void bottomMarginChanged();
384 void alignmentChanged();
385 void opacityChanged();
386 void dataChanged();
387 void delegateChanged();
388 void fillWidthChanged();
389 void fillHeightChanged();
390
391protected:
392 void forEachExistingNestedGroup(
393 const std::function<void (QQStyleKitPropertyGroup *)> &f) const override;
394
395private:
396 QPointer<QQuickGradient> m_gradient;
397 QQStyleKitBorderProperties *m_border = nullptr;
398 QQStyleKitShadowProperties *m_shadow = nullptr;
399 QQStyleKitImageProperties *m_image = nullptr;
400};
401
402// ************* QQStyleKitHandleProperties ****************
403
404class Q_LABSSTYLEKIT_EXPORT QQStyleKitHandleProperties : public QQStyleKitDelegateProperties
405{
406 Q_OBJECT
407 Q_PROPERTY(QQStyleKitDelegateProperties *first READ first NOTIFY firstChanged FINAL)
408 Q_PROPERTY(QQStyleKitDelegateProperties *second READ second NOTIFY secondChanged FINAL)
409 QML_UNCREATABLE("This component can only be instantiated by StyleKit")
410 QML_NAMED_ELEMENT(HandleStyle)
411
412public:
413 QQStyleKitHandleProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent = nullptr);
414 QQStyleKitDelegateProperties *first() const;
415 QQStyleKitDelegateProperties *second() const;
416
417signals:
418 void firstChanged();
419 void secondChanged();
420
421protected:
422 void forEachExistingNestedGroup(
423 const std::function<void (QQStyleKitPropertyGroup *)> &f) const override;
424
425private:
426 QQStyleKitDelegateProperties *m_first = nullptr;
427 QQStyleKitDelegateProperties *m_second = nullptr;
428
429 friend class QQStyleKitReader;
430 friend class QQStyleKitControlProperties;
431};
432
433// ************* QQStyleKitIndicatorProperties ****************
434
435class Q_LABSSTYLEKIT_EXPORT QQStyleKitIndicatorProperties : public QQStyleKitDelegateProperties
436{
437 Q_OBJECT
438 Q_PROPERTY(QQStyleKitDelegateProperties *foreground READ foreground NOTIFY foregroundChanged FINAL)
439 QML_UNCREATABLE("This component can only be instantiated by StyleKit")
440 QML_NAMED_ELEMENT(SubIndicatorStyle)
441
442public:
443 QQStyleKitIndicatorProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent = nullptr);
444
445 template <typename... CHANGED_SIGNALS>
446 void emitGlobally(CHANGED_SIGNALS... changedSignals) const;
447
448 QQStyleKitDelegateProperties *foreground() const;
449
450signals:
451 void foregroundChanged();
452
453protected:
454 void forEachExistingNestedGroup(
455 const std::function<void (QQStyleKitPropertyGroup *)> &f) const override;
456
457private:
458 QQStyleKitDelegateProperties *m_foreground = nullptr;
459
460 friend class QQStyleKitReader;
461 friend class QQStyleKitControlProperties;
462};
463
464// ************* QQStyleKitIndicatorWithSubTypes ****************
465
466class Q_LABSSTYLEKIT_EXPORT QQStyleKitIndicatorWithSubTypes : public QQStyleKitDelegateProperties
467{
468 Q_OBJECT
469 Q_PROPERTY(QQStyleKitDelegateProperties *foreground READ foreground NOTIFY foregroundChanged FINAL)
470 Q_PROPERTY(QQStyleKitIndicatorProperties *up READ up NOTIFY upChanged FINAL)
471 Q_PROPERTY(QQStyleKitIndicatorProperties *down READ down NOTIFY downChanged FINAL)
472 Q_PROPERTY(QQStyleKitIndicatorProperties *first READ first NOTIFY firstChanged FINAL)
473 Q_PROPERTY(QQStyleKitIndicatorProperties *second READ second NOTIFY secondChanged FINAL)
474 QML_UNCREATABLE("This component can only be instantiated by StyleKit")
475 QML_NAMED_ELEMENT(IndicatorStyle)
476
477public:
478 QQStyleKitIndicatorWithSubTypes(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent = nullptr);
479
480 template <typename... CHANGED_SIGNALS>
481 void emitGlobally(CHANGED_SIGNALS... changedSignals) const;
482
483 QQStyleKitDelegateProperties *foreground() const;
484 QQStyleKitIndicatorProperties *up() const;
485 QQStyleKitIndicatorProperties *down() const;
486 // Generic indicators
487 QQStyleKitIndicatorProperties *first() const;
488 QQStyleKitIndicatorProperties *second() const;
489
490signals:
491 void foregroundChanged();
492 void upChanged();
493 void downChanged();
494 void firstChanged();
495 void secondChanged();
496
497protected:
498 void forEachExistingNestedGroup(
499 const std::function<void (QQStyleKitPropertyGroup *)> &f) const override;
500
501private:
502 QQStyleKitDelegateProperties *m_foreground = nullptr;
503 QQStyleKitIndicatorProperties *m_first = nullptr;
504 QQStyleKitIndicatorProperties *m_second = nullptr;
505
506 friend class QQStyleKitReader;
507 friend class QQStyleKitControlProperties;
508};
509
510// ************* QQStyleKitTextProperties ****************
511
512class Q_LABSSTYLEKIT_EXPORT QQStyleKitTextProperties : public QQStyleKitPropertyGroup
513{
514 Q_OBJECT
515 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
516 Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged FINAL)
517 Q_PROPERTY(bool bold READ bold WRITE setBold NOTIFY boldChanged FINAL)
518 Q_PROPERTY(bool italic READ italic WRITE setItalic NOTIFY italicChanged FINAL)
519 Q_PROPERTY(qreal pointSize READ pointSize WRITE setPointSize NOTIFY pointSizeChanged FINAL)
520 Q_PROPERTY(qreal padding READ padding WRITE setPadding NOTIFY paddingChanged FINAL)
521 Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding NOTIFY leftPaddingChanged FINAL)
522 Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding NOTIFY rightPaddingChanged FINAL)
523 Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding NOTIFY topPaddingChanged FINAL)
524 Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding NOTIFY bottomPaddingChanged FINAL)
525 Q_PROPERTY(QQStyleKitTextProperties *first READ first NOTIFY firstChanged FINAL)
526 Q_PROPERTY(QQStyleKitTextProperties *second READ second NOTIFY secondChanged FINAL)
527 QML_UNCREATABLE("This component can only be instantiated by StyleKit")
528 QML_NAMED_ELEMENT(TextStyle)
529
530public:
531 QQStyleKitTextProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent = nullptr);
532
533 template <typename... CHANGED_SIGNALS>
534 void emitGlobally(CHANGED_SIGNALS... changedSignals) const;
535
536 QColor color() const;
537 void setColor(const QColor &color);
538
539 Qt::Alignment alignment() const;
540 void setAlignment(Qt::Alignment alignment);
541
542 bool bold() const;
543 void setBold(bool bold);
544
545 bool italic() const;
546 void setItalic(bool italic);
547
548 qreal pointSize() const;
549 void setPointSize(qreal pointSize);
550
551 qreal padding() const;
552 void setPadding(qreal padding);
553
554 qreal leftPadding() const;
555 void setLeftPadding(qreal leftPadding);
556
557 qreal rightPadding() const;
558 void setRightPadding(qreal rightPadding);
559
560 qreal topPadding() const;
561 void setTopPadding(qreal topPadding);
562
563 qreal bottomPadding() const;
564 void setBottomPadding(qreal bottomPadding);
565
566 QQStyleKitTextProperties *first() const;
567 QQStyleKitTextProperties *second() const;
568
569signals:
570 void colorChanged();
571 void alignmentChanged();
572 void boldChanged();
573 void italicChanged();
574 void pointSizeChanged();
575 void paddingChanged();
576 void leftPaddingChanged();
577 void rightPaddingChanged();
578 void topPaddingChanged();
579 void bottomPaddingChanged();
580 void firstChanged();
581 void secondChanged();
582
583protected:
584 void forEachExistingNestedGroup(
585 const std::function<void (QQStyleKitPropertyGroup *)> &f) const override;
586
587private:
588 QQStyleKitTextProperties *m_first = nullptr;
589 QQStyleKitTextProperties *m_second = nullptr;
590};
591
592/************* QQStyleKitControlProperties ****************
593 * QQStyleKitControlProperties (and all other subclasses of QQStyleKitPropertyGroup),
594 * is just an empty interface declaring the properties available for styling and reading.
595 * It contains as little data as possible since it will be instantiated a lot. E.g a style
596 * will instantiate them for every style.button, style.slider, etc defined, the same for a
597 * theme, and also each instance of a StyleKitReader. Those are all subclasses of this
598 * class. Each subclass will determine if the properties can be written to (as opposed to
599 * only be read), and if so, offer a storage for storing those values. That storage is typically
600 * a map that stores _only_ the properties that are written to, and nothing else.
601 */
602class Q_LABSSTYLEKIT_EXPORT QQStyleKitControlProperties : public QQStyleKitPropertyGroup
603{
604 Q_OBJECT
605 Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged FINAL)
606 Q_PROPERTY(qreal padding READ padding WRITE setPadding NOTIFY paddingChanged FINAL)
607 Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding NOTIFY leftPaddingChanged FINAL)
608 Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding NOTIFY rightPaddingChanged FINAL)
609 Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding NOTIFY topPaddingChanged FINAL)
610 Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding NOTIFY bottomPaddingChanged FINAL)
611 Q_PROPERTY(QQStyleKitDelegateProperties *background READ background NOTIFY backgroundChanged FINAL)
612 Q_PROPERTY(QQStyleKitHandleProperties *handle READ handle NOTIFY handleChanged FINAL)
613 Q_PROPERTY(QQStyleKitIndicatorWithSubTypes *indicator READ indicator NOTIFY indicatorChanged FINAL)
614 Q_PROPERTY(QQStyleKitTextProperties *text READ text NOTIFY textChanged FINAL)
615 Q_PROPERTY(QQuickTransition *transition READ transition WRITE setTransition NOTIFY transitionChanged FINAL)
616
617 QML_UNCREATABLE("This component can only be instantiated by StyleKit")
618 QML_NAMED_ELEMENT(ControlStyleProperties)
619
620public:
621 QQStyleKitControlProperties(QQSK::PropertyGroup group, QObject *parent = nullptr);
622
623 void emitChangedForAllStyleProperties(EmitFlags emitFlags);;
624 template <typename... CHANGED_SIGNALS>
625 void emitGlobally(CHANGED_SIGNALS... changedSignals) const;
626 void forEachUsedDelegate(
627 std::function<void (QQStyleKitDelegateProperties *, QQSK::Delegate, const QString &)> f);
628
629 QQStyleKitStyle *style() const;
630 QQSK::Subclass subclass() const;
631 QQStyleKitReader *asQQStyleKitReader() const;
632 QQStyleKitControlState *asQQStyleKitState() const;
633
634 qreal spacing() const;
635 void setSpacing(qreal spacing);
636
637 qreal padding() const;
638 void setPadding(qreal padding);
639
640 qreal leftPadding() const;
641 void setLeftPadding(qreal leftPadding);
642
643 qreal rightPadding() const;
644 void setRightPadding(qreal rightPadding);
645
646 qreal topPadding() const;
647 void setTopPadding(qreal topPadding);
648
649 qreal bottomPadding() const;
650 void setBottomPadding(qreal bottomPadding);
651
652 QQuickTransition* transition() const;
653 void setTransition(QQuickTransition *transition);
654
655 QQStyleKitTextProperties *text() const;
656
657 QQStyleKitDelegateProperties *background() const;
658 QQStyleKitHandleProperties *handle() const;
659 QQStyleKitIndicatorWithSubTypes *indicator() const;
660
661signals:
662 void backgroundChanged();
663 void handleChanged();
664 void indicatorChanged();
665 void spacingChanged();
666 void paddingChanged();
667 void leftPaddingChanged();
668 void rightPaddingChanged();
669 void topPaddingChanged();
670 void bottomPaddingChanged();
671 void transitionChanged();
672 void textChanged();
673
674protected:
675 void forEachExistingNestedGroup(
676 const std::function<void (QQStyleKitPropertyGroup *)> &f) const override;
677
678private:
679 Q_DISABLE_COPY(QQStyleKitControlProperties)
680
681 QQStyleKitDelegateProperties *m_background = nullptr;
682 QQStyleKitHandleProperties *m_handle = nullptr;
683 QQStyleKitIndicatorWithSubTypes *m_indicator = nullptr;
684 QQStyleKitTextProperties *m_text = nullptr;
685
686 friend class QQStyleKitPropertyResolver;
687 friend class QQStyleKitReader;
688};
689
690QT_END_NAMESPACE
691
692#endif // QQSTYLEKITCONTROLPROPERTIES_P_H
QQStyleKitDelegateProperties * delegateStyle() const
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
void setDelegateStyle(QQStyleKitDelegateProperties *delegateProperties)
bool setStyleProperty(QQSK::Property property, T value)
QQStyleKitPropertyGroupSpace m_groupSpace
T styleProperty(QQSK::Property property, QQSK::Property alternative=QQSK::Property::NoProperty) const
T * lazyCreateGroup(T *const &ptr, QQSK::PropertyGroup group) const
void forEachRelevantStyleReader(const QQStyleKitControl *control, const std::function< void(QQStyleKitReader *reader)> &f) const
void handleStylePropertyChanged(void(SUBCLASS::*changedSignal)())
virtual void forEachExistingNestedGroup(const std::function< void(QQStyleKitPropertyGroup *)> &f) const
void handleStylePropertiesChanged(CHANGED_SIGNALS... changedSignals)
bool isDefined(QQSK::Property property) const
QQStyleKitControlProperties * controlProperties() const
Combined button and popup list for selecting options.