import QtQuick 2.5 import Qt.labs.controls 1.0 import QtQuick.Layouts 1.1 import QtQuick.Controls.Styles 1.4 import ApplicationLauncher 1.0 import "qrc:/Globals" Item { id: updatePOPUP property bool popupVISIBLE: true property string popupTEXT: "" property var listData property int clickedINDEX: -1 property string selectedFileName: "" x: 20 y: 0 width: 500 height: 300 visible: popupVISIBLE function fillData() { popupData.clear(); var idx = 0; console.log(JSON.stringify(listData)); console.log(JSON.stringify(listData.length)); for ( var i = 0; i < listData.length; i++) { var entry = listData[i]; var filename = entry.split("/"); console.debug(idx + ":: " + "++++>:" + JSON.stringify(entry) + " ++ " + JSON.stringify(filename[filename.length - 1]) + " cnt:: " + JSON.stringify(filename.length)); popupData.append( {index: i, name: filename[filename.length - 1].split(".")[0], filename: entry } ); } } onPopupVISIBLEChanged: { if (popupVISIBLE) { z = 99; fillData(); } else { z = 0; clickedINDEX = -1; selectedFileName = ""; // popupData.clear(); } } onListDataChanged: { fillData(); } Component.onCompleted: { // fillData(); } Rectangle { id: popupWIN anchors.fill: parent color: "lightgray" border.width: 3 border.color: Globals.customer_color_base visible: popupVISIBLE Label { id: popupLABEL1 x: 10 y: 15 font.bold: true font.pixelSize: 16 text: popupTEXT clip: true } ListModel { id: popupData } Item { id: popupListArea y: 2 * popupLABEL1.height width: parent.width height: parent.height - 5 * popupLABEL1.height Component { id: popupDelegate Item { x:popupListArea.width * 0.1 width: popupListArea.width * 0.8 height: popupListArea.height / 5 Rectangle { anchors.fill: parent radius: 4 gradient: Gradient { GradientStop { position:0 ; color: (clickedINDEX == index) ? Globals.customer_color_base : "darkgray" } GradientStop { position:1 ; color: (clickedINDEX == index) ? Globals.customer_color_base : "black" } } } Text { anchors.centerIn: parent font.pixelSize: 14 color: "white" anchors.left: parent.Left text: index + " :: " + name } MouseArea { anchors.fill: parent onClicked: { clickedINDEX = index; selectedFileName = filename; } } } } ListView { id: popupLISTVIEW anchors.fill: parent model: popupData delegate: popupDelegate clip: true focus: true } } CustomBusyIndicator{ property alias running: updateBUSY.visible id:updateBUSY //anchors.centerIn: parent x: (popupWIN.width - popupWIN.height) / 2 width: popupWIN.height height: popupWIN.height bBgColor: Globals.customer_color_base bLength:50 opacity: 0.75 visible: false } ApplicationLaunch { id: appDoUPDATE appName: "" arguments: "" onAppFinished: { console.debug(stdOUT); updateBUSY.running = false; } } ButtHMI { buttX: 10 buttY: parent.height - 40 buttWidth: 30 buttHeight: buttWidth color: "green" text: "\uf058" //ok-sign visible: clickedINDEX >= 0 ? true:false onButtPressed: { //popupVISIBLE = false; var appname = "/opt/di-soric/Scripts/UpdateAndReboot.sh "; appname += selectedFileName + " "; appname += (sysinfo.currentCpuArchitecture == "x86_64")?"/home/ru/IFACE/update":"/"; appname += " " + sysinfo.currentCpuArchitecture; appDoUPDATE.appName = appname; updateBUSY.running = true; appDoUPDATE.launchScript(); } } ButtHMI { buttX: parent.width - buttWidth - 10 buttY: parent.height - 40 buttWidth: 30 buttHeight: buttWidth color: "red" text: "\uf057" //remove-sign onButtPressed: { if (updateBUSY.running == false) popupVISIBLE = false; //updateBUSY.running = updateBUSY.running?false:true; } } } }