From 9a7fc7bf3c5ccfd8025bfc98574254c43e3cb352 Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 19 Oct 2023 11:50:29 +0100 Subject: [PATCH] Hide empty categories when filtering When filtering the OS list, if all items in a category/sublist are filtered out then don't show the category/sublist. Also, clear the selected OS when the HW device is changed, otherwise you can get weird effects like having an incompatible (hw, os) pair selected or the highlighted OS moving when the items in the OS list change. --- src/main.qml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main.qml b/src/main.qml index 303a07a..9f48ae6 100644 --- a/src/main.qml +++ b/src/main.qml @@ -1444,6 +1444,11 @@ ApplicationWindow { if ("subitems" in entry) { filterItems(entry["subitems"], tags, hwTagMatchingType) + + // If this sub-list has no items then hide it + if (entry["subitems"].length == 0) { + list.splice(i, 1) + } } } } @@ -1655,6 +1660,15 @@ ApplicationWindow { } }) + // When the HW device is changed, reset the OS selection otherwise + // you get a weird effect with the selection moving around in the list + // when the user next opens the OS list, and the user could still have + // an OS selected which isn't compatible with this HW device + oslist.currentIndex = -1 + osswipeview.currentIndex = 0 + osbutton.text = qsTr("CHOOSE OS") + writebutton.enabled = false + hwbutton.text = hwmodel.name hwpopup.close() }