Changeset View
Changeset View
Standalone View
Standalone View
containments/desktop/package/contents/ui/FolderView.qml
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | 32 | FocusScope { | |||
---|---|---|---|---|---|
56 | property alias scrollLeft: gridView.scrollLeft | 56 | property alias scrollLeft: gridView.scrollLeft | ||
57 | property alias scrollRight: gridView.scrollRight | 57 | property alias scrollRight: gridView.scrollRight | ||
58 | property alias scrollUp: gridView.scrollUp | 58 | property alias scrollUp: gridView.scrollUp | ||
59 | property alias scrollDown: gridView.scrollDown | 59 | property alias scrollDown: gridView.scrollDown | ||
60 | property alias hoveredItem: gridView.hoveredItem | 60 | property alias hoveredItem: gridView.hoveredItem | ||
61 | property var history: [] | 61 | property var history: [] | ||
62 | property Item backButton: null | 62 | property Item backButton: null | ||
63 | property var dialog: null | 63 | property var dialog: null | ||
64 | property Item editor: null | ||||
64 | 65 | | |||
65 | function rename() | 66 | function rename() | ||
66 | { | 67 | { | ||
67 | if (gridView.currentIndex != -1) { | 68 | if (gridView.currentIndex != -1) { | ||
69 | if (!editor) { | ||||
70 | editor = editorComponent.createObject(listener); | ||||
71 | } | ||||
72 | | ||||
68 | editor.targetItem = gridView.currentItem; | 73 | editor.targetItem = gridView.currentItem; | ||
69 | } | 74 | } | ||
70 | } | 75 | } | ||
71 | 76 | | |||
72 | function cancelRename() { | 77 | function cancelRename() { | ||
78 | if (editor) { | ||||
73 | editor.targetItem = null; | 79 | editor.targetItem = null; | ||
74 | } | 80 | } | ||
81 | } | ||||
75 | 82 | | |||
76 | function linkHere(sourceUrl) { | 83 | function linkHere(sourceUrl) { | ||
77 | dir.linkHere(sourceUrl); | 84 | dir.linkHere(sourceUrl); | ||
78 | } | 85 | } | ||
79 | 86 | | |||
80 | function handleDragMove(x, y) { | 87 | function handleDragMove(x, y) { | ||
81 | var child = childAt(x, y); | 88 | var child = childAt(x, y); | ||
82 | 89 | | |||
▲ Show 20 Lines • Show All 171 Lines • ▼ Show 20 Line(s) | 260 | if (mouse.buttons & Qt.BackButton) { | |||
254 | if (root.isPopup && dir.resolvedUrl != dir.resolve(plasmoid.configuration.url)) { | 261 | if (root.isPopup && dir.resolvedUrl != dir.resolve(plasmoid.configuration.url)) { | ||
255 | doBack(); | 262 | doBack(); | ||
256 | mouse.accepted = true; | 263 | mouse.accepted = true; | ||
257 | } | 264 | } | ||
258 | 265 | | |||
259 | return; | 266 | return; | ||
260 | } | 267 | } | ||
261 | 268 | | |||
262 | if (childAt(mouse.x, mouse.y) != editor) { | 269 | if (editor && childAt(mouse.x, mouse.y) != editor) { | ||
263 | editor.commit(); | 270 | editor.commit(); | ||
264 | } | 271 | } | ||
265 | 272 | | |||
266 | pressX = mouse.x; | 273 | pressX = mouse.x; | ||
267 | pressY = mouse.y; | 274 | pressY = mouse.y; | ||
268 | 275 | | |||
269 | if (!hoveredItem || hoveredItem.blank) { | 276 | if (!hoveredItem || hoveredItem.blank) { | ||
270 | if (!gridView.ctrlPressed) { | 277 | if (!gridView.ctrlPressed) { | ||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | |||||
320 | 327 | | |||
321 | onCanceled: pressCanceled() | 328 | onCanceled: pressCanceled() | ||
322 | onReleased: pressCanceled() | 329 | onReleased: pressCanceled() | ||
323 | 330 | | |||
324 | onClicked: { | 331 | onClicked: { | ||
325 | clearPressState(); | 332 | clearPressState(); | ||
326 | 333 | | |||
327 | if (mouse.button === Qt.RightButton || | 334 | if (mouse.button === Qt.RightButton || | ||
328 | childAt(mouse.x, mouse.y) == editor) { | 335 | (editor && childAt(mouse.x, mouse.y) === editor)) { | ||
329 | return; | 336 | return; | ||
330 | } | 337 | } | ||
331 | 338 | | |||
332 | if (!hoveredItem || hoveredItem.blank || gridView.currentIndex == -1 || gridView.ctrlPressed || gridView.shiftPressed) { | 339 | if (!hoveredItem || hoveredItem.blank || gridView.currentIndex == -1 || gridView.ctrlPressed || gridView.shiftPressed) { | ||
333 | // Bug 357367: Replay mouse event, so containment actions assigned to left mouse button work. | 340 | // Bug 357367: Replay mouse event, so containment actions assigned to left mouse button work. | ||
334 | eventGenerator.sendMouseEvent(plasmoid, EventGenerator.MouseButtonPress, mouse.x, mouse.y, mouse.button, mouse.buttons, mouse.modifiers); | 341 | eventGenerator.sendMouseEvent(plasmoid, EventGenerator.MouseButtonPress, mouse.x, mouse.y, mouse.button, mouse.buttons, mouse.modifiers); | ||
335 | return; | 342 | return; | ||
336 | } | 343 | } | ||
▲ Show 20 Lines • Show All 276 Lines • ▼ Show 20 Line(s) | 618 | delegate: FolderItemDelegate { | |||
613 | height: gridView.cellHeight | 620 | height: gridView.cellHeight | ||
614 | } | 621 | } | ||
615 | 622 | | |||
616 | onContentXChanged: { | 623 | onContentXChanged: { | ||
617 | if (hoveredItem) { | 624 | if (hoveredItem) { | ||
618 | hoverActivateTimer.stop(); | 625 | hoverActivateTimer.stop(); | ||
619 | } | 626 | } | ||
620 | 627 | | |||
621 | editor.targetItem = null; | 628 | cancelRename(); | ||
622 | 629 | | |||
623 | dir.setDragHotSpotScrollOffset(contentX, contentY); | 630 | dir.setDragHotSpotScrollOffset(contentX, contentY); | ||
624 | 631 | | |||
625 | if (contentX == 0) { | 632 | if (contentX == 0) { | ||
626 | scrollLeft = false; | 633 | scrollLeft = false; | ||
627 | } | 634 | } | ||
628 | 635 | | |||
629 | if (contentX == contentItem.width - width) { | 636 | if (contentX == contentItem.width - width) { | ||
Show All 18 Lines | |||||
648 | } | 655 | } | ||
649 | } | 656 | } | ||
650 | 657 | | |||
651 | onContentYChanged: { | 658 | onContentYChanged: { | ||
652 | if (hoveredItem) { | 659 | if (hoveredItem) { | ||
653 | hoverActivateTimer.stop(); | 660 | hoverActivateTimer.stop(); | ||
654 | } | 661 | } | ||
655 | 662 | | |||
656 | editor.targetItem = null; | 663 | cancelRename(); | ||
657 | 664 | | |||
658 | dir.setDragHotSpotScrollOffset(contentX, contentY); | 665 | dir.setDragHotSpotScrollOffset(contentX, contentY); | ||
659 | 666 | | |||
660 | if (contentY == 0) { | 667 | if (contentY == 0) { | ||
661 | scrollUp = false; | 668 | scrollUp = false; | ||
662 | } | 669 | } | ||
663 | 670 | | |||
664 | if (contentY == contentItem.height - height) { | 671 | if (contentY == contentItem.height - height) { | ||
▲ Show 20 Lines • Show All 212 Lines • ▼ Show 20 Line(s) | 882 | if (currentIndex != -1 && dir.hasSelection() && currentItem) { | |||
877 | dir.openContextMenu(currentItem.frame, event.modifiers); | 884 | dir.openContextMenu(currentItem.frame, event.modifiers); | ||
878 | } else { | 885 | } else { | ||
879 | // Otherwise let the containment handle it. | 886 | // Otherwise let the containment handle it. | ||
880 | event.accepted = false; | 887 | event.accepted = false; | ||
881 | } | 888 | } | ||
882 | } | 889 | } | ||
883 | 890 | | |||
884 | Keys.onEscapePressed: { | 891 | Keys.onEscapePressed: { | ||
885 | if (!editor.targetItem) { | 892 | if (!editor || !editor.targetItem) { | ||
886 | dir.clearSelection(); | 893 | dir.clearSelection(); | ||
887 | event.accepted = false; | 894 | event.accepted = false; | ||
888 | } | 895 | } | ||
889 | } | 896 | } | ||
890 | 897 | | |||
891 | Folder.ShortCut { | 898 | Folder.ShortCut { | ||
892 | Component.onCompleted: { | 899 | Component.onCompleted: { | ||
893 | installAsEventFilterFor(gridView); | 900 | installAsEventFilterFor(gridView); | ||
▲ Show 20 Lines • Show All 289 Lines • ▼ Show 20 Line(s) | 1184 | Folder.ItemViewAdapter { | |||
1183 | adapterVisibleArea: Qt.rect(gridView.contentX, gridView.contentY, gridView.contentWidth, gridView.contentHeight) | 1190 | adapterVisibleArea: Qt.rect(gridView.contentX, gridView.contentY, gridView.contentWidth, gridView.contentHeight) | ||
1184 | 1191 | | |||
1185 | Component.onCompleted: { | 1192 | Component.onCompleted: { | ||
1186 | gridView.movementStarted.connect(viewAdapter.viewScrolled); | 1193 | gridView.movementStarted.connect(viewAdapter.viewScrolled); | ||
1187 | dir.viewAdapter = viewAdapter; | 1194 | dir.viewAdapter = viewAdapter; | ||
1188 | } | 1195 | } | ||
1189 | } | 1196 | } | ||
1190 | 1197 | | |||
1198 | Component { | ||||
1199 | id: editorComponent | ||||
1200 | | ||||
1191 | PlasmaComponents.TextArea { | 1201 | PlasmaComponents.TextArea { | ||
1192 | id: editor | 1202 | id: editor | ||
1193 | 1203 | | |||
1194 | visible: false | 1204 | visible: false | ||
1195 | 1205 | | |||
1196 | wrapMode: root.useListViewMode ? TextEdit.NoWrap : TextEdit.Wrap | 1206 | wrapMode: root.useListViewMode ? TextEdit.NoWrap : TextEdit.Wrap | ||
1197 | 1207 | | |||
1198 | textMargin: 0 | 1208 | textMargin: 0 | ||
▲ Show 20 Lines • Show All 141 Lines • ▼ Show 20 Line(s) | |||||
1340 | 1350 | | |||
1341 | function commit() { | 1351 | function commit() { | ||
1342 | if (targetItem) { | 1352 | if (targetItem) { | ||
1343 | dir.rename(positioner.map(targetItem.index), text); | 1353 | dir.rename(positioner.map(targetItem.index), text); | ||
1344 | targetItem = null; | 1354 | targetItem = null; | ||
1345 | } | 1355 | } | ||
1346 | } | 1356 | } | ||
1347 | } | 1357 | } | ||
1358 | } | ||||
1348 | 1359 | | |||
1349 | Component.onCompleted: { | 1360 | Component.onCompleted: { | ||
1350 | dir.requestRename.connect(rename); | 1361 | dir.requestRename.connect(rename); | ||
1351 | } | 1362 | } | ||
1352 | } | 1363 | } | ||
1353 | 1364 | | |||
1354 | Component.onCompleted: { | 1365 | Component.onCompleted: { | ||
1355 | if (backButton == null && root.useListViewMode) { | 1366 | if (backButton == null && root.useListViewMode) { | ||
1356 | backButton = makeBackButton(); | 1367 | backButton = makeBackButton(); | ||
1357 | } | 1368 | } | ||
1358 | } | 1369 | } | ||
1359 | } | 1370 | } |