HMI_Settings.qml 15 KB

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