[graphics/koko] src/qml/gallery: GalleryPage: Workaround ItemSelectionModel hasSelection not notifying
Oliver Beard <[email protected]> Tue, 4 Aug 2026 12:29:01 +0000 (UTC)
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 67a3bf58286de964d4b9cfef1ca9116ddfdda70e by Oliver Beard.
Committed on 04/08/2026 at 12:23.
Pushed by olib into branch 'master'.
GalleryPage: Workaround ItemSelectionModel hasSelection not notifying
`ItemSelectionModel`, when its model resets, loses all selections but does not emit `hasSelectionChanged` despite changing to false.
As such, the page's `selectionMode` property, a binding to this property, is not updated, and selection mode sticks when moving from one location to another.
Work around this by replacing it with a new binding to the value.
M +9 -0 src/qml/gallery/GalleryPage.qml
https://invent.kde.org/graphics/koko/-/commit/67a3bf58286de964d4b9cfef1ca9116ddfdda70e
diff --git a/src/qml/gallery/GalleryPage.qml b/src/qml/gallery/GalleryPage.qml
index 73f8a004..032255b2 100644
--- a/src/qml/gallery/GalleryPage.qml
+++ b/src/qml/gallery/GalleryPage.qml
@@ -650,6 +650,15 @@ Kirigami.ScrollablePage {
model: gallerySortFilterProxyModel
}
+ Connections {
+ target: gallerySortFilterProxyModel
+ function onModelReset() {
+ // HACK: ItemSelectionModel does not emit hasSelectionChanged
+ // after model reset results in no selection
+ page.selectionMode = Qt.binding(() => selectionModel.hasSelection);
+ }
+ }
+
Koko.CutFileHelper {
id: cutFileHelper
}