Warning, /plasma/discover/discover/qml/ReviewDelegate.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2012 Aleix Pol Gonzalez <aleixpol@blue-systems.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 0008 import QtQuick.Controls as QQC2 0009 import QtQuick.Layouts 0010 import org.kde.discover as Discover 0011 import org.kde.kirigami as Kirigami 0012 0013 Kirigami.AbstractCard { 0014 id: root 0015 0016 // type: roles of Discover.ReviewsModel 0017 required property var model 0018 0019 property bool compact: false 0020 property bool separator: true 0021 0022 signal markUseful(bool useful) 0023 0024 // Spacers to indent nested comments/replies 0025 Layout.leftMargin: model.depth * Kirigami.Units.largeSpacing 0026 0027 contentItem: Item { 0028 implicitHeight: mainContent.childrenRect.height 0029 implicitWidth: mainContent.childrenRect.width 0030 ColumnLayout { 0031 id: mainContent 0032 anchors { 0033 left: parent.left 0034 top: parent.top 0035 right: parent.right 0036 } 0037 // Header with stars and date of review 0038 RowLayout { 0039 Layout.fillWidth: true 0040 Layout.leftMargin: Kirigami.Units.largeSpacing 0041 Layout.rightMargin: Kirigami.Units.largeSpacing 0042 Rating { 0043 id: rating 0044 Layout.fillWidth: true 0045 Layout.bottomMargin: Kirigami.Units.largeSpacing 0046 value: root.model.rating 0047 starSize: Kirigami.Units.gridUnit 0048 } 0049 QQC2.Label { 0050 Layout.fillWidth: true 0051 horizontalAlignment: Text.AlignRight 0052 text: root.model.date.toLocaleDateString(Qt.locale(), "MMMM yyyy") 0053 opacity: 0.6 0054 } 0055 } 0056 0057 // Review title and author 0058 QQC2.Label { 0059 id: content 0060 Layout.fillWidth: true 0061 Layout.leftMargin: Kirigami.Units.largeSpacing 0062 Layout.rightMargin: Kirigami.Units.largeSpacing 0063 0064 elide: Text.ElideRight 0065 readonly property string author: root.model.reviewer || i18n("unknown reviewer") 0066 text: root.model.summary ? i18n("<b>%1</b> by %2", root.model.summary, author) : i18n("Comment by %1", author) 0067 } 0068 0069 // Review text 0070 QQC2.Label { 0071 Layout.fillWidth: true 0072 Layout.leftMargin: Kirigami.Units.largeSpacing 0073 Layout.rightMargin: Kirigami.Units.largeSpacing 0074 Layout.bottomMargin: Kirigami.Units.smallSpacing 0075 0076 text: root.model.display 0077 wrapMode: Text.Wrap 0078 } 0079 0080 QQC2.Label { 0081 Layout.fillWidth: true 0082 Layout.leftMargin: Kirigami.Units.largeSpacing 0083 Layout.rightMargin: Kirigami.Units.largeSpacing 0084 text: root.model.packageVersion ? i18n("Version: %1", root.model.packageVersion) : i18n("Version: unknown") 0085 elide: Text.ElideRight 0086 opacity: 0.6 0087 } 0088 } 0089 } 0090 0091 footer: Loader { 0092 active: !root.compact 0093 sourceComponent: RowLayout { 0094 spacing: Kirigami.Units.smallSpacing 0095 visible: !root.compact 0096 0097 QQC2.Label { 0098 Layout.leftMargin: Kirigami.Units.largeSpacing 0099 visible: root.model.usefulnessTotal !== 0 0100 text: i18n("Votes: %1 out of %2", root.model.usefulnessFavorable, root.model.usefulnessTotal) 0101 } 0102 0103 QQC2.Label { 0104 Layout.fillWidth: true 0105 Layout.leftMargin: root.model.usefulnessTotal === 0 ? Kirigami.Units.largeSpacing : 0 0106 horizontalAlignment: Text.AlignRight 0107 text: i18n("Was this review useful?") 0108 elide: Text.ElideLeft 0109 } 0110 0111 // Useful/Not Useful buttons 0112 QQC2.Button { 0113 id: yesButton 0114 Layout.maximumWidth: Kirigami.Units.gridUnit * 3 0115 Layout.topMargin: Kirigami.Units.smallSpacing 0116 Layout.bottomMargin: Kirigami.Units.smallSpacing 0117 Layout.alignment: Qt.AlignVCenter 0118 0119 text: i18nc("Keep this string as short as humanly possible", "Yes") 0120 0121 checkable: true 0122 checked: root.model.usefulChoice === Discover.ReviewsModel.Yes 0123 onClicked: { 0124 noButton.checked = false 0125 root.markUseful(true) 0126 } 0127 } 0128 QQC2.Button { 0129 id: noButton 0130 Layout.maximumWidth: Kirigami.Units.gridUnit * 3 0131 Layout.topMargin: Kirigami.Units.smallSpacing 0132 Layout.bottomMargin: Kirigami.Units.smallSpacing 0133 Layout.rightMargin: Kirigami.Units.largeSpacing 0134 Layout.alignment: Qt.AlignVCenter 0135 0136 text: i18nc("Keep this string as short as humanly possible", "No") 0137 0138 checkable: true 0139 checked: root.model.usefulChoice === Discover.ReviewsModel.No 0140 onClicked: { 0141 yesButton.checked = false 0142 root.markUseful(false) 0143 } 0144 } 0145 } 0146 } 0147 }