diff --git a/kded/qml/OsdSelector.qml b/kded/qml/OsdSelector.qml --- a/kded/qml/OsdSelector.qml +++ b/kded/qml/OsdSelector.qml @@ -39,7 +39,7 @@ PlasmaComponents.ButtonRow { id: buttonRow - exclusive: false + exclusive: true height: parent.height - label.height - ((units.smallSpacing/2) * 3) width: (actionRepeater.count * height) + ((actionRepeater.count - 1) * buttonRow.spacing); @@ -79,6 +79,7 @@ } ] delegate: PlasmaComponents.Button { + property var action: modelData.action PlasmaCore.IconItem { source: modelData.iconSource height: buttonRow.height - ((units.smallSpacing / 2) * 3) @@ -88,9 +89,26 @@ height: parent.height width: height - onHoveredChanged: root.infoText = (hovered ? modelData.label : "") + onHoveredChanged: { + if (hovered) { + checked = true + } + } - onClicked: root.clicked(modelData.action) + onClicked: root.clicked(action) + activeFocusOnTab: true + checked: activeFocus + onCheckedChanged: { + if (checked) { + root.infoText = modelData.label + } + } + Component.onCompleted: { + // arbitrary and not very sensible default, focus on first button + if (index == 0) { + forceActiveFocus() + } + } } } } @@ -115,6 +133,39 @@ Component.onCompleted: print("OsdSelector loaded..."); Keys.onEscapePressed: clicked("dialog-cancel") + Keys.onReturnPressed: { + clicked(buttonRow.checkedButton.action) + } + Keys.onPressed: { + if (event.key === Qt.Key_Right || event.key === Qt.Key_Left) { + var i = 0 + for (i = 0; i < buttonRow.children.length; i = i+1) { + if (buttonRow.children[i].checked) { + break; + } + } + // check for checked property, the repeater is also a child and must be skipped + if (event.key === Qt.Key_Left) { + do { + i = i - 1 + if (i < 0) { + i = buttonRow.children.length - 1 + } + } while (!buttonRow.children[i] || !buttonRow.children[i].hasOwnProperty("checked")) + + } + if (event.key === Qt.Key_Right) { + do { + i = i + 1 + if (i >= buttonRow.children.length) { + i = 0 + } + } while (!buttonRow.children[i] || !buttonRow.children[i].hasOwnProperty("checked")) + } + buttonRow.children[i].checked = true + return + } + } } }