Verified Commit 09715792 authored by Carl Schwan's avatar Carl Schwan 🚴 Committed by Fushan Wen
Browse files

Make keyboard navigation in the calendar possible



Co-authored-by: Jan Blackquill's avatarJanet Blackquill <uhhadd@gmail.com>
parent 8cc71558
Pipeline #209339 canceled with stage
in 1 minute and 6 seconds
......@@ -26,6 +26,10 @@ PlasmaComponents3.AbstractButton {
signal activated
readonly property date thisDate: new Date(yearNumber, typeof monthNumber !== "undefined" ? monthNumber - 1 : 0, typeof dayNumber !== "undefined" ? dayNumber : 1)
Accessible.name: thisDate.toLocaleDateString(Qt.locale(), Locale.LongFormat)
Accessible.description: (model.eventCount !== undefined && model.eventCount > 0) ? i18ndp("plasmashellprivateplugin", "%1 event", "%1 events") : i18nd("plasmashellprivateplugin", "No events")
readonly property bool today: {
const today = root.today;
let result = true;
......@@ -55,6 +59,20 @@ PlasmaComponents3.AbstractButton {
return result
}
PlasmaCore.FrameSvgItem {
id: focusEffect
anchors {
fill: parent
leftMargin: -margins.left
topMargin: -margins.top
rightMargin: -margins.right
bottomMargin: -margins.bottom
}
opacity: dayStyle.activeFocus ? 1 : 0
imagePath: "widgets/button"
prefix: ["toolbutton-focus", "focus"]
}
PlasmaExtras.Highlight {
id: todayRect
anchors.fill: parent
......@@ -66,6 +84,8 @@ PlasmaComponents3.AbstractButton {
return 0.6;
} else if (dayStyle.hovered) {
return 0.3;
} else if (dayStyle.activeFocus) {
return 0.1;
}
return 0;
}
......
......@@ -122,6 +122,31 @@ Item {
height: daysCalendar.cellHeight
dayModel: repeater.model
activeFocusOnTab: selected && daysCalendar.PlasmaComponents3.SwipeView.isCurrentItem
Keys.onPressed: {
switch (event.key) {
case Qt.Key_Space:
case Qt.Key_Enter:
case Qt.Key_Return:
case Qt.Key_Select:
daysCalendar.activated(index, model, delegate);
break;
}
}
KeyNavigation.left: if (index !== 0) {
return repeater.itemAt(index - 1);
} else {
return root.nextItemInFocusChain(false);
}
KeyNavigation.up: if (index >= daysCalendar.columns) {
return repeater.itemAt(index - daysCalendar.columns);
} else {
return root.nextItemInFocusChain(false);
}
Connections {
target: daysCalendar
function onActivateHighlightedItem(delegate) {
......
......@@ -336,6 +336,8 @@ PinchArea { // TODO KF6 switch to Item
right: parent.right
bottom: parent.bottom
}
activeFocusOnTab: false
clip: true
onCurrentIndexChanged: if (currentIndex > 1) {
......
Supports Markdown
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