HMI_Settings.qml 15 KB

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