aboutsummaryrefslogtreecommitdiffstats
path: root/src/labs/stylekit/doc/snippets/ReferenceFallbackStyle.qml
blob: 26f69ad5770833ffbbd0cc51fe4b4aba84753ad6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
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
730
731
732
// Copyright (C) 2026 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

//! [1]
import QtQuick
import Qt.labs.StyleKit

BaseStyle {
    id: style

    /* Properties and Controls left unspecified in a Style will be read from Style.fallbackStyle
     * instead (that is, this file, unless the fallback style is changed). Here we can give the
     * properties some sensible defaults. */

    /* Assign sensible light-theme colors to the controls. We intentionally avoid
     * binding to the OS palette (except for the accent color) because the fallback
     * style should provide a stable baseline for other styles and remain identical
     * and consistent across all platforms. Instead, it is the style developer’s
     * responsibility to bind individual colors to the palette if desired, and to
     * define separate themes for light and dark mode. */

    readonly property color __baseBlack: "black"
    readonly property color __baseWhite: "white"
    readonly property color __backgroundDefault: Qt.darker(__baseWhite, 1.1)
    readonly property color __backgroundMuted: Qt.darker(__baseWhite, 1.2)
    readonly property color __backgroundSubtle: Qt.darker(__baseWhite, 1.3)
    readonly property color __strokeStrong: Qt.darker(__baseWhite, 1.6)
    readonly property color __strokeMuted: Qt.darker(__baseWhite, 1.4)
    readonly property color __textDefault: Qt.darker(__baseWhite, 1.9)
    readonly property color __textSubtle: Qt.darker(__baseWhite, 1.6)
    readonly property color __transparent: "transparent"

    readonly property real indicatorSize: 24

    control {
        spacing: 5
        padding: 5

        background {
            radius: 2
            width: 100
            height: 40
            border.width: 1
            color: __backgroundDefault
            border.color: __strokeStrong
        }

        indicator {
            width: style.indicatorSize
            height: style.indicatorSize
            border.width: 1
            color: __baseWhite
            border.color: __strokeStrong
            foreground {
                fillWidth: false
                fillHeight: false
                margins: 1
                color: palette.accent
                image.color: palette.accent
                /* Note: don't set implicit size here, since the DelegateContainer will (and should)
                 * fall back to use the size of the image if not set. So if we hard-code a size here,
                 * it cannot be unset to be the size of the image (if any) again from the Style. */
            }
        }

        text {
            color: __baseBlack
        }

        handle {
            width: style.indicatorSize
            height: style.indicatorSize
            radius: style.indicatorSize / 2
            border.width: 1
            color: __backgroundDefault
            border.color: __strokeStrong
        }

        checked {
            background.color: __backgroundSubtle
        }

        hovered {
            handle.color: __backgroundMuted
        }

        disabled {
            background.color: __baseWhite
            text.color: __textSubtle
        }
    }

    abstractButton {
        hovered.background.color: __backgroundMuted
    }

    applicationWindow {
        background.color: __baseWhite
    }

    busyIndicator {
        background {
            visible: false
            width: 48
            height: 48
        }
        indicator {
            fillWidth: true
            fillHeight: true
            color: __transparent
            border.width: 0
            foreground {
                radius: 255
                delegate: BusyIndicatorDelegate { }
            }
        }
    }

    checkBox {
        background.visible: false
        indicator {
            foreground {
                fillWidth: true
                fillHeight: true
                color: __transparent
                visible: false
                image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/check.png"
            }
        }
        text {
            alignment: Qt.AlignVCenter | Qt.AlignLeft
        }
        checked {
            indicator.foreground.visible: true
        }
    }

    checkDelegate {
        text.alignment: Qt.AlignVCenter | Qt.AlignLeft
        background {
            radius: 0
            color: __baseWhite
            border.width: 0
        }
        indicator {
            alignment: Qt.AlignRight | Qt.AlignVCenter
            foreground {
                fillWidth: true
                fillHeight: true
                visible: false
                alignment: Qt.AlignCenter
                color: __transparent
                image.fillMode: Image.PreserveAspectFit
                image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/check.png"
            }
        }
        hovered.background.color: __backgroundDefault
        checked {
            indicator.foreground.visible: true
        }
    }

    comboBox {
        text.alignment: Qt.AlignVCenter | Qt.AlignLeft
        background.width: 150
        indicator {
            color: __transparent
            border.width: 0
            alignment: Qt.AlignRight | Qt.AlignVCenter
            foreground {
                width: 10
                height: 10
                alignment: Qt.AlignCenter
                color: __transparent
                image.color: __textDefault
                image.fillMode: Image.PreserveAspectFit
                image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/drop-indicator.png"
            }
        }
    }

    delayButton {
        padding: 0
        indicator {
            fillWidth: true
            fillHeight: true
            color: __transparent
            border.width: 0
            foreground {
                fillWidth: true
                fillHeight: true
                delegate: ProgressDelegate {}
            }
        }
    }

    dial {
        spacing: 0
        handle.width: 15
        handle.height: 15
        background.visible: false
        indicator {
            width: 60
            height: 60
            radius: 255
            foreground {
                fillWidth: true
                fillHeight: true
                width: 6
                height: 6
                delegate: DialDelegate {}
            }
        }
    }

    dialog {
        text {
            padding: 12
            alignment: Qt.AlignVCenter | Qt.AlignLeft
        }
        background.color: __baseWhite
    }

    dialogButtonBox {
        background {
            height: 40
            radius: 0
            color: __transparent
            border.width: 0
        }
    }

    drawer {
        background.color: __baseWhite
    }

    flatButton {
        background.visible: false
        hovered.background.visible: true
    }

    pane {
        padding: 12
        background {
            width: 200
            height: 200
            color: __baseWhite
        }
    }

    frame {
        background.color: Qt.darker(__baseWhite, 1.05)
    }

    groupBox {
        background.topMargin: 20
        background.height: 20
    }

    itemDelegate {
        text.alignment: Qt.AlignVCenter | Qt.AlignLeft
        background {
            // Make it flat
            radius: 0
            color: __baseWhite
            border.width: 0
            shadow.visible: false
        }
        hovered.background.color: __backgroundDefault
    }

    label {
        background.visible: false
    }

    menu {
        background {
            width: 200
            height: 40
        }
    }

    menuBar {
        background {
            radius: 0
            border.width: 0
            color: __backgroundDefault
        }
    }

    menuBarItem {
        text.alignment: Qt.AlignLeft | Qt.AlignVCenter
        background {
            width: 40
            height: 40
            radius: 0
            color: __transparent
            border.width: 0
        }
        hovered.background.color: __backgroundSubtle
    }

    menuItem {
        text.alignment: Qt.AlignLeft | Qt.AlignVCenter
        background {
            width: 200
            radius: 0
            border.width: 0
        }
        indicator {
            color: __transparent
            border.width: 0
            foreground {
                color: __transparent
                image.color: __textDefault
                image.fillMode: Image.PreserveAspectFit
                alignment: Qt.AlignCenter
            }
            first {
                alignment: Qt.AlignLeft
                foreground {
                    width: 20
                    height: 20
                    image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/check.png"
                }
            }
            second {
                alignment: Qt.AlignRight
                foreground {
                    width: 10
                    height: 10
                    image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/arrow-indicator.png"
                }
            }
        }
        hovered.background.color: __backgroundSubtle
    }

    menuSeparator {
        padding: 2
        background.visible: false
        indicator {
            width: 188
            height: 1
            border.width: 0
            color: __strokeMuted
            foreground.visible: false
        }
    }

    page {
        background.border.width: 0
    }

    pageIndicator {
        background.visible: false
        indicator {
            width: 5
            height: 5
            radius: 255
            border.width: 0
            color: __baseBlack
            opacity: 0.45
            foreground.visible: false
        }

        hovered.indicator {
            width: 6
            height: 6
            opacity: 0.7
        }

        pressed.indicator {
            width: 4
            height: 4
        }

        checked.indicator {
            width: 7
            height: 7
        }

        checked.hovered.indicator {
            width: 8
            height: 8
            opacity: 0.7
        }
    }

    popup {
        background {
            width: 200
            height: 200
            border.width: 1
        }
    }

    progressBar {
        background.visible: false
        indicator {
            width: 150
            foreground {
                fillWidth: true
                fillHeight: true
                delegate: ProgressDelegate {}
            }
        }
    }

    radioButton {
        background.visible: false
        indicator {
            radius: 255
            foreground {
                fillWidth: true
                fillHeight: true
                margins: 4
                visible: false
                radius: 255
            }
        }
        text.alignment: Qt.AlignVCenter | Qt.AlignLeft
        checked.indicator.foreground.visible: true
    }

    radioDelegate {
        text.alignment: Qt.AlignVCenter | Qt.AlignLeft
        background {
            radius: 0
            color: __baseWhite
            border.width: 0
        }
        indicator {
            alignment: Qt.AlignRight | Qt.AlignVCenter
            radius: 255
            foreground {
                fillWidth: true
                fillHeight: true
                margins: 4
                visible: false
                radius: 255
            }
        }
        hovered.background.color: __backgroundDefault
        checked.indicator.foreground.visible: true
    }

    roundButton {
        background.radius: 255
        text.alignment: Qt.AlignVCenter | Qt.AlignHCenter
    }

    scrollBar {
        padding: 0
        background {
            height: 10
        }
        indicator {
            height: 10
            radius: 255
            foreground {
                fillWidth: true
                fillHeight: true
                radius: 255
                color: __backgroundDefault
            }
        }
        vertical {
            background.width: 10
            indicator.width: 10
        }
        hovered {
            indicator.foreground.color: __backgroundMuted
        }
    }

    scrollIndicator {
        background {
            height: 6
            visible: false
        }
        indicator {
            border.width: 0
            height: 6
            radius: 255
            foreground {
                fillWidth: true
                fillHeight: true
                margins: 0
                radius: 255
                color: __backgroundDefault
            }
        }
        vertical {
            background.width: 6
            indicator.width: 6
        }
    }

    searchField {
        text.padding: 5
        text.alignment: Qt.AlignVCenter | Qt.AlignLeft
        text.color: __baseBlack
        background.width: 200

        indicator {
            fillHeight: true
            border.width: 0
            margins: 0
            color: __transparent
            foreground {
                width: 10
                height: 10
                alignment: Qt.AlignCenter
                color: __transparent
            }

            //search button
            first {
                alignment: Qt.AlignLeft
                image.color: __textDefault
                image.fillMode: Image.PreserveAspectFit
                image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/search-magnifier.png"
            }

            //clear button
            second {
                alignment: Qt.AlignRight
                image.color: __textDefault
                image.fillMode: Image.PreserveAspectFit
                image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/close_circle.png"
            }
        }
    }

    slider {
        background {
            visible: false
            width: 150
        }
        indicator {
            fillWidth: true
            height: 8
            radius: 8
            foreground {
                radius: 7
                fillWidth: true
                fillHeight: true
            }
        }
    }

    spinBox {
        text.alignment: Qt.AlignHCenter | Qt.AlignVCenter
        indicator {
            fillHeight: true
            border.width: 0
            margins: 0
            color: __transparent
            foreground {
                color: __transparent
                image.color: __textDefault
                image.fillMode: Image.PreserveAspectFit
                image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/arrow-indicator.png"

                // Note: since we set a rotation here, don't set fillWidth or fillHeight to true, since
                // the rotation is applied after the layout has been done based on the unrotated geometry
                // of the indicator. So we use a fixed implicit size instead, and let the layout stretch the
                // indicator by setting the alignment to AlignCenter. This way, the indicator will be
                // stretched in both dimensions, but still maintain its aspect ratio due to the image's fillMode
                // being PreserveAspectFit.
                width: 10
                height: 10
                alignment: Qt.AlignCenter
            }
            // up button
            first {
                alignment: Qt.AlignRight
                foreground.rotation: -90
            }
            // down button
            second {
                alignment: Qt.AlignLeft
                foreground.rotation: 90
            }
        }
    }

    swipeDelegate {
        text.alignment: Qt.AlignVCenter | Qt.AlignLeft
        background {
            radius: 0
            color: __baseWhite
            border.width: 0
        }
        hovered.background.color: __backgroundDefault
    }

    switchControl {
        background.visible: false
        text.alignment: Qt.AlignVCenter
        indicator {
            width: style.indicatorSize * 2
            height: style.indicatorSize
            alignment: Qt.AlignLeft | Qt.AlignVCenter
            radius: style.indicatorSize / 2
            foreground {
                fillWidth: true
                fillHeight: true
                radius: style.indicatorSize / 2
                color: __transparent
            }
        }
        checked {
            indicator.foreground.color: palette.accent
        }
    }

    switchDelegate {
        text.alignment: Qt.AlignVCenter | Qt.AlignLeft
        background {
            radius: 0
            color: __baseWhite
            border.width: 0
        }
        indicator {
            width: style.indicatorSize * 2
            height: style.indicatorSize
            alignment: Qt.AlignRight | Qt.AlignVCenter
            radius: style.indicatorSize / 2
            foreground {
                fillWidth: true
                fillHeight: true
                radius: style.indicatorSize / 2
                color: __transparent
            }
        }
        hovered.background.color: __backgroundDefault
        checked {
            indicator.foreground.color: palette.accent
        }
    }

    tabBar {
        padding: 0
        spacing: -1 // let tabButtons overlap slightly
    }

    tabButton {
        background {
            radius: 0
            topLeftRadius: 2
            topRightRadius: 2
        }
    }

    tableViewDelegate {
        text.alignment: Qt.AlignVCenter | Qt.AlignLeft
        background {
            radius: 0
            color: __baseWhite
            border.width: 0
        }
        hovered.background.color: __baseWhite
        highlighted.background.color: __strokeStrong
        highlighted.hovered.background.color: __strokeStrong
        focused.background.border.width: 2
    }

    textField {
        text.alignment: Qt.AlignVCenter
        background {
            width: 150
            gradient: null
        }
    }

    textInput {
        padding: 5
        background {
            width: 150
            height: 40
            border.width: 1
            color: __baseWhite
        }
        text {
            color: __baseBlack
        }
    }

    toolBar {
        background.height: 40
    }

    toolSeparator {
        padding: 2
        background.visible: false
        indicator {
            width: 30
            height: 1
            border.width: 0
            color: __strokeMuted
            foreground.visible: false
        }
    }

    toolTip {
        text.padding: 2
        background {
            width: 20
            height: 20
            color: __baseWhite
        }
    }

    tumbler {
        background {
            height: 200
            width: 60
            color: __transparent
            border.width: 0
        }
    }

    verticalHeaderViewDelegate {
        background {
            border.width: 1
            color: Qt.darker(__baseWhite, 1.05)
        }
    }
}
//! [1]