-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.qml
567 lines (537 loc) · 20.3 KB
/
main.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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
/*------------------------------------------------------------------------------------------------------------------
-- FILE: main.qml
--
-- DATE: March 20th, 2016
--
-- REVISIONS: March 20th, 2016: Created the initial UI
-- March 22nd, 2016: Updated the UI
-- March 23rd, 2016: Integrated the UI with the appropriate function calls & commented
--
-- DESIGNER: Micah Willems
--
-- PROGRAMMER: Micah Willems
--
-- NOTES:
-- The entire UI side of the application is held in this QML file. QML is the markup language of QT, which is used when
-- the user would like to get a level lower than QSS to do much more powerful UI development. Each open/closing tag
-- is the code inside of a QObject that can be used and referenced by the C++ code. This is the "view" of a MVC framework
-- one could say.
--
-- This file is NOT autogenerated.
----------------------------------------------------------------------------------------------------------------------*/
import QtQuick 2.5
import QtQuick.Window 2.2
import QtQuick.Controls 1.5
import QtQuick.Controls.Styles 1.4
import QtQuick.Dialogs 1.2
Window {
id: mainWindow
visible: true
width: 900
height: 600
flags: Qt.FramelessWindowHint | Qt.Window | Qt.CustomizeWindowHint
color: "transparent"
Rectangle {
id: mainContainer
anchors.fill: parent
radius: 3
gradient: Gradient {
GradientStop {
position: 0
color: "#8ffdf9"
}
GradientStop {
position: 1
color: "#00a9a2"
}
}
Image {
source:"images/window_controls/blue/close.png"
id: close
x: 552
width: 16
height: 16
z: 3
anchors.right: parent.right
anchors.rightMargin: 12
anchors.top: parent.top
anchors.topMargin: 8
fillMode: Image.PreserveAspectCrop
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit();
}
}
}
Rectangle {
id: closeBackFill
x: 578
width: 14
height: 14
z: 2
color: "#fff"
anchors.rightMargin: 1
anchors.topMargin: 1
anchors.top: close.top
anchors.right: close.right
}
Image {
source:"images/window_controls/blue/minimize.png"
id: minimize
x: 518
width: 16
height: 16
z: 3
anchors.right: close.left
anchors.rightMargin: 1
anchors.top: parent.top
anchors.topMargin: 8
fillMode: Image.PreserveAspectCrop
MouseArea {
anchors.fill: parent
onClicked: {
mainWindow.showMinimized();
}
}
}
Rectangle {
id: minimizeBackFill
x: 578
width: 14
height: 14
z: 2
color: "#fff"
anchors.rightMargin: 1
anchors.topMargin: 1
anchors.top: minimize.top
anchors.right: minimize.right
}
MouseArea {
id: mouseArea1
anchors.fill: parent
z: 1
property variant clickPos: "1,1"
property variant appStartPos: "1,1"
onPressed: {
// fetch global position due to bug on ubuntu
clickPos = gApplicationController.getCursorPos()
appStartPos = Qt.point(mainWindow.x, mainWindow.y)
}
onPositionChanged: {
var newPos = gApplicationController.getCursorPos()
var delta = Qt.point(newPos.x-clickPos.x, newPos.y-clickPos.y)
mainWindow.x = appStartPos.x+delta.x;
mainWindow.y = appStartPos.y+delta.y;
}
}
Rectangle {
id: chatContainer
x: 270
width: 600
height: 510
radius: 10
z: 2
anchors.top: parent.top
anchors.topMargin: 44
anchors.right: parent.right
anchors.rightMargin: 30
border.color: "#0954a0"
gradient: Gradient {
GradientStop {
position: 0
color: "#ffffff"
}
GradientStop {
position: 0.067
color: "#01c7c0"
}
GradientStop {
position: 0.068
color: "#37fff8"
}
GradientStop {
position: 1
color: "#c0fffd"
}
}
MouseArea {
anchors.fill: parent
}
border.width: 2
Rectangle {
id: chatTitleDivider
x: 0
width: 596
height: 2
color: "#ffffff"
border.color: "#0c80f3"
anchors.top: parent.top
anchors.topMargin: 34
anchors.right: parent.right
anchors.rightMargin: 2
border.width: 2
}
Text {
id: chatTitle
width: 320
height: 37
color: "#ffffff"
text: qsTr("Chatroom")
wrapMode: Text.WrapAnywhere
font.family: "Verdana"
verticalAlignment: Text.AlignVCenter
anchors.top: parent.top
anchors.topMargin: 0
anchors.left: parent.left
anchors.leftMargin: 20
textFormat: Text.AutoText
font.pixelSize: 20
}
Rectangle {
id: chatDisplayContainer
x: 20
y: 51
width: 559
height: 349
color: "#ffffff"
radius: 1
TextArea {
id: chatDisplayText
textFormat: Text.RichText
readOnly: true
font.family: "Arial"
anchors.fill: parent
clip: true
font.pointSize: 5
style: TextAreaStyle {
textColor: "#333"
selectionColor: "steelblue"
selectedTextColor: "#eee"
backgroundColor: "#eee"
}
ListView {
id: messageList
anchors.fill: parent
delegate: MessageIncoming {}
model: gApplicationController
}
}
}
Rectangle {
id: chatReplyContainer
width: 442
height: 42
color: "#ffffff"
radius: 1
anchors.top: chatDisplayContainer.bottom
anchors.topMargin: 26
anchors.left: parent.left
anchors.leftMargin: 20
Flickable {
id: chatReplyScrollFix
width: 432
height: 32
anchors.left: parent.left
anchors.leftMargin: 5
anchors.top: parent.top
anchors.topMargin: 5
contentWidth: chatReplyEdit.width
contentHeight: chatReplyEdit.height
clip: true
function ensureVisible(r)
{
if (contentX >= r.x)
contentX = r.x;
else if (contentX+width <= r.x+r.width)
contentX = r.x+r.width-width;
if (contentY >= r.y)
contentY = r.y;
else if (contentY+height <= r.y+r.height)
contentY = r.y+r.height-height;
}
TextEdit {
id: chatReplyEdit
text: qsTr("")
width: chatReplyScrollFix.width
height: chatReplyScrollFix.height
font.family: "Arial"
cursorVisible: false
wrapMode: TextEdit.Wrap
font.pixelSize: 12
onCursorRectangleChanged: chatReplyScrollFix.ensureVisible(cursorRectangle)
}
}
}
Image {
source: "images/window_controls/blue/button-blue.png"
id: sendButton
width: 90
height: 42
z: 3
anchors.left: chatReplyContainer.right
anchors.leftMargin: 17
anchors.top: chatDisplayContainer.bottom
anchors.topMargin: 26
MouseArea {
anchors.fill: parent
onPressed: {
sendButton.source = "images/window_controls/blue/button-blue-pressed.png"
}
onReleased: {
sendButton.source = "images/window_controls/blue/button-blue.png"
gApplicationController.sendButtonClicked(chatReplyEdit.text)
chatReplyEdit.text = ""
}
}
}
}
TabView {
id: optionsTabs
z: 2
width: 200
height: 510
anchors.top: parent.top
anchors.topMargin: 44
anchors.left: parent.left
anchors.leftMargin: 30
/*MouseArea {
anchors.fill: parent
}*/
Tab {
id: configTab
active: true
title: "Configuration"
Rectangle {
radius: 10
color: "#00a9a2"
Text {
id: nickLabel
x: 42
width: 150
height: 20
color: "#ffffff"
text: qsTr("Nickname:")
wrapMode: Text.WrapAnywhere
font.family: "Verdana"
verticalAlignment: Text.AlignVCenter
anchors.top: parent.top
anchors.topMargin: 100
anchors.left: parent.left
anchors.leftMargin: 30
textFormat: Text.AutoText
font.pixelSize: 14
}
TextField {
id: nickText
width: 150
height: 28
anchors.top: nickLabel.top
anchors.topMargin: 30
anchors.left: parent.left
anchors.leftMargin: 30
style: TextFieldStyle {
textColor: "black"
background: Rectangle {
radius: 2
implicitWidth: nickText.width
implicitHeight: nickText.height
border.width: 0
}
}
onTextChanged: {
if (nickText.text != "") {
buttonConnect.nick = true
buttonConnect.checkCompletion()
} else {
buttonConnect.nick = false
buttonConnect.enabled = false
buttonConnect.color0 = "#777"
buttonConnect.color1 = "#bbb"
}
}
}
Text {
id: avatarLabel
x: 42
width: 150
height: 20
color: "#ffffff"
text: qsTr("Avatar:")
wrapMode: Text.WrapAnywhere
font.family: "Verdana"
verticalAlignment: Text.AlignVCenter
anchors.top: nickText.top
anchors.topMargin: 50
anchors.left: parent.left
anchors.leftMargin: 30
textFormat: Text.AutoText
font.pixelSize: 14
}
SpinBox {
id: avatarNum
width: 50
height: 28
anchors.top: avatarLabel.top
anchors.topMargin: 30
anchors.left: parent.left
anchors.leftMargin: 30
minimumValue: 0
maximumValue: 21
}
Text {
id: ipLabel
x: 42
width: 160
height: 20
color: "#ffffff"
text: qsTr("Chatroom IP Address:")
wrapMode: Text.WrapAnywhere
font.family: "Verdana"
verticalAlignment: Text.AlignVCenter
anchors.top: avatarNum.top
anchors.topMargin: 50
anchors.left: parent.left
anchors.leftMargin: 30
textFormat: Text.AutoText
font.pixelSize: 14
}
TextField {
id: ipText
width: 150
height: 28
anchors.top: ipLabel.top
anchors.topMargin: 30
anchors.left: parent.left
anchors.leftMargin: 30
validator: RegExpValidator{regExp: /^(([01]?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))\.){3}([01]?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))$/}
style: TextFieldStyle {
textColor: "black"
background: Rectangle {
radius: 2
implicitWidth: nickText.width
implicitHeight: nickText.height
border.width: 0
}
}
onTextChanged: {
if (ipText.text != "") {
buttonConnect.ip = true
buttonConnect.checkCompletion()
} else {
buttonConnect.ip = false
buttonConnect.enabled = false
buttonConnect.color0 = "#777"
buttonConnect.color1 = "#bbb"
}
}
}
Button {
id: buttonConnect
text: qsTr("Connect")
anchors.top: ipText.top
anchors.topMargin: 50
anchors.left: parent.left
anchors.leftMargin: 30
enabled: false
property color color0: "#777"
property color color1: "#bbb"
style: ButtonStyle {
background: Rectangle {
implicitWidth: 100
implicitHeight: 25
border.width: control.activeFocus ? 2 : 1
border.color: "#888"
radius: 4
gradient: Gradient {
GradientStop { position: 0 ; color: control.pressed ? "#00a9a2" : buttonConnect.color0 }
GradientStop { position: 1 ; color: control.pressed ? "#8ffdf9" : buttonConnect.color1 }
}
}
}
property bool nick: false
property bool ip: false
function checkCompletion() {
if (nick & ip) {
buttonConnect.enabled = true
buttonConnect.color0 = "#8ffdf9"
buttonConnect.color1 = "#00a9a2"
}
}
onClicked : {
gApplicationController.connectButtonClicked(nickText.text, avatarNum.value, ipText.text)
buttonConnect.color0 = "#777"
buttonConnect.color1 = "#bbb"
buttonDisconnect.color0 = "#8ffdf9"
buttonDisconnect.color1 = "#00a9a2"
buttonConnect.enabled = false
ipText.enabled = false
ipText.text = ""
avatarNum.enabled = false
nickText.enabled = false
nickText.text = ""
buttonDisconnect.enabled = true
}
}
Button {
id: buttonDisconnect
text: qsTr("Disconnect")
anchors.top: buttonConnect.top
anchors.topMargin: 50
anchors.left: parent.left
anchors.leftMargin: 30
enabled: false
property color color0: "#777"
property color color1: "#bbb"
style: ButtonStyle {
background: Rectangle {
implicitWidth: 100
implicitHeight: 25
border.width: control.activeFocus ? 2 : 1
border.color: "#888"
radius: 4
gradient: Gradient {
GradientStop { position: 0 ; color: control.pressed ? "#00a9a2" : buttonDisconnect.color0 }
GradientStop { position: 1 ; color: control.pressed ? "#8ffdf9" : buttonDisconnect.color1 }
}
}
}
onClicked : {
gApplicationController.disconnect()
buttonDisconnect.color0 = "#777"
buttonDisconnect.color1 = "#bbb"
buttonConnect.color0 = "#8ffdf9"
buttonConnect.color1 = "#00a9a2"
buttonDisconnect.enabled = false
ipText.enabled = true
avatarNum.enabled = true
nickText.enabled = true
}
}
}
}
style: TabViewStyle {
frameOverlap: 10
tab: Rectangle {
color: styleData.selected ? "#00a9a2" : "#8ffdf9"
border.color: "#00a9a2"
implicitWidth: tabText.width + 19
implicitHeight: 34
radius: 5
Text {
id: tabText
anchors.centerIn: parent
text: styleData.title
color: styleData.selected ? "white" : "black"
font.family: "Verdana"
font.pixelSize: 17
}
}
frame: Rectangle {
radius: 10
color: "#00a9a2"
}
}
}
}
}