diff --git a/discover/qml/Rating.qml b/discover/qml/Rating.qml --- a/discover/qml/Rating.qml +++ b/discover/qml/Rating.qml @@ -27,7 +27,7 @@ id: view property bool editable: false property int max: 10 - property int rating: 2 + property int rating: 0 property real starSize: Kirigami.Units.gridUnit clip: true @@ -37,7 +37,7 @@ Repeater { id: theRepeater - model: view.rating>0 ? 5 : 0 + model: 5 delegate: Kirigami.Icon { Layout.minimumWidth: view.starSize Layout.minimumHeight: view.starSize diff --git a/discover/qml/ReviewDialog.qml b/discover/qml/ReviewDialog.qml --- a/discover/qml/ReviewDialog.qml +++ b/discover/qml/ReviewDialog.qml @@ -11,7 +11,7 @@ property QtObject application readonly property alias rating: ratingInput.rating - readonly property alias summary: summaryInput.text + readonly property alias summary: titleInput.text readonly property alias review: reviewInput.text property QtObject backend: null @@ -29,29 +29,31 @@ visible: reviewDialog.backend.userName.length > 0 text: visible ? i18n("Submission name: %1", reviewDialog.backend.userName) : "" } - Label { text: i18n("Summary:") } + Label { text: i18n("Title:") } TextField { - id: summaryInput + id: titleInput Layout.fillWidth: true - placeholderText: i18n("Short summary...") validator: RegExpValidator { regExp: /.{3,70}/ } } - + Label { text: i18n("Review:") } TextArea { id: reviewInput - readonly property bool acceptableInput: inputIssue.length === 0 - readonly property string inputIssue: length < 15 ? i18n("Comment too short") : - length > 3000 ? i18n("Comment too long") : "" + readonly property bool acceptableInput: length > 15 && length < 3000 Layout.fillWidth: true Layout.fillHeight: true } Button { id: acceptButton Layout.alignment: Qt.AlignRight - enabled: summaryInput.acceptableInput && reviewInput.acceptableInput - text: summaryInput.acceptableInput && reviewInput.acceptableInput ? i18n("Submit") - : !summaryInput.acceptableInput ? i18n("Improve summary") : reviewInput.inputIssue + enabled: rating > 2 && titleInput.acceptableInput && reviewInput.acceptableInput + text: { + if (rating < 2) return i18n("Enter a rating"); + if (! titleInput.acceptableInput) return i18n("Write a title"); + if (reviewInput.length < 15) return i18n("Keep writing..."); + if (reviewInput.length > 3000) return i18n("Too long!"); + return i18n("Submit review"); + } onClicked: { reviewDialog.accepted() reviewDialog.sheetOpen = false