Warning, /frameworks/knewstuff/src/qtquick/qml/private/EntryCommentDelegate.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2019 Dan Leinir Turthra Jensen <admin@leinir.dk> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 /** 0008 * @brief A card based delegate for showing a comment from a KNewStuffQuick::QuickCommentsModel 0009 */ 0010 0011 import QtQuick 2.11 0012 import QtQuick.Controls 2.11 as QtControls 0013 import QtQuick.Layouts 1.11 as QtLayouts 0014 0015 import org.kde.kirigami 2.7 as Kirigami 0016 0017 import org.kde.newstuff 1.62 as NewStuff 0018 0019 QtLayouts.RowLayout { 0020 id: component 0021 0022 /** 0023 * The KNSQuick Engine object which handles all our content 0024 */ 0025 property QtObject engine 0026 0027 /** 0028 * The username of the author of whatever the comment is attached to 0029 */ 0030 property string entryAuthorId 0031 /** 0032 * The provider ID as supplied by the entry the comment is attached to 0033 */ 0034 property string entryProviderId 0035 0036 /** 0037 * The username of the comment's author 0038 */ 0039 property string author 0040 /** 0041 * The OCS score, an integer from 1 to 100. It will be interpreted 0042 * as a 5 star rating, with half star support (0-10) 0043 */ 0044 property int score 0045 /** 0046 * The title or subject line for the comment 0047 */ 0048 property string title 0049 /** 0050 * The actual text of the comment 0051 */ 0052 property alias reviewText: reviewLabel.text 0053 /** 0054 * The depth of the comment (in essence, how many parents the comment has) 0055 */ 0056 property int depth 0057 0058 spacing: 0 0059 0060 property QtObject commentAuthor: NewStuff.Author { 0061 engine: component.engine 0062 providerId: component.entryProviderId 0063 username: component.author 0064 } 0065 0066 anchors { 0067 left: parent.left 0068 right: parent.right 0069 leftMargin: Kirigami.Units.largeSpacing 0070 rightMargin: Kirigami.Units.largeSpacing 0071 } 0072 0073 Repeater { 0074 model: component.depth 0075 delegate: Rectangle { 0076 QtLayouts.Layout.fillHeight: true 0077 QtLayouts.Layout.minimumWidth: Kirigami.Units.largeSpacing 0078 QtLayouts.Layout.maximumWidth: Kirigami.Units.largeSpacing 0079 color: Qt.tint(Kirigami.Theme.textColor, Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.8)) 0080 Rectangle { 0081 anchors { 0082 top: parent.top 0083 bottom: parent.bottom 0084 left: parent.left 0085 } 0086 width: 1 0087 color: Kirigami.Theme.backgroundColor 0088 } 0089 } 0090 } 0091 0092 QtLayouts.ColumnLayout { 0093 Item { 0094 visible: component.depth === 0 0095 QtLayouts.Layout.fillWidth: true 0096 QtLayouts.Layout.minimumHeight: Kirigami.Units.largeSpacing 0097 QtLayouts.Layout.maximumHeight: Kirigami.Units.largeSpacing 0098 } 0099 0100 Kirigami.Separator { 0101 QtLayouts.Layout.fillWidth: true 0102 } 0103 0104 QtLayouts.RowLayout { 0105 visible: (component.title !== "" || component.score !== 0) 0106 QtLayouts.Layout.fillWidth: true 0107 QtLayouts.Layout.leftMargin: Kirigami.Units.largeSpacing 0108 Kirigami.Heading { 0109 id: titleLabel 0110 text: ((component.title === "") ? i18ndc("knewstuff6", "Placeholder title for when a comment has no subject, but does have a rating", "<i>(no title)</i>") : component.title) 0111 level: 4 0112 QtLayouts.Layout.fillWidth: true 0113 } 0114 Rating { 0115 id: ratingStars 0116 rating: component.score 0117 reverseLayout: true 0118 } 0119 Item { 0120 QtLayouts.Layout.minimumWidth: Kirigami.Units.largeSpacing 0121 QtLayouts.Layout.maximumWidth: Kirigami.Units.largeSpacing 0122 } 0123 } 0124 0125 QtControls.Label { 0126 id: reviewLabel 0127 QtLayouts.Layout.fillWidth: true 0128 QtLayouts.Layout.leftMargin: Kirigami.Units.largeSpacing 0129 QtLayouts.Layout.rightMargin: Kirigami.Units.largeSpacing 0130 wrapMode: Text.Wrap 0131 } 0132 0133 QtLayouts.RowLayout { 0134 QtLayouts.Layout.fillWidth: true 0135 Item { 0136 QtLayouts.Layout.fillWidth: true 0137 } 0138 Kirigami.UrlButton { 0139 id: authorLabel 0140 visible: (url !== "") 0141 url: (component.commentAuthor.homepage === "") ? component.commentAuthor.profilepage : component.commentAuthor.homepage 0142 text: (component.author === component.entryAuthorId) ? i18ndc("knewstuff6", "The author label in case the comment was written by the author of the content entry the comment is attached to", "%1 <i>(author)</i>", component.commentAuthor.name) : component.commentAuthor.name 0143 } 0144 QtControls.Label { 0145 visible: !authorLabel.visible 0146 text: authorLabel.text 0147 } 0148 Image { 0149 id: authorIcon 0150 QtLayouts.Layout.maximumWidth: height 0151 QtLayouts.Layout.minimumWidth: height 0152 QtLayouts.Layout.preferredHeight: Kirigami.Units.iconSizes.medium 0153 fillMode: Image.PreserveAspectFit 0154 source: component.commentAuthor.avatarUrl 0155 Kirigami.Icon { 0156 anchors.fill: parent; 0157 source: "user" 0158 visible: opacity > 0 0159 opacity: authorIcon.status == Image.Ready ? 0 : 1 0160 Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } } 0161 } 0162 } 0163 Item { 0164 QtLayouts.Layout.minimumWidth: Kirigami.Units.largeSpacing 0165 QtLayouts.Layout.maximumWidth: Kirigami.Units.largeSpacing 0166 } 0167 } 0168 Item { 0169 QtLayouts.Layout.fillWidth: true 0170 QtLayouts.Layout.minimumHeight: Kirigami.Units.largeSpacing 0171 QtLayouts.Layout.maximumHeight: Kirigami.Units.largeSpacing 0172 } 0173 0174 } 0175 }