-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.qml
1297 lines (1250 loc) · 56.2 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
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import QtQuick 2.12
import QtQuick.Window 2.12
// import qt quick controls & layouts
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.12
// import some text field styles
import QtQuick.Controls.Styles 1.3
// import Qt Quick Dialogs
import QtQuick.Dialogs 1.2
ApplicationWindow {
id: rootElementId
visible: true
width: 720
height: 740
minimumWidth: credsGroupBoxId.width + systemInfoGroupBox.width + 30
minimumHeight: credsGroupBoxId.height + userMgmntId.height + 60
maximumWidth: credsGroupBoxId.width + systemInfoGroupBox.width + 80
maximumHeight: credsGroupBoxId.height + userMgmntId.height + 120
title: qsTr("Bienvenue au Linux Manager Utilitaire")
function getPassComplexity() {
// Fetch password's complexity from c++ logic real time
//
if (myManager.passComplexity==="None") {
return 10;
} else if(myManager.passComplexity==="Weak") {
return 30;
} else if(myManager.passComplexity==="Medium") {
return 50;
} else if(myManager.passComplexity==="Strong") {
return 70;
} else {
return 100;
}
}
// Add the Menu Bar for all items regarding Manager Application
//
menuBar: MenuBar {
// change default color of MenuBar
background: Rectangle {
color: "lightgray"
}
Menu {
title: "&Help"
Action {
id: aboutManagerId
text: qsTr("Manager &Help")
icon {source: "/aboutManager.png"; color: "transparent"}
onTriggered: {
aboutManagerDialogId.open()
}
}
Action {
id: aboutAuthorId
text: "About &Author"
icon {source: "/aboutAuthor.png"; color: "transparent"}
onTriggered: {
genericMessageDialog.title = "About Author"
genericMessageDialog.text = "Dimos Katsimardos\nwww.linkedin.com/in/dimkatsi91\nJanvier 06, 2020"
genericMessageDialog.open()
}
}
}
// Window Manager App MenuBar & respective Actions :
// [1] Change Manager background color & [2] Quit Manager Application
//
Menu {
title: qsTr("&Window")
width: 200
Action {
id: changeColorActionId
text: qsTr("Change Manager &Color")
icon {source: "/backColor.png"; color: "transparent"}
onTriggered: {
// open ColorDialog to choose a color
colorDialogId.open()
}
}
MenuSeparator {}
Action {
id: quitManagerAppId
text: qsTr("Quit &Manager")
icon {source: "/exit.png"; color: "transparent"}
onTriggered: {
quitManagerDialogId.open()
}
}
}
}
// A popUp Message Dialog in order to choose YES | NO upon quit action from Manager Application
//
MessageDialog {
id: quitManagerDialogId
title: "Quit Manager Application ?"
text: "Are you sure you want to exit Manager?"
standardButtons: StandardButton.Ok | StandardButton.Cancel
onAccepted: {
Qt.quit()
}
}
// Dialog to open when About Manager Action is chosen
//
Dialog {
id: aboutManagerDialogId
//x: (parent.width - width) / 2
//y: (parent.height - height) / 2
// correct this parent warning :: change 'parent' --> 'ApplicationWindow'
width: Math.min(ApplicationWindow.width, ApplicationWindow.height) / 3 * 2
////contentHeight: parent.height/2 // This doesn't cause the binding loop.
////parent: Overlay.overlay
title: "About Manager"
standardButtons: Dialog.Close
Column {
id: column
spacing: 20
width: rootElementId.width/3*2
height: rootElementId.height
Image {
id: logo
width: parent.width / 2
anchors.horizontalCenter: parent.horizontalCenter
fillMode: Image.PreserveAspectFit
source: "/manager.png"
}
Label {
width: parent.width
text: "This is a Qt Quick Linux Application that helps user create, remove or rename "
+ "a user in Linux Desktop. Enter current user username and type password two "
+ "times just for confirmation. Then, enter 'Submit' Button in order to continue. "
+ "Username and password fields can be cleared by switching the 'Clear' switch to the right. "
+ "Linux Manager Application also gives user the ability to add or remove a group from "
+ "its Linux Desktop. Last, but not least the user can check various information regarding "
+ "its Linux Desktop, like for example current real users, real groups, Firewall configuration "
+ "tables [Filter | RAW | Security | Mangle] can be printed out and see the applied rules for traffic. "
+ "Furthermore, Routing table and Network Interfaces can be checked out. \n\t\tHave fun!"
wrapMode: Label.Wrap
}
}
}
// A color dialog to choose Manager Application background color
//
ColorDialog {
id: colorDialogId
title: "Choose Manager Application background color"
visible: false
onAccepted: {
// choose a color opening systems default application
managerBackgroundColorId.color = colorDialogId.color
}
}
// Add the ToolBar Actions regarding Manager Application
//
header: ToolBar {
Row {
anchors.fill: parent
ToolButton {
action: aboutManagerId
}
ToolButton {
action: aboutAuthorId
}
ToolButton {
action: quitManagerAppId
}
}
}
// change the background color of application window using a rectangle
//
background: Rectangle {
id: managerBackgroundColorId
color: "lightblue"
}
font: {font.family="Arial"; font.pointSize=9;}
// quit() with ESC
//
Item {
id: quitItemId
// Attention: without focus property enabled it is not going to work!!!
//
focus: true
Keys.onPressed: {
if(event.key === Qt.Key_Escape) {
Qt.quit()
}
}
}
// Declare three global vars for username, pass(1) and pass(2)
//
property string username: ""
property string passwd_une: ""
property string passwd_deux: ""
// Declare variables for the new user that is about to be created
//
property string new_username: ""
property string new_user_realname: ""
property string new_user_group: ""
property string new_user_id: ""
property string new_user_shell: ""
property string new_user_encr_password: ""
// A few variables for the groups addition|removal|rename functionality
//
property string new_group_name: ""
property string new_group_id: ""
property string existing_group_new_name: ""
// The Firewall Table that will be chosen by the user from the respective ComboBox
// in the System & Networking Section related Actions | Default value: "filter" table
//
property string firewallTable: "filter"
GroupBox {
x: 5; y: 5
title: qsTr("Credentials")
id: credsGroupBoxId
font.bold: true
// this groupbox refers to operator credentials, i.e. username/password
// and a submit button in order to store these values
//
Column {
// Row element container for username fields
//
Row {
id: usernameRowId
spacing: 10
width: 300
bottomPadding: 5
// A label for username
Label {
text: "Type username : "
id: usernameLabelId
color: "gray"
}
// A text field to enter operator's username
TextField {
id:usernameTextFieldId
width: 100
placeholderText: "username"
placeholderTextColor: "lightgray"
ToolTip.delay: 500
ToolTip.timeout: 2000
ToolTip.visible: hovered
ToolTip.text: qsTr("Please type your username")
echoMode: TextInput.Normal
font: Qt.font({family: "Helvetica", pointSize: 9, italic: true})
onEditingFinished: {
username = text
}
// remove border color from the text field
background: Rectangle {
implicitWidth: 100
implicitHeight: 20
border.color: "transparent"
}
}
}
// Row element containing password fields #1st time
//
Row {
id: passwdUneRowId
spacing: 10
width: 300
bottomPadding: 5
// A label for password
Label {
text: "Type password : "
id: passwordLabel1Id
color: "gray"
}
// A text field to enter operator's password | time #1
TextField {
id: passwordTextField1Id
placeholderText: "password"
placeholderTextColor: "lightgray"
ToolTip.delay: 500
ToolTip.timeout: 2000
ToolTip.visible: hovered
ToolTip.text: qsTr("Please type your password")
// password should not be visible when typed
echoMode: TextInput.Password
font: Qt.font({family: "Helvetica", pointSize: 9, italic: true})
onEditingFinished: {
passwd_une = text
}
// remove border color from the text field
background: Rectangle {
implicitWidth: 100
implicitHeight: 20
border.color: "transparent"
}
}
}
// Row element containing password fields #2nd time
Row {
//
id: passwdDeuxRowId
spacing: 10
width: 300
bottomPadding: 5
// A label for password re-entry
Label {
text: "Retype password : "
id: passwordLabel2Id
color: "gray"
}
// A text field to enter operator's password | time #2
TextField {
id: passwordTextField2Id
placeholderText: "password"
placeholderTextColor: "lightgray"
ToolTip.delay: 500
ToolTip.timeout: 2000
ToolTip.visible: hovered
ToolTip.text: qsTr("Please type your password again")
// password should not be visible when typed
echoMode: TextInput.Password
font: Qt.font({family: "Helvetica", pointSize: 9, italic: true})
onEditingFinished: {
passwd_deux = text
}
// remove border color from the text field
background: Rectangle {
implicitWidth: 100
implicitHeight: 20
border.color: "transparent"
}
}
}
// A Row containing CheckBox | when checked passwords become visible
//
Row {
spacing: 10
width: 200
bottomPadding: 10
CheckBox {
id: showPasswdsCheckBoxId
checked: false
text: qsTr("Show passwords")
// when this checkBos is checked --> make passwords text fields visible
//
onClicked: {
if(checked===true) {
// make password #1/2 textInput field visible
passwordTextField1Id.echoMode = TextInput.Normal
passwordTextField2Id.echoMode = TextInput.Normal
} else {
// make password #1/2 textInput field invisible
passwordTextField1Id.echoMode = TextInput.Password
passwordTextField2Id.echoMode = TextInput.Password
}
}
}
}
// this is a MessageDialog to be called in various situations
//
MessageDialog {
id: genericMessageDialog
title: qsTr("WARNING")
text: "This is the default warning message. Should be changed when Dialog is called."
}
// A DelayButton to 'Submit' operator's username and password
// Should only be accepted IF and only IF password===retypeOfPassword
/// and username === getenv("USER")
Row {
spacing: 10
width: 300
bottomPadding: 10
DelayButton {
id: submitButtonId
property bool activated: false
// When the 'Submit' Button is pressed for '1.5' seconds, then it is activated and going on ...
delay: 1000
text: "Submit Credentials"
ToolTip.delay: 500
ToolTip.timeout: 1500
ToolTip.text: qsTr("Press this Button until it is activated.\nThen press it to proceed!")
ToolTip.visible: hovered
onActivated: {
activated = true
}
onPressed: {
if(activated === true) {
// TODO: Remove it at the end of this Manager Application
///////////////////////////////////
if(passwd_une === "" || passwd_deux === "" || username === "") {
genericMessageDialog.title = "CREDENTIALS WARNING"
genericMessageDialog.text = "Please provide your username and password and try again!"
genericMessageDialog.open()
} else {
if(passwd_une !== passwd_deux) {
genericMessageDialog.title = "PASSWORDS ERROR"
genericMessageDialog.text = "Passwords do not match. Type them correctly and try again!"
genericMessageDialog.open()
} else {
genericMessageDialog.title = "CREDENTIALS INFORMATION"
genericMessageDialog.text = "Credentials provided. Continuing procedure .."
genericMessageDialog.open()
// pass entered username from the TextField to my C++ code
//
myManager.setUsername(username)
// Same for password
//
myManager.setPassword(passwd_une)
// Last action -> compare current username into system with the entered username in the TextField
//
if(myManager.compare_usernames() === false) {
genericMessageDialog.title = "CURRENT USER ERROR"
genericMessageDialog.text = "Please provide correct current username and try again!"
genericMessageDialog.open()
// If username is fake -> then swipe switch to the right and clean up text fields
clearSwitchId.checked = true
clearSwitchId.checked = false
}
}
}
}
}
// align 'Submit' button in the center of the last Row
//
anchors.fill: parent.Center
opacity: .75
}
}
// Create a Switch to Clear Credentials Fields if the operator wants to
//
Switch {
id: clearSwitchId
text: "Clear Fields"
checked: false
ToolTip.delay: 500
ToolTip.timeout: 1500
ToolTip.text: qsTr("Clean up Credentials Text Fields!")
ToolTip.visible: hovered
onCheckedChanged: {
if(checked === true) {
usernameTextFieldId.text = ""
passwordTextField1Id.text = ""
passwordTextField2Id.text = ""
// Call c++ function that cleans up username/password Qstring variables
//
myManager.clearCredentials()
}
}
}
}
}
/* END OF Credentials GroupBox */
GroupBox {
id: userMgmntId
title: qsTr("User Management")
font: Qt.font({family: "Helvetica", pointSize: 9, italic: true, bold: true})
spacing: 5
anchors.top: credsGroupBoxId.bottom
width: credsGroupBoxId.width
height: 400
x: 5
ColumnLayout {
id: userMgmntColumnId
Row {
width: parent.width
bottomPadding: 10
// new user username Column
// label & TextField
Label {
text: "User Name "
id: newUsernameLabelId
}
TextField {
id: newUsernameTextFieldId
width: userMgmntId.width - newUsernameLabelId.width - 14
// remove border color from the text field
background: Rectangle {
border.color: "transparent"
}
placeholderText: " new user username"
placeholderTextColor: "lightgray"
ToolTip.delay: 500
ToolTip.timeout: 2000
ToolTip.visible: hovered
ToolTip.text: qsTr("New user to be created username")
onEditingFinished: {
new_username = newUsernameTextFieldId.text
}
}
}
Row {
width: parent.width
bottomPadding: 10
// new user real name Column
// label & TextField
Label {
text: "User Real Name "
id: newUserRealnameLabelId
}
TextField {
id: newUserRealnameTextFieldId
width: userMgmntId.width - newUserRealnameLabelId.width - 14
// remove border color from the text field
background: Rectangle {
border.color: "transparent"
}
placeholderText: " new user real name"
placeholderTextColor: "lightgray"
ToolTip.delay: 500
ToolTip.timeout: 2000
ToolTip.visible: hovered
ToolTip.text: qsTr("New user to be created real name")
onEditingFinished: {
new_user_realname = newUserRealnameTextFieldId.text
}
}
}
Row {
width: parent.width
bottomPadding: 10
// new user group Column
// label & TextField
Label {
text: "User Group Name "
id: newUserGroupLabelId
}
TextField {
id: newUserGroupTextFieldId
width: userMgmntId.width - newUserGroupLabelId.width - 14
// remove border color from the text field
background: Rectangle {
border.color: "transparent"
}
placeholderText: "new user's group"
placeholderTextColor: "lightgray"
ToolTip.delay: 500
ToolTip.timeout: 2000
ToolTip.visible: hovered
ToolTip.text: qsTr("New user to be created group")
onEditingFinished: {
new_user_group = newUserGroupTextFieldId.text
}
}
}
Row {
width: parent.width
bottomPadding: 10
// new user ID Column
// label & TextField
Label {
text: "User ID "
id: newUserIDLabelId
}
TextField {
id: newUserIDTextFieldId
width: userMgmntId.width - newUserIDLabelId.width - 14
// remove border color from the text field
background: Rectangle {
border.color: "transparent"
}
placeholderText: " new user's ID"
placeholderTextColor: "lightgray"
ToolTip.delay: 500
ToolTip.timeout: 2000
ToolTip.visible: hovered
ToolTip.text: qsTr("New user to be created ID")
onEditingFinished: {
new_user_id = newUserIDTextFieldId.text
}
}
}
Row {
width: parent.width
bottomPadding: 10
// new user Shell Column
// label & TextField
Label {
text: "User Shell "
id: newUserShellLabelId
}
TextField {
id: newUserShellTextFieldId
width: userMgmntId.width - newUserShellLabelId.width - 14
// remove border color from the text field
background: Rectangle {
border.color: "transparent"
}
placeholderText: " new user's shell"
placeholderTextColor: "lightgray"
ToolTip.delay: 500
ToolTip.timeout: 2000
ToolTip.visible: hovered
ToolTip.text: qsTr("New user to be created shell")
onEditingFinished: {
new_user_shell = newUserShellTextFieldId.text
}
}
}
Row {
width: parent.width
//bottomPadding: 10
// new user Password label & TextField
//
Label {
text: "User Password "
id: newUserPasswordLabelId
}
TextField {
id: newUserPasswordTextFieldId
width: userMgmntId.width - newUserPasswordLabelId.width - 14
// remove border color from the text field
background: Rectangle {
border.color: "transparent"
}
echoMode: TextInput.Password
placeholderText: " new user's password"
placeholderTextColor: "lightgray"
ToolTip.delay: 500
ToolTip.timeout: 2000
ToolTip.visible: hovered
ToolTip.text: qsTr("New user to be created password")
onEditingFinished: {
new_user_encr_password = newUserPasswordTextFieldId.text
// Here ,also call the C++ function to update passwords complexity
// If Uppercase letter exists: +1 || Lowercase: +1 || specialcharacter: +1 || digit: +1
myManager.setPassComplexity(new_user_encr_password)
}
}
}
// A ProgressBar that illustrates how strong the entered password is
//
Row {
width: parent.width
//bottomPadding: 10
ProgressBar {
id: howStrongPassIs
from: 10
to: 100
value: getPassComplexity()
height: 10
ToolTip.delay: 500
ToolTip.timeout: 4000
ToolTip.visible: hovered
ToolTip.text: qsTr("Classes: Lowercase | Uppercase | Digit | Special character\nWeak: 1 class | Medium: 2 classes | Strong: 3 classes | Very Strong: 4 classes")
//indeterminate: true
}
}
/////////////////////////////////////////////////////////////////////
Row {
width: parent.width
bottomPadding: 10
// Show passwords CheckBox Column
Switch {
id: showNewUserPasswdsSwitchId
text: "Show Password"
checked: false
onCheckedChanged: {
if(checked === true) {
newUserPasswordTextFieldId.echoMode = TextInput.Normal
} else {
newUserPasswordTextFieldId.echoMode = TextInput.Password
}
}
}
}
Row {
width: parent.width
bottomPadding: 10
// Clear all User Management Fields
Switch {
id: clearUserMgmntSwitchId
text: qsTr("Clear User Management Text Fields")
checked: false
onCheckedChanged: {
if(checked === true) {
newUsernameTextFieldId.text = ""
newUserGroupTextFieldId.text = ""
newUserRealnameTextFieldId.text = ""
newUserIDTextFieldId.text = ""
newUserShellTextFieldId.text = ""
newUserPasswordTextFieldId.text = ""
}
}
}
}
Row {
bottomPadding: 10
width: parent.width
// new user Confirm CheckBox Column
CheckBox {
text: "Confirm above elements"
checked: false
// when clicked, check if username or password of the new user is empty !
// IF empty , do not proceed
onClicked: {
if(checked === true) {
if(new_username === "" || new_user_encr_password === "") {
genericMessageDialog.text = "New user to be created username and password should be both specified! Please enter them and try again!"
genericMessageDialog.title = "CONFIRM ACTION ERROR"
genericMessageDialog.open()
} else if(myManager.is_username_valid(new_username)===false) {
genericMessageDialog.text = "Invalid username. Type another one and try again!"
genericMessageDialog.title = "USERNAME ERROR"
genericMessageDialog.open()
} else {
// call c++ code to pass string values from QML elements (TExtFieds) to c++ QString variables
// uername - real name (comment) - group - ID - user shell - password
//
myManager.setNew_username(new_username)
myManager.setNew_user_realname(new_user_realname)
myManager.setNew_user_group(new_user_group)
myManager.setNew_user_id(new_user_id)
myManager.setNew_user_shell(new_user_shell)
myManager.setNew_user_encr_password(new_user_encr_password)
}
}
}
}
}
Row {
bottomPadding: 10
width: parent.width
// new user 'CREATE' PushButton && 'REMOVE' DelayButton Row
RowLayout {
Button {
id: createNewUserButtonId
text: qsTr("CREATE")
ToolTip.delay: 500
ToolTip.timeout: 1500
ToolTip.text: qsTr("Create a new user!")
ToolTip.visible: hovered
onClicked: {
// check if 'Submit Credentials' is checked in order to enter this CREATE user procedure
//
if(myManager.getUsername()==="" && myManager.getPassword()==="") {
// display a message that credentials should be entered
genericMessageDialog.text = "Credentials should be provided to create a user!"
genericMessageDialog.title = "CREATE ACTION ERROR"
genericMessageDialog.open()
} else {
// Next check: If the new user username & password 'at least' are not provided, then abort
// DIsplay a message that the new user information should be provided
//
if(myManager.getNew_username()==="" || myManager.getNew_user_encr_password()==="") {
genericMessageDialog.text = "At least provide new user's username and password to create a new user!"
genericMessageDialog.title = "CREATE ACTION ERROR"
genericMessageDialog.open()
} else {
if(myManager.is_username_valid() === true) {
if(myManager.user_exists() === false) {
// if the user does not exist , then create him
if(myManager.adduser() === true) {
genericMessageDialog.text = qsTr("User: " + myManager.getNew_username() + " was succesfully created!")
genericMessageDialog.title = "CREATE ACTION INFO"
genericMessageDialog.open()
} else {
genericMessageDialog.text = qsTr("User: " + myManager.getNew_username() + " failed to be created! Please try again!")
genericMessageDialog.title = "CREATE ACTION ERROR"
genericMessageDialog.open()
}
}
} else {
genericMessageDialog.text = qsTr("User: " + myManager.getNew_username() + " is invalid. Try with another!")
genericMessageDialog.title = "CREATE ACTION ERROR"
genericMessageDialog.open()
}
}
}
}
}
DelayButton {
id: removeUserDelayButtonId
property bool userdelActivate: false
delay: 1000
text: qsTr("REMOVE")
//anchors.left: parent.right
ToolTip.delay: 500
ToolTip.timeout: 1500
ToolTip.text: qsTr("Remove a user from your Linux desktop!")
ToolTip.visible: hovered
onActivated: {
userdelActivate = true
}
onClicked: {
if(new_username==="" && new_user_encr_password==="") {
genericMessageDialog.text = "Please provide the user's username to remove"
genericMessageDialog.title = "REMOVE USER ERROR"
genericMessageDialog.open()
} else {
if(userdelActivate===true) {
if(myManager.user_exists() === false) {
genericMessageDialog.text = "Cannot remove user that does not exist in the system."
genericMessageDialog.title = "REMOVE ACTION ERROR"
genericMessageDialog.open()
} else {
if(myManager.deluser() === true && myManager.del_user_home()) {
genericMessageDialog.text = qsTr("Just deleted user: " + new_username + " from your system!")
genericMessageDialog.title = "REMOVE ACTION ERROR"
genericMessageDialog.open()
}
}
} else {
genericMessageDialog.text = "Please activate the REMOVE DelayButton in order to continue!"
genericMessageDialog.title = "REMOVE ACTION ERROR"
genericMessageDialog.open()
}
}
}
}
}
}
}
}
/* SYSTEM & NETWORKING INFORMATION */
GroupBox {
id: systemInfoGroupBox
title: qsTr("System & Networking Information")
x: 5
width: credsGroupBoxId.width
height: userMgmntId.height - 70
anchors.left: credsGroupBoxId.right
anchors.top: rootElementId.top
font: Qt.font({family: "Helvetica", pointSize: 9, italic: true, bold: true})
spacing: 5
leftInset: 20
// ColumnLayout for various checkBoxes
//
ColumnLayout {
id: systemInfoColumnId
anchors.left: parent.left
Row {
bottomPadding: 10
leftPadding: 20
// Show real system users
CheckBox {
id: catUsersId
text: "Show real users"
checked: false
onClicked: {
if(checked===true) {
// capture the real users calling appropriate c++ function
genericMessageDialog.text = qsTr(myManager.cat_users())
genericMessageDialog.title = "Real Users"
genericMessageDialog.open()
catUsersId.checked = false
}
}
}
}
Row {
bottomPadding: 10
leftPadding: 20
// Show real groups
CheckBox {
id: catGroupsId
text: "Show real groups"
onClicked: {
if(checked===true) {
// capture the real groups calling appropriate c++ function
genericMessageDialog.text = qsTr(myManager.cat_groups())
genericMessageDialog.title = "Real Groups"
genericMessageDialog.open()
catGroupsId.checked = false
}
}
}
}
Row {
bottomPadding: 10
leftPadding: 20
// show available shells
CheckBox {
id: catShells
text: "Show available system shells"
onClicked: {
if(checked===true) {
// capture the system shells calling appropriate c++ function
genericMessageDialog.text = qsTr(myManager.cat_shells())
genericMessageDialog.title = "Available System Shells"
genericMessageDialog.open()
catShells.checked = false
}
}
}
}
Row {
bottomPadding: 10
leftPadding: 20
// Show Networking interfaces
CheckBox {
id: interfacesId
text: "Show Network Interfaces"
onClicked: {
if(checked===true) {
// capture Network Interfaces calling appropriate c++ function
genericMessageDialog.text = qsTr(myManager.ifconfig())
genericMessageDialog.title = "Network Interfaces"
genericMessageDialog.open()
interfacesId.checked = false
}
}
}
}
Row {
bottomPadding: 10
leftPadding: 20
// Show Routing Table
CheckBox {
id: routingTableCheckBox
text: "Show Routing Table"
onClicked: {
if(checked===true) {
genericMessageDialog.text = qsTr(myManager.netstat())
genericMessageDialog.title = "Routing Table"
genericMessageDialog.open()
routingTableCheckBox.checked = false
}
}
}
}
Row {
bottomPadding: 10
leftPadding: 20
// Show Routing table
CheckBox {
id: firewall_4Id
text: "Show IPv4 Firewall Configuration"
onClicked: {
if(username==="" || passwordTextField1Id.text==="") {
//
genericMessageDialog.text = qsTr("Please provide your username & password to check IPv4 Firewall Configuration!")
genericMessageDialog.title = "WARNING"
genericMessageDialog.open()
firewall_4Id.checked = false
} else {
///////////////////////////////// IPv4 /////////////////////////
genericMessageDialog.text = qsTr(myManager.ip4tables() )
genericMessageDialog.title = qsTr("IPv4 Firewall Configuration " + myManager.getTable() + " Table")
genericMessageDialog.open()
firewall_4Id.checked = false
}
}
}
}
Row {
bottomPadding: 10
leftPadding: 20
// Show Routing table
CheckBox {
id: firewall_6Id
text: "Show IPv6 Firewall Configuration"
onClicked: {
if(username==="" || passwordTextField1Id.text==="") {
//
genericMessageDialog.text = qsTr("Please provide your username & password to check IPv6 Firewall Configuration!")
genericMessageDialog.title = "WARNING"
genericMessageDialog.open()
firewall_6Id.checked = false
} else {
///////////////////////////////// IPv6 /////////////////////////
genericMessageDialog.text = qsTr(myManager.ip6tables() )
genericMessageDialog.title = qsTr("IPv6 Firewall Configuration " + myManager.getTable() + " Table")
genericMessageDialog.open()
firewall_6Id.checked = false
}
}