Warning, /graphics/peruse/src/creator/qml/BookBinaries.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * Copyright (C) 2020 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.Layouts 1.4 0024 import QtQuick.Controls 2.12 as QtControls 0025 0026 import org.kde.kirigami 2.13 as Kirigami 0027 0028 import org.kde.peruse 0.1 as Peruse 0029 /** 0030 * @brief the page shows basic information about the book 0031 */ 0032 Kirigami.ScrollablePage { 0033 id: root; 0034 property string categoryName: "bookBinaries"; 0035 property QtObject model; 0036 signal requestCategoryChange(string categoryName); 0037 title: i18nc("title of the page which lets the user manage chunks of binary data embedded in the book", "Embedded Data"); 0038 actions { 0039 main: saveBookAction; 0040 right: addFileAction; 0041 } 0042 Kirigami.Action { 0043 id: saveBookAction; 0044 text: i18nc("Saves the book to a file on disk", "Save Book"); 0045 iconName: "document-save"; 0046 onTriggered: root.model.saveBook(); 0047 enabled: root.model ? root.model.hasUnsavedChanges : false; 0048 } 0049 Kirigami.Action { 0050 id: addFileAction; 0051 text: i18nc("Lets the user pick a file to append as a binary item", "Add File..."); 0052 iconName: "document-new"; 0053 onTriggered: { 0054 var newBinary = root.model.acbfData.data.addBinary(i18nc("The initial identifier used for a newly created binary data element", "Unnamed Binary")); 0055 editBinarySheet.editBinary(newBinary); 0056 } 0057 } 0058 0059 BookBinaryEditor { 0060 id: editBinarySheet; 0061 } 0062 0063 ListView { 0064 id: binariesList; 0065 Layout.fillWidth: true; 0066 model: Peruse.FilterProxy { 0067 filterRole: 259; // TypeRole 0068 filterInt: 1; // BinaryType 0069 sortRole: 258; // OriginalIndexRole 0070 sourceModel: Peruse.IdentifiedObjectModel { document: root.model.acbfData; } 0071 } 0072 header: ColumnLayout { 0073 width: binariesList.width - Kirigami.Units.largeSpacing * 4; 0074 Item { height: Kirigami.Units.largeSpacing; Layout.fillWidth: true; } 0075 RowLayout { 0076 Layout.fillWidth: true; 0077 Item { height: Kirigami.Units.gridUnit; Layout.fillWidth: true; Layout.minimumWidth: Kirigami.Units.largeSpacing * 2; } 0078 Kirigami.AbstractCard { 0079 header: Kirigami.Heading { 0080 text: binariesList.count === 0 0081 ? i18nc("title text for a card which informs the user there are no binary data entries, and what those are", "No Embedded Binary Data Entries") 0082 : i18nc("title text for a card which informs the user what binary data is", "Embedded Binary Data"); 0083 Layout.fillWidth: true; 0084 elide: Text.ElideRight; 0085 } 0086 contentItem: QtControls.Label { 0087 Layout.fillWidth: true; 0088 wrapMode: Text.Wrap; 0089 text: binariesList.count === 0 0090 ? i18nc("Help text for the binaries page, when there are no embedded binary data entries", "There is no embedded data in your book yet. You can add such data by creating a new entry, and then adding data to that entry from some existing file on your system. That data will be imported into your book, and leaves the external file otherwise untouched.") 0091 : i18nc("Help text for the binaries page, when there is already data embedded in the book", "You can add new binary data entries by creating a new entry, and then adding data to that entry from some existing file on your system. That data will be imported into your book, and leaves the external file otherwise untouched."); 0092 } 0093 } 0094 } 0095 Item { height: Kirigami.Units.largeSpacing; Layout.fillWidth: true; } 0096 } 0097 delegate: Kirigami.AbstractListItem { 0098 id: listItem; 0099 height: Kirigami.Units.iconSizes.huge + Kirigami.Units.smallSpacing * 2; 0100 supportsMouseEvents: true; 0101 onClicked: { 0102 editBinarySheet.editBinary(model.object); 0103 } 0104 RowLayout { 0105 Layout.fillWidth: true; 0106 Layout.fillHeight: true; 0107 Item { 0108 Layout.fillHeight: true; 0109 Layout.minimumWidth: height; 0110 Layout.maximumWidth: height; 0111 Image { 0112 id: thumbnail; 0113 anchors { 0114 fill: parent; 0115 margins: Kirigami.Units.smallSpacing; 0116 } 0117 asynchronous: true; 0118 fillMode: Image.PreserveAspectFit; 0119 source: model.object.size > 0 ? root.model.previewForId("#" + model.id) : ""; 0120 } 0121 Kirigami.Icon { 0122 anchors { 0123 fill: parent; 0124 margins: Kirigami.Units.smallSpacing; 0125 } 0126 source: "fileview-preview"; 0127 opacity: thumbnail.status == Image.Ready && thumbnail.source !== "" ? 0 : 1 0128 Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } } 0129 } 0130 } 0131 ColumnLayout { 0132 Layout.fillWidth: true; 0133 Layout.fillHeight: true; 0134 QtControls.Label { 0135 text: model.id === "" ? i18nc("Title used in the list of binary data when there is no id defined for that entry", "Unnamed piece of data") : model.id; 0136 Layout.fillWidth: true; 0137 Layout.fillHeight: true; 0138 } 0139 QtControls.Label { 0140 text: i18nc("Label which describes which content type this entry is supposed to be", "Content type: %1", model.object.contentType); 0141 Layout.fillWidth: true; 0142 Layout.fillHeight: true; 0143 } 0144 } 0145 } 0146 } 0147 Rectangle { 0148 id: processingBackground; 0149 anchors.fill: parent; 0150 opacity: root.model && root.model.processing ? 0.5 : 0; 0151 Behavior on opacity { NumberAnimation { duration: mainWindow.animationDuration; } } 0152 MouseArea { 0153 anchors.fill: parent; 0154 enabled: parent.opacity > 0; 0155 onClicked: { } 0156 } 0157 } 0158 QtControls.BusyIndicator { 0159 anchors { 0160 horizontalCenter: processingBackground.horizontalCenter; 0161 top: parent.top 0162 topMargin: x; 0163 } 0164 running: processingBackground.opacity > 0; 0165 visible: running; 0166 } 0167 } 0168 }