diff --git a/applets/systemtray/package/contents/ui/items/ItemLoader.qml b/applets/systemtray/package/contents/ui/items/ItemLoader.qml index 40141fe9a..0135ff705 100644 --- a/applets/systemtray/package/contents/ui/items/ItemLoader.qml +++ b/applets/systemtray/package/contents/ui/items/ItemLoader.qml @@ -9,6 +9,7 @@ import QtQuick 2.0 Loader { id: itemLoader + z: x property var itemModel: model onActiveFocusChanged: { if (activeFocus && item) { diff --git a/applets/systemtray/package/contents/ui/main.qml b/applets/systemtray/package/contents/ui/main.qml index e437a871e..7ef26defb 100644 --- a/applets/systemtray/package/contents/ui/main.qml +++ b/applets/systemtray/package/contents/ui/main.qml @@ -159,7 +159,23 @@ MouseArea { } } - delegate: ItemLoader {} + delegate: ItemLoader { + id: delegate + // We need to recalculate the stacking order of the z values due to how keyboard navigation works + // the tab order depends exclusively from this, so we redo it as the position in the list + // ensuring tab navigation focuses the expected items + Component.onCompleted: { + let item = tasksGrid.itemAtIndex(index - 1); + if (item) { + plasmoid.nativeInterface.stackItemBefore(delegate, item) + } else { + item = tasksGrid.itemAtIndex(index + 1); + } + if (item) { + plasmoid.nativeInterface.stackItemAfter(delegate, item) + } + } + } add: Transition { enabled: itemSize > 0 diff --git a/applets/systemtray/systemtray.cpp b/applets/systemtray/systemtray.cpp index dbc23e652..f1af1e60c 100644 --- a/applets/systemtray/systemtray.cpp +++ b/applets/systemtray/systemtray.cpp @@ -366,6 +366,22 @@ void SystemTray::stopApplet(const QString &pluginId) } } +void SystemTray::stackItemBefore(QQuickItem *newItem, QQuickItem *beforeItem) +{ + if (!newItem || !beforeItem) { + return; + } + newItem->stackBefore(beforeItem); +} + +void SystemTray::stackItemAfter(QQuickItem *newItem, QQuickItem *afterItem) +{ + if (!newItem || !afterItem) { + return; + } + newItem->stackAfter(afterItem); +} + K_PLUGIN_CLASS_WITH_JSON(SystemTray, "package/metadata.json") #include "systemtray.moc" diff --git a/applets/systemtray/systemtray.h b/applets/systemtray/systemtray.h index 28708ea8b..9fe70e288 100644 --- a/applets/systemtray/systemtray.h +++ b/applets/systemtray/systemtray.h @@ -67,6 +67,13 @@ public: */ Q_INVOKABLE bool isSystemTrayApplet(const QString &appletId); + /** + * Needed to preserve keyboard navigation + */ + Q_INVOKABLE void stackItemBefore(QQuickItem *newItem, QQuickItem *beforeItem); + + Q_INVOKABLE void stackItemAfter(QQuickItem *newItem, QQuickItem *afterItem); + private Q_SLOTS: // synchronizes with configuration and deletes not allowed applets void onEnabledAppletsChanged();