Commit c85eb1ae authored by Eike Hein's avatar Eike Hein

Implement Tab/Backtab navigation

Summary:
I'd like this in the 5.12 branch as it also fixes a shell freeze.

BUG:387316

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D10456
parent 4e479828
......@@ -319,6 +319,28 @@ Kicker.DashboardWindow {
flat: false
onClicked: searchField.clear();
Keys.onPressed: {
if (event.key == Qt.Key_Tab) {
event.accepted = true;
if (runnerModel.count) {
mainColumn.tryActivate(0, 0);
} else {
systemFavoritesGrid.tryActivate(0, 0);
}
} else if (event.key == Qt.Key_Backtab) {
event.accepted = true;
if (tabBar.visible) {
tabBar.focus = true;
} else if (globalFavoritesGrid.enabled) {
globalFavoritesGrid.tryActivate(0, 0);
} else {
systemFavoritesGrid.tryActivate(0, 0);
}
}
}
}
Row {
......@@ -339,8 +361,6 @@ Kicker.DashboardWindow {
Item {
id: favoritesColumn
anchors {
top: parent.top
bottom: parent.bottom
......@@ -438,6 +458,23 @@ Kicker.DashboardWindow {
systemFavoritesGrid.tryActivate(0, currentCol());
}
Keys.onPressed: {
if (event.key == Qt.Key_Tab) {
event.accepted = true;
if (tabBar.visible) {
tabBar.focus = true;
} else if (searching) {
cancelSearchButton.focus = true;
} else {
mainColumn.tryActivate(0, 0);
}
} else if (event.key == Qt.Key_Backtab) {
event.accepted = true;
systemFavoritesGrid.tryActivate(0, 0);
}
}
Binding {
target: globalFavorites
property: "iconSize"
......@@ -477,6 +514,32 @@ Kicker.DashboardWindow {
onKeyNavUp: {
globalFavoritesGrid.tryActivate(globalFavoritesGrid.rows - 1, currentCol());
}
Keys.onPressed: {
if (event.key == Qt.Key_Tab) {
event.accepted = true;
if (globalFavoritesGrid.enabled) {
globalFavoritesGrid.tryActivate(0, 0);
} else if (tabBar.visible) {
tabBar.focus = true;
} else if (searching && !runnerModel.count) {
cancelSearchButton.focus = true;
} else {
mainColumn.tryActivate(0, 0);
}
} else if (event.key == Qt.Key_Backtab) {
event.accepted = true;
if (filterList.enabled) {
filterList.forceActiveFocus();
} else if (searching && !runnerModel.count) {
cancelSearchButton.focus = true;
} else {
mainColumn.tryActivate(0, 0);
}
}
}
}
}
......@@ -693,6 +756,30 @@ Kicker.DashboardWindow {
target.tryActivate(targetRow, favoritesColumn.columns - 1);
}
}
Keys.onPressed: {
if (event.key == Qt.Key_Tab) {
event.accepted = true;
if (filterList.enabled) {
filterList.forceActiveFocus();
} else {
systemFavoritesGrid.tryActivate(0, 0);
}
} else if (event.key == Qt.Key_Backtab) {
event.accepted = true;
if (searching) {
cancelSearchButton.focus = true;
} else if (tabBar.visible) {
tabBar.focus = true;
} else if (globalFavoritesGrid.enabled) {
globalFavoritesGrid.tryActivate(0, 0);
} else {
systemFavoritesGrid.tryActivate(0, 0);
}
}
}
}
Item {
......@@ -953,6 +1040,12 @@ Kicker.DashboardWindow {
var currentRow = Math.max(0, Math.ceil(currentItem.y / mainGrid.cellHeight) - 1);
mainColumn.tryActivate(currentRow, mainColumn.columns - 1);
} else if (event.key == Qt.Key_Tab) {
event.accepted = true;
systemFavoritesGrid.tryActivate(0, 0);
} else if (event.key == Qt.Key_Backtab) {
event.accepted = true;
mainColumn.tryActivate(0, 0);
}
}
}
......
......@@ -66,5 +66,25 @@ Row {
activeTab = 1;
}
}
Keys.onPressed: {
if (event.key == Qt.Key_Tab) {
event.accepted = true;
if (searching) {
cancelSearchButton.focus = true;
} else {
mainColumn.tryActivate(0, 0);
}
} else if (event.key == Qt.Key_Backtab) {
event.accepted = true;
if (globalFavoritesGrid.enabled) {
globalFavoritesGrid.tryActivate(0, 0);
} else {
systemFavoritesGrid.tryActivate(0, 0);
}
}
}
}
......@@ -179,7 +179,9 @@ void DashboardWindow::keyPressEvent(QKeyEvent *e)
&& !(e->key() == Qt::Key_PageDown)
&& !(e->key() == Qt::Key_Enter)
&& !(e->key() == Qt::Key_Return)
&& !(e->key() == Qt::Key_Menu)) {
&& !(e->key() == Qt::Key_Menu)
&& !(e->key() == Qt::Key_Tab)
&& !(e->key() == Qt::Key_Backtab)) {
QPointer<QQuickItem> previousFocusItem = activeFocusItem();
......
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