Changeset View
Changeset View
Standalone View
Standalone View
discover/qml/ReviewDelegate.qml
Show All 25 Lines | |||||
26 | ColumnLayout | 26 | ColumnLayout | ||
27 | { | 27 | { | ||
28 | id: item | 28 | id: item | ||
29 | visible: model.shouldShow | 29 | visible: model.shouldShow | ||
30 | property bool compact: false | 30 | property bool compact: false | ||
31 | property bool separator: true | 31 | property bool separator: true | ||
32 | signal markUseful(bool useful) | 32 | signal markUseful(bool useful) | ||
33 | 33 | | |||
34 | function usefulnessToString(favorable, total) | | |||
35 | { | | |||
36 | return total===0 | | |||
37 | ? i18n("<em>Tell us about this review!</em>") | | |||
38 | : i18n("<em>%1 out of %2 people found this review useful</em>", favorable, total) | | |||
39 | } | | |||
40 | 34 | | |||
41 | RowLayout { | 35 | RowLayout { | ||
42 | Layout.fillWidth: true | 36 | Layout.fillWidth: true | ||
43 | Label { | 37 | Label { | ||
44 | id: content | 38 | id: content | ||
45 | Layout.fillWidth: true | 39 | Layout.fillWidth: true | ||
46 | elide: Text.ElideRight | 40 | elide: Text.ElideRight | ||
47 | readonly property string author: reviewer ? reviewer : i18n("unknown reviewer") | 41 | readonly property string author: reviewer ? reviewer : i18n("unknown reviewer") | ||
48 | text: summary ? i18n("<b>%1</b> by %2", summary, author) : i18n("Comment by %1", author) | 42 | text: summary ? i18n("<b>%1</b> by %2", summary, author) : i18n("Comment by %1", author) | ||
49 | } | 43 | } | ||
50 | Rating { | 44 | Rating { | ||
51 | id: rating | 45 | id: rating | ||
52 | rating: model.rating | 46 | rating: model.rating | ||
53 | starSize: content.font.pointSize | 47 | starSize: content.font.pointSize | ||
54 | } | 48 | } | ||
55 | } | 49 | } | ||
56 | Label { | 50 | Label { | ||
57 | Layout.fillWidth: true | 51 | Layout.fillWidth: true | ||
58 | text: display | 52 | text: display | ||
59 | maximumLineCount: item.compact ? 3 : undefined | 53 | maximumLineCount: item.compact ? 3 : undefined | ||
60 | wrapMode: Text.Wrap | 54 | wrapMode: Text.Wrap | ||
61 | } | 55 | } | ||
62 | Label { | 56 | | ||
57 | RowLayout { | ||||
58 | Layout.fillWidth: true | ||||
63 | visible: !item.compact | 59 | visible: !item.compact | ||
64 | text: usefulnessToString(usefulnessFavorable, usefulnessTotal) | 60 | opacity: 0.7 | ||
61 | | ||||
62 | Item { | ||||
63 | Layout.fillWidth: true | ||||
64 | } | ||||
65 | | ||||
66 | Label { | ||||
67 | visible: usefulnessTotal !== 0 | ||||
68 | text: i18n("%1 out of %2 people found this review useful", usefulnessFavorable, usefulnessTotal) | ||||
69 | font.pointSize: theme.smallestFont.pointSize | ||||
65 | } | 70 | } | ||
66 | 71 | | |||
67 | Label { | 72 | Label { | ||
68 | visible: !item.compact | | |||
69 | Layout.alignment: Qt.AlignRight | | |||
70 | text: { | 73 | text: { | ||
71 | switch(usefulChoice) { | 74 | switch(usefulChoice) { | ||
72 | case ReviewsModel.Yes: | 75 | case ReviewsModel.Yes: | ||
73 | i18n("<em>Useful? <a href='true'><b>Yes</b></a>/<a href='false'>No</a></em>") | 76 | i18n("<a href='true'><b>👍</b></a>/<a href='false'>👎</a>") | ||
74 | break; | 77 | break; | ||
75 | case ReviewsModel.No: | 78 | case ReviewsModel.No: | ||
76 | i18n("<em>Useful? <a href='true'>Yes</a>/<a href='false'><b>No</b></a></em>") | 79 | i18n("<a href='true'>👍</a>/<a href='false'><b>👎</b></a>") | ||
77 | break; | 80 | break; | ||
78 | default: | 81 | default: | ||
79 | i18n("<em>Useful? <a href='true'>Yes</a>/<a href='false'>No</a></em>") | 82 | i18n("<a href='true'>👍</a>/<a href='false'>👎</a>") | ||
80 | break; | 83 | break; | ||
81 | } | 84 | } | ||
82 | } | 85 | } | ||
86 | font.pointSize: theme.smallestFont.pointSize | ||||
83 | onLinkActivated: item.markUseful(link=='true') | 87 | onLinkActivated: item.markUseful(link=='true') | ||
84 | } | 88 | } | ||
89 | } | ||||
85 | Kirigami.Separator { | 90 | Kirigami.Separator { | ||
86 | visible: item.separator | 91 | visible: item.separator | ||
87 | Layout.fillWidth: true | 92 | Layout.fillWidth: true | ||
88 | } | 93 | } | ||
89 | } | 94 | } | ||
apol: `checked: usefulChoice === ReviewsModel.No` |
checked: usefulChoice === ReviewsModel.No