123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- import QtQuick 2.5
- //import Qt.labs.controls 1.0
- import QtQuick.Controls 2.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: parent.width * 0.025
- y: parent.height * 0.025
- width: parent.width * 0.95
- height: parent.height * 0.95
- 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 = Globals.baseDir + "/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;
- }
- }
- }
- }
|