PWD.qml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. import QtQuick 2.5
  2. import Qt.labs.controls 1.0
  3. import QtQuick.Layouts 1.1
  4. import "qrc:/Globals"
  5. Rectangle {
  6. property int roleFontSize: 20
  7. property int roleRectHeight: 40
  8. id: root
  9. width: parent.width
  10. height: parent.height
  11. color: "white"
  12. Flickable {
  13. id: flickable
  14. anchors.fill: parent
  15. contentWidth: content.width
  16. contentHeight: content.height
  17. interactive: contentHeight > height
  18. flickableDirection: Flickable.VerticalFlick
  19. Item {
  20. id: content
  21. x: 0
  22. y: 0
  23. width: flickable.width
  24. //============================================================================
  25. Rectangle {
  26. id: rectangle
  27. x: 0
  28. y: 0
  29. width: root.width
  30. height: root.height
  31. color: "white"
  32. // Rectangle {
  33. // property string userRole: "oper"
  34. // id: userRoleOperRECT
  35. // x: (parent.width / 17) * 2
  36. // y: (parent.height / 3) / 2
  37. // width: (parent.width / 17) * 3
  38. // height: roleRectHeight
  39. // color: Globals.actUserRole == userRole?Globals.customer_color_base:"lightgray"
  40. // border.color: Globals.actUserRole != userRole?Globals.customer_color_base:"lightgray"
  41. // border.width: 3
  42. // Label {
  43. // anchors.centerIn: parent
  44. // font.pixelSize: roleFontSize
  45. // text: Globals.getActUserRoleText(parent.userRole)
  46. // }
  47. // MouseArea {
  48. // anchors.fill : parent
  49. // onClicked: {
  50. // sysinfo.beep();
  51. // Globals.actUserRole = parent.userRole;
  52. // stackView.push(Qt.resolvedUrl("HMI_MainMenu.qml"));
  53. // }
  54. // }
  55. // }
  56. // Rectangle {
  57. // property string userRole: "eng"
  58. // id: userRoleEngRECT
  59. // x: (parent.width / 17) * 7
  60. // y: (parent.height / 3) / 2
  61. // width: (parent.width / 17) * 3
  62. // height: roleRectHeight
  63. // color: Globals.actUserRole == userRole?Globals.customer_color_base:"lightgray"
  64. // border.color: Globals.actUserRole != userRole?Globals.customer_color_base:"lightgray"
  65. // border.width: 3
  66. // Label {
  67. // anchors.centerIn: parent
  68. // font.pixelSize: roleFontSize
  69. // text: Globals.getActUserRoleText(parent.userRole)
  70. // }
  71. // MouseArea {
  72. // anchors.fill : parent
  73. // onClicked: {
  74. // sysinfo.beep();
  75. // Globals.actUserRole = parent.userRole;
  76. // if (settings.value("UserRoleEng/Password", "*") === "*") {
  77. // pwdINPUT.focus = false;
  78. // Qt.inputMethod.hide();
  79. // stackView.push(Qt.resolvedUrl("HMI_MainMenu.qml"));
  80. // } else {
  81. // pwdINPUT.focus = false;
  82. // pwdINPUT.focus = true;
  83. // }
  84. // }
  85. // }
  86. // }
  87. Rectangle {
  88. property string userRole: "admin"
  89. id: userRoleAdminRECT
  90. x: (parent.width / 17) * 7 //12
  91. y: (parent.height / 3) / 2
  92. width: (parent.width / 17) * 3
  93. height: roleRectHeight
  94. color: Globals.actUserRole == userRole?Globals.customer_color_base:"lightgray"
  95. border.color: Globals.actUserRole != userRole?Globals.customer_color_base:"lightgray"
  96. border.width: 3
  97. Label {
  98. anchors.centerIn: parent
  99. font.pixelSize: roleFontSize
  100. text: Globals.getActUserRoleText(parent.userRole)
  101. }
  102. MouseArea {
  103. anchors.fill : parent
  104. onClicked: {
  105. sysinfo.beep();
  106. Globals.actUserRole = parent.userRole;
  107. if (settings.value("UserRoleAdmin/Password", "*") === "*") {
  108. pwdINPUT.focus = false;
  109. Qt.inputMethod.hide();
  110. stackView.push(Qt.resolvedUrl("HMI_MainMenu.qml"));
  111. } else {
  112. pwdINPUT.focus = false;
  113. pwdINPUT.focus = true;
  114. }
  115. }
  116. }
  117. }
  118. Rectangle {
  119. id : pwdRECT
  120. x: (parent.width / 17) * 7
  121. y: (parent.height / 6) * 3
  122. width: (parent.width / 17) * 3
  123. height: 40
  124. radius: 4
  125. color: "silver"
  126. TextInput {
  127. id: pwdINPUT
  128. x: (parent.height - font.pixelSize) / 2
  129. y: x
  130. width: parent.width - (parent.height - font.pixelSize)
  131. clip: true
  132. color: "black"
  133. font.pixelSize: 25
  134. echoMode: TextInput.Password
  135. passwordMaskDelay: 250
  136. text: ""
  137. onAccepted: {
  138. console.debug(" TXT " + text + " " + Qt.md5(text));
  139. if(((settings.value("UserRoleEng/Password", "*") === Qt.md5(text)) && (Globals.actUserRole === "eng")) ||
  140. ((settings.value("UserRoleEng/Password", "*") === "*") && (Globals.actUserRole === "eng")) ) {
  141. focus = false;
  142. Qt.inputMethod.hide();
  143. stackView.push(Qt.resolvedUrl("HMI_MainMenu.qml"));
  144. }
  145. if(((settings.value("UserRoleAdmin/Password", "*") === Qt.md5(text)) && (Globals.actUserRole === "admin")) ||
  146. ((settings.value("UserRoleAdmin/Password", "*") === "*") && (Globals.actUserRole === "admin")) ) {
  147. focus = false;
  148. Qt.inputMethod.hide();
  149. stackView.push(Qt.resolvedUrl("HMI_MainMenu.qml"));
  150. }
  151. text = "";
  152. }
  153. }
  154. }
  155. Timer {
  156. interval: 1
  157. running: Globals.startTO.length > 0 ? true:false
  158. onTriggered: {
  159. if (Globals.startTO.length > 0) {
  160. stackView.push(Qt.resolvedUrl("HMI_MainMenu.qml"));
  161. }
  162. }
  163. }
  164. }
  165. //============================================================================
  166. }
  167. }
  168. }