Repository navigation
Expand file tree
/
Copy pathshell.qml
More file actions
869 lines (721 loc) · 33.1 KB
/
Copy pathshell.qml
File metadata and controls
869 lines (721 loc) · 33.1 KB
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
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
//@ pragma UseQApplication
import QtQuick
import qs.CyCommon.Widgets
import Quickshell
import qs.Common
import qs.Common as App
import qs.Services as AppServices
import qs.CyCommon.Common
import qs.CyCommon.Common as DC
import qs.CyCommon.Modals.FileBrowser
import qs.Services
ShellRoot {
readonly property var log: Log.scoped("Gallery")
Component.onCompleted: {
DC.Style.theme = App.Theme;
DC.Style.settings = App.SettingsData;
DC.I18n.backend = App.I18n;
DC.Paths.backend = App.Paths;
DC.Log.backend = AppServices.Log;
DC.Host.session = AppServices.SessionService;
DC.Host.cache = App.CacheData;
}
FloatingWindow {
id: window
readonly property var widthPresets: [
{
"label": "360",
"value": 360
},
{
"label": "480",
"value": 480
},
{
"label": "768",
"value": 768
},
{
"label": "Wide",
"value": 1000
}
]
property int widthPresetIndex: 3
readonly property int presetWidth: widthPresets[widthPresetIndex].value
readonly property string layoutClass: width < Style.smallBreakpoint ? "small" : width < Style.mediumBreakpoint ? "medium" : "large"
title: "CyCommon Gallery"
implicitWidth: presetWidth
implicitHeight: 800
minimumSize: Qt.size(360, 400)
color: Theme.surface
visible: true
Column {
anchors.fill: parent
anchors.margins: Theme.spacingL
spacing: Theme.spacingM
StyledRect {
id: inspector
width: parent.width
height: inspectorContent.implicitHeight + Theme.spacingM * 2
radius: Theme.cornerRadius
color: Theme.surfaceContainerHigh
Flow {
id: inspectorContent
anchors.fill: parent
anchors.margins: Theme.spacingM
spacing: Theme.spacingM
CyButton {
text: I18n.tr("Text fields")
onClicked: galleryFlickable.contentY = widgetExamples.y
}
Column {
width: Theme.fieldDefaultWidth
spacing: Theme.spacingXS
StyledText {
text: I18n.tr("Radius scale")
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceVariantText
}
CySlider {
width: parent.width
Accessible.name: I18n.tr("Radius scale")
value: Theme.radiusStrength
minimum: 0
maximum: 100
onSliderValueChanged: value => Theme.radiusStrength = value
}
}
Column {
spacing: Theme.spacingXS
StyledText {
text: "Window width"
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceVariantText
}
CyButtonGroup {
model: window.widthPresets.map(p => p.label)
currentIndex: window.widthPresetIndex
onSelectionChanged: (index, selected) => {
if (selected)
window.widthPresetIndex = index;
}
}
}
Column {
spacing: Theme.spacingXS
StyledText {
text: "Window"
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceVariantText
}
StyledText {
text: `${window.width}x${window.height} · ${window.layoutClass}`
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceText
}
}
}
}
StyledRect {
id: frame
width: parent.width
height: parent.height - inspector.height - Theme.spacingM
radius: Theme.cornerRadius
color: Theme.surface
border.color: Theme.outline
border.width: 1
clip: true
CyFlickable {
id: galleryFlickable
anchors.fill: parent
anchors.margins: Theme.spacingM
contentHeight: gallery.height
clip: true
Column {
id: gallery
width: parent.width
spacing: Theme.spacingL
Section {
text: I18n.tr("Buttons")
}
Flow {
width: parent.width
spacing: Theme.spacingM
CyButton {
property int clicks: 0
text: clicks > 0 ? `Clicked ${clicks}x` : "Filled"
iconName: "ads_click"
onClicked: clicks++
}
CyButton {
text: "Tonal"
backgroundColor: Theme.secondaryContainer
textColor: Theme.onSecondaryContainer
}
CyButton {
text: "Large"
buttonHeight: 56
iconName: "schedule"
onClicked: timePicker.open()
}
CyButton {
text: "Square button"
buttonHeight: 56
shape: "square"
iconName: "schedule"
onClicked: timePicker.open()
}
CyActionButton {
iconName: "info"
buttonSize: Theme.iconButtonSize
tooltipText: I18n.tr("Icon button")
}
CyRefreshButton {
property bool spin: false
busy: spin
onClicked: spin = !spin
}
}
CyButtonGroup {
model: ["List", "Grid", "Tree"]
currentIndex: 0
onSelectionChanged: (index, selected) => {
if (selected)
currentIndex = index;
}
}
Section {
text: "CySplitButton"
}
Column {
id: splitButtonExamples
width: parent.width
spacing: Theme.spacingM
CySplitButton {
id: splitSortButton
property bool descending: false
property string sortBy: I18n.tr("Name")
text: I18n.tr("Sort by") + ": " + sortBy
iconName: descending ? "arrow_downward" : "arrow_upward"
variant: "tonal"
maximumWidth: parent.width
expanded: splitSortMenu.menuVisible
tooltipText: descending ? I18n.tr("Ascending") : I18n.tr("Descending")
menuTooltipText: I18n.tr("Sort by")
onClicked: descending = !descending
onMenuClicked: {
splitSortMenu.currentValue = sortBy;
splitSortMenu.openDropdownMenu();
}
CyDropdown {
id: splitSortMenu
showTrigger: false
popupAnchorItem: splitSortButton.trailingButton
focusReturnTarget: splitSortButton.trailingButton
popupWidth: Math.min(splitButtonExamples.width, Theme.fieldDefaultWidth)
options: [I18n.tr("Name"), I18n.tr("Author"), I18n.tr("Last modified")]
onValueChanged: value => splitSortButton.sortBy = value
}
}
CySplitButton {
id: splitFilterButton
property string filter: I18n.tr("Enabled")
text: I18n.tr("Filter") + ": " + filter
iconName: "filter_list"
menuOnly: true
variant: "tonal"
maximumWidth: parent.width
expanded: splitFilterMenu.menuVisible
menuTooltipText: I18n.tr("Filter")
onMenuClicked: {
splitFilterMenu.currentValue = filter;
splitFilterMenu.openDropdownMenu();
}
CyDropdown {
id: splitFilterMenu
showTrigger: false
popupAnchorItem: splitFilterButton.trailingButton
focusReturnTarget: splitFilterButton.trailingButton
popupWidth: Math.min(splitButtonExamples.width, Theme.fieldDefaultWidth)
options: [I18n.tr("All"), I18n.tr("Enabled"), I18n.tr("Disabled")]
onValueChanged: value => splitFilterButton.filter = value
}
}
Flow {
width: parent.width
spacing: Theme.spacingM
Repeater {
model: ["filled", "tonal", "outlined", "elevated"]
CySplitButton {
required property string modelData
property int clicks: 0
text: modelData + (clicks ? " · " + clicks : "")
variant: modelData
iconName: "add"
maximumWidth: splitButtonExamples.width
onClicked: clicks++
onMenuClicked: expanded = !expanded
}
}
CySplitButton {
text: I18n.tr("Disabled")
iconName: "add"
enabled: false
maximumWidth: splitButtonExamples.width
}
}
Repeater {
model: ["xs", "s", "m", "l", "xl"]
CySplitButton {
required property string modelData
property int clicks: 0
text: modelData.toUpperCase() + (clicks ? " · " + clicks : "")
size: modelData
iconName: size === "l" || size === "xl" ? "" : "add"
maximumWidth: splitButtonExamples.width
onClicked: clicks++
onMenuClicked: expanded = !expanded
}
}
}
CyButtonGroup {
model: ["Mon", "Tue", "Wed", "Thu", "Fri"]
selectionMode: "multi"
initialSelection: ["Mon", "Fri"]
}
Section {
text: I18n.tr("Selection")
}
CyToggle {
id: featureToggle
text: I18n.tr("Toggle")
description: "Spring thumb, M3 switch metrics"
checked: true
onToggled: checked => featureToggle.checked = checked
}
CyToggle {
id: gatedToggle
text: "Gated toggle"
description: featureToggle.checked ? "Enabled by the one above" : "Disabled by the one above"
enabled: featureToggle.checked
onToggled: checked => gatedToggle.checked = checked
}
CyFilterChips {
width: Math.min(340, gallery.width)
model: ["All", "Active", "Muted"]
}
CyTabBar {
width: Math.min(340, gallery.width)
model: [
{
"icon": "home",
"text": "Home"
},
{
"icon": "palette",
"text": "Theme"
},
{
"icon": "info",
"text": "About"
}
]
onTabClicked: index => currentIndex = index
}
Section {
text: I18n.tr("Sliders")
}
CySlider {
width: Math.min(340, gallery.width)
value: 50
step: 25
showStops: true
onSliderValueChanged: newValue => value = newValue
}
CySlider {
width: Math.min(340, gallery.width)
value: 30
enabled: false
}
CySlider {
width: Math.min(340, gallery.width)
value: 65
size: "m"
onSliderValueChanged: newValue => value = newValue
}
CySlider {
width: Math.min(340, gallery.width)
value: 65
size: "m"
onSliderValueChanged: newValue => value = newValue
insetIcon: "brightness_high"
insetIconPosition: "end"
}
CySlider {
width: Math.min(340, gallery.width)
value: 45
size: "xl"
startIcon: "brightness_low"
endIcon: "brightness_high"
iconsClickable: true
onSliderValueChanged: newValue => value = newValue
}
Section {
text: I18n.tr("Text fields")
}
Flow {
width: parent.width
spacing: Theme.spacingM
CySearchField {
width: Math.min(300, gallery.width)
placeholderText: "Search settings"
}
CyTextField {
width: Math.min(300, gallery.width)
labelText: "Password"
outlined: true
leftIconName: "lock"
placeholderText: "Reveal with the eye"
echoMode: TextInput.Password
showPasswordToggle: true
}
}
WidgetGallery {
id: widgetExamples
width: parent.width
flickable: galleryFlickable
}
CyTextEdit {
width: parent.width
leftIconName: "edit"
placeholderText: "Multi-line notes..."
}
CyDropdown {
width: Math.min(320, gallery.width)
text: "Fruit"
description: "Fuzzy search enabled"
enableFuzzySearch: true
options: ["Apple", "Banana", "Cherry", "Dragonfruit", "Elderberry", "Fig", "Grape"]
currentValue: "Apple"
onValueChanged: value => currentValue = value
}
CyCollapsibleSection {
width: Math.min(340, gallery.width)
title: "Details"
description: "Grouped header, expands below"
showBackground: true
StyledText {
text: "Collapsible content"
}
}
CyNumberStepper {
property int count: 5
text: count
onIncrement: () => count++
onDecrement: () => count--
}
CyTimePicker {
id: timePicker
parent: window.contentItem
hour: 7
minute: 0
onAccepted: (h, m) => log.info("time:", h, m)
}
Section {
text: I18n.tr("File browser")
}
Flow {
width: parent.width
spacing: Theme.spacingM
CyButton {
text: I18n.tr("Pick a file")
iconName: "folder_open"
onClicked: fileBrowser.open()
}
CyButton {
text: I18n.tr("Pick a folder")
iconName: "folder"
onClicked: folderBrowser.open()
}
}
Section {
text: "Bottom sheet"
}
Flow {
width: parent.width
spacing: Theme.spacingM
CyButton {
id: sheetOpener
text: I18n.tr("Open bottom sheet")
iconName: "expand_less"
onClicked: {
bottomSheet.dismissible = true;
bottomSheet.opened = true;
}
}
CyButton {
text: I18n.tr("Open modal sheet")
iconName: "lock"
onClicked: {
bottomSheet.dismissible = false;
bottomSheet.opened = true;
}
}
}
CyBottomSheet {
id: bottomSheet
parent: window.contentItem
title: I18n.tr("Outputs")
initialFocusItem: mirrorToggle
returnFocusItem: sheetOpener
onDismissRequested: opened = false
CyToggle {
id: mirrorToggle
width: parent.width
text: "Mirror displays"
description: bottomSheet.dismissible ? "Swipe the handle or tap outside to close" : "Modal: use the button below"
checked: true
onToggled: value => mirrorToggle.checked = value
}
Repeater {
model: 8
CyToggle {
required property int index
width: parent.width
text: `Output ${index + 1}`
description: index % 2 ? "1920x1080 · 60 Hz" : "2560x1440 · 144 Hz"
onToggled: value => checked = value
}
}
CyButton {
width: parent.width
text: I18n.tr("Close")
onClicked: bottomSheet.opened = false
}
}
Section {
text: "Icons"
}
Flow {
width: parent.width
spacing: Theme.spacingM
CyIcon {
name: "palette"
color: Theme.primary
}
CyIcon {
name: "favorite"
filled: true
color: Theme.error
}
CyNFIcon {
name: "arch"
size: Theme.iconSizeLarge
}
CyNFIcon {
name: "file"
size: Theme.iconSizeLarge
}
CyColorSwatch {
swatchColor: Theme.primary
}
CyColorSwatch {
swatchColor: Theme.withAlpha(Theme.secondary, 0.5)
}
CySpinner {
size: Theme.iconSizeLarge
}
}
Section {
text: "List view"
}
StyledRect {
width: Math.min(340, gallery.width)
height: 180
color: Theme.surfaceContainer
radius: Theme.cornerRadius
CyListView {
anchors.fill: parent
anchors.margins: Theme.spacingS
clip: true
model: 20
spacing: Theme.spacingXXS
delegate: StyledRect {
required property int index
width: parent ? parent.width : 0
height: 36
radius: Theme.cornerRadius
color: rowLayer.containsMouse ? Theme.surfacePressed : "transparent"
StyledText {
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: Theme.spacingM
text: `Row ${index + 1}`
}
StateLayer {
id: rowLayer
cornerRadius: Theme.cornerRadius
onClicked: log.info("row clicked:", index + 1)
}
}
}
}
Section {
text: "Grid view"
}
StyledRect {
width: Math.min(340, gallery.width)
height: 180
color: Theme.surfaceContainer
radius: Theme.cornerRadius
CyGridView {
anchors.fill: parent
anchors.margins: Theme.spacingS
clip: true
model: 40
cellWidth: 64
cellHeight: 64
delegate: Item {
required property int index
width: 64
height: 64
StyledRect {
anchors.fill: parent
anchors.margins: Theme.spacingXS
radius: Theme.cornerRadius
color: Theme.withAlpha(Theme.primary, 0.1 + (index % 8) * 0.1)
StyledText {
anchors.centerIn: parent
text: index + 1
font.pixelSize: Theme.fontSizeSmall
}
}
}
}
}
Section {
text: "Surfaces and elevation"
}
StyledRect {
id: card
width: Math.min(340, gallery.width)
height: 100
color: Theme.surfaceContainerHigh
radius: Theme.cornerRadius
ElevationShadow {
anchors.fill: parent
z: -1
targetRadius: card.radius
targetColor: card.color
}
StyledText {
anchors.centerIn: parent
text: "StyledRect + ElevationShadow + StateLayer"
width: parent.width - Theme.spacingL * 2
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
}
StateLayer {
cornerRadius: card.radius
onClicked: log.info("card clicked")
}
}
Section {
text: I18n.tr("Progress")
}
CySlider {
width: Math.min(340, gallery.width)
value: 40
startIcon: "volume_down"
endIcon: "volume_up"
iconsClickable: true
onSliderValueChanged: newValue => log.info("slider:", newValue)
}
M3WaveProgress {
width: Math.min(340, gallery.width)
height: 24
value: 0.6
isPlaying: true
}
Section {
text: "Avatars and logos"
}
Flow {
width: parent.width
spacing: Theme.spacingL
CyCircularImage {
width: 48
height: 48
fallbackIcon: "person"
fallbackText: "DK"
}
SystemLogo {
width: 48
height: 48
}
}
Section {
text: "Numeric text"
}
NumericText {
text: "1234.56"
reserveText: "8888.88"
font.pixelSize: Theme.fontSizeXLarge
}
Section {
text: "Icon picker"
}
CyIconPicker {
onIconSelected: (iconName, iconType) => log.info("icon:", iconName, iconType)
}
Section {
text: "Location search"
}
CyLocationSearch {
width: Math.min(340, gallery.width)
onLocationSelected: (displayName, coordinates) => log.info("location:", displayName, coordinates)
}
Section {
text: "Cursor and blink"
}
Flow {
width: parent.width
spacing: Theme.spacingL
StyledText {
id: blinkTarget
text: "CyBlink target"
}
CyBlink {
target: blinkTarget
}
CyTextCursor {
height: 20
}
}
Item {
width: 1
height: Theme.spacingL
}
}
}
}
}
}
component Section: StyledText {
font.pixelSize: Theme.fontSizeLarge
font.weight: Style.fontWeightMedium
color: Theme.primary
}
FileBrowserModal {
id: fileBrowser
browserTitle: "Pick a file"
onFileSelected: path => log.info("file selected:", path)
}
FileBrowserModal {
id: folderBrowser
browserTitle: "Pick a folder"
browserIcon: "folder"
folderMode: true
onFileSelected: path => log.info("folder selected:", path)
}
}