diff options
author | Matias Linares <matias.linares@comprandoengrupo.net> | 2024-11-25 16:43:20 -0300 |
---|---|---|
committer | Matias Linares <matias.linares@comprandoengrupo.net> | 2024-11-25 16:44:12 -0300 |
commit | c5f854946a40b1ec278dfa999b3aaba9109dfc42 (patch) | |
tree | 10aaa3a64626b1465df267554471f2666736a3e9 | |
parent | 2ef76e8acee23c344335b0118aadd5de96a7dfff (diff) | |
download | kodereviewer-c5f854946a40b1ec278dfa999b3aaba9109dfc42.tar.gz |
Add quote action to comment list
-rw-r--r-- | kodereviewer/qml/.CommentPage.qml.kate-swp | bin | 232 -> 0 bytes | |||
-rw-r--r-- | kodereviewer/qml/CommentDelegate.qml | 14 | ||||
-rw-r--r-- | kodereviewer/qml/CommentPage.qml | 36 | ||||
-rw-r--r-- | kodereviewer/qml/ReviewList.qml | 2 |
4 files changed, 46 insertions, 6 deletions
diff --git a/kodereviewer/qml/.CommentPage.qml.kate-swp b/kodereviewer/qml/.CommentPage.qml.kate-swp Binary files differdeleted file mode 100644 index a72cf10..0000000 --- a/kodereviewer/qml/.CommentPage.qml.kate-swp +++ /dev/null diff --git a/kodereviewer/qml/CommentDelegate.qml b/kodereviewer/qml/CommentDelegate.qml index 3b2681b..536fada 100644 --- a/kodereviewer/qml/CommentDelegate.qml +++ b/kodereviewer/qml/CommentDelegate.qml @@ -13,6 +13,8 @@ Kirigami.AbstractCard { required property string username required property string body + signal quote(string body); + header: RowLayout { KirigamiComponents.Avatar { name: root.username @@ -34,7 +36,13 @@ Kirigami.AbstractCard { actions: [ Kirigami.Action { icon.name: "overflow-menu" - + Kirigami.Action { + text: i18n("Quote") + icon.name: "format-text-blockquote-symbolic" + onTriggered: { + root.quote(root.quoteText()) + } + } Kirigami.Action { text: "Edit" icon.name: "edit-comment" @@ -72,4 +80,8 @@ Kirigami.AbstractCard { } } } + + function quoteText() { + return root.body.split("\n").map((line) => "> " + line).join("\n") + } } diff --git a/kodereviewer/qml/CommentPage.qml b/kodereviewer/qml/CommentPage.qml index 756f5da..c63aac5 100644 --- a/kodereviewer/qml/CommentPage.qml +++ b/kodereviewer/qml/CommentPage.qml @@ -23,6 +23,10 @@ Kirigami.ScrollablePage { actions: commonActions + property string comment: "" + + onPullRequestChanged: comment = "" + Timer { // Ten minutes? id: getCommentsTimer @@ -36,6 +40,17 @@ Kirigami.ScrollablePage { } } + // Delay getCommentsTimer for 2s + Timer { + id: delayTimer + interval: 1000 * 2 + running: false + repeat: false + onTriggered: { + getCommentsTimer.restart() + } + } + Loader { id: commentModelLoader active: !!root.pullRequest @@ -54,13 +69,26 @@ Kirigami.ScrollablePage { Layout.fillHeight: true visible: !!root.pullRequest model: commentModelLoader.item - delegate: CommentDelegate {} + + signal quote(string a) + + delegate: CommentDelegate { + onQuote: (quote) => { + if (root.comment.length > 0) + root.comment += "\n\n" + root.comment += quote + } + } + + footerPositioning: ListView.InlineFooter + footer: Item { id: rootFooter anchors.left: parent.left anchors.right: parent.right height: footerLayout.implicitHeight + RowLayout { id: footerLayout anchors.fill: parent @@ -69,6 +97,7 @@ Kirigami.ScrollablePage { MarkdownTextArea { id: newCommentTextArea Layout.fillWidth: true + text: root.comment } QQC2.Button { icon.name: "document-send-symbolic" @@ -81,12 +110,11 @@ Kirigami.ScrollablePage { } root.connection.createComment(root.pullRequest.number, newCommentTextArea.text) - newCommentTextArea.text == '' - getCommentsTimer.restart() + root.comment = '' + delayTimer.restart() } } } - } } } diff --git a/kodereviewer/qml/ReviewList.qml b/kodereviewer/qml/ReviewList.qml index 77a00e0..9b4b690 100644 --- a/kodereviewer/qml/ReviewList.qml +++ b/kodereviewer/qml/ReviewList.qml @@ -88,7 +88,7 @@ Kirigami.CardsListView { } root.connection.createComment(root.pullRequest.number, newCommentTextArea.text) - newCommentTextArea.text == '' + newCommentTextArea.text = '' getCommentsTimer.restart() } } |