summaryrefslogtreecommitdiff
path: root/kodereviewer/qml/ReviewDialog.qml
blob: 7dcaf9c70d8b693e0925b08fe63880915bc8026e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
pragma ComponentBehavior: Bound
import QtQuick
import QtCore
import QtQuick.Controls as QQC2
import QtQuick.Layouts

import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.formcard as FormCard

import org.deprecated.kodereviewer 1.0


Kirigami.Dialog {
    id: root
    standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel
    title: i18nc("@title:window", "Review changes")
    padding: Kirigami.Units.largeSpacing
    preferredWidth: Kirigami.Units.gridUnit * 20
    property string event: ''
    property alias reviewBodyText: reviewBody.text
    ColumnLayout {
        MarkdownTextArea {
            id: reviewBody
            Layout.fillWidth: true
        }
        Kirigami.Separator {
            Kirigami.FormData.isSection: true
            Layout.fillWidth: true
        }
        QQC2.RadioButton {
            id: approveRadioButton
            text: "Approve"
            onCheckedChanged: if(checked) {
                root.event = 'APPROVE'
            }
        }
        QQC2.RadioButton {
            id: commentRadioButton
            text: "Comment"
            onCheckedChanged: if(checked) {
                root.event = 'COMMENT'
            }
        }
        QQC2.RadioButton {
            id: requestChangesRadioButton
            text: "Request changes"
            onCheckedChanged: if(checked) {
                root.event = 'REQUEST_CHANGES'
            }
        }
    }

    function requiredFieldsFilled() {
        return event != '' && reviewBodyText != ''
    }

    function clearForm() {
        reviewBodyText = ''
        approveRadioButton.checked = false
        commentRadioButton.checked = false
        requestChangesRadioButton = false
        event = ''
    }

    Component.onCompleted: {
        const button = standardButton(Kirigami.Dialog.Ok);
        button.enabled = Qt.binding( () => requiredFieldsFilled() );
    }
}