Warning, /graphics/peruse/src/creator/qml/BookStylesheet.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: "bookStylesheet"; 0035 property QtObject model; 0036 signal requestCategoryChange(string categoryName); 0037 title: i18nc("title of the page which lets the user manage the book's stylesheet", "Stylesheet"); 0038 actions { 0039 main: saveBookAction; 0040 right: addStyleAction; 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: addStyleAction; 0051 text: i18nc("Creates a new, empty stylesheet entry and lets the user edit it", "Add Style..."); 0052 iconName: "list-add-font"; 0053 onTriggered: { 0054 var newStyle = root.model.acbfData.styleSheet.addStyle(); 0055 editStyleSheet.editStyle(newStyle); 0056 } 0057 } 0058 0059 Kirigami.OverlaySheet { 0060 id: editStyleSheet; 0061 property QtObject styleObject: null; 0062 function editStyle(styleObject) { 0063 editStyleSheet.styleObject = styleObject; 0064 styleElement.text = styleObject.element; 0065 open(); 0066 } 0067 showCloseButton: true 0068 header: RowLayout { 0069 Kirigami.Heading { 0070 text: i18nc("title text for a sheet which lets the user edit a binary entry", "Edit Style"); 0071 Layout.fillWidth: true; 0072 elide: Text.ElideRight; 0073 } 0074 QtControls.ToolButton { 0075 icon.name: "document-save"; 0076 text: i18nc("label for a button which updates the style entry with the new details", "OK"); 0077 onClicked: { 0078 editStyleSheet.styleObject.element = styleElement.text; 0079 editStyleSheet.close(); 0080 } 0081 } 0082 } 0083 Kirigami.FormLayout { 0084 QtControls.TextField { 0085 id: styleElement; 0086 Layout.fillWidth: true; 0087 Kirigami.FormData.label: i18nc("Label for the style element input field", "Element"); 0088 placeholderText: i18nc("Placeholder text for the style element input field", "Enter the name of the element you want to style"); 0089 } 0090 } 0091 } 0092 0093 ListView { 0094 id: stylesList; 0095 Layout.fillWidth: true; 0096 model: root.model.acbfData.styleSheet.styles; 0097 header: ColumnLayout { 0098 width: stylesList.width - Kirigami.Units.largeSpacing * 4; 0099 Item { height: Kirigami.Units.largeSpacing; Layout.fillWidth: true; } 0100 RowLayout { 0101 Layout.fillWidth: true; 0102 Item { height: Kirigami.Units.gridUnit; Layout.fillWidth: true; Layout.minimumWidth: Kirigami.Units.largeSpacing * 2; } 0103 Kirigami.AbstractCard { 0104 header: Kirigami.Heading { 0105 text: stylesList.count === 0 0106 ? i18nc("title text for a card which informs the user there are no styles defined, and what those are", "No Styling Information") 0107 : i18nc("title text for a card which informs the user what styles are", "Styling Information"); 0108 Layout.fillWidth: true; 0109 elide: Text.ElideRight; 0110 } 0111 contentItem: QtControls.Label { 0112 Layout.fillWidth: true; 0113 wrapMode: Text.Wrap; 0114 text: stylesList.count === 0 0115 ? i18nc("Help text for the stylesheet page, when there are no styles defined", "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.") 0116 : i18nc("Help text for the stylesheet page, when there is already styles defined in the book", "You can add such 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."); 0117 } 0118 } 0119 } 0120 Item { height: Kirigami.Units.largeSpacing; Layout.fillWidth: true; } 0121 } 0122 delegate: Kirigami.BasicListItem { 0123 id: listItem; 0124 height: Kirigami.Units.iconSizes.huge + Kirigami.Units.smallSpacing * 2; 0125 supportsMouseEvents: true; 0126 onClicked: { 0127 editStyleSheet.editStyle(modelData); 0128 } 0129 icon: "font-select-symbolic"; 0130 label: { 0131 if (modelData.inverted === true) { 0132 if (modelData.type === "") { 0133 return i18nc("The title of a style entry which has a type, and which represents the inverted version of that style", "%1 (inverted)", modelData.element); 0134 } else { 0135 return i18nc("The title of a style entry which does not have type, and which represents the inverted version of that style", "%1 (sub type: %2, inverted)", modelData.element, modelData.type); 0136 } 0137 } else { 0138 if (modelData.type === "") { 0139 return i18nc("The title of a style entry which has a type", "%1", modelData.element); 0140 } else { 0141 return i18nc("The title of a style entry which does not have type", "%1 (sub type: %2)", modelData.element, modelData.type); 0142 } 0143 } 0144 } 0145 subtitle: modelData.string; 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 }