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)
wilder-5.25
Marco Martin 4 years ago
parent 2e509a949f
commit 73d13d1bfe
  1. 1
      applets/systemtray/package/contents/ui/items/ItemLoader.qml
  2. 18
      applets/systemtray/package/contents/ui/main.qml
  3. 16
      applets/systemtray/systemtray.cpp
  4. 7
      applets/systemtray/systemtray.h

@ -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();

Loading…
Cancel
Save