[app] Show book count as menu label when appropriate

This commit is contained in:
Slava Monich 2021-08-07 04:49:49 +03:00
parent 902d6c20af
commit 7ceb720633
3 changed files with 14 additions and 18 deletions

View file

@ -51,6 +51,8 @@ Item {
property alias shelf: shelfModel property alias shelf: shelfModel
property alias device: shelfModel.device property alias device: shelfModel.device
property alias dummyItemIndex: shelfModel.dummyItemIndex property alias dummyItemIndex: shelfModel.dummyItemIndex
property alias bookCount: shelfModel.bookCount
property alias bookCountVisible: storageHeader.needed
signal openBook(var book) signal openBook(var book)
signal dropItem(var mouseX, var mouseY) signal dropItem(var mouseX, var mouseY)

View file

@ -1,6 +1,6 @@
/* /*
Copyright (C) 2015-2020 Jolla Ltd. Copyright (C) 2015-2021 Jolla Ltd.
Copyright (C) 2015-2020 Slava Monich <slava.monich@jolla.com> Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
You may use this file under the terms of BSD license as follows: You may use this file under the terms of BSD license as follows:
@ -58,20 +58,8 @@ Column {
property int count property int count
property bool showCount: true property bool showCount: true
property int _shownCount
signal clicked() signal clicked()
function updateShownCount() {
if (count > 0) {
_shownCount = count
}
}
onCountChanged: updateShownCount()
Component.onCompleted: updateShownCount()
Item { Item {
width: parent.width width: parent.width
height: Math.max(storageLabel.height, bookCount.height) height: Math.max(storageLabel.height, bookCount.height)
@ -134,12 +122,10 @@ Column {
} }
//: Number of books in the storage header //: Number of books in the storage header
//% "%0 book(s)" //% "%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 font.pixelSize: Theme.fontSizeExtraSmall
color: Theme.highlightColor color: Theme.highlightColor
opacity: (showCount && count > 0) ? 1 : 0 visible: (showCount && needed && count > 0) ? 1 : 0
visible: opacity > 0
Behavior on opacity { FadeAnimation {} }
} }
} }

View file

@ -131,6 +131,14 @@ Item {
enabled: currentShelf && (currentShelf.count > 0) enabled: currentShelf && (currentShelf.count > 0)
onClicked: storageModel.setDeleteAllRequest(storageListWatcher.currentIndex, true) 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: { onEditModeChanged: {