HMI_UpdatePopup.qml 5.4 KB

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