blob: 25c1164c82cb915a0c99d1ebca3945ecf7e9c6f3 (
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
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 = ""
root.currentSha = ""
}
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 + '.diff'
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()}`)
const component = Qt.createComponent("ReviewWindow.qml")
print(applicationWindow().project)
const params = {
project: applicationWindow().project,
pullRequestNumber: root.pullRequest.number,
diffText: root.currentText,
path: root.currentFile,
startLine: editor.selectionStartLine(),
endLine: editor.selectionEndLine(),
commitId: root.pullRequest.last_commit
}
component.createObject(applicationWindow(), params)
//popup.open()
}
}
}
}
}
}
Connections {
target: contextDrawer
function onFileSelected(filename, text) {
console.log("file changed!")
root.currentFile = filename
root.currentText = text
}
}
}
|