Commit 3a83cae8 authored by Nate Graham's avatar Nate Graham 🔩
Browse files

Polish review input dialog

- Use a FormLayout
- Tweak layout to be a bit prettier
- Use an explanatory label instead of changing the button text
- Make sure the review text box is tall by default
parent 8367532c
......@@ -3,7 +3,7 @@ import QtQuick.Controls 2.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import QtQuick.Window 2.0
import org.kde.kirigami 2.0 as Kirigami
import org.kde.kirigami 2.10 as Kirigami
Kirigami.OverlaySheet
{
......@@ -18,48 +18,76 @@ Kirigami.OverlaySheet
signal accepted()
ColumnLayout {
height: Kirigami.Units.gridUnit * 22
Kirigami.Heading { level: 3; text: i18n("Reviewing '%1'", application.name) }
Label { text: i18n("Rating:") }
Rating {
id: ratingInput
editable: true
}
Layout.maximumWidth: Kirigami.Units.gridUnit * 8
Label {
visible: reviewDialog.backend.userName.length > 0
Kirigami.Heading {
Layout.fillWidth: true
elide: Text.ElideRight
text: visible ? xi18nc("@info", "Submission name:<nl/>%1", reviewDialog.backend.userName) : ""
Layout.bottomMargin: Kirigami.Units.largeSpacing * 2
wrapMode: Text.WordWrap
level: 2
text: i18n("Reviewing %1", application.name)
}
Label { text: i18n("Title:") }
TextField {
id: titleInput
Layout.fillWidth: true
validator: RegExpValidator { regExp: /.{3,70}/ }
Kirigami.FormLayout {
id: contentLayout
Layout.fillHeight: true
Rating {
id: ratingInput
Kirigami.FormData.label: i18n("Rating:")
editable: true
}
Label {
Kirigami.FormData.label: i18n("Name:")
visible: reviewDialog.backend.userName.length > 0
Layout.fillWidth: true
elide: Text.ElideRight
text: visible ? reviewDialog.backend.userName : ""
}
TextField {
id: titleInput
Kirigami.FormData.label: i18n("Title:")
Layout.fillWidth: true
validator: RegExpValidator { regExp: /.{3,70}/ }
}
}
Label { text: i18n("Review:") }
TextArea {
id: reviewInput
readonly property bool acceptableInput: length > 15 && length < 3000
Layout.fillWidth: true
Layout.fillHeight: true
Layout.minimumHeight: Kirigami.Units.gridUnit * 8
}
Button {
id: acceptButton
Layout.alignment: Qt.AlignRight
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");
RowLayout {
Label {
id: instructionalLabel
Layout.fillWidth: true
text: {
if (rating < 2) return i18n("Enter a rating");
if (! titleInput.acceptableInput) return i18n("Write the title");
if (reviewInput.length === 0) return i18n("Write the review");
if (reviewInput.length < 15) return i18n("Keep writing...");
if (reviewInput.length > 3000) return i18n("Too long!");
return "";
}
wrapMode: Text.WordWrap
opacity: 0.6
visible: text.length > 0
}
Item {
Layout.fillWidth: true
visible: !instructionalLabel.visible
}
onClicked: {
reviewDialog.accepted()
reviewDialog.sheetOpen = false
Button {
id: acceptButton
enabled: !instructionalLabel.visible
text: i18n("Submit review")
onClicked: {
reviewDialog.accepted()
reviewDialog.sheetOpen = false
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment