Changeset View
Changeset View
Standalone View
Standalone View
discover/qml/ReviewDialog.qml
1 | import QtQuick 2.3 | 1 | import QtQuick 2.3 | ||
---|---|---|---|---|---|
2 | import QtQuick.Controls 1.2 | 2 | import QtQuick.Controls 1.2 | ||
3 | import QtQuick.Dialogs 1.2 | 3 | import QtQuick.Dialogs 1.2 | ||
4 | import QtQuick.Layouts 1.1 | 4 | import QtQuick.Layouts 1.1 | ||
5 | import QtQuick.Window 2.0 | 5 | import QtQuick.Window 2.0 | ||
6 | import org.kde.kirigami 2.0 as Kirigami | 6 | import org.kde.kirigami 2.0 as Kirigami | ||
7 | 7 | | |||
8 | Kirigami.OverlaySheet | 8 | Kirigami.OverlaySheet | ||
9 | { | 9 | { | ||
10 | id: reviewDialog | 10 | id: reviewDialog | ||
11 | 11 | | |||
12 | property QtObject application | 12 | property QtObject application | ||
13 | readonly property alias rating: ratingInput.rating | 13 | readonly property alias rating: ratingInput.rating | ||
14 | readonly property alias summary: summaryInput.text | 14 | readonly property alias summary: titleInput.text | ||
15 | readonly property alias review: reviewInput.text | 15 | readonly property alias review: reviewInput.text | ||
16 | property QtObject backend: null | 16 | property QtObject backend: null | ||
17 | 17 | | |||
18 | signal accepted() | 18 | signal accepted() | ||
19 | 19 | | |||
20 | ColumnLayout { | 20 | ColumnLayout { | ||
21 | Kirigami.Heading { level: 3; text: i18n("Reviewing '%1'", application.name) } | 21 | Kirigami.Heading { level: 3; text: i18n("Reviewing '%1'", application.name) } | ||
22 | Label { text: i18n("Rating:") } | 22 | Label { text: i18n("Rating:") } | ||
23 | Rating { | 23 | Rating { | ||
24 | id: ratingInput | 24 | id: ratingInput | ||
25 | editable: true | 25 | editable: true | ||
26 | } | 26 | } | ||
27 | 27 | | |||
28 | Label { | 28 | Label { | ||
29 | visible: reviewDialog.backend.userName.length > 0 | 29 | visible: reviewDialog.backend.userName.length > 0 | ||
30 | text: visible ? i18n("Submission name: %1", reviewDialog.backend.userName) : "" | 30 | text: visible ? i18n("Submission name: %1", reviewDialog.backend.userName) : "" | ||
31 | } | 31 | } | ||
32 | Label { text: i18n("Summary:") } | 32 | Label { text: i18n("Title:") } | ||
33 | TextField { | 33 | TextField { | ||
34 | id: summaryInput | 34 | id: titleInput | ||
35 | Layout.fillWidth: true | 35 | Layout.fillWidth: true | ||
36 | placeholderText: i18n("Short summary...") | | |||
37 | validator: RegExpValidator { regExp: /.{3,70}/ } | 36 | validator: RegExpValidator { regExp: /.{3,70}/ } | ||
38 | } | 37 | } | ||
39 | 38 | Label { text: i18n("Review:") } | |||
40 | TextArea { | 39 | TextArea { | ||
41 | id: reviewInput | 40 | id: reviewInput | ||
42 | readonly property bool acceptableInput: inputIssue.length === 0 | 41 | readonly property bool acceptableInput: inputIssue.length === 0 | ||
43 | readonly property string inputIssue: length < 15 ? i18n("Comment too short") : | 42 | readonly property string inputIssue: length < 15 ? i18n("Keep writing...") : | ||
44 | length > 3000 ? i18n("Comment too long") : "" | 43 | length > 3000 ? i18n("Too long!") : "" | ||
45 | Layout.fillWidth: true | 44 | Layout.fillWidth: true | ||
46 | Layout.fillHeight: true | 45 | Layout.fillHeight: true | ||
47 | } | 46 | } | ||
48 | 47 | | |||
49 | Button { | 48 | Button { | ||
50 | id: acceptButton | 49 | id: acceptButton | ||
51 | Layout.alignment: Qt.AlignRight | 50 | Layout.alignment: Qt.AlignRight | ||
52 | enabled: summaryInput.acceptableInput && reviewInput.acceptableInput | 51 | enabled: titleInput.acceptableInput && reviewInput.acceptableInput | ||
53 | text: summaryInput.acceptableInput && reviewInput.acceptableInput ? i18n("Submit") | 52 | text: titleInput.acceptableInput && reviewInput.acceptableInput ? i18n("Submit") | ||
54 | : !summaryInput.acceptableInput ? i18n("Improve summary") : reviewInput.inputIssue | 53 | : !titleInput.acceptableInput ? i18n("Add a title") : reviewInput.inputIssue | ||
55 | onClicked: { | 54 | onClicked: { | ||
56 | reviewDialog.accepted() | 55 | reviewDialog.accepted() | ||
57 | reviewDialog.sheetOpen = false | 56 | reviewDialog.sheetOpen = false | ||
58 | } | 57 | } | ||
59 | } | 58 | } | ||
60 | } | 59 | } | ||
61 | } | 60 | } |