From 7ceb7206334bf050d51ac7e9f751ff3de51fb46f Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Sat, 7 Aug 2021 04:49:49 +0300 Subject: [PATCH] [app] Show book count as menu label when appropriate --- app/qml/BooksShelfView.qml | 2 ++ app/qml/BooksStorageHeader.qml | 22 ++++------------------ app/qml/BooksStorageView.qml | 8 ++++++++ 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/app/qml/BooksShelfView.qml b/app/qml/BooksShelfView.qml index 8aa8225..ffb3bf9 100644 --- a/app/qml/BooksShelfView.qml +++ b/app/qml/BooksShelfView.qml @@ -51,6 +51,8 @@ Item { property alias shelf: shelfModel property alias device: shelfModel.device property alias dummyItemIndex: shelfModel.dummyItemIndex + property alias bookCount: shelfModel.bookCount + property alias bookCountVisible: storageHeader.needed signal openBook(var book) signal dropItem(var mouseX, var mouseY) diff --git a/app/qml/BooksStorageHeader.qml b/app/qml/BooksStorageHeader.qml index 64d38ea..7a3aaed 100644 --- a/app/qml/BooksStorageHeader.qml +++ b/app/qml/BooksStorageHeader.qml @@ -1,6 +1,6 @@ /* - Copyright (C) 2015-2020 Jolla Ltd. - Copyright (C) 2015-2020 Slava Monich + Copyright (C) 2015-2021 Jolla Ltd. + Copyright (C) 2015-2021 Slava Monich You may use this file under the terms of BSD license as follows: @@ -58,20 +58,8 @@ Column { property int count property bool showCount: true - property int _shownCount - signal clicked() - function updateShownCount() { - if (count > 0) { - _shownCount = count - } - } - - onCountChanged: updateShownCount() - - Component.onCompleted: updateShownCount() - Item { width: parent.width height: Math.max(storageLabel.height, bookCount.height) @@ -134,12 +122,10 @@ Column { } //: Number of books in the storage header //% "%0 book(s)" - text: qsTrId("harbour-books-storage-book_count",_shownCount).arg(_shownCount) + text: qsTrId("harbour-books-storage-book_count",count).arg(count) font.pixelSize: Theme.fontSizeExtraSmall color: Theme.highlightColor - opacity: (showCount && count > 0) ? 1 : 0 - visible: opacity > 0 - Behavior on opacity { FadeAnimation {} } + visible: (showCount && needed && count > 0) ? 1 : 0 } } diff --git a/app/qml/BooksStorageView.qml b/app/qml/BooksStorageView.qml index 9f0e1b6..a978337 100644 --- a/app/qml/BooksStorageView.qml +++ b/app/qml/BooksStorageView.qml @@ -131,6 +131,14 @@ Item { enabled: currentShelf && (currentShelf.count > 0) onClicked: storageModel.setDeleteAllRequest(storageListWatcher.currentIndex, true) } + MenuLabel { + //: Number of books in the storage header + //% "%0 book(s)" + text: qsTrId("harbour-books-storage-book_count",bookCount).arg(bookCount) + visible: !bookCountVisible && bookCount > 0 + readonly property int bookCount: storageList.currentItem ? storageList.currentItem.bookCount : 0 + readonly property bool bookCountVisible: storageList.currentItem && storageList.currentItem.bookCountVisible + } } onEditModeChanged: {