ADMIN_Settings.qml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. import QtQuick 2.5
  2. import QtQuick.Controls 1.4
  3. import QtQuick.Layouts 1.0
  4. import ApplicationLauncher 1.0
  5. import "qrc:/Globals"
  6. Rectangle {
  7. id: root
  8. width: parent.width
  9. height: parent.height
  10. color: "white"
  11. border.color: "red"
  12. border.width: 3
  13. property color inputBackgrund: "lightgray"
  14. property int inputRadius: 4
  15. property int inputHeight: 40
  16. property int inputFontSize: 22
  17. Flickable {
  18. id: flickable
  19. anchors.fill: parent
  20. contentWidth: content.width
  21. contentHeight: content.height
  22. interactive: contentHeight > height
  23. flickableDirection: Flickable.VerticalFlick
  24. Item {
  25. id: content
  26. x: 0
  27. y: 0
  28. width: flickable.width
  29. //============================================================================
  30. ApplicationLaunch {
  31. id: factoryResetSCRIPT
  32. appName: ""
  33. arguments: ""
  34. onAppFinished: {
  35. Qt.quit(); //Beenden und am Target neustarten
  36. }
  37. }
  38. Rectangle {
  39. property int factoryRestFontSize: 20
  40. property int factoryResetRectHeight: 40
  41. id: factoryResetRECT
  42. x: root.width - root.width * 0.03 - width
  43. y: (root.height / 12)
  44. width: factoryResetLabel.implicitWidth * 1.2
  45. height: factoryResetLabel.implicitHeight * 2
  46. color: Globals.customer_color_base
  47. border.color: "lightgray"
  48. border.width: 3
  49. Label {
  50. id: factoryResetLabel
  51. anchors.centerIn: parent
  52. font.pixelSize: roleFontSize
  53. //:ID: admin_factory_reset_butt buttontext for factory reset button
  54. text: qsTrId("_factory_reset")
  55. }
  56. MouseArea {
  57. anchors.fill : parent
  58. onClicked: {
  59. sysinfo.beep();
  60. factoryResetSCRIPT.appName = Globals.baseDir + "/Scripts/FactoryReset.sh " + sysinfo.currentCpuArchitecture;
  61. factoryResetSCRIPT.launchScript();
  62. }
  63. }
  64. }
  65. // Rectangle {
  66. // id : pwdEngRECT
  67. // x: (root.width / 17) * 4
  68. // y: (root.height / 6)
  69. // width: (parent.width / 17) * 3
  70. // height: inputHeight
  71. // radius: inputRadius
  72. // color: inputBackgrund
  73. // TextInput {
  74. // id: pwdEngINPUT
  75. // y: (parent.height - font.pixelSize) / 2
  76. // x: y
  77. // width: parent.width - (parent.height - font.pixelSize)
  78. // clip: true
  79. // color: "black"
  80. // font.pixelSize: inputFontSize
  81. // echoMode: TextInput.Password
  82. // passwordMaskDelay: 250
  83. // text: ""
  84. // onAccepted: {
  85. // }
  86. // Keys.onPressed: {
  87. // if(event.key == Qt.Key_Left) {
  88. // pwdAdminRepeatINPUT.focus = true;
  89. // }
  90. // if(event.key == Qt.Key_Right) {
  91. // pwdEngRepeatINPUT.focus = true;
  92. // }
  93. // if(event.key == Qt.Key_Up)
  94. // {
  95. // pwdAdminINPUT.focus = true;
  96. // }
  97. // if(event.key == Qt.Key_Down)
  98. // {
  99. // pwdAdminINPUT.focus = true;
  100. // }
  101. // if((event.key == Qt.Key_Enter) || (event.key == Qt.Key_Return))
  102. // {
  103. // pwdEngRepeatINPUT.focus = true;
  104. // }
  105. // }
  106. // }
  107. // }
  108. // Rectangle {
  109. // id : pwdEngRepatRECT
  110. // x: (root.width / 17) * 8
  111. // y: (root.height / 6)
  112. // width: (parent.width / 17) * 3
  113. // height: inputHeight
  114. // radius: inputRadius
  115. // color: inputBackgrund
  116. // TextInput {
  117. // id: pwdEngRepeatINPUT
  118. // x: (parent.height - font.pixelSize) / 2
  119. // y: x
  120. // width: parent.width - (parent.height - font.pixelSize)
  121. // clip: true
  122. // color: "black"
  123. // font.pixelSize: inputFontSize
  124. // echoMode: TextInput.Password
  125. // passwordMaskDelay: 250
  126. // text: ""
  127. // onAccepted: {
  128. // }
  129. // Keys.onPressed: {
  130. // if(event.key == Qt.Key_Left) {
  131. // pwdEngINPUT.focus = true;
  132. // }
  133. // if(event.key == Qt.Key_Right) {
  134. // pwdAdminINPUT.focus = true;
  135. // }
  136. // if(event.key == Qt.Key_Up)
  137. // {
  138. // pwdAdminRepeatINPUT.focus = true;
  139. // }
  140. // if(event.key == Qt.Key_Down)
  141. // {
  142. // pwdAdminRepeatINPUT.focus = true;
  143. // }
  144. // if((event.key == Qt.Key_Enter) || (event.key == Qt.Key_Return))
  145. // {
  146. // pwdAdminINPUT.focus = true;
  147. // }
  148. // }
  149. // }
  150. // }
  151. // Rectangle {
  152. // id : pwdEngRECTLAB
  153. // x: (root.width / 17) / 3
  154. // y: (root.height / 6)
  155. // width: (parent.width / 17) * 3
  156. // height: inputHeight
  157. // Label {
  158. // id: pwdEngLABEL
  159. // x: (parent.height - font.pixelSize) / 2
  160. // y: x
  161. // font.pixelSize: inputFontSize
  162. // text: Globals.getActUserRoleText("eng")
  163. // }
  164. // }
  165. // ButtHMI {
  166. // id : pwdEngBUTT
  167. // property bool isValid : ((pwdEngINPUT.length > 0) && (pwdEngINPUT.text == pwdEngRepeatINPUT.text)) ? true : false
  168. // buttX: (root.width / 17) * 12
  169. // buttY: (root.height / 6)
  170. // buttWidth: inputHeight
  171. // buttHeight: buttWidth
  172. // text: "\uf0c7" //floppy-sign
  173. // color: isValid == true ?Globals.customer_color_base:inputBackgrund //((pwdEngINPUT.length > 0) && (pwdEngINPUT.text == pwdEngRepeatINPUT.text)) ? Globals.customer_color_base : inputBackgrund
  174. // borderColor: color
  175. // onButtPressed: {
  176. // if(isValid) {
  177. // if(pwdEngINPUT.text == "*")
  178. // settings.setValue("UserRoleEng/Password", "*");
  179. // else
  180. // settings.setValue("UserRoleEng/Password", Qt.md5(pwdEngINPUT.text));
  181. // pwdEngINPUT.text = pwdEngRepeatINPUT.text = "";
  182. // }
  183. // }
  184. // }
  185. Rectangle {
  186. id : pwdAdminRECT
  187. x: (root.width / 17) * 4
  188. y: (root.height / 6) * 3
  189. width: (parent.width / 17) * 3
  190. height: inputHeight
  191. radius: inputRadius
  192. color: inputBackgrund
  193. TextInput {
  194. id: pwdAdminINPUT
  195. x: (parent.height - font.pixelSize) / 2
  196. y: x
  197. width: parent.width - (parent.height - font.pixelSize)
  198. clip: true
  199. color: "black"
  200. font.pixelSize: inputFontSize
  201. echoMode: TextInput.Password
  202. passwordMaskDelay: 250
  203. text: ""
  204. onAccepted: {
  205. }
  206. Keys.onPressed: {
  207. if(event.key == Qt.Key_Left) {
  208. pwdEngRepeatINPUT.focus = true;
  209. }
  210. if(event.key == Qt.Key_Right) {
  211. pwdAdminRepeatINPUT.focus = true;
  212. }
  213. if(event.key == Qt.Key_Up)
  214. {
  215. pwdEngINPUT.focus = true;
  216. }
  217. if(event.key == Qt.Key_Down)
  218. {
  219. pwdEngINPUT.focus = true;
  220. }
  221. if((event.key == Qt.Key_Enter) || (event.key == Qt.Key_Return))
  222. {
  223. pwdAdminRepeatINPUT.focus = true;
  224. }
  225. }
  226. }
  227. }
  228. Rectangle {
  229. id : pwdAdminRepatRECT
  230. x: (root.width / 17) * 8
  231. y: (root.height / 6) * 3
  232. width: (parent.width / 17) * 3
  233. height: inputHeight
  234. radius: inputRadius
  235. color: inputBackgrund
  236. TextInput {
  237. id: pwdAdminRepeatINPUT
  238. x: (parent.height - font.pixelSize) / 2
  239. y: x
  240. width: parent.width - (parent.height - font.pixelSize)
  241. clip: true
  242. color: "black"
  243. font.pixelSize: inputFontSize
  244. passwordMaskDelay: 250
  245. echoMode: TextInput.Password
  246. text: ""
  247. onAccepted: {
  248. }
  249. Keys.onPressed: {
  250. if(event.key == Qt.Key_Left) {
  251. pwdAdminINPUT.focus = true;
  252. }
  253. if(event.key == Qt.Key_Right) {
  254. pwdEngINPUT.focus = true;
  255. }
  256. if(event.key == Qt.Key_Up)
  257. {
  258. pwdEngRepeatINPUT.focus = true;
  259. }
  260. if(event.key == Qt.Key_Down)
  261. {
  262. pwdEngRepeatINPUT.focus = true;
  263. }
  264. if((event.key == Qt.Key_Enter) || (event.key == Qt.Key_Return))
  265. {
  266. pwdEngINPUT.focus = true;
  267. }
  268. }
  269. }
  270. }
  271. Rectangle {
  272. id : pwdAdminRECTLAB
  273. x: (root.width / 17) / 3
  274. y: (root.height / 6) * 3
  275. width: (parent.width / 17) * 3
  276. height: inputHeight
  277. Label {
  278. id: pwdAdminLABEL
  279. x: (parent.height - font.pixelSize) / 2
  280. y: x
  281. font.pixelSize: inputFontSize
  282. text: Globals.getActUserRoleText("admin")
  283. }
  284. }
  285. ButtHMI {
  286. id : pwdAdminBUTT
  287. property bool isValid : ((pwdAdminINPUT.length > 0) && (pwdAdminINPUT.text == pwdAdminRepeatINPUT.text)) ? true : false
  288. buttX: (root.width / 17) * 12
  289. buttY: (root.height / 6) * 3
  290. buttWidth: inputHeight
  291. buttHeight: buttWidth
  292. text: "\uf0c7" //floppy-sign
  293. color: isValid == true ?Globals.customer_color_base:inputBackgrund
  294. borderColor: color
  295. onButtPressed: {
  296. if(isValid) {
  297. if(pwdAdminINPUT.text == "*")
  298. settings.setValue("UserRoleAdmin/Password", "*");
  299. else
  300. settings.setValue("UserRoleAdmin/Password", Qt.md5(pwdAdminINPUT.text));
  301. pwdAdminINPUT.text = pwdAdminRepeatINPUT.text = "";
  302. }
  303. }
  304. }
  305. //============================================================================
  306. }
  307. }
  308. }