HMI_UpdatePopup.qml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 QtQuick.Controls.Styles 1.4
  6. import ApplicationLauncher 1.0
  7. import "qrc:/Globals"
  8. Item {
  9. id: updatePOPUP
  10. property bool popupVISIBLE: true
  11. property string popupTEXT: ""
  12. property var listData
  13. property int clickedINDEX: -1
  14. property string selectedFileName: ""
  15. x: 20
  16. y: 0
  17. width: 500
  18. height: 300
  19. visible: popupVISIBLE
  20. function fillData() {
  21. popupData.clear();
  22. var idx = 0;
  23. console.log(JSON.stringify(listData));
  24. console.log(JSON.stringify(listData.length));
  25. for ( var i = 0; i < listData.length; i++) {
  26. var entry = listData[i];
  27. var filename = entry.split("/");
  28. console.debug(idx + ":: " + "++++>:" + JSON.stringify(entry) + " ++ " + JSON.stringify(filename[filename.length - 1]) + " cnt:: " + JSON.stringify(filename.length));
  29. popupData.append( {index: i,
  30. name: filename[filename.length - 1].split(".")[0],
  31. filename: entry
  32. } );
  33. }
  34. }
  35. onPopupVISIBLEChanged: {
  36. if (popupVISIBLE) {
  37. z = 99;
  38. fillData();
  39. } else {
  40. z = 0;
  41. clickedINDEX = -1;
  42. selectedFileName = "";
  43. // popupData.clear();
  44. }
  45. }
  46. onListDataChanged: {
  47. fillData();
  48. }
  49. Component.onCompleted: {
  50. // fillData();
  51. }
  52. Rectangle {
  53. id: popupWIN
  54. anchors.fill: parent
  55. color: "lightgray"
  56. border.width: 3
  57. border.color: Globals.customer_color_base
  58. visible: popupVISIBLE
  59. Label {
  60. id: popupLABEL1
  61. x: 10
  62. y: 15
  63. font.bold: true
  64. font.pixelSize: 16
  65. text: popupTEXT
  66. clip: true
  67. }
  68. ListModel {
  69. id: popupData
  70. }
  71. Item {
  72. id: popupListArea
  73. y: 2 * popupLABEL1.height
  74. width: parent.width
  75. height: parent.height - 5 * popupLABEL1.height
  76. Component {
  77. id: popupDelegate
  78. Item {
  79. x:popupListArea.width * 0.1
  80. width: popupListArea.width * 0.8
  81. height: popupListArea.height / 5
  82. Rectangle {
  83. anchors.fill: parent
  84. radius: 4
  85. gradient: Gradient {
  86. GradientStop { position:0 ; color: (clickedINDEX == index) ? Globals.customer_color_base : "darkgray" }
  87. GradientStop { position:1 ; color: (clickedINDEX == index) ? Globals.customer_color_base : "black" }
  88. }
  89. }
  90. Text {
  91. anchors.centerIn: parent
  92. font.pixelSize: 14
  93. color: "white"
  94. anchors.left: parent.Left
  95. text: index + " :: " + name
  96. }
  97. MouseArea {
  98. anchors.fill: parent
  99. onClicked: {
  100. clickedINDEX = index;
  101. selectedFileName = filename;
  102. }
  103. }
  104. }
  105. }
  106. ListView {
  107. id: popupLISTVIEW
  108. anchors.fill: parent
  109. model: popupData
  110. delegate: popupDelegate
  111. clip: true
  112. focus: true
  113. }
  114. }
  115. CustomBusyIndicator{
  116. property alias running: updateBUSY.visible
  117. id:updateBUSY
  118. //anchors.centerIn: parent
  119. x: (popupWIN.width - popupWIN.height) / 2
  120. width: popupWIN.height
  121. height: popupWIN.height
  122. bBgColor: Globals.customer_color_base
  123. bLength:50
  124. opacity: 0.75
  125. visible: false
  126. }
  127. ApplicationLaunch {
  128. id: appDoUPDATE
  129. appName: ""
  130. arguments: ""
  131. onAppFinished: {
  132. console.debug(stdOUT);
  133. updateBUSY.running = false;
  134. }
  135. }
  136. ButtHMI {
  137. buttX: 10
  138. buttY: parent.height - 40
  139. buttWidth: 30
  140. buttHeight: buttWidth
  141. color: "green"
  142. text: "\uf058" //ok-sign
  143. visible: clickedINDEX >= 0 ? true:false
  144. onButtPressed: {
  145. //popupVISIBLE = false;
  146. var appname = Globals.baseDir + "/Scripts/UpdateAndReboot.sh "
  147. appname += selectedFileName + " ";
  148. appname += (sysinfo.currentCpuArchitecture == "x86_64")?"/home/ru/IFACE/update":"/";
  149. appname += " " + sysinfo.currentCpuArchitecture;
  150. appDoUPDATE.appName = appname;
  151. updateBUSY.running = true;
  152. appDoUPDATE.launchScript();
  153. }
  154. }
  155. ButtHMI {
  156. buttX: parent.width - buttWidth - 10
  157. buttY: parent.height - 40
  158. buttWidth: 30
  159. buttHeight: buttWidth
  160. color: "red"
  161. text: "\uf057" //remove-sign
  162. onButtPressed: {
  163. if (updateBUSY.running == false) popupVISIBLE = false;
  164. //updateBUSY.running = updateBUSY.running?false:true;
  165. }
  166. }
  167. }
  168. }