HMI_Settings.qml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. import QtQuick 2.5
  2. import QtQuick.Controls 1.4
  3. import QtQuick.Controls.Styles 1.4
  4. //import Qt.labs.controls 1.0
  5. import QtQuick.Controls 2.0
  6. import QtQuick.Layouts 1.1
  7. import QtQml 2.2
  8. import ApplicationLauncher 1.0
  9. import "qrc:/Globals"
  10. Rectangle {
  11. id: root
  12. width: parent.width
  13. height: parent.height
  14. color: "white"
  15. Flickable {
  16. id: flickable
  17. anchors.fill: parent
  18. contentWidth: content.width
  19. contentHeight: content.height
  20. interactive: contentHeight > height
  21. flickableDirection: Flickable.VerticalFlick
  22. Item {
  23. id: content
  24. x: 0
  25. y: 0
  26. width: flickable.width
  27. //============================================================================
  28. Component.onCompleted: {
  29. setEth0.doGetInterface();
  30. hmiIP.ipFocus = 0;
  31. }
  32. Rectangle {
  33. id: setNetworkADDRESS
  34. width: root.width / 2
  35. height: root.height
  36. //border.color: "blue"
  37. //border.width: 2
  38. property double ipDisplayFontSize: (height / 16) * 0.74
  39. property int ipsettingsXpos: (width / 3) * 1.25
  40. property double ipsettingsWidth: width - ipsettingsXpos
  41. // Rectangle{
  42. // x: 100
  43. // y: 50
  44. // width:200
  45. // height: 50
  46. // color: "lightgray"
  47. // Switch {
  48. // id:dhcpSWITCH
  49. // checked: false
  50. // text: (checked)?"DHCP":"STATIC"
  51. // font.pixelSize: 20
  52. // onCheckedChanged: {
  53. // hmiIP.ipvisible = !checked;
  54. // hmiNETMASK.ipvisible = !checked;
  55. // hmiGATEWAY.ipvisible = !checked;
  56. // hmiDNS.ipvisible = !checked;
  57. // }
  58. // }
  59. // }
  60. Label {
  61. id: lab1
  62. x: hmiIP.posX - lab1.implicitWidth
  63. y: hmiIP.posY
  64. // visible: !dhcpSWITCH.checked
  65. font.pixelSize: parent.ipDisplayFontSize //20
  66. //: ID:_sys_ipaddress Ip Address settings
  67. text: qsTrId("_sys_ipaddress") + " : " + transLoad.emptyString //qsTr("IP-Adresse : ") + transLoad.emptyString
  68. }
  69. IpAddressInput {
  70. id: hmiIP
  71. posX: parent.ipsettingsXpos
  72. posY: parent.height / 16 * 4
  73. ipwidth: parent.ipsettingsWidth
  74. ipcolor: "black"
  75. ipFontSize: parent.ipDisplayFontSize //20
  76. onIpAddressChanged: {
  77. setEth0.address = ipAddress;
  78. }
  79. onKeyDownPressed: {
  80. var foc = ipFocus;
  81. ipFocus = 0;
  82. hmiNETMASK.ipFocus = foc;
  83. }
  84. onKeyUpPressed: {
  85. var foc = ipFocus;
  86. ipFocus = 0;
  87. hmiDNS.ipFocus = foc;
  88. }
  89. }
  90. Label {
  91. id: lab2
  92. x: hmiNETMASK.posX - lab2.implicitWidth
  93. y: hmiNETMASK.posY
  94. // visible: !dhcpSWITCH.checked
  95. font.pixelSize: parent.ipDisplayFontSize // 20
  96. //: ID:_sys_netmask Ip Address settings Netmask
  97. text: qsTrId("_sys_netmask") + " : " + transLoad.emptyString //qsTr("Netmask : ") + transLoad.emptyString
  98. }
  99. IpAddressInput {
  100. id: hmiNETMASK
  101. posX: parent.ipsettingsXpos
  102. posY: parent.height / 16 * 6
  103. ipwidth: parent.ipsettingsWidth
  104. ipcolor: "black"
  105. ipFontSize: parent.ipDisplayFontSize //20
  106. onIpAddressChanged: {
  107. setEth0.netmask = ipAddress;
  108. }
  109. onKeyDownPressed: {
  110. var foc = ipFocus;
  111. ipFocus = 0;
  112. hmiGATEWAY.ipFocus = foc;
  113. }
  114. onKeyUpPressed: {
  115. var foc = ipFocus;
  116. ipFocus = 0;
  117. hmiIP.ipFocus = foc;
  118. }
  119. }
  120. Label {
  121. id: lab3
  122. x: hmiGATEWAY.posX - lab3.implicitWidth
  123. y: hmiGATEWAY.posY
  124. // visible: !dhcpSWITCH.checked
  125. font.pixelSize: parent.ipDisplayFontSize //20
  126. //: ID:_sys_defaultrouter Ip Address settings Defaultrouter
  127. text: qsTrId("_sys_defaultrouter") + " : " + transLoad.emptyString //qsTr("Def. Router : ") + transLoad.emptyString
  128. }
  129. IpAddressInput {
  130. id: hmiGATEWAY
  131. posX: parent.ipsettingsXpos
  132. posY: parent.height / 16 * 8
  133. ipwidth: parent.ipsettingsWidth
  134. ipcolor: "black"
  135. ipFontSize: parent.ipDisplayFontSize //20
  136. onIpAddressChanged: {
  137. setEth0.gateway = ipAddress;
  138. }
  139. onKeyDownPressed: {
  140. var foc = ipFocus;
  141. ipFocus = 0;
  142. hmiDNS.ipFocus = foc;
  143. }
  144. onKeyUpPressed: {
  145. var foc = ipFocus;
  146. ipFocus = 0;
  147. hmiNETMASK.ipFocus = foc;
  148. }
  149. }
  150. Label {
  151. id: lab4
  152. x: hmiDNS.posX - lab4.implicitWidth
  153. y: hmiDNS.posY
  154. // visible: !dhcpSWITCH.checked
  155. font.pixelSize: parent.ipDisplayFontSize //20
  156. //: ID:_sys_dns1 Ip Address settings DNS Server 1
  157. text: qsTrId("_sys_dns1") + " : " + transLoad.emptyString //qsTr("DNS Server : ") + transLoad.emptyString
  158. }
  159. IpAddressInput {
  160. id: hmiDNS
  161. posX: parent.ipsettingsXpos
  162. posY: parent.height / 16 * 10
  163. ipwidth: parent.ipsettingsWidth
  164. ipcolor: "black"
  165. ipFontSize: parent.ipDisplayFontSize //20
  166. onIpAddressChanged: {
  167. setEth0.nameserver = ipAddress;
  168. }
  169. onKeyDownPressed: {
  170. var foc = ipFocus;
  171. ipFocus = 0;
  172. hmiIP.ipFocus = foc;
  173. }
  174. onKeyUpPressed: {
  175. var foc = ipFocus;
  176. ipFocus = 0;
  177. hmiGATEWAY.ipFocus = foc;
  178. }
  179. }
  180. ButtHMI {
  181. buttX: parent.width/3 * 0.5
  182. buttY: parent.height / 16 * 12
  183. buttWidth:parent.height / 16 * 2
  184. buttHeight: buttWidth
  185. text: "\uf0c7" //floppy-sign
  186. color: Globals.customer_color_base
  187. onButtPressed: {
  188. hmiIP.makeIpAddress();
  189. hmiNETMASK.makeIpAddress();
  190. hmiGATEWAY.makeIpAddress();
  191. hmiDNS.makeIpAddress();
  192. setEth0.doSetInterface();
  193. }
  194. }
  195. ButtHMI {
  196. buttX: parent.width/3 * 1.5
  197. buttY: parent.height / 16 * 12
  198. buttWidth: parent.height / 16 * 2
  199. buttHeight: buttWidth
  200. color: Globals.customer_color_base
  201. text: "\uf046" //check-sqare
  202. onButtPressed: {
  203. hmiIP.makeIpAddress();
  204. hmiNETMASK.makeIpAddress();
  205. hmiGATEWAY.makeIpAddress();
  206. hmiDNS.makeIpAddress();
  207. setEth0.doRestartNetwork();
  208. }
  209. }
  210. ButtHMI {
  211. id: buttUPDATE
  212. buttX: parent.width/3 * 2.5
  213. buttY: parent.height / 16 * 12
  214. buttWidth: parent.height / 16 * 2
  215. buttHeight: buttWidth
  216. visible: false
  217. color: Globals.customer_color_base
  218. text: "\uf0c5" //files -- für Update
  219. onButtPressed: {
  220. console.debug("Update Button Pressed");
  221. updateHMI.popupVISIBLE = true;
  222. }
  223. }
  224. HMI_UpdatePopup {
  225. id: updateHMI
  226. popupVISIBLE: false
  227. //: ID:_sys_update_hmi Headline HMI Updatewindow
  228. popupTEXT: qsTrId("_sys_update_hmi") + transLoad.emptyString
  229. }
  230. SetNetworkInterface {
  231. id: setEth0
  232. mode: "static"
  233. ifacename: "eth0"
  234. address: "192.168.0.125"
  235. netmask: "255.255.0.0"
  236. nameserver: "192.168.0.1"
  237. gateway: "192.168.0.1"
  238. infile: (sysinfo.currentCpuArchitecture == "x86_64") ?"/home/ru/IFACE/interfaces":"/etc/network/interfaces"
  239. outfile: (sysinfo.currentCpuArchitecture == "x86_64") ?"/home/ru/IFACE/interfaces":"/etc/network/interfaces"
  240. onAddressChanged: {
  241. hmiIP.ipAddress = address;
  242. }
  243. onNetmaskChanged: {
  244. hmiNETMASK.ipAddress = netmask;
  245. }
  246. onGatewayChanged: {
  247. hmiGATEWAY.ipAddress = gateway;
  248. }
  249. onNameserverChanged: {
  250. hmiDNS.ipAddress = nameserver;
  251. }
  252. onCmdDone: {
  253. hmiIP.ipAddress = setEth0.address;
  254. hmiNETMASK.ipAddress = setEth0.netmask;
  255. hmiGATEWAY.ipAddress = setEth0.gateway;
  256. hmiDNS.ipAddress = setEth0.nameserver;
  257. }
  258. }
  259. }
  260. //============================================================================
  261. //Language settings
  262. Rectangle {
  263. id: langSelect
  264. width: (height / 5) * 1.5
  265. height: root.height
  266. x: root.width / 2
  267. y:0
  268. color: "lightgray"
  269. function dispLang(){
  270. // setze aktive Sprache
  271. idACTLANGIMG.source = "qrc:/Languages/FLAG-" + transLoad.getActiveLanguage() + ".svg";
  272. var languages = transLoad.getLanguages();
  273. langData.clear();
  274. languages.forEach(function(entry) {
  275. if (entry.length > 0) {
  276. console.debug(JSON.stringify(entry));
  277. langData.append( {flag: "qrc:/Languages/FLAG-" + entry + ".svg",
  278. name: entry
  279. } );
  280. }
  281. });
  282. }
  283. Image {
  284. x: 0
  285. y: 0
  286. id: idACTLANGIMG
  287. fillMode: Image.PreserveAspectFit
  288. sourceSize.height: parent.height / 5
  289. sourceSize.width: parent.height / 5
  290. height: sourceSize.height
  291. width:sourceSize.width
  292. }
  293. ListModel {
  294. id: langData
  295. }
  296. Item {
  297. id: langListArea
  298. width: parent.width
  299. height: parent.height - idACTLANGIMG.sourceSize.height
  300. y: idACTLANGIMG.sourceSize.height
  301. Component {
  302. id: langDataDelegate
  303. Item {
  304. x:langListArea.width * 0.1
  305. width: height * 1.5
  306. height: langListArea.height / 5
  307. Rectangle {
  308. anchors.fill: parent
  309. radius: 4
  310. gradient: Gradient {
  311. GradientStop { position:0 ; color: (transLoad.getActiveLanguage() === name) ? Globals.customer_color_base : "darkgray" }
  312. GradientStop { position:1 ; color: (transLoad.getActiveLanguage() === name) ? Globals.customer_color_base : "black" }
  313. }
  314. }
  315. Image {
  316. id:langFLAGIMG
  317. anchors.centerIn: parent
  318. fillMode: Image.PreserveAspectFit
  319. sourceSize.height: parent.height - parent.height * 0.25
  320. sourceSize.width: parent.width
  321. height: sourceSize.height
  322. width:sourceSize.width
  323. source: flag
  324. smooth: true
  325. }
  326. MouseArea {
  327. anchors.fill: parent
  328. onClicked: {
  329. settings.setValue("HMI/Language", name); // unbedingt vor dispLang()
  330. transLoad.selectLanguage(name);
  331. langSelect.dispLang();
  332. dateTimeSettings.datetimeSet(); // aktuelle Zeit Setzen
  333. }
  334. }
  335. }
  336. }
  337. ListView {
  338. id: langLISTVIEW
  339. anchors.fill: parent
  340. model: langData
  341. delegate: langDataDelegate
  342. clip: true
  343. focus: true
  344. }
  345. }
  346. Component.onCompleted: {
  347. dispLang();
  348. var count = langData.rowCount();
  349. // set active item for Joblist, scroll to active job
  350. for (var i = 0, len = langData.count; i < len; i++) {
  351. var actlang = langData.get(i).name;
  352. if ( actlang === transLoad.getActiveLanguage() )
  353. langLISTVIEW.currentIndex = i;
  354. }
  355. }
  356. }
  357. //Languagesettings end
  358. //Test Month/Day
  359. Rectangle {
  360. width: root.width / 2 - langSelect.width //(root.height / 5) * 1.5
  361. height: root.height
  362. x: root.width / 2 + langSelect.width
  363. y: 0
  364. //color: Globals.customer_color_base //"blue"
  365. HMI_DateTimeSettings {
  366. id: dateTimeSettings
  367. anchors.fill: parent
  368. }
  369. }
  370. //Test Month/Day end
  371. // Update tarFiles von USB
  372. Item {
  373. id: updateItem
  374. ApplicationLaunch {
  375. id: appUPDATE
  376. appName: "sudo " + Globals.baseDir + "/Scripts/FindUpdate.sh "
  377. arguments: ""
  378. onAppFinished: {
  379. var lines = stdOUT.split(/[\r\n]+/g);
  380. var idx = 0;
  381. var files = [];
  382. lines.forEach(function(entry) {
  383. if (entry.length > 0) {
  384. if(!updateHMI.popupVISIBLE) { // Datenstruktur nur wenn nicht sichtbar aufbauen
  385. files.push(entry);
  386. }
  387. ++idx;
  388. }
  389. });
  390. updateTIMER.interval = 5000;
  391. updateTIMER.restart();
  392. buttUPDATE.visible = (idx > 0)?true:false;
  393. if ((updateHMI.popupVISIBLE) && (idx == 0)) updateHMI.popupVISIBLE = false;
  394. if (!updateHMI.popupVISIBLE) updateHMI.listData = files;
  395. }
  396. }
  397. Timer {
  398. id: updateTIMER
  399. interval: 500
  400. running: true
  401. repeat: false
  402. onTriggered: {
  403. appUPDATE.launchScript();
  404. }
  405. }
  406. }
  407. // Update tarFiles von USB
  408. }
  409. }
  410. }