Repository navigation
Expand file tree
/
Copy pathPanel.qml
More file actions
2173 lines (2013 loc) · 96.3 KB
/
Copy pathPanel.qml
File metadata and controls
2173 lines (2013 loc) · 96.3 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
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import QtQuick
import QtQuick.Controls
import Quickshell
import Quickshell.Io
import qs.Commons
import qs.Ui
import "./js"
import "./components"
import "./views"
Panel {
id: root
moduleName: "roddy.seafile"
manageIpc: false
property QtObject hostWidget: null
property var anchorItem: null
property var bar: null
property string state: "login"
property string serverUrl: ""
property var currentRepo: null
property string currentPath: "/"
property var pathHistory: []
property var libraries: []
property var currentItems: []
property bool loading: false
property string errorMessage: ""
property string depErrorMessage: ""
property bool depsChecked: false
property bool forceRefresh: false
property string destinationMode: ""
property string destinationOperation: "move"
property var destinationSources: []
property var destinationSourceRepoId: ""
property string destinationSourcePath: "/"
property var destinationSourceHistory: []
property bool destinationSubmitting: false
property int navigationGeneration: 0
property int sessionGeneration: 0
property int connectionTestGeneration: 0
property int loginGeneration: 0
function beginNavigationTiming(label, cacheHit) {
console.log("SEAFILE_TIMING navigation_start label=" + label + " cache=" + (cacheHit ? "hit" : "miss"))
}
function navigationPhase(phase, startedAt) {
console.log("SEAFILE_TIMING navigation_phase phase=" + phase + " duration_ms=" + Math.max(0, Date.now() - startedAt))
}
function navigationComplete(startedAt, rows) {
root.navigationPhase("first_visible_model", startedAt)
console.log("SEAFILE_TIMING navigation_complete rows=" + rows + " total_ms=" + Math.max(0, Date.now() - startedAt))
}
property var activeTransfers: []
property int activeTransferCount: 0
property bool hasTransferFailures: false
property var fileTransfers: ({})
property int transferRevision: 0
property bool showTransfers: false
// ===== SEARCH STATE =====
property string searchQuery: ""
property string searchState: "idle"
property var searchResults: []
property string searchErrorMessage: ""
property int searchGeneration: 0
property bool searchActive: false
property int searchPendingCount: 0
property bool searchTruncated: false
// ===== HISTORY / TRASH STATE =====
property bool showHistory: false
property bool showTrash: false
property var historyFileName: ""
property var historyFilePath: ""
property var historyRepoId: ""
property int historyGeneration: 0
// ===== SELECTION STATE =====
property var selectedItems: []
property var selectionAnchor: null
property bool contextMenuAddedSelection: false
// ===== UX PREFERENCES =====
property bool singleClickOpen: setting("singleClickOpen", false)
function setSetting(name, value) {
var next = Object.assign({}, root.settings)
next[name] = value
root.settings = next
if (root.hostWidget && "settings" in root.hostWidget) root.hostWidget.settings = next
if (root.bar && root.bar.shell && typeof root.bar.shell.updateEntryInline === "function")
root.bar.shell.updateEntryInline(root.moduleName, next)
}
// Directories before files when sorting by Name/Size/Modified. Type sorting
// keeps its own logical semantics regardless of this switch.
property bool foldersFirst: setting("foldersFirst", true)
// Single source of truth for the displayed version, kept in step with
// manifest.json by scripts/test_v11_remediation.py.
readonly property string pluginVersion: "1.2.0"
function selectionKeyForItem(item) {
return SelectionHelper.makeKey(item)
}
function isItemSelected(item) {
var key = root.selectionKeyForItem(item)
if (!key) return false
for (var i = 0; i < root.selectedItems.length; i++) {
if (root.selectionKeyForItem(root.selectedItems[i]) === key) return true
}
return false
}
function toggleSelection(item) {
var key = root.selectionKeyForItem(item)
if (!key) return
root.selectedItems = SelectionHelper.toggleSelection(root.selectedItems, item)
root.selectionAnchor = item
}
function selectOnly(item) {
if (!item) return
root.selectedItems = [item]
root.selectionAnchor = item
}
function selectRange(item, visibleItems) {
var items = visibleItems || root.currentItems
var anchor = root.selectionAnchor
if (!anchor) {
anchor = items.length > 0 ? items[0] : null
}
root.selectedItems = SelectionHelper.rangeSelect(root.selectedItems, anchor, item, items)
root.selectionAnchor = item
}
// Plain click on a file: clear batch selection but keep the file as the
// Shift+click range anchor and keyboard cursor position.
function positionOn(item) {
root.selectedItems = []
root.selectionAnchor = item
}
function selectAll() {
root.selectedItems = root.currentItems.slice()
}
function clearSelection() {
root.selectedItems = []
root.selectionAnchor = null
}
// Favorites persist per account, so every mutation writes the scoped store
// (plus the one-time legacy-migration markers) back to settings. The legacy
// pre-1.1 blob is kept under its own key so it can be imported exactly once.
function persistFavorites() {
root.setSetting("favoritesStore", Favorites.saveToSettings())
root.setSetting("favoritesLegacyMigrated", Favorites.saveMigratedKeys())
// GLOBAL migration-complete marker: once set, no other account ever
// imports the pre-1.1 legacy blob on a later startup.
root.setSetting("favoritesLegacyMigratedGlobally", Favorites.saveGloballyMigrated())
}
function addToFavorites(item) {
if (!item) return
if (!root.currentRepo) {
var libResult = Favorites.addLibrary(item.id, item.name)
if (libResult.error) root.showToast(libResult.error, "error")
else if (libResult.changed) { root.persistFavorites(); root.showToast("Added to Quick Access") }
return
}
if (item.type !== "dir") {
root.showToast("Only libraries and folders can be added to Quick Access", "warning")
return
}
// Identity is the folder's own FULL path, not its parent, so sibling
// folders with the same name under different parents stay distinct.
var fullPath = root.currentPath === "/" ? "/" + item.name : root.currentPath + "/" + item.name
var folderResult = Favorites.addFolder(root.currentRepo.id, root.currentRepo.name, fullPath, item.name)
if (folderResult.error) root.showToast(folderResult.error, "error")
else if (folderResult.changed) { root.persistFavorites(); root.showToast("Added to Quick Access") }
}
// Accepts either a favorite record (Home's Quick Access rows) or a browsed
// item (context menu). A favorite record carries its own identity, so
// removal works while currentRepo is null - identity is never derived from
// the browsing context.
function removeFromFavorites(entry) {
if (!entry) return
var result
if (entry.type === "library" || entry.type === "folder") {
result = Favorites.removeEntry(entry)
} else if (root.currentRepo) {
if (entry.type === "dir") {
var dirFullPath = root.currentPath === "/" ? "/" + entry.name : root.currentPath + "/" + entry.name
result = Favorites.removeFolder(root.currentRepo.id, dirFullPath)
} else {
result = Favorites.removeLibrary(root.currentRepo.id)
}
} else {
return
}
if (result.error) { root.showToast(result.error, "error"); return }
if (result.changed) { root.persistFavorites(); root.showToast("Removed from Quick Access") }
}
// Resolve a favorite to a concrete destination. A stale library or folder
// produces feedback without crashing, and the entry stays removable.
function openFavorite(entry) {
if (!entry) return
var repo = null
for (var i = 0; i < root.libraries.length; i++) {
if (root.libraries[i].id === entry.repoId) { repo = root.libraries[i]; break }
}
if (!repo) {
root.showToast("Library is no longer available. You can remove this entry from Quick Access.", "error")
return
}
root.clearSelection()
root.currentRepo = repo
if (entry.type === "library") {
root.pathHistory = [{ name: repo.name, path: "/", repoId: repo.id }]
root.loadFolder(repo.id, "/")
return
}
var fullPath = Favorites.normalizePath(entry.path)
if (fullPath === "") {
root.showToast("This Quick Access entry has no folder path", "error")
return
}
root.buildPathHistory(repo, fullPath)
root.loadFolder(repo.id, fullPath)
}
// Build a breadcrumb chain for an absolute folder path.
function buildPathHistory(repo, fullPath) {
var history = [{ name: repo.name, path: "/", repoId: repo.id }]
var normalized = Favorites.normalizePath(fullPath)
if (normalized !== "") {
var segments = normalized.split("/").filter(function(seg) { return seg !== "" })
var acc = ""
for (var i = 0; i < segments.length; i++) {
acc += "/" + segments[i]
history.push({ name: segments[i], path: acc, repoId: repo.id })
}
}
root.pathHistory = history
}
function handleBackClick() {
if (root.destinationSubmitting) return
if (root.showTransfers) { root.showTransfers = false }
else if (root.showHistory) { root.historyGeneration++; root.showHistory = false; historyLoader.sourceComponent = undefined }
else if (root.showTrash) { root.showTrash = false; trashLoader.sourceComponent = undefined }
else if (settingsLoader.sourceComponent) { root.closeSettings() }
else { root.goBack() }
}
// Closes the topmost open modal, if any. Returns true when a dialog was
// dismissed so Escape can close dialogs before it closes the panel.
function closeTopDialog() {
if (root.destinationMode) { root.cancelDestinationMode(); return true }
if (contextMenu.opened) { contextMenu.close(); return true }
if (shareLoader.item && shareLoader.item.revokeConfirmationOpen) { shareLoader.item.cancelRevoke(); return true }
if (shareLoader.item) { root.cancelShare(); return true }
if (uploadLoader.item) { root.cancelFilePicker(); return true }
if (confirmLoader.item) { root.cancelDelete(); return true }
if (renameLoader.item) { root.cancelRename(); return true }
if (createFolderLoader.item) { root.cancelCreateFolder(); return true }
if (historyLoader.item) { root.historyGeneration++; root.showHistory = false; historyLoader.sourceComponent = undefined; return true }
if (trashLoader.item) { root.showTrash = false; trashLoader.sourceComponent = undefined; return true }
if (settingsLoader.item) { root.closeSettings(); return true }
// Transfers surface: Escape returns to the underlying view (Libraries
// root or the browser), never closes the whole panel.
if (root.showTransfers) { root.showTransfers = false; return true }
return false
}
function showTrashPanel() {
root.openTrash()
}
function pruneSelection() {
if (!root.currentItems || root.currentItems.length === 0) {
root.selectedItems = []
return
}
var validKeys = {}
for (var i = 0; i < root.currentItems.length; i++) {
var item = root.currentItems[i]
var key = SelectionHelper.makeKey(item)
validKeys[key] = true
}
root.selectedItems = root.selectedItems.filter(function(item) {
var key = SelectionHelper.makeKey(item)
return validKeys[key] === true
})
}
function refreshTransferBindings() {
var active = TransferService.getActiveTransfers()
root.activeTransfers = active
root.activeTransferCount = active.length
root.hasTransferFailures = TransferService.hasFailures()
var map = {}
for (var i = 0; i < active.length; i++) {
var t = active[i]
if (t.repoId === (root.currentRepo ? root.currentRepo.id : "")) {
map[t.id] = t
if (t.fileName) map["name:" + t.fileName] = t
}
}
root.fileTransfers = map
root.transferRevision++
}
Connections {
target: TransferService
function onTransfersChanged() { root.refreshTransferBindings() }
function onTransferProgressChanged(transfer) { root.refreshTransferBindings() }
function onTransferStateChanged(transfer) {
if (transfer.state === "completed" || transfer.state === "failed" || transfer.state === "cancelled" || transfer.state === "auth_failed") {
root.handleTransferCompletion(transfer)
}
}
function onTransferError(message) {
root.showToast(message, "error")
}
}
Timer {
id: searchDebounceTimer
interval: 300
repeat: false
onTriggered: root.executeSearch()
}
function open() {
// Refresh connectivity state immediately so a stale "Offline" banner
// clears as soon as the panel is shown (server reachable).
panelConnectionService.forceCheck()
// Load libraries if empty (e.g., panel was recreated after being closed).
if (root.state === "browse" && (!root.libraries || root.libraries.length === 0)) {
root.loadLibraries()
}
root.controller.show()
}
function close() { root.controller.hide() }
function toggle() { root.opened ? close() : open() }
function toggleTransfersView() {
root.showTransfers = !root.showTransfers
}
function showToast(message, type) {
toast.show(message, type || "success")
}
// Own the IPC target (manageIpc:false above) — same pattern as the
// shell's dropbox/network panels: base-Panel handlers plus extras.
IpcHandler {
target: root.moduleName
function open(): void { root.open() }
function close(): void { root.close() }
function show(): void { root.open() }
function hide(): void { root.close() }
function toggle(): void { root.toggle() }
function status(): string { return root.state }
}
// Rename target: the single selected item, else the list's current item.
function renameTarget() {
if (!root.currentRepo) return null
if (root.selectedItems.length === 1) return root.selectedItems[0]
var list = root.activeFileList()
if (!list) return null
if (list.currentItem) return list.currentItem.item
if (list.count > 0) {
list.currentIndex = 0
return list.itemAtIndex(0)
}
return null
}
function showItemContextMenu(item, x, y) {
if (!item || root.destinationMode) return
root.contextMenuAddedSelection = root.currentRepo !== null && !root.isItemSelected(item)
if (!root.currentRepo) root.clearSelection()
else if (root.contextMenuAddedSelection) root.selectOnly(item)
contextMenu.item = item
contextMenu.isDir = item.type === "dir"
contextMenu.libraryMode = root.currentRepo === null
contextMenu.selectionCount = root.selectedItems.length > 0 ? root.selectedItems.length : 1
if (root.currentRepo) {
// Type is part of favorite identity, and a folder is keyed by its
// own full path rather than by its parent directory.
if (item.type === "dir") {
var dirFullPath = root.currentPath === "/" ? "/" + item.name : root.currentPath + "/" + item.name
contextMenu.isFavorite = Favorites.isFolderFavorite(root.currentRepo.id, dirFullPath)
} else {
// Files are not Quick Access targets in v1.1.
contextMenu.isFavorite = false
}
} else {
contextMenu.isFavorite = Favorites.isLibraryFavorite(item.id)
}
// Parent to the keyboard-panel window's overlay: never clipped by the
// file list, and rendered in the window that owns pointer/keyboard.
contextMenu.parent = keyCatcher.Overlay.overlay
contextMenu.x = Math.max(0, Math.min(x, contextMenu.parent.width - contextMenu.width))
contextMenu.y = Math.max(0, Math.min(y, contextMenu.parent.height - contextMenu.implicitHeight))
contextMenu.open()
}
function shareFromContextMenu(item) {
var clearTemporarySelection = root.contextMenuAddedSelection
root.contextMenuAddedSelection = false
if (clearTemporarySelection) root.clearSelection()
root.pickShare(item)
}
function showKeyboardContextMenu() {
if (root.destinationSubmitting) return
var list = root.activeFileList()
if (!list || list.count <= 0) return
if (list.currentIndex < 0) list.currentIndex = 0
var current = list.currentItem || list.itemAtIndex(list.currentIndex)
if (!current) return
var item = current.item || current.modelData
if (!item) return
var overlay = keyCatcher.Overlay.overlay
var point = current.mapToItem(overlay, current.width / 2, current.height / 2)
root.showItemContextMenu(item, point.x, point.y)
}
ConnectionService {
id: panelConnectionService
serverUrl: root.serverUrl
}
function updateConnectionServiceUrl() {
panelConnectionService.setServerUrl(root.serverUrl)
}
KeyboardPanel {
id: panel
anchorItem: root.anchorItem
owner: root.hostWidget || root
bar: root.bar
open: root.opened
focusTarget: keyCatcher
contentWidth: panel.fittedContentWidth(Style.space(480))
contentHeight: panel.fittedContentHeight(content.implicitHeight)
PanelKeyCatcher {
id: keyCatcher
anchors.fill: parent
blocked: root.textInputActive
onCloseRequested: {
if (root.closeTopDialog()) return
root.close()
}
// dialogOpen guard: while any modal/view is up (even ones without
// a text field, e.g. the delete confirmation), panel-level
// navigation and item actions must stay inert — only Escape
// (via closeTopDialog above) acts on them.
onMoveRequested: function(dx, dy) {
if (root.state !== "browse" || root.searchActive || root.dialogOpen || root.showTransfers || root.destinationSubmitting) return
var list = root.activeFileList()
if (!list) return
if (dx < 0) { root.goBack(); return }
if (dx > 0) {
if (list.currentItem && list.currentItem.item.type === "dir") root.onItemClicked(list.currentItem.item)
return
}
if (dy > 0) list.incrementCurrentIndex()
else if (dy < 0) list.decrementCurrentIndex()
}
onActivateRequested: {
if (root.state !== "browse" || root.searchActive || root.dialogOpen || root.showTransfers || root.destinationSubmitting) return
var list = root.activeFileList()
if (!list || !list.currentItem) return
var item = list.currentItem.item
if (item && item.type === "dir") root.onItemClicked(item)
else if (item && !root.destinationMode) root.openFile(item)
}
onDeleteRequested: {
if (root.state !== "browse" || root.searchActive || root.dialogOpen || root.destinationMode || root.showTransfers) return
if (root.selectedItems.length > 0) { root.deleteItems(); return }
var list = root.activeFileList()
if (!list || !list.currentItem) return
root.pickDelete(list.currentItem.item)
}
Shortcut {
sequence: "F2"
enabled: root.state === "browse" && !root.searchActive && !root.dialogOpen && !root.destinationMode && !root.showTransfers && root.currentRepo !== null
onActivated: {
var target = root.renameTarget()
if (target) root.pickRename(target)
}
}
Shortcut {
sequence: "Ctrl+A"
enabled: root.state === "browse" && !root.searchActive && !root.dialogOpen && !root.destinationMode && !root.showTransfers && root.currentRepo !== null
onActivated: root.selectAll()
}
Shortcut {
sequence: "Delete"
enabled: root.state === "browse" && !root.searchActive && !root.dialogOpen && !root.destinationMode && !root.showTransfers && root.currentRepo !== null
onActivated: {
if (root.selectedItems.length > 0) { root.deleteItems(); return }
var list = root.activeFileList()
if (!list || !list.currentItem) return
root.pickDelete(list.currentItem.item)
}
}
// Single context menu at panel level, parented to the window
// overlay so the file list never clips it.
ContextMenu {
id: contextMenu
bar: root.bar
onOpenClicked: function(item) { if (item) item.type === "dir" ? root.onItemClicked(item) : root.openFile(item) }
onDownloadClicked: function(item) { root.downloadFile(item) }
onRenameClicked: function(item) { root.pickRename(item) }
onMoveClicked: function(item) { root.moveItems(item) }
onCopyClicked: function(item) { root.copyItems(item) }
onShareClicked: function(item) { root.shareFromContextMenu(item) }
onHistoryClicked: function(item) { root.openHistory(item) }
onDeleteClicked: function(item) {
if (root.selectedItems.length > 1) root.deleteItems()
else if (item) root.pickDelete(item)
}
onAddToFavoritesClicked: function(item) { root.addToFavorites(item) }
onRemoveFromFavoritesClicked: function(item) { root.removeFromFavorites(item) }
}
Column {
id: content
width: parent.width
// Keep the content viewport bounded by KeyboardPanel's card;
// FileList/ListView handles scrolling inside this clipped area.
height: parent.height
clip: true
spacing: 0
Toast {
id: toast
width: parent.width
bar: root.bar
}
ToolBar {
id: toolBar
width: parent.width
bar: root.bar
overlay: keyCatcher.Overlay.overlay
visible: root.state !== "login"
title: root.settingsOpen ? "Settings" : (root.showTransfers ? "Transfers" : (root.searchActive ? "Search" : (root.currentRepo ? root.currentRepo.name : "Libraries")))
showBack: root.state === "browse" && !root.searchActive && (!root.dialogOpen || root.settingsOpen) && (root.pathHistory.length > 0 || root.settingsOpen || root.showTransfers)
// While the Transfers surface is active the underlying
// browser view is hidden, so only intentional global actions
// (Back, Logout, Settings, the Transfers indicator) stay on.
showRefresh: root.state === "browse" && !root.searchActive && !root.dialogOpen && !root.destinationMode && !root.showTransfers
showUpload: root.state === "browse" && root.currentRepo !== null && !root.searchActive && !root.dialogOpen && !root.destinationMode && !root.showTransfers
showCreateFolder: root.state === "browse" && !root.searchActive && !root.dialogOpen && !root.destinationMode && !root.showTransfers && root.currentRepo !== null
showSearch: root.state === "browse" && !root.dialogOpen && !root.destinationMode && !root.showTransfers
showLogout: root.state === "browse" && !root.dialogOpen && !root.destinationMode
showTransfers: root.state === "browse" && !root.dialogOpen && !root.destinationMode && !root.showTransfers
showTrash: root.state === "browse" && root.currentRepo !== null && !root.dialogOpen && !root.destinationMode && !root.showTransfers
showSettings: root.state === "browse" && !root.dialogOpen && !root.destinationMode
activeTransferCount: root.activeTransferCount
hasTransferFailures: root.hasTransferFailures
showOffline: !panelConnectionService.online
searchActive: root.searchActive
searchQuery: root.searchQuery
selectionCount: (!root.dialogOpen && !contextMenu.opened && root.selectedItems.length > 1)
? root.selectedItems.length : 0
destinationMode: root.destinationMode
destinationOperation: root.destinationOperation
destinationCount: root.destinationSources.length
destinationPath: root.destinationMode !== "" && root.currentRepo ? root.currentRepo.name + (root.currentPath !== "/" ? " / " + root.currentPath.substring(1) : "") : ""
onBackClicked: root.handleBackClick
onRefreshClicked: root.refresh
onUploadClicked: root.pickFileForUpload
onCreateFolderClicked: root.pickCreateFolder
onSearchChanged: root.onSearchQueryChanged
onSearchSubmitted: root.executeSearch
onSearchActiveToggled: root.onSearchActiveToggle
onLogoutClicked: root.doLogout
onTransfersClicked: root.toggleTransfersView
onTrashClicked: root.showTrashPanel
onSettingsClicked: root.openSettings
onMoveBatch: root.moveItems
onCopyBatch: root.copyItems
onDeleteBatch: root.deleteItems
onClearSelection: root.clearSelection
onDestinationCancel: root.cancelDestinationMode
onDestinationConfirm: root.confirmDestination
}
Loader {
id: stateLoader
sourceComponent: root.state === "login" ? loginComponent : (root.currentRepo ? browserComponent : homeComponent)
width: parent.width
visible: !root.dialogOpen && !root.showTransfers
height: visible ? implicitHeight : 0
}
Loader {
id: destinationBarLoader
sourceComponent: root.destinationMode ? destinationBarComponent : undefined
width: parent.width
height: item ? item.implicitHeight : 0
}
Loader { id: createFolderLoader; sourceComponent: undefined; width: parent.width; height: item ? item.implicitHeight : 0 }
Loader { id: renameLoader; sourceComponent: undefined; width: parent.width; height: item ? item.implicitHeight : 0 }
Loader { id: confirmLoader; sourceComponent: undefined; width: parent.width; height: item ? item.implicitHeight : 0 }
Loader { id: shareLoader; sourceComponent: undefined; width: parent.width; height: item ? item.implicitHeight : 0 }
Loader { id: uploadLoader; sourceComponent: undefined; width: parent.width; height: item ? item.implicitHeight : 0 }
Loader { id: historyLoader; sourceComponent: undefined; width: parent.width; height: item ? item.implicitHeight : 0 }
Loader { id: trashLoader; sourceComponent: undefined; width: parent.width; height: item ? item.implicitHeight : 0 }
Loader { id: settingsLoader; sourceComponent: undefined; width: parent.width; height: item ? item.implicitHeight : 0 }
// Panel-level Transfers surface. It lives here rather than
// inside BrowserView so it works from the Libraries root, where
// currentRepo is null and BrowserView is not even instantiated.
// This is the only TransferManager in the app, so there is a
// single source of transfer state.
Loader {
id: transfersLoader
sourceComponent: root.state === "browse" && root.showTransfers ? transfersComponent : undefined
width: parent.width
visible: root.state === "browse" && root.showTransfers && !root.dialogOpen && !root.searchActive
height: visible && item ? item.implicitHeight : 0
}
Component {
id: loginComponent
LoginDialog {
id: loginDialog
bar: root.bar
serverField.text: root.serverUrl
depErrorMessage: root.depErrorMessage
errorMessage: root.errorMessage
loading: root.loading
onLogin: function(url, email, pass) { root.doLogin(url, email, pass) }
onDismiss: function() { root.close() }
}
}
Component {
id: destinationBarComponent
Item {
id: destBar
width: parent.width
height: childrenRect.height
Column {
width: parent.width
spacing: 0
Item {
width: parent.width
height: Style.space(8)
}
Text {
width: parent.width
text: (root.destinationOperation === "move" ? "Moving " : "Copying ") + root.destinationSources.length + (root.destinationSources.length === 1 ? " item to:" : " items to:")
color: root.bar.foreground
font.family: root.bar.fontFamily
font.pixelSize: Style.font.caption
horizontalAlignment: Text.AlignHCenter
textFormat: Text.PlainText
}
Text {
width: parent.width
text: Models.boundedDisplayText(root.currentRepo ? root.currentRepo.name + (root.currentPath === "/" ? " /" : " / " + root.currentPath.substring(1)) : "", 4096)
color: Qt.darker(root.bar.foreground, 1.3)
font.family: root.bar.fontFamily
font.pixelSize: Style.font.caption
font.bold: true
elide: Text.ElideMiddle
horizontalAlignment: Text.AlignHCenter
textFormat: Text.PlainText
}
Row {
width: parent.width
height: implicitHeight
spacing: Style.space(8)
Button {
id: cancelBtn
text: "Cancel"
width: parent.width / 2 - Style.space(4)
height: Style.space(32)
enabled: !root.destinationSubmitting
onClicked: root.cancelDestinationMode()
}
Button {
id: actionBtn
text: root.destinationOperation === "move" ? "Move here" : "Copy here"
width: parent.width / 2 - Style.space(4)
height: Style.space(32)
enabled: !root.destinationSubmitting && !root.loading
onClicked: root.confirmDestination()
}
}
}
}
}
Component {
id: homeComponent
HomeView {
id: homeView
width: parent.width
bar: root.bar
libraries: root.libraries
currentRepo: root.currentRepo
currentPath: root.currentPath
pathHistory: root.pathHistory
loading: root.loading
errorMessage: root.errorMessage
selectedItems: root.selectedItems
selectionAnchor: root.selectionAnchor
destinationMode: root.destinationMode
onItemClicked: function(item) { root.onItemClicked(item) }
onNavigateToPath: function(index) { root.navigateToPath(index) }
onRefresh: function() { root.refresh() }
onToggleSelection: root.destinationMode || !root.currentRepo ? function() {} : root.toggleSelection
onSelectRange: root.destinationMode || !root.currentRepo ? function() {} : root.selectRange
onSelectOnly: root.destinationMode ? function() {} : root.selectOnly
onPositionClicked: root.positionOn
onContextMenuRequested: root.showItemContextMenu
onDownloadClicked: function(item) { root.destinationMode ? null : root.downloadFile(item) }
onOpenClicked: function(item) { root.destinationMode ? null : root.openFile(item) }
onRenameClicked: function(item) { root.destinationMode ? null : root.pickRename(item) }
onMoveClicked: function(item) { root.destinationMode ? null : root.beginDestinationMode("move", [item]) }
onDeleteClicked: function(item) { root.destinationMode ? null : root.pickDelete(item) }
onShareClicked: function(item) { root.destinationMode ? null : root.pickShare(item) }
onHistoryClicked: root.openHistory
onSortChanged: function(column, ascending) {
root.setSetting("sortColumn", column)
root.setSetting("sortAscending", ascending)
}
searchActive: root.searchActive
searchState: root.searchState
searchResults: root.searchResults
searchErrorMessage: root.searchErrorMessage
searchPendingCount: root.searchPendingCount
searchTruncated: root.searchTruncated
maxSearchResults: root.maxSearchResults
onSearchRetry: function() { root.executeSearch() }
onSearchResultClicked: root.onSearchResultClicked
onAddToFavorites: function(item) { root.addToFavorites(item) }
onRemoveFromFavorites: function(item) { root.removeFromFavorites(item) }
onFavoriteClicked: function(entry) { root.openFavorite(entry) }
onRemoveFavorite: function(entry) { root.removeFromFavorites(entry) }
onTransferCancel: function(transfer) { TransferService.cancelTransfer(transfer.id) }
activeTransfers: root.activeTransfers
activeCount: root.activeTransferCount
transferRevision: root.transferRevision
}
}
Component {
id: browserComponent
BrowserView {
id: browserView
width: parent.width
bar: root.bar
currentItems: root.currentItems
pathHistory: root.pathHistory
libraries: root.libraries
loading: root.loading
errorMessage: root.errorMessage
searchActive: root.searchActive
searchState: root.searchState
searchResults: root.searchResults
searchErrorMessage: root.searchErrorMessage
searchTruncated: root.searchTruncated
maxSearchResults: root.maxSearchResults
showTransfers: root.showTransfers
transferRevision: root.transferRevision
selectedItems: root.selectedItems
selectionAnchor: root.selectionAnchor
contextMenuOpen: contextMenu.opened
currentRepo: root.currentRepo
currentPath: root.currentPath
destinationMode: root.destinationMode
connectionService: panelConnectionService
searchPendingCount: root.searchPendingCount
onItemClicked: function(item) { root.onItemClicked(item) }
onDownloadClicked: function(item) { root.destinationMode ? null : root.downloadFile(item) }
onOpenClicked: function(item) { root.destinationMode ? null : root.openFile(item) }
onRenameClicked: function(item) { root.destinationMode ? null : root.pickRename(item) }
onMoveClicked: function(item) { root.destinationMode ? null : root.beginDestinationMode("move", [item]) }
onDeleteClicked: function(item) { root.destinationMode ? null : root.pickDelete(item) }
onShareClicked: function(item) { root.destinationMode ? null : root.pickShare(item) }
onHistoryClicked: root.openHistory
onSearchResultClicked: function(result) { root.onSearchResultClicked(result) }
onNavigateToPath: function(index) { root.navigateToPath(index) }
onRefresh: function() { root.refresh() }
onToggleSelection: root.destinationMode || !root.currentRepo ? function() {} : root.toggleSelection
onSelectRange: root.destinationMode || !root.currentRepo ? function() {} : root.selectRange
onSelectOnly: root.destinationMode ? function() {} : root.selectOnly
onPositionClicked: root.positionOn
onContextMenuRequested: root.showItemContextMenu
onSortChanged: function(column, ascending) {
root.setSetting("sortColumn", column)
root.setSetting("sortAscending", ascending)
}
onSearchRetry: function() { root.executeSearch() }
singleClickOpen: root.singleClickOpen
foldersFirst: root.foldersFirst
}
}
}
}
Item {
width: 0
height: 0
Shortcut {
sequence: "Shift+F10"
context: Qt.ApplicationShortcut
enabled: root.opened && root.state === "browse" && !root.searchActive && !root.dialogOpen && !root.destinationMode && !root.showTransfers && !contextMenu.opened
onActivated: root.showKeyboardContextMenu()
}
}
}
// The navigable FileList is owned by whichever view the state Loader is
// currently showing. It is DERIVED on demand from stateLoader.item rather
// than cached: caching a Loader child would keep a pointer to an object
// destroyed as soon as the view changes. Returns null when the login view
// is active, when the loaded view exposes no list, or when the Loader has
// no item - so every caller must null-check.
function activeFileList() {
var view = stateLoader.item
if (!view) return null
var list = view.activeFileList
return (list === undefined || list === null) ? null : list
}
function focusActiveFileList() {
var list = null
try { list = root.activeFileList() } catch (e) { return }
if (list && typeof list.forceActiveFocus === "function") list.forceActiveFocus()
}
readonly property bool settingsOpen: settingsLoader.item !== null
readonly property bool dialogOpen: settingsLoader.item !== null || createFolderLoader.item !== null || renameLoader.item !== null || confirmLoader.item !== null || shareLoader.item !== null || uploadLoader.item !== null || historyLoader.item !== null || trashLoader.item !== null
// True while keyboard input belongs to a text-editing surface: the search
// bar, the login form, settings, or the editable field of any open dialog.
// Drives PanelKeyCatcher.blocked so h/j/k/l/x, arrows, Enter, Space,
// Delete and Escape reach the focused control instead of being interpreted
// as panel-level navigation/actions while the user is typing. Each editor
// surface exposes its own declarative `editing` flag (any of its fields
// focused); this binding is the single central condition — the same
// mode-derived pattern the shell's network panel uses for its passphrase
// editor. Loaders recreate items on open, so `editing` resets per dialog.
function _loaderEditing(loader) {
return loader.item !== null && loader.item.editing === true
}
readonly property bool textInputActive:
root.searchActive
|| (root.state === "login" && _loaderEditing(stateLoader))
|| _loaderEditing(createFolderLoader)
|| _loaderEditing(renameLoader)
|| _loaderEditing(uploadLoader)
|| _loaderEditing(shareLoader)
|| _loaderEditing(settingsLoader)
// ===== DIALOG LOADERS =====
Component {
id: createFolderComponent
CreateFolderDialog {
bar: root.bar
onCreate: function() { root.confirmCreateFolder(nameField.text) }
onCancel: function() { root.cancelCreateFolder() }
}
}
Component {
id: renameComponent
RenameDialog {
bar: root.bar
title: {
var d = root.renameItemData
if (!d || d.items.length === 0) return "Rename"
return d.items[0].type === "dir" ? "Rename Folder" : "Rename File"
}
nameField.text: root.renameItemData && root.renameItemData.items.length > 0 ? (root.renameItemData.items[0].name || "") : ""
onRename: function() { root.confirmRename(nameField.text) }
onCancel: function() { root.cancelRename() }
}
}
Component {
id: confirmComponent
ConfirmDialog {
bar: root.bar
// Canonical item-context shape: { items: [...], isDir }. The legacy
// { item } field is honored only as a safety fallback.
message: Models.boundedDisplayText((function() {
var d = root.deleteItemData
if (!d) return "Are you sure?"
var list = d.items && d.items.length > 0 ? d.items : (d.item ? [d.item] : [])
if (list.length === 0) return "Delete selection?"
if (list.length > 1) return "Delete " + list.length + " item(s)?"
var it = list[0]
return "Delete " + (it.type === "dir" ? "folder" : "file") + " \"" + (it.name || "") + "\"?"
})(), 4096)
onConfirm: function() { root.confirmDelete() }
onCancel: function() { root.cancelDelete() }
}
}
Component {
id: shareComponent
ShareDialog {
bar: root.bar
item: root.shareItemData ? root.shareItemData.item : null
repoId: root.currentRepo ? root.currentRepo.id : ""
repoName: root.currentRepo ? root.currentRepo.name : ""
itemPath: root.shareItemData ? root.shareItemData.fullPath : ""
isDir: root.shareItemData ? root.shareItemData.isDir : false
onDone: function() { root.cancelShare() }
onCancel: function() { root.cancelShare() }
onToast: function(msg) { root.showToast(msg) }
}
}
Component {
id: uploadComponent
UploadDialog {
bar: root.bar
onUpload: function() { root.confirmUpload(pathField.text) }
onCancel: function() { root.cancelFilePicker() }
onFilesSelected: function(paths) {
if (!paths || paths.length === 0) return
// The picker emits raw filesystem paths. They must be passed
// through verbatim: turning them into file:// URLs and then
// decodeURIComponent()ing them corrupts real filenames such as
// "100% termine.txt" or a literal "foo%20bar.txt".
for (var i = 0; i < paths.length; i++) {
var path = paths[i]
if (typeof path !== "string" || path === "") continue
root.startUpload(path)
}
root.cancelFilePicker()
}
}
}
Component {
id: historyComponent
HistoryPanel {
bar: root.bar
repoId: root.historyRepoId
filePath: root.historyFilePath
fileName: root.historyFileName
onDownloadRevision: function(revision) {
var repoId = root.historyRepoId
var filePath = root.historyFilePath
var fileName = root.historyFileName
var serverUrl = root.serverUrl
var token = Auth.getToken()
var session = root.sessionGeneration
var generation = root.historyGeneration
SeafileAPI.downloadRevision(repoId, filePath, revision.commitId, function(success, data, error) {
if (session !== root.sessionGeneration || generation !== root.historyGeneration) return
if (success && typeof data === "string" && data !== "") {
SafePath.getDownloadsDir(function(dir) {
if (session !== root.sessionGeneration || generation !== root.historyGeneration || !dir) return
TransferService.startDownload(
{ name: fileName + " (rev " + revision.commitId.substring(0, 8) + ")", type: "file" },
token, serverUrl, repoId, dir, filePath, data
)
})
root.showHistory = false
historyLoader.sourceComponent = undefined
root.showToast("Downloading historical revision...")
} else {
root.showToast("Failed to download revision: " + error, "error")
}
})
}
onClose: function() { root.historyGeneration++; root.showHistory = false; historyLoader.sourceComponent = undefined }
}
}