Changeset View
Changeset View
Standalone View
Standalone View
src/creator/qml/BookMetainfoPage.qml
Context not available. | |||||
21 | 21 | | |||
---|---|---|---|---|---|
22 | import QtQuick 2.2 | 22 | import QtQuick 2.2 | ||
23 | import QtQuick.Controls 2.2 as QtControls | 23 | import QtQuick.Controls 2.2 as QtControls | ||
24 | import QtQuick.Dialogs 1.2 | ||||
24 | 25 | | |||
25 | import org.kde.kirigami 2.1 as Kirigami | 26 | import org.kde.kirigami 2.1 as Kirigami | ||
26 | 27 | | |||
Context not available. | |||||
109 | text:root.model.acbfData ? root.model.acbfData.metaData.bookInfo.keywords("").join(", ") : ""; | 110 | text:root.model.acbfData ? root.model.acbfData.metaData.bookInfo.keywords("").join(", ") : ""; | ||
110 | } | 111 | } | ||
111 | 112 | | |||
113 | Kirigami.Heading { | ||||
114 | width: parent.width; | ||||
115 | height: paintedHeight + Kirigami.Units.smallSpacing * 2; | ||||
116 | text: i18nc("label text for the edit field for the language list", "Languages"); | ||||
117 | } | ||||
118 | | ||||
119 | Repeater { | ||||
120 | model: root.model.acbfData ? root.model.acbfData.metaData.bookInfo.languageEntryList: 0; | ||||
121 | delegate: QtControls.Label { | ||||
122 | width:parent.width - showLanguageCheckbox.width - setDefaultLanguage.width -removeLanguageButton.width - (Kirigami.Units.smallSpacing*3); | ||||
123 | height: setDefaultLanguage.height; | ||||
124 | text: modelData !== ""? Qt.locale(modelData).nativeLanguageName + " (%1)".arg(modelData): i18nc("default textlayer", "Default"); | ||||
125 | QtControls.Button { | ||||
126 | id: setDefaultLanguage; | ||||
127 | anchors { | ||||
128 | left: parent.right; | ||||
129 | leftMargin: Kirigami.Units.smallSpacing; | ||||
130 | } | ||||
131 | text: i18nc("Text for copy button", "Copy to default layer"); | ||||
132 | visible: modelData !== ""; | ||||
133 | onClicked: { | ||||
134 | var text = root.model.acbfData.metaData.bookInfo.title(modelData); | ||||
135 | root.model.acbfData.metaData.bookInfo.setTitle(text, ""); | ||||
136 | defaultTitle.text = text;; | ||||
137 | text = root.model.acbfData.metaData.bookInfo.annotation(modelData); | ||||
138 | root.model.acbfData.metaData.bookInfo.setAnnotation(text, ""); | ||||
139 | defaultAnnotation.text = text.join("\n\n"); | ||||
140 | text = root.model.acbfData.metaData.bookInfo.keywords(modelData); | ||||
141 | root.model.acbfData.metaData.bookInfo.setKeywords(text, ""); | ||||
142 | defaultKeywords.text = text.join(", "); | ||||
143 | for (var i = 0; i< root.model.acbfData.body.pageCount; i++) { | ||||
144 | root.model.acbfData.body.page(i).duplicateTextLayer(modelData, ""); | ||||
145 | } | ||||
146 | root.model.setDirty(); | ||||
147 | } | ||||
148 | } | ||||
149 | QtControls.CheckBox{ | ||||
150 | id: showLanguageCheckbox; | ||||
151 | anchors { | ||||
152 | left: setDefaultLanguage.right; | ||||
153 | leftMargin: Kirigami.Units.smallSpacing; | ||||
154 | } | ||||
155 | checked: root.model.acbfData.metaData.bookInfo.language(index).show; | ||||
156 | text: i18nc("Label of checkbox for the 'show' property.", "Show"); | ||||
157 | height: parent.height; | ||||
158 | onToggled: root.model.acbfData.metaData.bookInfo.language(index).show = checked; | ||||
159 | } | ||||
160 | | ||||
161 | QtControls.Button { | ||||
162 | id: removeLanguageButton; | ||||
163 | anchors { | ||||
164 | left: showLanguageCheckbox.right; | ||||
165 | leftMargin: Kirigami.Units.smallSpacing; | ||||
166 | } | ||||
167 | contentItem: Kirigami.Icon { | ||||
168 | source: "list-remove"; | ||||
169 | } | ||||
170 | height: parent.height; | ||||
171 | width: height; | ||||
172 | onClicked: { | ||||
173 | // When removing, set the model dirty first, and then remove the entry to avoid reference errors. | ||||
174 | for (var i = 0; i< root.model.acbfData.body.pageCount; i++) { | ||||
175 | root.model.acbfData.body.page(i).removeTextLayer(modelData); | ||||
176 | } | ||||
177 | root.model.setDirty(); | ||||
178 | root.model.acbfData.metaData.bookInfo.removeLanguage(index); | ||||
179 | } | ||||
180 | } | ||||
181 | } | ||||
182 | } | ||||
183 | Item { | ||||
184 | width: parent.width; | ||||
185 | height: childrenRect.height; | ||||
186 | QtControls.Button { | ||||
187 | text: i18nc("Label for POT export button.", "Export default language POT"); | ||||
188 | width: (parent.width-Kirigami.Units.smallSpacing)/2; | ||||
189 | onClicked: exportPOT.open(); | ||||
190 | id: exportPOTButton; | ||||
191 | } | ||||
192 | QtControls.Button { | ||||
193 | anchors { | ||||
194 | left: exportPOTButton.right; | ||||
195 | leftMargin: Kirigami.Units.smallSpacing; | ||||
196 | top: exportPOTButton.top; | ||||
197 | } | ||||
198 | | ||||
199 | text: i18nc("Label for PO impot button.", "Import translation PO"); | ||||
200 | width: (parent.width-Kirigami.Units.smallSpacing)/2; | ||||
201 | onClicked: importPO.open(); | ||||
202 | } | ||||
203 | } | ||||
204 | | ||||
112 | Kirigami.Heading { | 205 | Kirigami.Heading { | ||
113 | width: parent.width; | 206 | width: parent.width; | ||
114 | height: paintedHeight + Kirigami.Units.smallSpacing * 2; | 207 | height: paintedHeight + Kirigami.Units.smallSpacing * 2; | ||
Context not available. | |||||
1051 | root.model.setDirty(); | 1144 | root.model.setDirty(); | ||
1052 | } | 1145 | } | ||
1053 | } | 1146 | } | ||
1147 | | ||||
1148 | FileDialog { | ||||
1149 | id: exportPOT; | ||||
1150 | title: i18nc("Title of the folder selection fialog for exporting pot","Please choose a location to save the POT file.") | ||||
1151 | folder: mainWindow.homeDir(); | ||||
1152 | selectFolder: true; | ||||
1153 | property int splitPos: osIsWindows ? 8 : 7; | ||||
1154 | onAccepted: { | ||||
1155 | if(folder.toString().substring(0, 7) === "file://") { | ||||
1156 | var file = model.filename.split("/").pop(); | ||||
1157 | file = file.split(".")[0]; | ||||
1158 | root.model.generatePot( folder.toString().substring(splitPos)+"/"+file+".pot", ""); | ||||
1159 | } | ||||
1160 | } | ||||
1161 | onRejected: { | ||||
1162 | // Just do nothing, we don't really care... | ||||
1163 | } | ||||
1164 | } | ||||
1165 | | ||||
1166 | FileDialog { | ||||
1167 | id: importPO; | ||||
1168 | title: i18nc("Title of the file selection fialog for importing po files","Please choose a PO file to load.") | ||||
1169 | folder: mainWindow.homeDir(); | ||||
1170 | nameFilters: ["PO translation files (*.po)"]; | ||||
1171 | property int splitPos: osIsWindows ? 8 : 7; | ||||
1172 | onAccepted: { | ||||
1173 | if(fileUrl.toString().substring(0, 7) === "file://") { | ||||
1174 | addLanguageFromPOFile.summary = root.model.readPoFileSummary(fileUrl.toString().substring(splitPos)); | ||||
1175 | addLanguageFromPOFile.url = fileUrl.toString().substring(splitPos); | ||||
1176 | addLanguageFromPOFile.open(); | ||||
1177 | } | ||||
1178 | } | ||||
1179 | onRejected: { | ||||
1180 | // Just do nothing, we don't really care... | ||||
1181 | } | ||||
1182 | } | ||||
1183 | | ||||
1184 | Dialog { | ||||
1185 | id: addLanguageFromPOFile; | ||||
1186 | property var summary: ["lang", "author"]; | ||||
1187 | property string url: ""; | ||||
1188 | signal save(); | ||||
1189 | title: i18nc("Title for adding translation from po file.", "Add translation from PO file"); | ||||
1190 | standardButtons: StandardButton.Save | StandardButton.Cancel; | ||||
1191 | width: childrenRect.width; | ||||
1192 | Column { | ||||
1193 | width: parent.width; | ||||
1194 | height: childrenRect.height; | ||||
1195 | spacing: Kirigami.Units.smallSpacing; | ||||
1196 | QtControls.Label{ | ||||
1197 | width: parent.width; | ||||
1198 | text: i18nc("Language label for import Po file", "Language: %1 (%2)", Qt.locale(addLanguageFromPOFile.summary[0]).nativeLanguageName, addLanguageFromPOFile.summary[0]); | ||||
1199 | } | ||||
1200 | Item { | ||||
1201 | width: parent.width; | ||||
1202 | height: Kirigami.Units.smallSpacing; | ||||
1203 | } | ||||
1204 | QtControls.Label{ | ||||
1205 | width: parent.width; | ||||
1206 | text: i18nc("Author label for import Po file", "Author: %1", addLanguageFromPOFile.summary[1]); | ||||
1207 | } | ||||
1208 | Item { | ||||
1209 | width: parent.width; | ||||
1210 | height: Kirigami.Units.smallSpacing; | ||||
1211 | } | ||||
1212 | QtControls.CheckBox { | ||||
1213 | id: emailCheckBox; | ||||
1214 | width: parent.width; | ||||
1215 | text: i18nc("label for include translator's email checkbox", "Include translator's email"); | ||||
1216 | checked: false; | ||||
1217 | } | ||||
1218 | } | ||||
1219 | onAccepted: { | ||||
1220 | root.model.readPoFile(url, emailCheckBox.checked); | ||||
1221 | } | ||||
1222 | } | ||||
1054 | } | 1223 | } | ||
1055 | } | 1224 | } | ||
Context not available. |