Commit 73d13d1b authored by Marco Martin's avatar Marco Martin
Browse files

redo the stackorder based on where the item is.

With the keyboard navigation patch there is the issue that sometimes,
due to sorting by SortFilterModel, the stack order of the items doesn't
correspond to the visual order of the items.
This is a problem wrt the recently introduced keyboard navigation, as
the tab order of items in qml is completely tied to the stack order,
resulting in an erratic tab navigation order (usually happens with
device notifier or bluetooth applets for instance)
parent 2e509a94
Pipeline #140881 passed with stage
in 5 minutes and 34 seconds
......@@ -9,6 +9,7 @@ import QtQuick 2.0
Loader {
id: itemLoader
z: x
property var itemModel: model
onActiveFocusChanged: {
if (activeFocus && item) {
......
......@@ -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
......
......@@ -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"
......@@ -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();
......
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