14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
52
53
54
55
56
57
58
61
62
63
64
65
66
67
68
69
70
71
74
75
76
77
78
79
80
81
82
83
86
87
88
89
90
91
92
95
96
97
98
99
100
101
102
103
104
107
108
109
110
111
112
113
116
117
118
119
120
123
124
125
126
129
130
131
132
133
134
135
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
185
186
187
188
189
192
193
194
195
198
199
200
201
202
203
206
207
208
209
210
211
212
215
216
217
218
219
220
223
224
225
226
229
230
231
232
233
234
235
236
237
238
239
240
241
242
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
305
306
307
308
309
310
311
312
313
314
315
316
317
318
321
322
323
324
325
326
329
330
331
332
335
336
337
338
339
342
343
344
345
346
347
348
351
352
353
354
355
356
357
358
361
362
363
364
365
368
369
370
371
372
373
374
377
378
379
380
381
382
383
384
387
388
389
390
391
392
393
396
397
398
399
402
403
404
405
408
409
410
411
412
413
416
417
418
419
420
421
424
425
426
427
428
429
430
433
434
435
436
437
438
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
460
461
462
463
464
465
466
467
468
469
470
471
472
475
476
477
478
479
482
483
484
485
486
487
490
491
492
493
498
499
500
501
502
503
504
505
506
507
508
509
510
513
514
515
516
519
520
521
522
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
551
552
553
554
555
556
559
560
561
562
563
564
565
568
569
570
571
572
573
576
577
578
579
582
583
584
585
586
587
588
591
592
593
594
595
598
599
600
601
604
605
606
607
608
609
610
611
612
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
639
640
641
642
643
644
647
648
649
650
651
652
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
679
680
681
682
683
684
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
732
733
734
735
736
737
738
739
740
741
742
743
746
747
748
749
750
751
752
753
754
755
756
757
758
759
762
763
764
765
766
767
768
769
770
771
772
773
774
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
801
802
803
804
807
808
809
810
811
812
813
816
817
818
819
820
821
822
825
826
827
828
831
832
833
834
835
836
837
840
841
842
843
844
845
846
849
850
851
852
853
854
855
856
859
860
861
862
865
866
867
868
869
870
871
874
875
876
877
878
879
880
884QHash<PropertyPathId_t, QString> QQStyleKitPropertyGroup::s_pathStrings;
893 if (flag == PropertyPathId::Flag::IncludeSubtype) {
894 if (m_pathFlags.testFlag(QQSK::PropertyPathFlag::DelegateSubtype1))
895 return PropertyPathId(property, m_groupSpace.start, QQSK::PropertyGroup::DelegateSubtype1);
896 else if (m_pathFlags.testFlag(QQSK::PropertyPathFlag::DelegateSubtype2))
897 return PropertyPathId(property, m_groupSpace.start, QQSK::PropertyGroup::DelegateSubtype2);
899 return PropertyPathId(property, m_groupSpace.start, QQSK::PropertyGroup::DelegateSubtype0);
905
906
907
908
909
910
911
912
913
914 if (s_pathStrings.contains(m_groupSpace.start))
915 return s_pathStrings[m_groupSpace.start];
917 constexpr PropertyPathId_t rootGroupsSize = nestedGroupsStartSize / nestedGroupCount;
918 const auto metaEnum = QMetaEnum::fromType<QQSK::PropertyGroup>();
920 PropertyPathId_t nestedGroupStart = m_groupSpace.start;
921 PropertyPathId_t nestedGroupSize = rootGroupsSize;
922 PropertyPathId_t nestedGroupIndex = nestedGroupStart / nestedGroupSize;
923 auto groupType = QQSK::PropertyGroup(nestedGroupIndex);
924 if (groupType == QQSK::PropertyGroup::Control)
927 QString groupName = QString::fromLatin1(metaEnum.valueToKey(
static_cast<
int>(groupType)));
928 groupName[0] = groupName[0].toLower();
929 QString pathString = groupName;
932 nestedGroupStart -= nestedGroupIndex * nestedGroupSize;
933 nestedGroupSize /= nestedGroupCount;
934 nestedGroupIndex = nestedGroupStart / nestedGroupSize;
935 groupType = QQSK::PropertyGroup(nestedGroupIndex);
936 if (groupType == QQSK::PropertyGroup::Control)
939 QString groupName = QString::fromLatin1(metaEnum.valueToKey(
static_cast<
int>(groupType)));
940 groupName[0] = groupName[0].toLower();
941 pathString +=
'.'_L1 + groupName;
944 s_pathStrings.insert(m_groupSpace.start, pathString);
951 Q_ASSERT(qobject_cast<
const QQStyleKitControlProperties *>(
this));
953 return static_cast<QQStyleKitControlProperties *>(self);
955 Q_ASSERT(qobject_cast<
const QQStyleKitControlProperties *>(parent()));
956 return static_cast<QQStyleKitControlProperties *>(parent());
962 T *nestedGroup = QQSK::lazyCreate(ptr, controlProperties(), group);
965 nestedGroup->m_pathFlags = m_pathFlags;
967 if (group == QQSK::PropertyGroup::DelegateSubtype1) {
969
970
971
972
973
974
975 nestedGroup->m_pathFlags.setFlag(QQSK::PropertyPathFlag::DelegateSubtype1);
976 nestedGroup->m_groupSpace = m_groupSpace;
977 }
else if (group == QQSK::PropertyGroup::DelegateSubtype2) {
978 nestedGroup->m_pathFlags.setFlag(QQSK::PropertyPathFlag::DelegateSubtype2);
979 nestedGroup->m_groupSpace = m_groupSpace;
982
983
984 const PropertyPathId_t nestedGroupIndex = PropertyPathId_t(group);
985 const PropertyPathId_t nestedGroupSize = m_groupSpace.size / nestedGroupCount;
986 nestedGroup->m_groupSpace.size = nestedGroupSize;
987 nestedGroup->m_groupSpace.start = m_groupSpace.start + (nestedGroupIndex * nestedGroupSize);
989
990
991
992
993
994 Q_ASSERT(nestedGroupSize >= PropertyPathId_t(QQSK::Property::COUNT));
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010#define CONDITIONALLY_EMIT_SIGNALS_GLOBALLY_FOR(CONTROL_PROPERTIES, GROUP_PATH) if
1011 (this == CONTROL_PROPERTIES -> GROUP_PATH ) {
1012 for (QQStyleKitReader *reader : QQStyleKitReader::s_allReaders) {
1013 const auto baseTypes = QQStyleKitPropertyResolver::baseTypesForType(reader->controlType());
1014 if (reader->controlType() != controlType && !baseTypes.contains(controlType))
1016 reader->clearLocalStorage();
1017 ((reader-> GROUP_PATH ->*changedSignals)(), ...);
1020}
1022template<
typename SUBCLASS>
1024 handleStylePropertiesChanged<SUBCLASS>(changedSignal);
1027template <
typename SUBCLASS,
typename... CHANGED_SIGNALS>
1031
1032
1033
1034
1035
1036
1037
1038 static_assert(std::is_base_of<QQStyleKitPropertyGroup, SUBCLASS>::value,
1039 "SUBCLASS must inherit QQStyleKitPropertyGroup");
1041 auto *group =
static_cast<SUBCLASS *>(
this);
1044 if (objectWrittenTo == QQSK::Subclass::QQStyleKitState) {
1045 ((group->*changedSignals)(), ...);
1047 if (shouldEmitGlobally()) {
1049 const QQStyleKitExtendableControlType type = control->controlType();
1050 group->emitGlobally(type, changedSignals...);
1055 if (objectWrittenTo == QQSK::Subclass::QQStyleKitReader) {
1057
1058
1059
1060 if (shouldEmitLocally()) {
1063
1064
1065
1066
1067 if (!reader->m_target)
1068 ((group->*changedSignals)(), ...);
1070 QCoreApplication::postEvent(reader->m_target,
new QEvent(QEvent::StyleAnimationUpdate));
1081
1082
1083 const int startIndex = QQStyleKitPropertyGroup::staticMetaObject.propertyOffset();
1084 const QMetaObject* meta = metaObject();
1085 for (
int i = startIndex; i < meta->propertyCount(); ++i) {
1086 const QMetaProperty prop = meta->property(i);
1087 const QMetaObject* propMetaObject = QMetaType::fromName(prop.typeName()).metaObject();
1088 if (propMetaObject) {
1089 if (propMetaObject->inherits(&QQStyleKitDelegateProperties::staticMetaObject)) {
1091
1092
1095 if (propMetaObject->inherits(&QQStyleKitPropertyGroup::staticMetaObject)) {
1097 QObject *childObj = qvariant_cast<QObject *>(property(prop.name()));
1098 if (
auto *child = qobject_cast<QQStyleKitPropertyGroup *>(childObj))
1099 child->emitChangedForAllStylePropertiesRecursive(emitFlags);
1104 if (!emitFlags.testFlag(EmitFlag::AllProperties)) {
1106 if (emitFlags.testFlag(EmitFlag::Colors)) {
1107 if (prop.metaType() != QMetaType::fromType<QColor>())
1113 Q_ASSERT(prop.hasNotifySignal());
1114 QMetaMethod notify = prop.notifySignal();
1115 notify.invoke(
this, Qt::DirectConnection);
1130 if (parentStyle->loaded() && !parentStyle->m_isUpdatingPalette) {
1132
1133
1134
1135
1136
1137
1138 return parentStyle == QQStyleKitStyle::current();
1145QQStyleKitImageProperties::QQStyleKitImageProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent)
1146 : QQStyleKitPropertyGroup(group, parent)
1150template <
typename... CHANGED_SIGNALS>
1151void QQStyleKitImageProperties::emitGlobally(
1152 QQStyleKitExtendableControlType controlType, CHANGED_SIGNALS... changedSignals)
const
1155 const QQStyleKitControlProperties *cp = controlProperties();
1162QUrl QQStyleKitImageProperties::source()
const
1164 return styleProperty<QUrl>(QQSK::Property::Source);
1167void QQStyleKitImageProperties::setSource(
const QUrl &source)
1169 if (setStyleProperty(QQSK::Property::Source, source))
1170 handleStylePropertyChanged(&QQStyleKitImageProperties::sourceChanged);
1173QColor QQStyleKitImageProperties::color()
const
1175 return styleProperty<QColor>(QQSK::Property::Color);
1178void QQStyleKitImageProperties::setColor(
const QColor &color)
1180 if (setStyleProperty(QQSK::Property::Color, color))
1181 handleStylePropertyChanged(&QQStyleKitImageProperties::colorChanged);
1184QQuickImage::FillMode QQStyleKitImageProperties::fillMode()
const
1186 return styleProperty<QQuickImage::FillMode>(QQSK::Property::FillMode);
1189void QQStyleKitImageProperties::setFillMode(QQuickImage::FillMode fillMode)
1191 if (setStyleProperty(QQSK::Property::FillMode, fillMode))
1192 handleStylePropertyChanged(&QQStyleKitImageProperties::fillModeChanged);
1197QQStyleKitBorderProperties::QQStyleKitBorderProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent)
1198 : QQStyleKitPropertyGroup(group, parent)
1202template <
typename... CHANGED_SIGNALS>
1203void QQStyleKitBorderProperties::emitGlobally(
1204 QQStyleKitExtendableControlType controlType, CHANGED_SIGNALS... changedSignals)
const
1207 const QQStyleKitControlProperties *cp = controlProperties();
1214qreal QQStyleKitBorderProperties::width()
const
1216 return styleProperty<qreal>(QQSK::Property::Width);
1219void QQStyleKitBorderProperties::setWidth(qreal width)
1221 if (setStyleProperty(QQSK::Property::Width, width))
1222 handleStylePropertyChanged(&QQStyleKitBorderProperties::widthChanged);
1225QColor QQStyleKitBorderProperties::color()
const
1227 return styleProperty<QColor>(QQSK::Property::Color, Qt::transparent);
1230void QQStyleKitBorderProperties::setColor(
const QColor &color)
1232 if (setStyleProperty(QQSK::Property::Color, color))
1233 handleStylePropertyChanged(&QQStyleKitBorderProperties::colorChanged);
1238QQStyleKitShadowProperties::QQStyleKitShadowProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent)
1239 : QQStyleKitPropertyGroup(group, parent)
1243template <
typename... CHANGED_SIGNALS>
1244void QQStyleKitShadowProperties::emitGlobally(
1245 QQStyleKitExtendableControlType controlType, CHANGED_SIGNALS... changedSignals)
const
1248 const QQStyleKitControlProperties *cp = controlProperties();
1255QColor QQStyleKitShadowProperties::color()
const
1257 return styleProperty<QColor>(QQSK::Property::Color, Qt::transparent);
1260void QQStyleKitShadowProperties::setColor(QColor color)
1262 if (setStyleProperty(QQSK::Property::Color, color))
1263 handleStylePropertyChanged(&QQStyleKitShadowProperties::colorChanged);
1266qreal QQStyleKitShadowProperties::opacity()
const
1268 return styleProperty<qreal>(QQSK::Property::Opacity, 1.0);
1271void QQStyleKitShadowProperties::setOpacity(qreal opacity)
1273 if (setStyleProperty(QQSK::Property::Opacity, opacity))
1274 handleStylePropertyChanged(&QQStyleKitShadowProperties::opacityChanged);
1277qreal QQStyleKitShadowProperties::scale()
const
1279 return styleProperty<qreal>(QQSK::Property::Scale, 1.0);
1282void QQStyleKitShadowProperties::setScale(qreal scale)
1284 if (setStyleProperty(QQSK::Property::Scale, scale))
1285 handleStylePropertyChanged(&QQStyleKitShadowProperties::scaleChanged);
1288qreal QQStyleKitShadowProperties::verticalOffset()
const
1290 return styleProperty<qreal>(QQSK::Property::VOffset);
1293void QQStyleKitShadowProperties::setVerticalOffset(qreal verticalOffset)
1295 if (setStyleProperty(QQSK::Property::VOffset, verticalOffset))
1296 handleStylePropertyChanged(&QQStyleKitShadowProperties::verticalOffsetChanged);
1299qreal QQStyleKitShadowProperties::horizontalOffset()
const
1301 return styleProperty<qreal>(QQSK::Property::HOffset);
1304void QQStyleKitShadowProperties::setHorizontalOffset(qreal horizontalOffset)
1306 if (setStyleProperty(QQSK::Property::HOffset, horizontalOffset))
1307 handleStylePropertyChanged(&QQStyleKitShadowProperties::horizontalOffsetChanged);
1310qreal QQStyleKitShadowProperties::blur()
const
1312 return styleProperty<qreal>(QQSK::Property::Blur, 10.0);
1315void QQStyleKitShadowProperties::setBlur(qreal blur)
1317 if (setStyleProperty(QQSK::Property::Blur, blur))
1318 handleStylePropertyChanged(&QQStyleKitShadowProperties::blurChanged);
1321bool QQStyleKitShadowProperties::visible()
const
1323 return styleProperty<
bool>(QQSK::Property::Visible,
true);
1326void QQStyleKitShadowProperties::setVisible(
bool visible)
1328 if (setStyleProperty(QQSK::Property::Visible, visible))
1329 handleStylePropertyChanged(&QQStyleKitShadowProperties::visibleChanged);
1332QQmlComponent *QQStyleKitShadowProperties::delegate()
const
1334 return styleProperty<QQmlComponent *>(QQSK::Property::Delegate);
1337void QQStyleKitShadowProperties::setDelegate(QQmlComponent *delegate)
1339 if (setStyleProperty(QQSK::Property::Delegate, delegate))
1340 handleStylePropertyChanged(&QQStyleKitShadowProperties::delegateChanged);
1345QQStyleKitDelegateProperties::QQStyleKitDelegateProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent)
1346 : QQStyleKitPropertyGroup(group, parent)
1350template <
typename... CHANGED_SIGNALS>
1351void QQStyleKitDelegateProperties::emitGlobally(
1352 QQStyleKitExtendableControlType controlType, CHANGED_SIGNALS... changedSignals)
const
1355 const QQStyleKitControlProperties *cp = controlProperties();
1362qreal QQStyleKitDelegateProperties::radius()
const
1364 return styleProperty<qreal>(QQSK::Property::Radius);
1367void QQStyleKitDelegateProperties::setRadius(qreal radius)
1369 if (setStyleProperty(QQSK::Property::Radius, radius))
1370 handleStylePropertiesChanged<QQStyleKitDelegateProperties>(
1371 &QQStyleKitDelegateProperties::radiusChanged,
1372 &QQStyleKitDelegateProperties::topLeftRadiusChanged,
1373 &QQStyleKitDelegateProperties::topRightRadiusChanged,
1374 &QQStyleKitDelegateProperties::bottomLeftRadiusChanged,
1375 &QQStyleKitDelegateProperties::bottomRightRadiusChanged);
1378qreal QQStyleKitDelegateProperties::topLeftRadius()
const
1380 return styleProperty<qreal>(QQSK::Property::TopLeftRadius, QQSK::Property::Radius);
1383void QQStyleKitDelegateProperties::setTopLeftRadius(qreal radius)
1385 if (setStyleProperty(QQSK::Property::TopLeftRadius, radius))
1386 handleStylePropertyChanged(&QQStyleKitDelegateProperties::topLeftRadiusChanged);
1389qreal QQStyleKitDelegateProperties::topRightRadius()
const
1391 return styleProperty<qreal>(QQSK::Property::TopRightRadius, QQSK::Property::Radius);
1394void QQStyleKitDelegateProperties::setTopRightRadius(qreal radius)
1396 if (setStyleProperty(QQSK::Property::TopRightRadius, radius))
1397 handleStylePropertyChanged(&QQStyleKitDelegateProperties::topRightRadiusChanged);
1400qreal QQStyleKitDelegateProperties::bottomLeftRadius()
const
1402 return styleProperty<qreal>(QQSK::Property::BottomLeftRadius, QQSK::Property::Radius);
1405void QQStyleKitDelegateProperties::setBottomLeftRadius(qreal radius)
1407 if (setStyleProperty(QQSK::Property::BottomLeftRadius, radius))
1408 handleStylePropertyChanged(&QQStyleKitDelegateProperties::bottomLeftRadiusChanged);
1411qreal QQStyleKitDelegateProperties::bottomRightRadius()
const
1413 return styleProperty<qreal>(QQSK::Property::BottomRightRadius, QQSK::Property::Radius);
1416void QQStyleKitDelegateProperties::setBottomRightRadius(qreal radius)
1418 if (setStyleProperty(QQSK::Property::BottomRightRadius, radius))
1419 handleStylePropertyChanged(&QQStyleKitDelegateProperties::bottomRightRadiusChanged);
1422qreal QQStyleKitDelegateProperties::scale()
const
1424 return styleProperty<qreal>(QQSK::Property::Scale, 1.0);
1427void QQStyleKitDelegateProperties::setScale(qreal scale)
1429 if (setStyleProperty(QQSK::Property::Scale, scale))
1430 handleStylePropertyChanged(&QQStyleKitDelegateProperties::scaleChanged);
1433qreal QQStyleKitDelegateProperties::rotation()
const
1435 return styleProperty<qreal>(QQSK::Property::Rotation);
1438void QQStyleKitDelegateProperties::setRotation(qreal rotation)
1440 if (setStyleProperty(QQSK::Property::Rotation, rotation))
1441 handleStylePropertyChanged(&QQStyleKitDelegateProperties::rotationChanged);
1444qreal QQStyleKitDelegateProperties::implicitWidth()
const
1446 return styleProperty<qreal>(QQSK::Property::ImplicitWidth);
1449void QQStyleKitDelegateProperties::setImplicitWidth(qreal width)
1451 if (setStyleProperty(QQSK::Property::ImplicitWidth, width))
1452 handleStylePropertyChanged(&QQStyleKitDelegateProperties::implicitWidthChanged);
1455qreal QQStyleKitDelegateProperties::implicitHeight()
const
1457 return styleProperty<qreal>(QQSK::Property::ImplicitHeight);
1460void QQStyleKitDelegateProperties::setImplicitHeight(qreal height)
1462 if (setStyleProperty(QQSK::Property::ImplicitHeight, height))
1463 handleStylePropertyChanged(&QQStyleKitDelegateProperties::implicitHeightChanged);
1466qreal QQStyleKitDelegateProperties::minimumWidth()
const
1468 return styleProperty<qreal>(QQSK::Property::MinimumWidth);
1471void QQStyleKitDelegateProperties::setMinimumWidth(qreal width)
1473 if (setStyleProperty(QQSK::Property::MinimumWidth, width))
1474 handleStylePropertyChanged(&QQStyleKitDelegateProperties::minimumWidthChanged);
1477qreal QQStyleKitDelegateProperties::margins()
const
1479 return styleProperty<qreal>(QQSK::Property::Margins);
1482void QQStyleKitDelegateProperties::setMargins(qreal margins)
1484 if (setStyleProperty(QQSK::Property::Margins, margins))
1485 handleStylePropertiesChanged<QQStyleKitDelegateProperties>(
1486 &QQStyleKitDelegateProperties::marginsChanged,
1487 &QQStyleKitDelegateProperties::leftMarginChanged,
1488 &QQStyleKitDelegateProperties::rightMarginChanged,
1489 &QQStyleKitDelegateProperties::topMarginChanged,
1490 &QQStyleKitDelegateProperties::bottomMarginChanged);
1493qreal QQStyleKitDelegateProperties::leftMargin()
const
1495 return styleProperty<qreal>(QQSK::Property::LeftMargin, QQSK::Property::Margins);
1498void QQStyleKitDelegateProperties::setLeftMargin(qreal margin)
1500 if (setStyleProperty(QQSK::Property::LeftMargin, margin))
1501 handleStylePropertyChanged(&QQStyleKitDelegateProperties::leftMarginChanged);
1504qreal QQStyleKitDelegateProperties::rightMargin()
const
1506 return styleProperty<qreal>(QQSK::Property::RightMargin, QQSK::Property::Margins);
1509void QQStyleKitDelegateProperties::setRightMargin(qreal margin)
1511 if (setStyleProperty(QQSK::Property::RightMargin, margin))
1512 handleStylePropertyChanged(&QQStyleKitDelegateProperties::rightMarginChanged);
1515qreal QQStyleKitDelegateProperties::topMargin()
const
1517 return styleProperty<qreal>(QQSK::Property::TopMargin, QQSK::Property::Margins);
1520void QQStyleKitDelegateProperties::setTopMargin(qreal margin)
1522 if (setStyleProperty(QQSK::Property::TopMargin, margin))
1523 handleStylePropertyChanged(&QQStyleKitDelegateProperties::topMarginChanged);
1526qreal QQStyleKitDelegateProperties::bottomMargin()
const
1528 return styleProperty<qreal>(QQSK::Property::BottomMargin, QQSK::Property::Margins);
1531void QQStyleKitDelegateProperties::setBottomMargin(qreal margin)
1533 if (setStyleProperty(QQSK::Property::BottomMargin, margin))
1534 handleStylePropertyChanged(&QQStyleKitDelegateProperties::bottomMarginChanged);
1537Qt::Alignment QQStyleKitDelegateProperties::alignment()
const
1539 return styleProperty<Qt::Alignment>(QQSK::Property::Alignment, Qt::AlignLeft | Qt::AlignVCenter);
1542void QQStyleKitDelegateProperties::setAlignment(Qt::Alignment alignment)
1544 if (setStyleProperty(QQSK::Property::Alignment, alignment))
1545 handleStylePropertyChanged(&QQStyleKitDelegateProperties::alignmentChanged);
1548qreal QQStyleKitDelegateProperties::opacity()
const
1550 return styleProperty<qreal>(QQSK::Property::Opacity, 1.0);
1553void QQStyleKitDelegateProperties::setOpacity(qreal opacity)
1555 if (setStyleProperty(QQSK::Property::Opacity, opacity))
1556 handleStylePropertyChanged(&QQStyleKitDelegateProperties::opacityChanged);
1559QColor QQStyleKitDelegateProperties::color()
const
1561 return styleProperty<QColor>(QQSK::Property::Color, Qt::transparent);
1564void QQStyleKitDelegateProperties::setColor(
const QColor &color)
1566 if (setStyleProperty(QQSK::Property::Color, color))
1567 handleStylePropertyChanged(&QQStyleKitDelegateProperties::colorChanged);
1570bool QQStyleKitDelegateProperties::visible()
const
1572 return styleProperty<
bool>(QQSK::Property::Visible,
true);
1575void QQStyleKitDelegateProperties::setVisible(
bool visible)
1577 if (setStyleProperty(QQSK::Property::Visible, visible))
1578 handleStylePropertyChanged(&QQStyleKitDelegateProperties::visibleChanged);
1581bool QQStyleKitDelegateProperties::clip()
const
1583 return styleProperty<
bool>(QQSK::Property::Clip,
false);
1586void QQStyleKitDelegateProperties::setClip(
bool clip)
1588 if (setStyleProperty(QQSK::Property::Clip, clip))
1589 handleStylePropertyChanged(&QQStyleKitDelegateProperties::clipChanged);
1592QQuickGradient *QQStyleKitDelegateProperties::gradient()
const
1594 return styleProperty<QQuickGradient *>(QQSK::Property::Gradient);
1597void QQStyleKitDelegateProperties::setGradient(QQuickGradient *gradient)
1599 if (setStyleProperty(QQSK::Property::Gradient, gradient))
1600 handleStylePropertyChanged(&QQStyleKitDelegateProperties::gradientChanged);
1603QObject *QQStyleKitDelegateProperties::data()
const
1605 return styleProperty<QObject *>(QQSK::Property::Data);
1608void QQStyleKitDelegateProperties::setData(QObject *data)
1610 if (setStyleProperty(QQSK::Property::Data, data))
1611 handleStylePropertyChanged(&QQStyleKitDelegateProperties::dataChanged);
1614QQmlComponent *QQStyleKitDelegateProperties::delegate()
const
1616 return styleProperty<QQmlComponent *>(QQSK::Property::Delegate);
1619void QQStyleKitDelegateProperties::setDelegate(QQmlComponent *delegate)
1621 if (setStyleProperty(QQSK::Property::Delegate, delegate))
1622 handleStylePropertyChanged(&QQStyleKitDelegateProperties::delegateChanged);
1625QQStyleKitBorderProperties *QQStyleKitDelegateProperties::border()
const
1627 return lazyCreateGroup(m_border, QQSK::PropertyGroup::Border);
1630QQStyleKitShadowProperties *QQStyleKitDelegateProperties::shadow()
const
1632 return lazyCreateGroup(m_shadow, QQSK::PropertyGroup::Shadow);
1635QQStyleKitImageProperties *QQStyleKitDelegateProperties::image()
const
1637 return lazyCreateGroup(m_image, QQSK::PropertyGroup::Image);
1643 : QQStyleKitDelegateProperties(group, parent)
1649 return lazyCreateGroup(m_first, QQSK::PropertyGroup::DelegateSubtype1);
1654 return lazyCreateGroup(m_second, QQSK::PropertyGroup::DelegateSubtype2);
1660 QQSK::PropertyGroup group, QQStyleKitControlProperties *parent)
1661 : QQStyleKitDelegateProperties(group, parent)
1665template <
typename... CHANGED_SIGNALS>
1667 QQStyleKitExtendableControlType controlType, CHANGED_SIGNALS... changedSignals)
const
1670 const QQStyleKitControlProperties *cp = controlProperties();
1677 return lazyCreateGroup(m_foreground, QQSK::PropertyGroup::Foreground);
1683 QQSK::PropertyGroup group, QQStyleKitControlProperties *parent)
1684 : QQStyleKitDelegateProperties(group, parent)
1688template <
typename... CHANGED_SIGNALS>
1690 QQStyleKitExtendableControlType controlType, CHANGED_SIGNALS... changedSignals)
const
1693 const QQStyleKitControlProperties *cp = controlProperties();
1699 return lazyCreateGroup(m_foreground, QQSK::PropertyGroup::Foreground);
1714 return lazyCreateGroup(m_first, QQSK::PropertyGroup::DelegateSubtype1);
1719 return lazyCreateGroup(m_second, QQSK::PropertyGroup::DelegateSubtype2);
1728template <
typename... CHANGED_SIGNALS>
1730 QQStyleKitExtendableControlType controlType, CHANGED_SIGNALS... changedSignals)
const
1738 return styleProperty<QColor>(QQSK::Property::Color);
1743 if (setStyleProperty(QQSK::Property::Color, color))
1744 handleStylePropertyChanged(&QQStyleKitTextProperties::colorChanged);
1749 return styleProperty<Qt::Alignment>(QQSK::Property::Alignment);
1754 if (setStyleProperty(QQSK::Property::Alignment, alignment))
1755 handleStylePropertyChanged(&QQStyleKitTextProperties::alignmentChanged);
1760 return styleProperty<
bool>(QQSK::Property::Bold,
false);
1765 if (setStyleProperty(QQSK::Property::Bold, bold))
1771 return styleProperty<
bool>(QQSK::Property::Italic,
false);
1776 if (setStyleProperty(QQSK::Property::Italic, italic))
1782 return styleProperty<qreal>(QQSK::Property::PointSize);
1787 if (setStyleProperty(QQSK::Property::PointSize, pointSize))
1793 return styleProperty<qreal>(QQSK::Property::Padding);
1798 if (setStyleProperty(QQSK::Property::Padding, padding))
1809 return styleProperty<qreal>(QQSK::Property::LeftPadding, QQSK::Property::Padding);
1814 if (setStyleProperty(QQSK::Property::LeftPadding, padding))
1820 return styleProperty<qreal>(QQSK::Property::RightPadding, QQSK::Property::Padding);
1825 if (setStyleProperty(QQSK::Property::RightPadding, padding))
1831 return styleProperty<qreal>(QQSK::Property::TopPadding, QQSK::Property::Padding);
1836 if (setStyleProperty(QQSK::Property::TopPadding, padding))
1842 return styleProperty<qreal>(QQSK::Property::BottomPadding, QQSK::Property::Padding);
1847 if (setStyleProperty(QQSK::Property::BottomPadding, padding))
1853QQStyleKitControlProperties::QQStyleKitControlProperties(QQSK::PropertyGroup group, QObject *parent)
1854 : QQStyleKitPropertyGroup(group, parent)
1857
1858
1859
1860
1861 m_groupSpace.size = nestedGroupsStartSize;
1862 m_groupSpace.start = 0;
1864 if (group == QQSK::PropertyGroup::GlobalFlag) {
1866
1867
1868
1869
1870
1871
1872 m_pathFlags.setFlag(QQSK::PropertyPathFlag::Global);
1876QQStyleKitStyle *QQStyleKitControlProperties::style()
const
1878 if (subclass() == QQSK::Subclass::QQStyleKitState) {
1880
1881
1882
1883
1884
1885
1886 QObject *obj = parent();
1887 while (obj && !obj->metaObject()->inherits(&QQStyleKitStyle::staticMetaObject))
1888 obj = obj->parent();
1889 return obj ?
static_cast<QQStyleKitStyle *>(obj) :
nullptr;
1892 if (subclass() == QQSK::Subclass::QQStyleKitReader) {
1893 const auto *reader =
static_cast<
const QQStyleKitReader *>(
this);
1894 if (reader->m_explicitStyle)
1895 return reader->m_explicitStyle;
1899 return QQStyleKitStyle::current();
1902QQSK::Subclass QQStyleKitControlProperties::subclass()
const
1905
1906
1907
1908
1909
1910 if (metaObject()->inherits(&QQStyleKitReader::staticMetaObject))
1911 return QQSK::Subclass::QQStyleKitReader;
1912 if (metaObject()->inherits(&QQStyleKitControlState::staticMetaObject))
1913 return QQSK::Subclass::QQStyleKitState;
1917QQStyleKitReader *QQStyleKitControlProperties::asQQStyleKitReader()
const
1919 Q_ASSERT(subclass() == QQSK::Subclass::QQStyleKitReader);
1920 return static_cast<QQStyleKitReader *>(
const_cast<QQStyleKitControlProperties *>(
this));
1923QQStyleKitControlState *QQStyleKitControlProperties::asQQStyleKitState()
const
1925 Q_ASSERT(subclass() == QQSK::Subclass::QQStyleKitState);
1926 Q_ASSERT(metaObject()->inherits(&QQStyleKitControlState::staticMetaObject));
1927 return static_cast<QQStyleKitControlState *>(
const_cast<QQStyleKitControlProperties *>(
this));
1930void QQStyleKitControlProperties::forEachUsedDelegate(
1931 std::function<
void (QQStyleKitDelegateProperties *, QQSK::Delegate,
const QString &)> f)
1935 f(m_background, QQSK::Delegate::Background,
"background"_L1);
1938 f(m_indicator, QQSK::Delegate::Indicator,
"indicator"_L1);
1939 if (m_indicator->m_foreground)
1940 f(m_indicator->m_foreground, QQSK::Delegate::IndicatorForeground,
"indicator.foreground"_L1);
1941 if (m_indicator->m_first) {
1942 f(m_indicator->m_first, QQSK::Delegate::IndicatorFirst,
"indicator.first"_L1);
1943 if (m_indicator->m_first->m_foreground)
1944 f(m_indicator->m_first->m_foreground, QQSK::Delegate::IndicatorFirstForeground,
"indicator.first.foreground"_L1);
1946 if (m_indicator->m_second) {
1947 f(m_indicator->m_second, QQSK::Delegate::IndicatorSecond,
"indicator.second"_L1);
1948 if (m_indicator->m_second->m_foreground)
1949 f(m_indicator->m_second->m_foreground, QQSK::Delegate::IndicatorSecondForeground,
"indicator.second.foreground"_L1);
1954 f(m_handle, QQSK::Delegate::Handle,
"handle"_L1);
1955 if (m_handle->m_first)
1956 f(m_handle->m_first, QQSK::Delegate::HandleFirst,
"handle.first"_L1);
1957 if (m_handle->m_second)
1958 f(m_handle->m_second, QQSK::Delegate::HandleSecond,
"handle.second"_L1);
1962void QQStyleKitControlProperties::emitChangedForAllStyleProperties(EmitFlags emitFlags)
1965
1966
1967 if (emitFlags.testFlag(EmitFlag::AllProperties)) {
1968 emit leftPaddingChanged();
1969 emit rightPaddingChanged();
1970 emit topPaddingChanged();
1971 emit bottomPaddingChanged();
1972 emit spacingChanged();
1973 emit transitionChanged();
1977 forEachUsedDelegate([=](QQStyleKitDelegateProperties *delegate, QQSK::Delegate,
const QString &){
1978 delegate->emitChangedForAllStylePropertiesRecursive(emitFlags);
1982template <
typename... CHANGED_SIGNALS>
1983void QQStyleKitControlProperties::emitGlobally(
1984 QQStyleKitExtendableControlType controlType, CHANGED_SIGNALS... changedSignals)
const
1986 for (QQStyleKitReader *reader : QQStyleKitReader::s_allReaders) {
1987 if (reader->controlType() != controlType)
1989 ((reader->*changedSignals)(), ...);
1993qreal QQStyleKitControlProperties::spacing()
const
1995 return styleProperty<qreal>(QQSK::Property::Spacing);
1998void QQStyleKitControlProperties::setSpacing(qreal spacing)
2000 if (setStyleProperty(QQSK::Property::Spacing, spacing))
2001 handleStylePropertyChanged(&QQStyleKitControlProperties::spacingChanged);
2004qreal QQStyleKitControlProperties::padding()
const
2006 return styleProperty<qreal>(QQSK::Property::Padding);
2009void QQStyleKitControlProperties::setPadding(qreal padding)
2011 if (setStyleProperty(QQSK::Property::Padding, padding))
2012 handleStylePropertiesChanged<QQStyleKitControlProperties>(
2013 &QQStyleKitControlProperties::paddingChanged,
2014 &QQStyleKitControlProperties::leftPaddingChanged,
2015 &QQStyleKitControlProperties::rightPaddingChanged,
2016 &QQStyleKitControlProperties::topPaddingChanged,
2017 &QQStyleKitControlProperties::bottomPaddingChanged);
2020qreal QQStyleKitControlProperties::leftPadding()
const
2022 return styleProperty<qreal>(QQSK::Property::LeftPadding, QQSK::Property::Padding);
2025void QQStyleKitControlProperties::setLeftPadding(qreal leftPadding)
2027 if (setStyleProperty(QQSK::Property::LeftPadding, leftPadding))
2028 handleStylePropertyChanged(&QQStyleKitControlProperties::leftPaddingChanged);
2031qreal QQStyleKitControlProperties::rightPadding()
const
2033 return styleProperty<qreal>(QQSK::Property::RightPadding, QQSK::Property::Padding);
2036void QQStyleKitControlProperties::setRightPadding(qreal rightPadding)
2038 if (setStyleProperty(QQSK::Property::RightPadding, rightPadding))
2039 handleStylePropertyChanged(&QQStyleKitControlProperties::rightPaddingChanged);
2042qreal QQStyleKitControlProperties::topPadding()
const
2044 return styleProperty<qreal>(QQSK::Property::TopPadding, QQSK::Property::Padding);
2047void QQStyleKitControlProperties::setTopPadding(qreal topPadding)
2049 if (setStyleProperty(QQSK::Property::TopPadding, topPadding))
2050 handleStylePropertyChanged(&QQStyleKitControlProperties::topPaddingChanged);
2053qreal QQStyleKitControlProperties::bottomPadding()
const
2055 return styleProperty<qreal>(QQSK::Property::BottomPadding, QQSK::Property::Padding);
2058void QQStyleKitControlProperties::setBottomPadding(qreal bottomPadding)
2060 if (setStyleProperty(QQSK::Property::BottomPadding, bottomPadding))
2061 handleStylePropertyChanged(&QQStyleKitControlProperties::bottomPaddingChanged);
2064QQuickTransition *QQStyleKitControlProperties::transition()
const
2066 return styleProperty<QQuickTransition *>(QQSK::Property::Transition);
2069void QQStyleKitControlProperties::setTransition(QQuickTransition *transition)
2071 if (setStyleProperty(QQSK::Property::Transition, transition))
2072 handleStylePropertyChanged(&QQStyleKitControlProperties::transitionChanged);
2075QQStyleKitTextProperties *QQStyleKitControlProperties::text()
const
2077 return lazyCreateGroup(m_text, QQSK::PropertyGroup::Text);
2080QQStyleKitDelegateProperties *QQStyleKitControlProperties::background()
const
2082 return lazyCreateGroup(m_background, QQSK::PropertyGroup::Background);
2085QQStyleKitHandleProperties *QQStyleKitControlProperties::handle()
const
2087 return lazyCreateGroup(m_handle, QQSK::PropertyGroup::Handle);
2090QQStyleKitIndicatorWithSubTypes *QQStyleKitControlProperties::indicator()
const
2092 return lazyCreateGroup(m_indicator, QQSK::PropertyGroup::Indicator);
2097#include "moc_qqstylekitcontrolproperties_p.cpp"
QQStyleKitDelegateProperties * first() const
QQStyleKitDelegateProperties * second() const
QQStyleKitDelegateProperties * foreground() const
void emitGlobally(QQStyleKitExtendableControlType controlType, CHANGED_SIGNALS... changedSignals) const
void emitGlobally(QQStyleKitExtendableControlType controlType, CHANGED_SIGNALS... changedSignals) const
QQStyleKitDelegateProperties * foreground() const
QQStyleKitIndicatorProperties * down() const
QQStyleKitIndicatorProperties * up() const
QQStyleKitIndicatorProperties * second() const
QQStyleKitIndicatorProperties * first() const
void emitChangedForAllStylePropertiesRecursive(EmitFlags emitFlags)
T * lazyCreateGroup(T *const &ptr, QQSK::PropertyGroup group) const
void handleStylePropertyChanged(void(SUBCLASS::*changedSignal)())
void handleStylePropertiesChanged(CHANGED_SIGNALS... changedSignals)
QQStyleKitControlProperties * controlProperties() const
QString pathToString() const
bool isControlProperties() const
void setRightPadding(qreal rightPadding)
void setBottomPadding(qreal bottomPadding)
void setTopPadding(qreal topPadding)
void setLeftPadding(qreal leftPadding)
void setPadding(qreal padding)
qreal rightPadding() const
void setItalic(bool italic)
qreal bottomPadding() const
void setPointSize(qreal pointSize)
void setColor(const QColor &color)
void bottomPaddingChanged()
Qt::Alignment alignment() const
void emitGlobally(QQStyleKitExtendableControlType controlType, CHANGED_SIGNALS... changedSignals) const
void rightPaddingChanged()
void leftPaddingChanged()
qreal leftPadding() const
Combined button and popup list for selecting options.
#define CONDITIONALLY_EMIT_SIGNALS_GLOBALLY_FOR(CONTROL_PROPERTIES, GROUP_PATH)