Warning, /plasma/discover/discover/qml/ReviewDialog.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick 0002 import QtQuick.Controls as QQC2 0003 import QtQuick.Layouts 0004 import org.kde.kirigami as Kirigami 0005 import org.kde.discover as Discover 0006 0007 Kirigami.PromptDialog { 0008 id: reviewDialog 0009 0010 required property Discover.AbstractResource application 0011 required property Discover.AbstractReviewsBackend backend 0012 0013 readonly property alias rating: ratingInput.value 0014 readonly property alias name: nameInput.text 0015 readonly property alias summary: titleInput.text 0016 readonly property alias review: reviewInput.text 0017 0018 preferredWidth: Kirigami.Units.gridUnit * 30 0019 0020 title: i18n("Reviewing %1", application.name) 0021 0022 standardButtons: Kirigami.Dialog.NoButton 0023 0024 customFooterActions: [ 0025 Kirigami.Action { 0026 id: submitAction 0027 text: i18n("Submit review") 0028 icon.name: "document-send" 0029 enabled: !instructionalLabel.visible 0030 onTriggered: reviewDialog.accept(); 0031 } 0032 ] 0033 0034 ColumnLayout { 0035 Kirigami.FormLayout { 0036 Layout.fillWidth: true 0037 0038 Rating { 0039 id: ratingInput 0040 Kirigami.FormData.label: i18n("Rating:") 0041 readOnly: false 0042 } 0043 QQC2.TextField { 0044 id: nameInput 0045 Kirigami.FormData.label: i18n("Name:") 0046 visible: page.reviewsBackend !== null && reviewDialog.backend.preferredUserName.length > 0 0047 Layout.fillWidth: true 0048 readOnly: !reviewDialog.backend.supportsNameChange 0049 text: visible ? reviewDialog.backend.preferredUserName : "" 0050 } 0051 QQC2.TextField { 0052 id: titleInput 0053 Kirigami.FormData.label: i18n("Title:") 0054 Layout.fillWidth: true 0055 validator: RegularExpressionValidator { regularExpression: /.{3,70}/ } 0056 } 0057 } 0058 0059 QQC2.TextArea { 0060 id: reviewInput 0061 readonly property bool acceptableInput: length > 15 && length < 3000 0062 Layout.fillWidth: true 0063 Layout.minimumHeight: Kirigami.Units.gridUnit * 8 0064 KeyNavigation.priority: KeyNavigation.BeforeItem 0065 wrapMode: TextEdit.Wrap 0066 } 0067 0068 QQC2.Label { 0069 id: instructionalLabel 0070 Layout.fillWidth: true 0071 text: { 0072 if (rating < 2) { 0073 return i18n("Enter a rating"); 0074 } 0075 if (!titleInput.acceptableInput) { 0076 return i18n("Write the title"); 0077 } 0078 if (reviewInput.length === 0) { 0079 return i18n("Write the review"); 0080 } 0081 if (reviewInput.length < 15) { 0082 return i18n("Keep writing…"); 0083 } 0084 if (reviewInput.length > 3000) { 0085 return i18n("Too long!"); 0086 } 0087 if (nameInput.visible && nameInput.length < 1) { 0088 return i18nc("@info:usagetip", "Insert a name"); 0089 } 0090 return ""; 0091 } 0092 wrapMode: Text.WordWrap 0093 opacity: 0.6 0094 visible: text.length > 0 0095 } 0096 } 0097 0098 onOpened: { 0099 ratingInput.forceActiveFocus(Qt.PopupFocusReason); 0100 } 0101 0102 Component.onCompleted: { 0103 const submitButton = customFooterButton(submitAction); 0104 if (submitButton) { 0105 reviewInput.KeyNavigation.tab = submitButton; 0106 submitButton.KeyNavigation.tab = ratingInput; 0107 } 0108 } 0109 }