From 9ee4d70420e72bd4193e19b37d6c7f9c2d0ddfe9 Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Mon, 22 Dec 2025 00:04:50 +0800 Subject: [PATCH] fix: select library screen skipped even we have 2+ libraries --- ComicSelectionPage.qml | 27 +++++++++++++++++++-------- LibrarySelectionPage.qml | 14 +++++++++----- appcontroller.cpp | 1 + appcontroller.h | 1 + 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/ComicSelectionPage.qml b/ComicSelectionPage.qml index a1022f3..dd76afa 100644 --- a/ComicSelectionPage.qml +++ b/ComicSelectionPage.qml @@ -11,16 +11,27 @@ Item { width: Math.min(0.66 * parent.width, 320) height: parent.height - ListView { - id: listView - clip: true + ColumnLayout { anchors.fill: parent - model: AppController.foldersModel - delegate: ItemDelegate { - text: model.display - width: listView.width + ListView { + id: listView + clip: true + Layout.fillWidth: true + Layout.fillHeight: true + model: AppController.foldersModel + delegate: ItemDelegate { + text: model.display + width: listView.width + onClicked: function() { + AppController.updateComicsInFolder(model.folderId) + } + } + } + Button { + Layout.fillWidth: true + text: "Select Library" onClicked: function() { - AppController.updateComicsInFolder(model.folderId) + AppController.selectedLibraryId = -1 } } } diff --git a/LibrarySelectionPage.qml b/LibrarySelectionPage.qml index 99518c1..90a0a1e 100644 --- a/LibrarySelectionPage.qml +++ b/LibrarySelectionPage.qml @@ -25,11 +25,6 @@ Control { AppController.selectedLibraryId = model.libraryId } } - onCountChanged: function() { - if (count == 1) { - AppController.selectedLibraryId = model.data(modelIndex(0), LibraryItem.IdRole) - } - } } } @@ -37,4 +32,13 @@ Control { AppController.updateLibraries() } } + + Connections { + target: AppController + onLibrariesLoaded: function(count) { + if (count === 1) { + AppController.selectedLibraryId = model.data(modelIndex(0), LibraryItem.IdRole) + } + } + } } diff --git a/appcontroller.cpp b/appcontroller.cpp index 29e379e..c2e716e 100644 --- a/appcontroller.cpp +++ b/appcontroller.cpp @@ -72,6 +72,7 @@ void AppController::updateLibraries() libraryObj["name"].toString(), libraryObj["uuid"].toString())); } + emit librariesLoaded(array.count()); } } }); diff --git a/appcontroller.h b/appcontroller.h index cd66473..cbc27ed 100644 --- a/appcontroller.h +++ b/appcontroller.h @@ -39,6 +39,7 @@ public: Q_INVOKABLE QString comicImageSource(int page); signals: + void librariesLoaded(int count); void connectionStateChanged(ConnectionState newState); void currentLibraryIdChanged(int newLibraryId); void currentComicIdChanged(QString newComicId);