From e799513fb46562245fe3799973442cc0fa5d981c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 16 May 2021 08:57:18 +0200 Subject: [PATCH] Reset the grid current index when the grid content changes `model` object doesn't really change so we can't use `onModelChanged` in QML to reset the index. --- YACReaderLibrary/grid_comics_view.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/YACReaderLibrary/grid_comics_view.cpp b/YACReaderLibrary/grid_comics_view.cpp index f442bece..b844bfa6 100644 --- a/YACReaderLibrary/grid_comics_view.cpp +++ b/YACReaderLibrary/grid_comics_view.cpp @@ -259,6 +259,12 @@ void GridComicsView::setModel(ComicModel *model) ctxt->setContextProperty("dropManager", this); ctxt->setContextProperty("comicInfoHelper", comicInfoHelper); + auto grid = view->rootObject()->findChild(QStringLiteral("grid")); + + if (grid != nullptr) { + grid->setProperty("currentIndex", 0); + } + updateBackgroundConfig(); selectionHelper->clear();