diff options
Diffstat (limited to 'kodereviewer/qml')
-rw-r--r-- | kodereviewer/qml/CommentDelegate.qml | 4 | ||||
-rw-r--r-- | kodereviewer/qml/MarkdownLabel.qml | 17 | ||||
-rw-r--r-- | kodereviewer/qml/PullRequestPage.qml | 106 |
3 files changed, 77 insertions, 50 deletions
diff --git a/kodereviewer/qml/CommentDelegate.qml b/kodereviewer/qml/CommentDelegate.qml index bac75d0..3b2681b 100644 --- a/kodereviewer/qml/CommentDelegate.qml +++ b/kodereviewer/qml/CommentDelegate.qml @@ -66,11 +66,9 @@ Kirigami.AbstractCard { Kirigami.Separator { Layout.fillWidth: true } - QQC2.Label { + MarkdownLabel { Layout.fillWidth: true text: root.body - textFormat: Text.MarkdownText - wrapMode: Text.WordWrap } } } diff --git a/kodereviewer/qml/MarkdownLabel.qml b/kodereviewer/qml/MarkdownLabel.qml new file mode 100644 index 0000000..1bf6b20 --- /dev/null +++ b/kodereviewer/qml/MarkdownLabel.qml @@ -0,0 +1,17 @@ +/* A for markdown rendering + * This Control accepts clicks for urls! + */ +import QtQml +import QtQuick 6.7 +import QtQuick.Controls 6.7 as QQC2 + +QQC2.Label { + textFormat: Text.MarkdownText + wrapMode: Text.WordWrap + onLinkActivated: link => Qt.openUrlExternally(link) + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.NoButton // we don't want to eat clicks on the Text + cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor + } +} diff --git a/kodereviewer/qml/PullRequestPage.qml b/kodereviewer/qml/PullRequestPage.qml index 19defdc..5a687e9 100644 --- a/kodereviewer/qml/PullRequestPage.qml +++ b/kodereviewer/qml/PullRequestPage.qml @@ -18,67 +18,79 @@ Kirigami.ScrollablePage { Kirigami.Theme.colorSet: Kirigami.Theme.View Kirigami.Theme.inherit: false + property string currentView: "info" + CommentModel { id: commentModel pullRequest: root.pullRequest - onPullRequestChanged: root.connection.getPullRequestComments(pullRequest.number) + onPullRequestChanged: root.connection.getPullRequestComments(root.pullRequest.number) } - ListView { - id: listView - model: commentModel - spacing: Kirigami.Units.largeSpacing * 2 - topMargin: Kirigami.Units.largeSpacing * 2 - rightMargin: Kirigami.Units.largeSpacing * 2 - leftMargin: Kirigami.Units.largeSpacing * 2 - bottomMargin: Kirigami.Units.largeSpacing * 2 // + commentToolbar.heigh - - header: ColumnLayout { - id: headerLayout - visible: !!root.pullRequest - width: ListView.view ? ListView.view.width - ListView.view.leftMargin - ListView.view.rightMargin : 0 - - 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.PlaceholderMessage { + visible: !root.pullRequest + anchors.centerIn: parent + icon.name: "org.deprecated.kodereviewer" + text: "Select a pull request" + } - Kirigami.ListSectionHeader { - Layout.fillWidth: true - text: "description" - } + ColumnLayout { + id: mainLayout + visible: !!root.pullRequest && root.currentView == "info" - QQC2.Label { - Layout.fillWidth: true - Layout.fillHeight: false - leftPadding: Kirigami.Units.largeSpacing - rightPadding: Kirigami.Units.largeSpacing - text: root.pullRequest ? root.pullRequest.body : "" - textFormat: Text.MarkdownText - wrapMode: Text.WordWrap - } + spacing: Kirigami.Units.largeSpacing * 2 - Kirigami.ListSectionHeader { - Layout.fillWidth: true - text: "Comments" - } + 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 } - delegate: CommentDelegate {} + Kirigami.ListSectionHeader { + Layout.fillWidth: true + text: "description" + } - Kirigami.PlaceholderMessage { - visible: !root.pullRequest - anchors.centerIn: parent - icon.name: "org.deprecated.kodereviewer" - text: "Select a pull request" + MarkdownLabel { + Layout.fillWidth: true + Layout.fillHeight: false + leftPadding: Kirigami.Units.largeSpacing + rightPadding: Kirigami.Units.largeSpacing + text: root.pullRequest ? root.pullRequest.body : "" + } + } + ColumnLayout { + visible: !!root.pullRequest && root.currentView == "comments" + Repeater { + model: commentModel + delegate: CommentDelegate {} } } + + 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" + } + ] + } } |