Changeset View
Changeset View
Standalone View
Standalone View
src/app/qml/listcomponents/BookTile.qml
Show All 32 Lines | |||||
33 | * It pops up after finishing a book in Book, and when pressing long | 33 | * It pops up after finishing a book in Book, and when pressing long | ||
34 | * on a BookTileTall item in BookShelf. | 34 | * on a BookTileTall item in BookShelf. | ||
35 | * | 35 | * | ||
36 | */ | 36 | */ | ||
37 | Item { | 37 | Item { | ||
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: peruseConfig.getFilesystemProperty(root.filename, "comment"); | ||||
50 | property var tags: peruseConfig.getFilesystemProperty(root.filename, "tags").split(","); | ||||
51 | property int rating: peruseConfig.getFilesystemProperty(root.filename, "rating"); | ||||
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 | contentList.setBookData(root.filename, "rating", rating); | ||||
65 | peruseConfig.setFilesystemProperty(root.filename, "rating", rating); | ||||
66 | } | ||||
67 | onTagsChanged: { | ||||
68 | contentList.setBookData(root.filename, "tags", tags.join(",")); | ||||
69 | peruseConfig.setFilesystemProperty(root.filename, "tags", tags.join(",")); | ||||
70 | } | ||||
71 | onCommentChanged: { | ||||
72 | contentList.setBookData(root.filename, "comment", comment); | ||||
73 | peruseConfig.setFilesystemProperty(root.filename, "comment", comment); | ||||
74 | } | ||||
75 | | ||||
55 | Rectangle { | 76 | Rectangle { | ||
56 | anchors.fill: parent; | 77 | anchors.fill: parent; | ||
57 | color: Kirigami.Theme.highlightColor; | 78 | color: Kirigami.Theme.highlightColor; | ||
58 | opacity: root.selected ? 1 : 0; | 79 | opacity: root.selected ? 1 : 0; | ||
59 | Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } } | 80 | Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } } | ||
60 | } | 81 | } | ||
61 | Item { | 82 | Item { | ||
62 | id: bookCover; | 83 | id: bookCover; | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
109 | QtControls.Label { | 130 | QtControls.Label { | ||
110 | id: bookAuthorLabel; | 131 | id: bookAuthorLabel; | ||
111 | anchors { | 132 | anchors { | ||
112 | top: bookTitle.bottom; | 133 | top: bookTitle.bottom; | ||
113 | left: bookCover.right; | 134 | left: bookCover.right; | ||
114 | leftMargin: Kirigami.Units.smallSpacing; | 135 | leftMargin: Kirigami.Units.smallSpacing; | ||
115 | } | 136 | } | ||
116 | width: paintedWidth; | 137 | width: paintedWidth; | ||
117 | text: "Author"; | 138 | text: i18nc("Label for authors", "Author(s)"); | ||
118 | font.bold: true; | 139 | font.weight: Font.Bold; | ||
119 | } | 140 | } | ||
120 | QtControls.Label { | 141 | QtControls.Label { | ||
121 | id: bookAuthor; | 142 | id: bookAuthor; | ||
122 | anchors { | 143 | anchors { | ||
123 | top: bookTitle.bottom; | 144 | top: bookTitle.bottom; | ||
124 | left: bookAuthorLabel.right; | 145 | left: bookAuthorLabel.right; | ||
125 | leftMargin: Kirigami.Units.smallSpacing; | 146 | leftMargin: Kirigami.Units.smallSpacing; | ||
126 | right: parent.right; | 147 | right: parent.right; | ||
127 | } | 148 | } | ||
128 | elide: Text.ElideRight; | 149 | elide: Text.ElideRight; | ||
129 | text: root.author === "" ? "(unknown)" : root.author; | 150 | text: root.author.length === 0 ? "(unknown)" : root.author.join(", "); | ||
130 | opacity: (text === "(unknown)" || text === "") ? 0.3 : 1; | 151 | opacity: (text === "(unknown)" || text === "") ? 0.3 : 1; | ||
131 | } | 152 | } | ||
132 | QtControls.Label { | 153 | QtControls.Label { | ||
133 | id: bookPublisherLabel; | 154 | id: bookPublisherLabel; | ||
134 | anchors { | 155 | anchors { | ||
135 | top: bookAuthorLabel.bottom; | 156 | top: bookAuthorLabel.bottom; | ||
136 | left: bookCover.right; | 157 | left: bookCover.right; | ||
137 | leftMargin: Kirigami.Units.smallSpacing; | 158 | leftMargin: Kirigami.Units.smallSpacing; | ||
138 | } | 159 | } | ||
139 | width: paintedWidth; | 160 | width: paintedWidth; | ||
140 | text: "Publisher"; | 161 | text: i18nc("Label for publisher", "Publisher"); | ||
141 | font.bold: true; | 162 | font.weight: Font.Bold; | ||
142 | } | 163 | } | ||
143 | QtControls.Label { | 164 | QtControls.Label { | ||
144 | id: bookPublisher; | 165 | id: bookPublisher; | ||
145 | anchors { | 166 | anchors { | ||
146 | top: bookAuthor.bottom; | 167 | top: bookAuthor.bottom; | ||
147 | left: bookPublisherLabel.right; | 168 | left: bookPublisherLabel.right; | ||
148 | leftMargin: Kirigami.Units.smallSpacing; | 169 | leftMargin: Kirigami.Units.smallSpacing; | ||
149 | right: parent.right; | 170 | right: parent.right; | ||
Show All 11 Lines | 178 | anchors { | |||
161 | right: parent.right; | 182 | right: parent.right; | ||
162 | } | 183 | } | ||
163 | elide: Text.ElideMiddle; | 184 | elide: Text.ElideMiddle; | ||
164 | opacity: 0.3; | 185 | opacity: 0.3; | ||
165 | font.pointSize: Kirigami.Theme.defaultFont.pointSize * 0.8; | 186 | font.pointSize: Kirigami.Theme.defaultFont.pointSize * 0.8; | ||
166 | maximumLineCount: 1; | 187 | maximumLineCount: 1; | ||
167 | } | 188 | } | ||
168 | Item { | 189 | Item { | ||
169 | id: descriptionContainer; | 190 | id: ratingContainer; | ||
170 | anchors { | 191 | anchors { | ||
171 | top: bookFile.bottom; | 192 | top: bookFile.bottom; | ||
172 | left: bookCover.right; | 193 | left: bookCover.right; | ||
173 | right: parent.right; | 194 | right: parent.right; | ||
195 | margins: Kirigami.Units.smallSpacing; | ||||
196 | } | ||||
197 | Row { | ||||
198 | id: ratingRow; | ||||
199 | QtControls.Label { | ||||
200 | width: paintedWidth; | ||||
201 | text: i18nc("label for rating widget","Rating"); | ||||
202 | height: Kirigami.Units.iconSizes.medium; | ||||
203 | font.weight: Font.Bold; | ||||
204 | anchors.rightMargin: Kirigami.Units.smallSpacing; | ||||
205 | } | ||||
206 | property int potentialRating: root.rating; | ||||
207 | Repeater{ | ||||
208 | model: 5; | ||||
209 | Item { | ||||
210 | | ||||
211 | height: Kirigami.Units.iconSizes.medium; | ||||
212 | width: Kirigami.Units.iconSizes.medium; | ||||
213 | | ||||
214 | Kirigami.Icon { | ||||
215 | source: "rating"; | ||||
216 | opacity: (ratingRow.potentialRating-2)/2 >= index? 1.0: 0.3; | ||||
217 | anchors.fill:parent; | ||||
218 | | ||||
219 | MouseArea { | ||||
220 | anchors.fill: parent; | ||||
221 | hoverEnabled: true; | ||||
222 | onEntered: { | ||||
223 | if (ratingRow.potentialRating === (index+1)*2) { | ||||
224 | ratingRow.potentialRating = ratingRow.potentialRating-1; | ||||
225 | } else { | ||||
226 | ratingRow.potentialRating = (index+1)*2; | ||||
227 | } | ||||
228 | } | ||||
229 | onExited: { | ||||
230 | ratingRow.potentialRating = root.rating; | ||||
231 | } | ||||
232 | onClicked: root.rating === ratingRow.potentialRating? | ||||
233 | root.rating = ratingRow.potentialRating-1 : | ||||
234 | root.rating = ratingRow.potentialRating; | ||||
235 | } | ||||
236 | | ||||
237 | } | ||||
238 | Kirigami.Icon { | ||||
239 | source: "rating"; | ||||
240 | height: parent.height/2; | ||||
241 | clip: true; | ||||
242 | anchors.centerIn: parent; | ||||
243 | width: height; | ||||
244 | visible: ratingRow.potentialRating === (index*2)+1; | ||||
245 | } | ||||
246 | } | ||||
247 | } | ||||
248 | } | ||||
249 | | ||||
250 | height: childrenRect.height; | ||||
251 | } | ||||
252 | Item { | ||||
253 | id: tagsContainer; | ||||
254 | height: root.showCommentTags? childrenRect.height: 0; | ||||
255 | visible: root.showCommentTags; | ||||
256 | anchors { | ||||
257 | top: ratingContainer.bottom; | ||||
258 | left: bookCover.right; | ||||
259 | right: parent.right; | ||||
260 | margins: Kirigami.Units.smallSpacing; | ||||
261 | } | ||||
262 | QtControls.Label { | ||||
263 | text: i18nc("label for tags field","Tags"); | ||||
264 | height: tagField.height; | ||||
265 | font.weight: Font.Bold; | ||||
266 | id: tagsLabel; | ||||
267 | } | ||||
268 | QtControls.TextField { | ||||
269 | id: tagField; | ||||
270 | anchors{ | ||||
271 | leftMargin: Kirigami.Units.smallSpacing; | ||||
272 | left: tagsLabel.right; | ||||
273 | top: parent.top; | ||||
274 | right: parent.right; | ||||
275 | } | ||||
276 | width: {parent.width - tagsLabel.width - Kirigami.Units.smallSpacing;} | ||||
277 | | ||||
278 | text: root.tags.length !== 0? root.tags.join(", "): ""; | ||||
279 | placeholderText: i18nc("Placeholder tag field", "(No tags)"); | ||||
280 | onEditingFinished: { | ||||
281 | var tags = text.split(","); | ||||
282 | for (var i in tags) { | ||||
283 | tags[i] = tags[i].trim(); | ||||
284 | } | ||||
285 | root.tags = tags; | ||||
286 | } | ||||
287 | } | ||||
288 | } | ||||
289 | Item { | ||||
290 | id: commentContainer; | ||||
291 | anchors { | ||||
292 | top: tagsContainer.bottom; | ||||
293 | left: bookCover.right; | ||||
294 | right: parent.right; | ||||
295 | margins: Kirigami.Units.smallSpacing; | ||||
296 | } | ||||
297 | QtControls.Label { | ||||
298 | text: i18nc("label for comment field","Comment"); | ||||
299 | height: tagField.height; | ||||
300 | font.weight: Font.Bold; | ||||
301 | id: commentLabel; | ||||
302 | } | ||||
303 | QtControls.TextField { | ||||
304 | id: commentField; | ||||
305 | anchors{ | ||||
306 | leftMargin: Kirigami.Units.smallSpacing; | ||||
307 | left: commentLabel.right; | ||||
308 | top: parent.top; | ||||
309 | right: parent.right; | ||||
310 | } | ||||
311 | width: parent.width - commentLabel.width - Kirigami.Units.smallSpacing; | ||||
312 | | ||||
313 | text: root.comment !== ""? root.comment: ""; | ||||
314 | placeholderText: i18nc("Placeholder comment field", "(No comment)"); | ||||
315 | onEditingFinished: { | ||||
316 | root.comment = text; | ||||
317 | } | ||||
318 | } | ||||
319 | height: root.showCommentTags? childrenRect.height: 0; | ||||
320 | visible: root.showCommentTags; | ||||
321 | } | ||||
322 | Item { | ||||
323 | id: descriptionContainer; | ||||
324 | anchors { | ||||
325 | top: commentContainer.bottom; | ||||
326 | left: bookCover.right; | ||||
327 | right: parent.right; | ||||
174 | bottom: deleteBase.top; | 328 | bottom: deleteBase.top; | ||
175 | margins: Kirigami.Units.smallSpacing; | 329 | margins: Kirigami.Units.smallSpacing; | ||
176 | } | 330 | } | ||
177 | QtControls.Label { | 331 | QtControls.Label { | ||
178 | anchors.fill: parent; | 332 | anchors.fill: parent; | ||
179 | verticalAlignment: Text.AlignTop; | 333 | verticalAlignment: Text.AlignTop; | ||
180 | text: i18nc("Placeholder text for the book description field when no description is set", "(no description available for this book)"); | 334 | text: root.description.length !== 0? | ||
181 | opacity: 0.3; | 335 | root.description.join("\n\n"): | ||
336 | i18nc("Placeholder text for the book description field when no description is set", "(no description available for this book)"); | ||||
337 | wrapMode: Text.WrapAtWordBoundaryOrAnywhere | ||||
338 | opacity: root.description.length !== 0? 1.0: 0.3; | ||||
182 | } | 339 | } | ||
183 | } | 340 | } | ||
184 | Item { | 341 | Item { | ||
185 | id: deleteBase; | 342 | id: deleteBase; | ||
186 | anchors { | 343 | anchors { | ||
187 | left: bookCover.right; | 344 | left: bookCover.right; | ||
188 | leftMargin: Kirigami.Units.smallSpacing; | 345 | leftMargin: Kirigami.Units.smallSpacing; | ||
189 | right: parent.right; | 346 | right: parent.right; | ||
▲ Show 20 Lines • Show All 69 Lines • Show Last 20 Lines |