Changeset View
Changeset View
Standalone View
Standalone View
src/app/qml/listcomponents/BookTile.qml
Context not available. | |||||
38 | id: root; | 38 | id: root; | ||
---|---|---|---|---|---|
39 | property bool selected: false; | 39 | property bool selected: false; | ||
40 | property alias title: bookTitle.text; | 40 | property alias title: bookTitle.text; | ||
41 | property string author; | 41 | property var author: []; | ||
42 | property string publisher; | 42 | property string publisher; | ||
43 | property alias filename: bookFile.text; | 43 | property alias filename: bookFile.text; | ||
44 | property alias thumbnail: coverImage.source; | 44 | property alias thumbnail: coverImage.source; | ||
45 | property int categoryEntriesCount; | 45 | property int categoryEntriesCount; | ||
46 | property string currentPage; | 46 | property string currentPage; | ||
47 | property string totalPages; | 47 | property string totalPages; | ||
48 | property var description: []; | ||||
49 | property string comment; | ||||
50 | property var tags: []; | ||||
51 | property int rating: 0; | ||||
48 | signal bookSelected(string filename, int currentPage); | 52 | signal bookSelected(string filename, int currentPage); | ||
49 | signal bookDeleteRequested(); | 53 | signal bookDeleteRequested(); | ||
50 | 54 | | |||
51 | property int neededHeight: bookCover.height;// + bookAuthorLabel.height + bookFile.height + Kirigami.Units.smallSpacing * 4; | 55 | property int neededHeight: bookCover.height;// + bookAuthorLabel.height + bookFile.height + Kirigami.Units.smallSpacing * 4; | ||
56 | property bool showCommentTags: neededHeight > bookTitle.height + bookAuthorLabel.height | ||||
57 | + bookPublisherLabel.height + ratingContainer.height | ||||
58 | + tagsContainer.height + commentContainer.height + deleteButton.height + Kirigami.Units.smallSpacing * 7; | ||||
52 | visible: height > 1; | 59 | visible: height > 1; | ||
53 | enabled: visible; | 60 | enabled: visible; | ||
54 | clip: true; | 61 | clip: true; | ||
62 | | ||||
63 | onRatingChanged: { | ||||
64 | peruseConfig.setFilesystemProperty(root.filename, "rating", rating); | ||||
65 | } | ||||
66 | | ||||
67 | onTagsChanged: { | ||||
68 | peruseConfig.setFilesystemProperty(root.filename, "tags", tags.join(",")); | ||||
69 | } | ||||
70 | onCommentChanged: { | ||||
71 | peruseConfig.setFilesystemProperty(root.filename, "comment", comment); | ||||
72 | } | ||||
73 | | ||||
55 | Rectangle { | 74 | Rectangle { | ||
56 | anchors.fill: parent; | 75 | anchors.fill: parent; | ||
57 | color: Kirigami.Theme.highlightColor; | 76 | color: Kirigami.Theme.highlightColor; | ||
Context not available. | |||||
114 | leftMargin: Kirigami.Units.smallSpacing; | 133 | leftMargin: Kirigami.Units.smallSpacing; | ||
115 | } | 134 | } | ||
116 | width: paintedWidth; | 135 | width: paintedWidth; | ||
117 | text: "Author"; | 136 | text: i18nc("Label for authors", "Author(s)"); | ||
118 | font.bold: true; | 137 | font.weight: Font.Bold; | ||
119 | } | 138 | } | ||
120 | QtControls.Label { | 139 | QtControls.Label { | ||
121 | id: bookAuthor; | 140 | id: bookAuthor; | ||
Context not available. | |||||
126 | right: parent.right; | 145 | right: parent.right; | ||
127 | } | 146 | } | ||
128 | elide: Text.ElideRight; | 147 | elide: Text.ElideRight; | ||
129 | text: root.author === "" ? "(unknown)" : root.author; | 148 | text: root.author.length === 0 ? "(unknown)" : root.author.join(", "); | ||
130 | opacity: (text === "(unknown)" || text === "") ? 0.3 : 1; | 149 | opacity: (text === "(unknown)" || text === "") ? 0.3 : 1; | ||
131 | } | 150 | } | ||
132 | QtControls.Label { | 151 | QtControls.Label { | ||
Context not available. | |||||
137 | leftMargin: Kirigami.Units.smallSpacing; | 156 | leftMargin: Kirigami.Units.smallSpacing; | ||
138 | } | 157 | } | ||
139 | width: paintedWidth; | 158 | width: paintedWidth; | ||
140 | text: "Publisher"; | 159 | text: i18nc("Label for publisher", "Publisher"); | ||
141 | font.bold: true; | 160 | font.weight: Font.Bold; | ||
142 | } | 161 | } | ||
143 | QtControls.Label { | 162 | QtControls.Label { | ||
144 | id: bookPublisher; | 163 | id: bookPublisher; | ||
Context not available. | |||||
166 | maximumLineCount: 1; | 185 | maximumLineCount: 1; | ||
167 | } | 186 | } | ||
168 | Item { | 187 | Item { | ||
169 | id: descriptionContainer; | 188 | id: ratingContainer; | ||
170 | anchors { | 189 | anchors { | ||
171 | top: bookFile.bottom; | 190 | top: bookFile.bottom; | ||
172 | left: bookCover.right; | 191 | left: bookCover.right; | ||
173 | right: parent.right; | 192 | right: parent.right; | ||
193 | margins: Kirigami.Units.smallSpacing; | ||||
194 | } | ||||
195 | Row { | ||||
196 | id: ratingRow; | ||||
197 | QtControls.Label { | ||||
198 | width: paintedWidth; | ||||
199 | text: i18nc("label for rating widget","Rating"); | ||||
200 | height: Kirigami.Units.iconSizes.medium; | ||||
201 | font.weight: Font.Bold; | ||||
202 | anchors.rightMargin: Kirigami.Units.smallSpacing; | ||||
203 | } | ||||
204 | property int potentialRating: root.rating; | ||||
205 | Repeater{ | ||||
206 | model: 5; | ||||
207 | Item { | ||||
208 | | ||||
209 | height: Kirigami.Units.iconSizes.medium; | ||||
210 | width: Kirigami.Units.iconSizes.medium; | ||||
211 | | ||||
212 | Kirigami.Icon { | ||||
213 | source: "rating"; | ||||
214 | opacity: (ratingRow.potentialRating-2)/2 >= index? 1.0: 0.3; | ||||
215 | anchors.fill:parent; | ||||
216 | | ||||
217 | MouseArea { | ||||
218 | anchors.fill: parent; | ||||
219 | hoverEnabled: true; | ||||
220 | onEntered: { | ||||
221 | if (ratingRow.potentialRating === (index+1)*2) { | ||||
222 | ratingRow.potentialRating = ratingRow.potentialRating-1; | ||||
223 | } else { | ||||
224 | ratingRow.potentialRating = (index+1)*2; | ||||
225 | } | ||||
226 | } | ||||
227 | onExited: { | ||||
228 | ratingRow.potentialRating = root.rating; | ||||
229 | } | ||||
230 | onClicked: root.rating === ratingRow.potentialRating? | ||||
231 | root.rating = ratingRow.potentialRating-1 : | ||||
232 | root.rating = ratingRow.potentialRating; | ||||
233 | } | ||||
234 | | ||||
235 | } | ||||
236 | Kirigami.Icon { | ||||
237 | source: "rating"; | ||||
238 | height: parent.height/2; | ||||
239 | clip: true; | ||||
240 | anchors.centerIn: parent; | ||||
241 | width: height; | ||||
242 | visible: ratingRow.potentialRating === (index*2)+1; | ||||
243 | } | ||||
244 | } | ||||
245 | } | ||||
246 | } | ||||
247 | | ||||
248 | height: childrenRect.height; | ||||
249 | } | ||||
250 | Item { | ||||
251 | id: tagsContainer; | ||||
252 | height: root.showCommentTags? childrenRect.height: 0; | ||||
253 | visible: root.showCommentTags; | ||||
254 | anchors { | ||||
255 | top: ratingContainer.bottom; | ||||
256 | left: bookCover.right; | ||||
257 | right: parent.right; | ||||
258 | margins: Kirigami.Units.smallSpacing; | ||||
259 | } | ||||
260 | QtControls.Label { | ||||
261 | text: i18nc("label for tags field","Tags"); | ||||
262 | height: tagField.height; | ||||
263 | font.weight: Font.Bold; | ||||
264 | id: tagsLabel; | ||||
265 | } | ||||
266 | QtControls.TextField { | ||||
267 | id: tagField; | ||||
268 | anchors{ | ||||
269 | leftMargin: Kirigami.Units.smallSpacing; | ||||
270 | left: tagsLabel.right; | ||||
271 | top: parent.top; | ||||
272 | right: parent.right; | ||||
273 | } | ||||
274 | width: {parent.width - tagsLabel.width - Kirigami.Units.smallSpacing;} | ||||
275 | | ||||
276 | text: root.tags.length !== 0? root.tags.join(", "): ""; | ||||
277 | placeholderText: i18nc("Placeholder tag field", "(No tags)"); | ||||
278 | onEditingFinished: { | ||||
279 | var tags = text.split(","); | ||||
280 | for (var i in tags) { | ||||
281 | tags[i] = tags[i].trim(); | ||||
282 | } | ||||
283 | root.tags = tags; | ||||
284 | } | ||||
285 | } | ||||
286 | } | ||||
287 | Item { | ||||
288 | id: commentContainer; | ||||
289 | anchors { | ||||
290 | top: tagsContainer.bottom; | ||||
291 | left: bookCover.right; | ||||
292 | right: parent.right; | ||||
293 | margins: Kirigami.Units.smallSpacing; | ||||
294 | } | ||||
295 | QtControls.Label { | ||||
296 | text: i18nc("label for comment field","Comment"); | ||||
297 | height: tagField.height; | ||||
298 | font.weight: Font.Bold; | ||||
299 | id: commentLabel; | ||||
300 | } | ||||
301 | QtControls.TextField { | ||||
302 | id: commentField; | ||||
303 | anchors{ | ||||
304 | leftMargin: Kirigami.Units.smallSpacing; | ||||
305 | left: commentLabel.right; | ||||
306 | top: parent.top; | ||||
307 | right: parent.right; | ||||
308 | } | ||||
309 | width: parent.width - commentLabel.width - Kirigami.Units.smallSpacing; | ||||
310 | | ||||
311 | text: root.comment !== ""? root.comment: ""; | ||||
312 | placeholderText: i18nc("Placeholder comment field", "(No comment)"); | ||||
313 | onEditingFinished: { | ||||
314 | root.comment = text; | ||||
315 | } | ||||
316 | } | ||||
317 | height: root.showCommentTags? childrenRect.height: 0; | ||||
318 | visible: root.showCommentTags; | ||||
319 | } | ||||
320 | Item { | ||||
321 | id: descriptionContainer; | ||||
322 | anchors { | ||||
323 | top: commentContainer.bottom; | ||||
324 | left: bookCover.right; | ||||
325 | right: parent.right; | ||||
174 | bottom: deleteBase.top; | 326 | bottom: deleteBase.top; | ||
175 | margins: Kirigami.Units.smallSpacing; | 327 | margins: Kirigami.Units.smallSpacing; | ||
176 | } | 328 | } | ||
177 | QtControls.Label { | 329 | QtControls.Label { | ||
178 | anchors.fill: parent; | 330 | anchors.fill: parent; | ||
179 | verticalAlignment: Text.AlignTop; | 331 | verticalAlignment: Text.AlignTop; | ||
180 | text: i18nc("Placeholder text for the book description field when no description is set", "(no description available for this book)"); | 332 | text: root.description.length !== 0? | ||
181 | opacity: 0.3; | 333 | root.description.join("\n\n"): | ||
334 | i18nc("Placeholder text for the book description field when no description is set", "(no description available for this book)"); | ||||
335 | wrapMode: Text.WrapAtWordBoundaryOrAnywhere | ||||
336 | opacity: root.description.length !== 0? 1.0: 0.3; | ||||
182 | } | 337 | } | ||
183 | } | 338 | } | ||
184 | Item { | 339 | Item { | ||
Context not available. |