Changeset View
Standalone View
containments/desktop/package/contents/ui/FolderView.qml
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | 32 | FocusScope { | |||
---|---|---|---|---|---|
54 | property alias cellHeight: gridView.cellHeight | 54 | property alias cellHeight: gridView.cellHeight | ||
55 | property alias overflowing: gridView.overflowing | 55 | property alias overflowing: gridView.overflowing | ||
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 var lastPosition: null | ||||
63 | property bool goingBack: false | ||||
62 | property Item backButton: null | 64 | property Item backButton: null | ||
63 | property var dialog: null | 65 | property var dialog: null | ||
64 | property Item editor: null | 66 | property Item editor: null | ||
65 | 67 | | |||
66 | function rename() { | 68 | function rename() { | ||
67 | if (gridView.currentIndex != -1) { | 69 | if (gridView.currentIndex != -1) { | ||
68 | var renameAction = folderView.model.action("rename"); | 70 | var renameAction = folderView.model.action("rename"); | ||
69 | if (renameAction && !renameAction.enabled) { | 71 | if (renameAction && !renameAction.enabled) { | ||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Line(s) | 183 | Binding { | |||
184 | value: !gridView.model && dir.status === Folder.FolderModel.Listing | 186 | value: !gridView.model && dir.status === Folder.FolderModel.Listing | ||
185 | } | 187 | } | ||
186 | 188 | | |||
187 | function makeBackButton() { | 189 | function makeBackButton() { | ||
188 | return Qt.createQmlObject("BackButtonItem {}", main); | 190 | return Qt.createQmlObject("BackButtonItem {}", main); | ||
189 | } | 191 | } | ||
190 | 192 | | |||
191 | function doCd(row) { | 193 | function doCd(row) { | ||
192 | history.push(url); | 194 | history.push({"url": url, "index": gridView.currentIndex, "yPosition": gridView.visibleArea.yPosition}); | ||
hein: You're still storing contentY here. | |||||
193 | updateHistory(); | 195 | updateHistory(); | ||
194 | dir.cd(row); | 196 | dir.cd(row); | ||
197 | gridView.currentIndex = -1; | ||||
195 | } | 198 | } | ||
196 | 199 | | |||
197 | function doBack() { | 200 | function doBack() { | ||
198 | url = history.pop(); | 201 | goingBack = true; | ||
202 | gridView.currentIndex = -1; | ||||
203 | lastPosition = history.pop(); | ||||
204 | url = lastPosition.url; | ||||
199 | updateHistory(); | 205 | updateHistory(); | ||
200 | } | 206 | } | ||
201 | 207 | | |||
202 | // QML doesn't detect change in the array(history) property, so update it explicitly. | 208 | // QML doesn't detect change in the array(history) property, so update it explicitly. | ||
203 | function updateHistory() { | 209 | function updateHistory() { | ||
204 | history = history; | 210 | history = history; | ||
205 | } | 211 | } | ||
206 | 212 | | |||
▲ Show 20 Lines • Show All 895 Lines • ▼ Show 20 Line(s) | 1104 | Folder.FolderModel { | |||
1102 | sortDesc: plasmoid.configuration.sortDesc | 1108 | sortDesc: plasmoid.configuration.sortDesc | ||
1103 | sortDirsFirst: plasmoid.configuration.sortDirsFirst | 1109 | sortDirsFirst: plasmoid.configuration.sortDirsFirst | ||
1104 | parseDesktopFiles: (plasmoid.configuration.url == "desktop:/") | 1110 | parseDesktopFiles: (plasmoid.configuration.url == "desktop:/") | ||
1105 | previews: plasmoid.configuration.previews | 1111 | previews: plasmoid.configuration.previews | ||
1106 | previewPlugins: plasmoid.configuration.previewPlugins | 1112 | previewPlugins: plasmoid.configuration.previewPlugins | ||
1107 | appletInterface: plasmoid | 1113 | appletInterface: plasmoid | ||
1108 | 1114 | | |||
1109 | onListingCompleted: { | 1115 | onListingCompleted: { | ||
1110 | if (!gridView.model && plasmoid.expanded) { | 1116 | if (!gridView.model && plasmoid.expanded) { | ||
Do we have grodView.model after back clicked? If we do in expanded view (that's when Folder View is embedded in the panel) goingBack will not be performed. anthonyfieroni: Do we have grodView.model after back clicked? If we do in expanded view (that's when Folder… | |||||
My understanding was that the gridView.model could be undefined only if the FolderModel was not ready. But if we navigated into a subfolder and we are asking to go back, than the FolderModel had to be up and running already. Could be safe to move this 'if' outside the 'else' though. thsurrel: My understanding was that the gridView.model could be undefined only if the FolderModel was not… | |||||
Ok, then just embed Folder View in the panel (by right click on the panel, panel options -> add widgets or drag'n'drop it in) then navigate to check that should it goback to be applied as well. anthonyfieroni: Ok, then just embed Folder View in the panel (by right click on the panel, panel options -> add… | |||||
Oh, it does, what you describe is the very use case this patch is about. I tested it :) thsurrel: Oh, it does, what you describe is the very use case this patch is about. I tested it :)
It's… | |||||
1111 | gridView.model = positioner; | 1117 | gridView.model = positioner; | ||
1118 | } else if (goingBack) { | ||||
1119 | goingBack = false; | ||||
1120 | gridView.currentIndex = Math.min(lastPosition.index, gridView.count - 1); | ||||
1121 | setSelected(positioner.map(gridView.currentIndex)); | ||||
1122 | gridView.contentY = lastPosition.yPosition * gridView.contentHeight; | ||||
I don't think this works as intended. It means "only change to this contentY if it's lower than the current contentY". I'm not really happy with the use of contentY to begin with, though, unfortunately. The problem is that contentY isn't really something that's a good idea to store permanently, because it's relative to originY, and originY can change arbitrarily depending on things like delegate inseration/removal outside the viewport, which can depend on the number of items in the model. Could you try using the normalized values in gridView.visibleArea.* instead? If you use visibleArea.yPosition you can even forego the bounds check since it can't be out of bounds. hein: I don't think this works as intended. It means "only change to this contentY if it's lower than… | |||||
1112 | } | 1123 | } | ||
1113 | } | 1124 | } | ||
1114 | 1125 | | |||
1115 | onMove: { | 1126 | onMove: { | ||
1116 | var rows = (gridView.flow == GridView.FlowLeftToRight); | 1127 | var rows = (gridView.flow == GridView.FlowLeftToRight); | ||
1117 | var axis = rows ? gridView.width : gridView.height; | 1128 | var axis = rows ? gridView.width : gridView.height; | ||
1118 | var step = rows ? cellWidth : cellHeight; | 1129 | var step = rows ? cellWidth : cellHeight; | ||
1119 | var perStripe = Math.floor(axis / step); | 1130 | var perStripe = Math.floor(axis / step); | ||
▲ Show 20 Lines • Show All 258 Lines • Show Last 20 Lines |
You're still storing contentY here.