Warning, /graphics/peruse/src/app/qml/BookDetails.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * Copyright (C) 2015 Dan Leinir Turthra Jensen <admin@leinir.dk> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Lesser General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2.1 of the License, or (at your option) version 3, or any 0008 * later version accepted by the membership of KDE e.V. (or its 0009 * successor approved by the membership of KDE e.V.), which shall 0010 * act as a proxy defined in Section 6 of version 3 of the license. 0011 * 0012 * This library is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 * Lesser General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU Lesser General Public 0018 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 0019 * 0020 */ 0021 0022 import QtQuick 2.12 0023 import QtQuick.Controls 2.12 as QtControls 0024 0025 import org.kde.kirigami 2.7 as Kirigami 0026 0027 import org.kde.peruse 0.1 as Peruse 0028 import "listcomponents" as ListComponents 0029 0030 Item { 0031 id: root; 0032 property string file; 0033 height: childrenRect.height; 0034 onFileChanged: { 0035 var book = contentList.get(contentList.indexOfFile(file)); 0036 filename = book.readProperty("filename"); 0037 filetitle = book.readProperty("filetitle"); 0038 title = book.readProperty("title"); 0039 series = book.readProperty("series"); 0040 author = book.readProperty("author"); 0041 publisher = book.readProperty("publisher"); 0042 created = book.readProperty("created"); 0043 lastOpenedTime = book.readProperty("lastOpenedTime"); 0044 totalPages = book.readProperty("totalPages"); 0045 currentPage = book.readProperty("currentPage"); 0046 thumbnail = book.readProperty("thumbnail"); 0047 0048 dataRepeater.model.clear(); 0049 dataRepeater.model.append({"label": i18nc("Label for the author field", "Author:"), value: root.author}); 0050 dataRepeater.model.append({"label": i18nc("Label for the publisher field", "Publisher:"), value: root.publisher}); 0051 dataRepeater.model.append({"label": i18nc("Label for the series field", "Series:"), value: root.series}); 0052 dataRepeater.model.append({"label": i18nc("Label for the filename field", "Filename:"), value: root.filename}); 0053 } 0054 property string filename; 0055 property string filetitle; 0056 // property string title; 0057 property string series; 0058 property string author; 0059 property string publisher; 0060 property date created; 0061 property date lastOpenedTime; 0062 property int totalPages; 0063 property int currentPage; 0064 property string thumbnail; 0065 0066 Column { 0067 anchors.horizontalCenter: parent.horizontalCenter; 0068 spacing: Kirigami.Units.smallSpacing; 0069 width: parent.width; 0070 height: childrenRect.height; 0071 Item { 0072 id: bookCover; 0073 anchors { 0074 horizontalCenter: parent.horizontalCenter; 0075 margins: Kirigami.Units.largeSpacing; 0076 } 0077 width: Math.min(parent.width - Kirigami.Units.largeSpacing * 2, Kirigami.Units.iconSizes.enormous + Kirigami.Units.largeSpacing * 2); 0078 height: width; 0079 Rectangle { 0080 anchors.centerIn: coverImage; 0081 width: coverImage.paintedWidth + Kirigami.Units.smallSpacing * 2; 0082 height: coverImage.paintedHeight + Kirigami.Units.smallSpacing * 2; 0083 color: Kirigami.Theme.backgroundColor; 0084 border { 0085 width: 2; 0086 color: Kirigami.Theme.textColor; 0087 } 0088 radius: 2; 0089 } 0090 Image { 0091 id: coverImage; 0092 anchors { 0093 fill: parent; 0094 margins: Kirigami.Units.largeSpacing; 0095 } 0096 source: root.thumbnail; 0097 asynchronous: true; 0098 fillMode: Image.PreserveAspectFit; 0099 } 0100 } 0101 Repeater { 0102 id: dataRepeater; 0103 model: ListModel {} 0104 delegate: Item { 0105 id: base; 0106 width: root.width; 0107 height: valueLabel.height; 0108 QtControls.Label { 0109 anchors { 0110 top: parent.top; 0111 left: parent.left; 0112 right: parent.horizontalCenter; 0113 bottom: parent.bottom; 0114 } 0115 verticalAlignment: Text.AlignTop; 0116 text: model.label; 0117 } 0118 QtControls.Label { 0119 id: valueLabel; 0120 anchors { 0121 top: parent.top; 0122 left: parent.horizontalCenter; 0123 right: parent.right; 0124 } 0125 verticalAlignment: Text.AlignTop; 0126 height: paintedHeight; 0127 wrapMode: Text.WordWrap; 0128 text: model.value; 0129 } 0130 } 0131 } 0132 Item { 0133 id: deleteBase; 0134 width: root.width; 0135 height: deleteButton.height + Kirigami.Units.largeSpacing * 2; 0136 Behavior on height { NumberAnimation { duration: applicationWindow().animationDuration; } } 0137 states: [ 0138 State { 0139 name: "confirmDelete"; 0140 PropertyChanges { target: deleteButton; opacity: 0; } 0141 PropertyChanges { target: deleteConfirmBase; opacity: 1; } 0142 PropertyChanges { target: deleteBase; height: deleteConfirmBase.height; } 0143 } 0144 ] 0145 QtControls.Button { 0146 id: deleteButton; 0147 text: i18nc("Spawn inline dialog box to confirm permanent removal of this book", "Delete from Device"); 0148 anchors { 0149 top: parent.top; 0150 topMargin: Kirigami.Units.largeSpacing; 0151 horizontalCenter: parent.horizontalCenter; 0152 } 0153 iconName: "edit-delete"; 0154 onClicked: deleteBase.state = "confirmDelete"; 0155 Behavior on opacity { NumberAnimation { duration: applicationWindow().animationDuration; } } 0156 } 0157 Item { 0158 id: deleteConfirmBase; 0159 opacity: 0; 0160 width: root.width; 0161 Behavior on opacity { NumberAnimation { duration: applicationWindow().animationDuration; } } 0162 height: yesDelete.height + confirmDeleteLabel.height + Kirigami.Units.largeSpacing * 2 + Kirigami.Units.smallSpacing; 0163 QtControls.Label { 0164 id: confirmDeleteLabel; 0165 anchors { 0166 top: parent.top; 0167 topMargin: Kirigami.Units.largeSpacing; 0168 left: parent.left; 0169 right: parent.right; 0170 } 0171 height: paintedHeight; 0172 wrapMode: Text.WordWrap; 0173 horizontalAlignment: Text.AlignHCenter; 0174 text: i18nc("Dialog text for delete book dialog", "Are you sure you want to delete this from your device?"); 0175 } 0176 QtControls.Button { 0177 id: yesDelete; 0178 anchors { 0179 top: confirmDeleteLabel.bottom; 0180 topMargin: Kirigami.Units.smallSpacing; 0181 right: parent.horizontalCenter; 0182 rightMargin: (parent.width - width) / 4; 0183 } 0184 text: i18nc("Confirmation button for book delete dialog", "Yes, Really Delete"); 0185 iconName: "dialog-ok"; 0186 onClicked: { 0187 contentList.removeBook(root.file, true); 0188 applicationWindow().pageStack.pop(); 0189 } 0190 } 0191 QtControls.Button { 0192 anchors { 0193 top: confirmDeleteLabel.bottom; 0194 topMargin: Kirigami.Units.smallSpacing; 0195 left: parent.horizontalCenter; 0196 leftMargin: (parent.width - width) / 4; 0197 } 0198 text: i18nc("Cancellation button or book delete dialog", "No, Cancel Delete"); 0199 iconName: "dialog-cancel"; 0200 onClicked: deleteBase.state = ""; 0201 } 0202 } 0203 } 0204 } 0205 }