Warning, /graphics/arianna/src/content/ui/LibraryPage.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2022 Carl Schwan <carl@carlschwan.eu> 0002 // SPDX-License-Identifier: LGPL-2.1-only or LGPL-3.0-only or LicenseRef-KDE-Accepted-LGPL 0003 0004 import QtQuick 2.15 0005 import QtQuick.Controls 2.15 as QQC2 0006 import QtWebEngine 1.4 0007 import QtWebChannel 1.4 0008 import QtQuick.Layouts 1.15 0009 import org.kde.kirigami 2.13 as Kirigami 0010 import org.kde.quickcharts 1.0 as Charts 0011 import org.kde.arianna 1.0 0012 0013 Kirigami.ScrollablePage { 0014 id: root 0015 0016 property CategoryEntriesModel bookListModel 0017 0018 title: i18n("Library") 0019 0020 GridView { 0021 id: contentDirectoryView 0022 0023 leftMargin: Kirigami.Units.smallSpacing 0024 rightMargin: Kirigami.Units.smallSpacing 0025 topMargin: Kirigami.Units.smallSpacing 0026 bottomMargin: Kirigami.Units.smallSpacing 0027 0028 model: root.bookListModel 0029 0030 cellWidth: { 0031 const viewWidth = contentDirectoryView.width - Kirigami.Units.smallSpacing * 2; 0032 let columns = Math.max(Math.floor(viewWidth / 170), 2); 0033 return Math.floor(viewWidth / columns); 0034 } 0035 cellHeight: { 0036 if (Kirigami.Settings.isMobile) { 0037 return cellWidth + Kirigami.Units.gridUnit * 2 + Kirigami.Units.largeSpacing; 0038 } else { 0039 return 170 + Kirigami.Units.gridUnit * 2 + Kirigami.Units.largeSpacing 0040 } 0041 } 0042 currentIndex: -1 0043 reuseItems: true 0044 activeFocusOnTab: true 0045 keyNavigationEnabled: true 0046 0047 delegate: GridBrowserDelegate { 0048 id: bookDelegate 0049 0050 required property string thumbnail 0051 required property string title 0052 required property string filename 0053 required property var author 0054 required property var locations 0055 required property var currentLocation 0056 required property int categoryEntriesCount 0057 required property var categoryEntriesModel 0058 0059 width: Kirigami.Settings.isMobile ? contentDirectoryView.cellWidth : 170 0060 height: contentDirectoryView.cellHeight 0061 0062 imageUrl: categoryEntriesModel === '' ? ('file://' + thumbnail) : '' 0063 iconName: if (categoryEntriesModel !== '') { 0064 return thumbnail; 0065 } else if (thumbnail === '') { 0066 return 'application-epub+zip'; 0067 } else { 0068 return ''; 0069 } 0070 0071 mainText: bookDelegate.title 0072 secondaryText: author ? bookDelegate.author.join(', ') : '' 0073 0074 onClicked: if (categoryEntriesModel) { 0075 Navigation.openLibrary(title, categoryEntriesModel, false); 0076 } else { 0077 Navigation.openBook(filename, locations, currentLocation); 0078 } 0079 } 0080 0081 Kirigami.PlaceholderMessage { 0082 anchors.centerIn: parent 0083 width: parent.width - (Kirigami.Units.largeSpacing * 4) 0084 visible: contentDirectoryView.count === 0 0085 icon.name: "application-epub+zip" 0086 text: i18nc("@info placeholder", "Add some books") 0087 helpfulAction: root.actions[0] 0088 } 0089 } 0090 }