Commit 6736bdaa authored by Thomas Surrel's avatar Thomas Surrel

[Folder View] Remember selected item when navigating in subfolders

Summary:
When using the folder view in a panel as a popup, being in list view
mode, getting into subfolders and back with arrow keys had a weird
behaviour: the currentItem would just stay the same accross folders.

This patch restores both the proper selected item and the scrolling
position when navigating back.

BUG: 359310

Test Plan:
- Add a folder view in a panel, configure it in list view mode
- Enter a subfolder and go back
The folder you had gone into should be selected and the scrolling
position should be the same than when you entered it.

Reviewers: #plasma, broulik, hein

Reviewed By: #plasma, hein

Subscribers: anthonyfieroni, ngraham, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D15840
parent 3afa202c
......@@ -59,6 +59,8 @@ FocusScope {
property alias scrollDown: gridView.scrollDown
property alias hoveredItem: gridView.hoveredItem
property var history: []
property var lastPosition: null
property bool goingBack: false
property Item backButton: null
property var dialog: null
property Item editor: null
......@@ -189,13 +191,17 @@ FocusScope {
}
function doCd(row) {
history.push(url);
history.push({"url": url, "index": gridView.currentIndex, "yPosition": gridView.visibleArea.yPosition});
updateHistory();
dir.cd(row);
gridView.currentIndex = -1;
}
function doBack() {
url = history.pop();
goingBack = true;
gridView.currentIndex = -1;
lastPosition = history.pop();
url = lastPosition.url;
updateHistory();
}
......@@ -1109,6 +1115,11 @@ FocusScope {
onListingCompleted: {
if (!gridView.model && plasmoid.expanded) {
gridView.model = positioner;
} else if (goingBack) {
goingBack = false;
gridView.currentIndex = Math.min(lastPosition.index, gridView.count - 1);
setSelected(positioner.map(gridView.currentIndex));
gridView.contentY = lastPosition.yPosition * gridView.contentHeight;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment