Commit 0619c454 authored by Marco Martin's avatar Marco Martin

make krunner accessible

Summary:
enable actual keyboard navigation, as the previous
completely manual keyboard navigation in krunner completely broke
the screen reader support, rendering it inaccessible (while
potentially krunner is one of the most useful apps for blind
users)

Test Plan:
tested to navigate with keyboard (still similar behavior as before)
while having orca running, which correctly read the result entries

Reviewers: #plasma, davidedmundson, broulik

Reviewed By: #plasma, davidedmundson

Subscribers: gladhorn, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D7765
parent dea32eb1
......@@ -62,6 +62,8 @@ View::View(QWindow *)
KCrash::setFlags(KCrash::AutoRestart);
//used only by screen readers
setTitle(i18n("KRunner"));
m_config = KConfigGroup(KSharedConfig::openConfig(QStringLiteral("krunnerrc")), "General");
setFreeFloating(m_config.readEntry("FreeFloating", false));
......
......@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.0
import QtQuick 2.6
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
......@@ -97,19 +97,26 @@ ColumnLayout {
Keys.onPressed: allowCompletion = (event.key !== Qt.Key_Backspace && event.key !== Qt.Key_Delete)
Keys.onUpPressed: {
if (length === 0) {
root.showHistory = true
root.showHistory = true;
listView.forceActiveFocus();
} else {
results.forceActiveFocus();
}
}
Keys.onDownPressed: {
if (length === 0) {
root.showHistory = true
root.showHistory = true;
listView.forceActiveFocus();
} else {
results.forceActiveFocus();
}
}
Keys.onEnterPressed: results.runCurrentIndex()
Keys.onReturnPressed: results.runCurrentIndex()
Keys.onEscapePressed: {
runnerWindow.visible = false
}
Keys.forwardTo: [listView, results]
}
PlasmaComponents.ToolButton {
iconSource: "window-close"
......@@ -131,6 +138,13 @@ ColumnLayout {
queryString: root.query
runner: root.runner
Keys.onPressed: {
if (event.text != "") {
queryField.text += event.text;
queryField.focus = true;
}
}
onActivated: {
runnerWindow.addToHistory(queryString)
runnerWindow.visible = false
......@@ -156,6 +170,7 @@ ColumnLayout {
keyNavigationWraps: true
highlight: PlasmaComponents.Highlight {}
highlightMoveDuration: 0
activeFocusOnTab: true
// we store 50 entries in the history but only show 20 in the UI so it doesn't get too huge
model: root.showHistory ? runnerWindow.history.slice(0, 20) : []
delegate: Milou.ResultDelegate {
......@@ -166,13 +181,38 @@ ColumnLayout {
icon: "list-remove",
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Remove")
}]
Accessible.description: i18n("in category recent queries")
}
onActiveFocusChanged: {
if (!activeFocus && currentIndex == listView.count-1) {
currentIndex = 0;
}
}
Keys.onReturnPressed: runCurrentIndex()
Keys.onEnterPressed: runCurrentIndex()
Keys.onTabPressed: incrementCurrentIndex()
Keys.onBacktabPressed: decrementCurrentIndex()
Keys.onTabPressed: {
if (currentIndex == listView.count-1) {
listView.nextItemInFocusChain(true).forceActiveFocus();
} else {
incrementCurrentIndex()
}
}
Keys.onBacktabPressed: {
if (currentIndex == 0) {
listView.nextItemInFocusChain(false).forceActiveFocus();
} else {
decrementCurrentIndex()
}
}
Keys.onPressed: {
if (event.text != "") {
queryField.text += event.text;
queryField.focus = true;
}
}
Keys.onUpPressed: decrementCurrentIndex()
Keys.onDownPressed: incrementCurrentIndex()
......@@ -180,6 +220,7 @@ ColumnLayout {
var entry = runnerWindow.history[currentIndex]
if (entry) {
queryField.text = entry
queryField.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