Verified Commit 77fc223b authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

applet: add arrow key navigation support

parent d0e32061
Pipeline #216580 passed with stage
in 1 minute and 23 seconds
......@@ -5,7 +5,7 @@
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
import QtQuick 2.4
import QtQuick 2.15
import QtQuick.Controls 2.4
import org.kde.bluezqt 1.0 as BluezQt
import org.kde.plasma.core 2.0 as PlasmaCore
......@@ -24,6 +24,18 @@ PlasmaExtras.Representation {
focus: true
collapseMarginsHint: true
Keys.onDownPressed: {
if (listView.count === 0) {
return;
}
if (listView.currentIndex < 0 || toolbar.checkbox.activeFocus) {
listView.incrementCurrentIndex();
listView.currentItem.forceActiveFocus();
} else {
event.accepted = false;
}
}
Action {
id: addBluetoothDeviceAction
......@@ -108,6 +120,15 @@ PlasmaExtras.Representation {
highlightResizeDuration: 0
delegate: DeviceItem {}
Keys.onUpPressed: {
if (listView.currentIndex === 0) {
listView.currentIndex = -1;
toolbar.checkbox.forceActiveFocus(Qt.BacktabFocusReason);
} else {
event.accepted = false;
}
}
Loader {
anchors.centerIn: parent
width: parent.width - (4 * PlasmaCore.Units.largeSpacing)
......
......@@ -16,11 +16,14 @@ import org.kde.plasma.private.bluetooth 1.0 as PlasmaBt
PlasmaExtras.PlasmoidHeading {
id: toolbar
property alias checkbox: checkbox
leftPadding: PlasmaCore.Units.smallSpacing
contentItem: RowLayout {
spacing: PlasmaCore.Units.smallSpacing
PlasmaComponents3.CheckBox {
id: checkbox
text: i18n("Enable Bluetooth")
icon.name: "preferences-system-bluetooth"
checked: btManager.bluetoothOperational
......
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