PWD.qml 7.8 KB

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