Commit 03b17ac5 authored by Eike Hein's avatar Eike Hein

Focus handling fixes

Summary:
* Fix keyboard nav on the desktop again.
BUG:399566
* Fix initial focus properly.
* Make sure when using arrows after starting Plasma or after clicking
  into empty space, the first selected item is always 0, not 1 or
  some random item based on previous activity.
* Make sure the view is always scrolled up when (re)opening the popup.

Reviewers: broulik

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D16106
parent 004d838c
......@@ -62,8 +62,11 @@ FocusScope {
property Item backButton: null
property var dialog: null
function rename()
{
function positionViewAtBeginning() {
gridView.positionViewAtBeginning();
}
function rename() {
if (gridView.currentIndex != -1) {
editor.targetItem = gridView.currentItem;
}
......@@ -268,6 +271,7 @@ FocusScope {
if (!hoveredItem || hoveredItem.blank) {
if (!gridView.ctrlPressed) {
gridView.currentIndex = -1;
dir.clearSelection();
}
......@@ -1089,6 +1093,7 @@ FocusScope {
onListingCompleted: {
if (!gridView.model && plasmoid.expanded) {
gridView.model = positioner;
gridView.currentIndex = isPopup ? 0 : -1;
}
}
......
......@@ -39,6 +39,10 @@ FocusScope {
property alias overflowing: folderView.overflowing
property alias flow: folderView.flow
readonly property bool lockedByKiosk: !KAuthorized.authorize("editable_desktop_icons")
focus: true
function updateContextualActions() {
folderView.model.updateActions();
......@@ -158,6 +162,7 @@ FocusScope {
if (plasmoid.expanded) {
folderView.currentIndex = -1;
folderView.forceActiveFocus();
folderView.positionViewAtBeginning();
} else {
goHome();
......
......@@ -239,6 +239,12 @@ FolderViewDropArea {
return length >= Qt.styleHints.startDragDistance;
}
onFocusChanged: {
if (focus && isFolder) {
folderViewLayer.item.forceActiveFocus();
}
}
onDragEnter: {
if (isContainment && plasmoid.immutable && !(isFolder && FolderTools.isFileDrag(event))) {
event.ignore();
......@@ -395,8 +401,9 @@ FolderViewDropArea {
MouseArea { // unfocus any plasmoid when clicking empty desktop area
anchors.fill: parent
onPressed: {
root.forceActiveFocus()
root.forceActiveFocus();
mouse.accepted = false // Bug 351277
if (toolBox && toolBox.open) {
toolBox.open = false;
}
......@@ -428,8 +435,9 @@ FolderViewDropArea {
Connections {
target: folderViewLayer.view
// `FolderViewDropArea` is not a FocusScope. We need to forward manually.
onPressed: {
folderViewLayer.focus = true;
folderViewLayer.forceActiveFocus();
}
}
}
......
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