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