Warning, /plasma/discover/discover/qml/ReviewDialog.qml is written in an unsupported language. File is not indexed.

0001 import QtQuick 2.15
0002 import QtQuick.Controls 2.15 as QQC2
0003 import QtQuick.Layouts 1.1
0004 import org.kde.kirigami 2.20 as Kirigami
0005 
0006 Kirigami.PromptDialog
0007 {
0008     id: reviewDialog
0009     preferredWidth: Kirigami.Units.gridUnit * 30
0010 
0011     property QtObject application
0012     readonly property alias rating: ratingInput.rating
0013     readonly property alias name: nameInput.text
0014     readonly property alias summary: titleInput.text
0015     readonly property alias review: reviewInput.text
0016     property QtObject backend: null
0017 
0018     title: i18n("Reviewing %1", application.name)
0019 
0020     standardButtons: Kirigami.Dialog.NoButton
0021     
0022     customFooterActions: [
0023         Kirigami.Action {
0024             text: i18n("Submit review")
0025             icon.name: "document-send"
0026             enabled: !instructionalLabel.visible
0027             onTriggered: reviewDialog.accept();
0028         }
0029     ]
0030     
0031     ColumnLayout {
0032         Kirigami.FormLayout {
0033             Layout.fillWidth: true
0034 
0035             Rating {
0036                 id: ratingInput
0037                 Kirigami.FormData.label: i18n("Rating:")
0038                 editable: true
0039             }
0040             QQC2.TextField {
0041                 id: nameInput
0042                 Kirigami.FormData.label: i18n("Name:")
0043                 visible: page.reviewsBackend !== null && reviewDialog.backend.preferredUserName.length > 0
0044                 Layout.fillWidth: true
0045                 readOnly: !reviewDialog.backend.supportsNameChange
0046                 text: visible ? reviewDialog.backend.preferredUserName : ""
0047             }
0048             QQC2.TextField {
0049                 id: titleInput
0050                 Kirigami.FormData.label: i18n("Title:")
0051                 Layout.fillWidth: true
0052                 validator: RegularExpressionValidator { regularExpression: /.{3,70}/ }
0053             }
0054         }
0055 
0056         QQC2.TextArea {
0057             id: reviewInput
0058             readonly property bool acceptableInput: length > 15 && length < 3000
0059             Layout.fillWidth: true
0060             Layout.minimumHeight: Kirigami.Units.gridUnit * 8
0061         }
0062 
0063         QQC2.Label {
0064             id: instructionalLabel
0065             Layout.fillWidth: true
0066             text: {
0067                 if (rating < 2) return i18n("Enter a rating");
0068                 if (! titleInput.acceptableInput) return i18n("Write the title");
0069                 if (reviewInput.length === 0) return i18n("Write the review");
0070                 if (reviewInput.length < 15) return i18n("Keep writing…");
0071                 if (reviewInput.length > 3000) return i18n("Too long!");
0072                 if (nameInput.visible && nameInput.length < 1) return i18nc("@info:usagetip", "Insert a name");
0073                 return "";
0074             }
0075             wrapMode: Text.WordWrap
0076             opacity: 0.6
0077             visible: text.length > 0
0078         }
0079     }
0080 }