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.kde.kirigamiaddons.components as KirigamiComponents 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 title: pullRequest ? `#${pullRequest.number}` : "" property ReviewHelper reviewHelper: applicationWindow().reviewHelper property string currentFile: "" property string currentText: "" onPullRequestChanged: { root.currentFile = "" root.currentText = "" } Component.onCompleted: { actions = commonActions.concat(actions) } actions: [ Kirigami.Action { id: openFiles text: "Files" icon.name: "file-catalog-symbolic" enabled: !!root.pullRequest onTriggered: { if(contextDrawer.opened) { contextDrawer.close() } else { contextDrawer.open() } } } ] Kirigami.Dialog { id: popup popupType: QQC2.Popup.Window focus: true title: i18n("Add review to " + root.currentFile) showCloseButton: false preferredWidth: Kirigami.Units.gridUnit * 20 preferredHeight: Kirigami.Units.gridUnit * 20 padding: Kirigami.Units.largeSpacing MarkdownTextArea { id: reviewTextArea } standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel onAccepted: { root.reviewHelper.addFileReview(root.currentFile, reviewTextArea.text, editor.selectionEndLine()) } } Kirigami.PlaceholderMessage { visible: root.currentFile == '' anchors.centerIn: parent icon.name: "org.deprecated.kodereviewer" text: "No file selected" } ColumnLayout { anchors.fill: parent visible: root.currentFile != '' Editor { id: editor Layout.fillWidth: true Layout.fillHeight: true file: root.currentFile text: root.currentText MouseArea { anchors.fill: parent //propagateComposedEvents: true acceptedButtons: Qt.RightButton cursorShape: Qt.IBeamCursor onClicked: event => { if (event.button === Qt.RightButton) { // 'mouse' is a MouseEvent argument passed into the onClicked signal handler editorMenu.popup() } } QQC2.Menu { id: editorMenu QQC2.MenuItem { text: "Add review" icon.name: "preview-symbolic" onTriggered: { console.log("triggered review") console.log(`start line: ${editor.selectionStartLine()} to ${editor.selectionEndLine()}`) popup.open() } } } } } } Connections { target: contextDrawer function onFileSelected(filename, text) { console.log("file changed!") root.currentFile = filename + '.diff' root.currentText = text } } }