Changeset View
Changeset View
Standalone View
Standalone View
discover/qml/ReviewDelegate.qml
Show All 24 Lines | |||||
25 | 25 | | |||
26 | RowLayout { | 26 | RowLayout { | ||
27 | id: item | 27 | id: item | ||
28 | visible: model.shouldShow | 28 | visible: model.shouldShow | ||
29 | property bool compact: false | 29 | property bool compact: false | ||
30 | property bool separator: true | 30 | property bool separator: true | ||
31 | signal markUseful(bool useful) | 31 | signal markUseful(bool useful) | ||
32 | 32 | | |||
33 | function usefulnessToString(favorable, total) | | |||
34 | { | | |||
35 | return total===0 | | |||
36 | ? i18n("<em>Tell us about this review!</em>") | | |||
37 | : i18n("<em>%1 out of %2 people found this review useful</em>", favorable, total) | | |||
38 | } | | |||
39 | 33 | | |||
40 | Repeater { | 34 | Repeater { | ||
41 | model: depth | 35 | model: depth | ||
42 | delegate: Rectangle { | 36 | delegate: Rectangle { | ||
43 | Layout.fillHeight: true | 37 | Layout.fillHeight: true | ||
44 | Layout.minimumWidth: Kirigami.Units.largeSpacing | 38 | Layout.minimumWidth: Kirigami.Units.largeSpacing | ||
45 | Layout.maximumWidth: Kirigami.Units.largeSpacing | 39 | Layout.maximumWidth: Kirigami.Units.largeSpacing | ||
46 | color: Qt.tint(Kirigami.Theme.textColor, Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.8)) | 40 | color: Qt.tint(Kirigami.Theme.textColor, Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.8)) | ||
Show All 30 Lines | 69 | Label { | |||
77 | text: display | 71 | text: display | ||
78 | maximumLineCount: item.compact ? 3 : undefined | 72 | maximumLineCount: item.compact ? 3 : undefined | ||
79 | wrapMode: Text.Wrap | 73 | wrapMode: Text.Wrap | ||
80 | } | 74 | } | ||
81 | Label { | 75 | Label { | ||
82 | visible: !item.compact | 76 | visible: !item.compact | ||
83 | text: item.usefulnessToString(usefulnessFavorable, usefulnessTotal) | 77 | text: item.usefulnessToString(usefulnessFavorable, usefulnessTotal) | ||
84 | } | 78 | } | ||
85 | 79 | } | |||
86 | Label { | 80 | Label { | ||
81 | Layout.fillWidth: true | ||||
82 | text: display | ||||
83 | maximumLineCount: item.compact ? 3 : undefined | ||||
84 | wrapMode: Text.Wrap | ||||
85 | } | ||||
86 | | ||||
87 | RowLayout { | ||||
88 | Layout.fillWidth: true | ||||
87 | visible: !item.compact | 89 | visible: !item.compact | ||
88 | Layout.alignment: Qt.AlignRight | 90 | opacity: 0.7 | ||
91 | | ||||
92 | Item { | ||||
93 | Layout.fillWidth: true | ||||
94 | } | ||||
95 | | ||||
96 | Label { | ||||
97 | visible: usefulnessTotal !== 0 | ||||
98 | text: i18n("%1 out of %2 people found this review useful", usefulnessFavorable, usefulnessTotal) | ||||
99 | font.pointSize: theme.smallestFont.pointSize | ||||
100 | } | ||||
101 | | ||||
102 | Label { | ||||
89 | text: { | 103 | text: { | ||
90 | switch(usefulChoice) { | 104 | switch(usefulChoice) { | ||
91 | case ReviewsModel.Yes: | 105 | case ReviewsModel.Yes: | ||
92 | i18n("<em>Useful? <a href='true'><b>Yes</b></a>/<a href='false'>No</a></em>") | 106 | i18n("<a href='true'><b>👍</b></a>/<a href='false'>👎</a>") | ||
93 | break; | 107 | break; | ||
94 | case ReviewsModel.No: | 108 | case ReviewsModel.No: | ||
95 | i18n("<em>Useful? <a href='true'>Yes</a>/<a href='false'><b>No</b></a></em>") | 109 | i18n("<a href='true'>👍</a>/<a href='false'><b>👎</b></a>") | ||
96 | break; | 110 | break; | ||
97 | default: | 111 | default: | ||
98 | i18n("<em>Useful? <a href='true'>Yes</a>/<a href='false'>No</a></em>") | 112 | i18n("<a href='true'>👍</a>/<a href='false'>👎</a>") | ||
99 | break; | 113 | break; | ||
100 | } | 114 | } | ||
101 | } | 115 | } | ||
116 | font.pointSize: theme.smallestFont.pointSize | ||||
102 | onLinkActivated: item.markUseful(link=='true') | 117 | onLinkActivated: item.markUseful(link=='true') | ||
103 | } | 118 | } | ||
119 | } | ||||
104 | Kirigami.Separator { | 120 | Kirigami.Separator { | ||
105 | visible: item.separator | 121 | visible: item.separator | ||
106 | Layout.fillWidth: true | 122 | Layout.fillWidth: true | ||
107 | } | 123 | } | ||
108 | } | 124 | } | ||
apol: `checked: usefulChoice === ReviewsModel.No` | |||||
109 | } | |
checked: usefulChoice === ReviewsModel.No