-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWhiteboardSession.qml
192 lines (175 loc) · 5.12 KB
/
WhiteboardSession.qml
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
import QtQuick
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Controls.Material
import QtQuick.Layouts
import QtQuick.Dialogs
Item {
property string folderpath
property bool dialogopen
width: parent.width
height: parent.height
visible: true
id: focusArea
focus: true
Material.theme: Material.Light
Material.primary: Material.Blue
Material.accent: "#6C63FF"
Component.onCompleted: function () {
videoStreamer.startStream(0)
focusArea.focus = true
}
Component.onDestruction: videoStreamer.stopStream()
RowLayout {
id: buttons
width: parent.width
height: 50
spacing: (width / 4) - 100
Button {
Material.background: "#5D3FD3"
width: 80
height: 40
contentItem: Text {
text: qsTr("Clear")
color: "white"
font.pixelSize: 16
font.bold: true
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
// anchors.top: parent.top
// anchors.left: parent.left
onClicked: {
whiteboardManager.clearWhiteboard()
}
}
Button {
Material.background: "#5D3FD3"
width: 80
height: 40
contentItem: Text {
text: qsTr("Back")
color: "white"
font.pixelSize: 16
font.bold: true
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
// anchors.bottom: parent.bottom
// anchors.left: parent.left
onClicked: stackView.pop()
}
Button {
Material.background: "#5D3FD3"
width: 150
height: 40
contentItem: Text {
text: qsTr("Save Snapshot")
color: "white"
font.pixelSize: 16
font.bold: true
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
// anchors.top: parent.top
// anchors.right: parent.right
onClicked: {
snapshotDialog.forceActiveFocus()
snapshotDialog.open()
}
}
Button {
Material.background: "#5D3FD3"
width: 150
height: 40
contentItem: Text {
text: qsTr("Upload Image")
color: "white"
font.pixelSize: 16
font.bold: true
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
// anchors.horizontalCenter: parent.horizontalCenter
text: "Upload Image"
onClicked: {
fileDialog.open()
}
}
}
FileDialog {
id: fileDialog
title: "Select an Image"
onAccepted: {
whiteboardManager.loadImage(fileDialog.selectedFile.toString(
).replace("file:///", ""))
}
onRejected: {
console.log("Canceled")
}
}
Image {
id: whiteboardSpace
fillMode: Image.PreserveAspectFit
width: 800
height: 600
anchors.top: buttons.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
source: "image://whiteboard/image"
cache: false
function reload() {
source = "image://whiteboard/image?id=" + Date.now()
}
}
Dialog {
id: snapshotDialog
title: "Save Snapshot"
standardButtons: Dialog.Ok | Dialog.Cancel
width: 300
height: 250
anchors.centerIn: parent
modal: true
ColumnLayout {
spacing: 10
width: parent.width
Text {
text: "Enter the name for the snapshot:"
Layout.alignment: Qt.AlignLeft
}
TextField {
id: snapshotNameInput
placeholderText: "Snapshot name"
Layout.fillWidth: true
}
}
onAccepted: {
var rawPath = folderpath + "/" + snapshotNameInput.text + ".png"
var cleanedPath = rawPath.replace("file:///", "")
whiteboardManager.saveSnapshot(cleanedPath)
console.log("Snapshot saved to " + cleanedPath)
focusArea.focus = true
}
onRejected: {
console.log("Snapshot save canceled")
focusArea.focus = true
}
}
Connections {
target: whiteboardImageProvider
function onImageChanged() {
whiteboardSpace.reload()
}
}
Keys.onPressed: {
if (event.key === Qt.Key_Control) {
whiteboardManager.enableDrawing()
}
}
Keys.onReleased: {
if (event.key === Qt.Key_Control) {
whiteboardManager.disableDrawing()
}
}
}