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.ScrollablePage { id: root property var pullRequest property NetworkManager connection Kirigami.Theme.colorSet: Kirigami.Theme.View Kirigami.Theme.inherit: false property string currentView: "info" actions: [ Kirigami.Action { id: reviewChangesAction text: "Review changes" icon.name: "preview-symbolic" enabled: !!root.pullRequest onTriggered: reviewChangesDialog.open() } ] Kirigami.Dialog { id: reviewChangesDialog standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel title: i18nc("@title:window", "Review changes") padding: Kirigami.Units.largeSpacing preferredWidth: Kirigami.Units.gridUnit * 20 ColumnLayout { MarkdownTextArea { Layout.fillWidth: true } Kirigami.Separator { Kirigami.FormData.isSection: true Layout.fillWidth: true } QQC2.RadioButton { text: "Approve" } QQC2.RadioButton { text: "Comment" } QQC2.RadioButton { text: "Request changes" } } } Loader { id: commentModelLoader active: !!root.pullRequest sourceComponent: CommentModel { id: commentModel pullRequest: root.pullRequest onPullRequestChanged: root.connection.getPullRequestComments(root.pullRequest.number) } } Loader { id: fileModelLoader active: !!root.pullRequest sourceComponent: FileModel { id: fileModel pullRequest: root.pullRequest onPullRequestChanged: root.connection.getFiles(root.pullRequest.number) } } Kirigami.PlaceholderMessage { visible: !root.pullRequest anchors.centerIn: parent icon.name: "org.deprecated.kodereviewer" text: "Select a pull request" } Kirigami.FormLayout { id: descriptionLayout visible: !!root.pullRequest && root.currentView == "info" anchors.fill: parent implicitWidth: parent.width Kirigami.Heading { Layout.fillWidth: true Layout.alignment: Qt.AlignHCenter leftPadding: Kirigami.Units.largeSpacing rightPadding: Kirigami.Units.largeSpacing level: 1 text: root.pullRequest ? root.pullRequest.title : "" wrapMode: Text.WordWrap } Kirigami.Separator { Kirigami.FormData.isSection: true } RowLayout { QQC2.Label { text: "Author" elide: Text.ElideRight } QQC2.Label { text: root.pullRequest ? root.pullRequest.username : "" elide: Text.ElideLeft } } RowLayout { QQC2.Label { text: "State: " elide: Text.ElideRight } QQC2.Label { text: root.pullRequest ? root.pullRequest.state : "" elide: Text.ElideLeft } } RowLayout { QQC2.Label { text: "Draft?: " elide: Text.ElideRight } QQC2.Label { text: root.pullRequest ? root.pullRequest.draft ? i18n("Yes") : i18n("No") : "" elide: Text.ElideLeft } } Loader { id: labelModelLoader active: !!root.pullRequest sourceComponent: LabelModel { pullRequest: root.pullRequest } } RowLayout { Repeater { model: labelModelLoader.item delegate: Rectangle { required property string name required property string labelColor required property string textColor color: labelColor width: thelabel.implicitWidth height: thelabel.implicitHeight radius: 5 QQC2.Label { id: thelabel padding: Kirigami.Units.smallSpacing text: name color: textColor } } } } Kirigami.Separator { Kirigami.FormData.isSection: true Kirigami.FormData.label: "Description" } MarkdownLabel { Layout.fillWidth: true Layout.fillHeight: false leftPadding: Kirigami.Units.largeSpacing rightPadding: Kirigami.Units.largeSpacing text: root.pullRequest ? (root.pullRequest.body != "" ? root.pullRequest.body : "*No description provided.*") : "" } } ColumnLayout { visible: !!root.pullRequest && root.currentView == "comments" Repeater { model: commentModelLoader.item delegate: CommentDelegate {} } } FilesView { visible: !!root.pullRequest && root.currentView == "files" fileModel: fileModelLoader.item } footer: Kirigami.NavigationTabBar { actions: [ Kirigami.Action { icon.name: "info" text: i18n("Info") onTriggered: root.currentView = "info" }, Kirigami.Action { icon.name: "comment-symbolic" text: i18n("Comments") onTriggered: root.currentView = "comments" }, Kirigami.Action { icon.name: "file-catalog-symbolic" text: i18n("Files") onTriggered: root.currentView = "files" } ] } }