Commit d82e74a8 authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

applet: support arrow key navigation

KeyNavigation is not used because the order is not stable.
parent 56ec17ae
......@@ -28,12 +28,14 @@ PC3.ItemDelegate {
property string /* "sink" | "sink-input" | "source" | "source-output" */ type
property string fullNameToShowOnHover: ""
highlighted: dropArea.containsDrag
highlighted: dropArea.containsDrag || activeFocus
background.visible: highlighted
opacity: (plasmoid.rootItem.draggedStream && plasmoid.rootItem.draggedStream.deviceIndex === item.model.Index) ? 0.3 : 1.0
ListView.delayRemove: clientIcon.Drag.active
Keys.forwardTo: [slider]
contentItem: RowLayout {
id: controlsRow
spacing: item.spacing
......
......@@ -437,6 +437,8 @@ Item {
Layout.preferredWidth: main.Layout.preferredWidth
collapseMarginsHint: true
KeyNavigation.down: tabBar.currentItem
function beginMoveStream(type, stream) {
if (type === "sink") {
contentView.hiddenTypes = "source"
......@@ -474,6 +476,8 @@ Item {
}
}
Keys.onDownPressed: contentView.currentItem.contentItem.upperListView.itemAtIndex(0).forceActiveFocus();
onCurrentIndexChanged: {
switch (currentIndex) {
case devicesTab.PC3.TabBar.index:
......@@ -619,6 +623,10 @@ Item {
}
contentItem: Flickable {
contentHeight: layout.implicitHeight
property ListView upperListView: upperSection.visible ? upperSection : lowerSection
property ListView lowerListView: lowerSection.visible ? lowerSection : upperSection
ColumnLayout {
id: layout
width: parent.width
......@@ -631,6 +639,29 @@ Item {
implicitHeight: contentHeight
model: scrollView.upperModel
delegate: scrollView.upperDelegate
focus: visible
Keys.onDownPressed: {
if (currentIndex < count - 1) {
incrementCurrentIndex();
currentItem.forceActiveFocus();
} else if (lowerSection.visible) {
lowerSection.currentIndex = 0;
lowerSection.currentItem.forceActiveFocus();
} else {
raiseMaximumVolumeCheckbox.forceActiveFocus(Qt.TabFocusReason);
}
event.accepted = true;
}
Keys.onUpPressed: {
if (currentIndex > 0) {
decrementCurrentIndex();
currentItem.forceActiveFocus();
} else {
tabBar.currentItem.forceActiveFocus(Qt.BacktabFocusReason);
}
event.accepted = true;
}
}
PlasmaCore.SvgItem {
elementId: "horizontal-line"
......@@ -649,6 +680,29 @@ Item {
implicitHeight: contentHeight
model: scrollView.lowerModel
delegate: scrollView.lowerDelegate
focus: visible && !upperSection.visible
Keys.onDownPressed: {
if (currentIndex < count - 1) {
incrementCurrentIndex();
currentItem.forceActiveFocus();
} else {
raiseMaximumVolumeCheckbox.forceActiveFocus(Qt.TabFocusReason);
}
event.accepted = true;
}
Keys.onUpPressed: {
if (currentIndex > 0) {
decrementCurrentIndex();
currentItem.forceActiveFocus();
} else if (upperSection.visible) {
upperSection.currentIndex = upperSection.count - 1;
upperSection.currentItem.forceActiveFocus();
} else {
tabBar.currentItem.forceActiveFocus(Qt.BacktabFocusReason);
}
event.accepted = true;
}
}
}
}
......@@ -663,6 +717,10 @@ Item {
anchors.verticalCenter: parent.verticalCenter
checked: plasmoid.configuration.raiseMaximumVolume
KeyNavigation.backtab: contentView.currentItem.contentItem.lowerListView.itemAtIndex(contentView.currentItem.contentItem.lowerListView.count - 1)
Keys.onUpPressed: KeyNavigation.backtab.forceActiveFocus(Qt.BacktabFocusReason);
onToggled: {
plasmoid.configuration.raiseMaximumVolume = checked
if (!checked) {
......
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