New GUI
[ubi] / qml / ubi / components / Bar.qml
index 0b07274..ff0df97 100644 (file)
@@ -7,64 +7,82 @@ Item {
     property string label
     property bool isDownload: false
     property bool isUpload: false
-    height: 32
-
-    Image {
-        id: icon
-        width: root.height
-        height: root.height
-        source: isDownload? "../"+Const.ICON_DOWN : (isUpload? "../"+Const.ICON_UP : "")
-        sourceSize.width: width
-        sourceSize.height: height
-        visible: isDownload || isUpload
-    }
+    height: button.height
+    //width: parent.width
 
-    Rectangle {
-        id: bbar
+    width: mainWindow.width-3*Const.DEFAULT_MARGIN
 
-        color: Const.TRANSPARENT
-        border.width: 2
-        radius: 5
-        border.color: Const.DEFAULT_FOREGROUND_COLOR
-        height: root.height
-        width: icon.visible? root.width-icon.width-5 : root.width
-        x: icon.visible? icon.width+5 : 0
+    signal cancel(string file);
 
-        Rectangle {
-            id: bar
-            height: parent.height
-            width: 0
-            x:0
-            radius: 5
-            color: Const.DEFAULT_FOREGROUND_COLOR
-            state: "right"
-
-            states: [
-                State {
-                    name: "right"
-                },
-                State {
-                    name: "left"
-                },
-                State {
-                    name: "progress"
-                }
-            ]
+    Row {
+        spacing: Const.DEFAULT_MARGIN
+        anchors.verticalCenter: parent.verticalCenter
+
+        Image {
+            id: icon
+            source: isDownload? "../images/download.png" :
+                    isUpload? "../images/upload.png" : ""
+            visible: isDownload || isUpload
+            anchors.verticalCenter: parent.verticalCenter
         }
 
-        Text {
-            id: caption
-            font.pixelSize: 25
-            anchors.centerIn: parent
-            //color: Const.DEFAULT_FOREGROUND_COLOR
-            text: root.label.length>28 ? root.label.substring(0,25)+"..." : root.label
-            color: "black"
+        Rectangle {
+            id: bbar
+            anchors.verticalCenter: parent.verticalCenter
+            color: Const.TRANSPARENT
+            border.width: 2
+            //radius: 5
+            border.color: Const.DEFAULT_FOREGROUND_COLOR
+            height: 40
+            width: icon.visible?
+                       root.width-icon.width-button.width-2*Const.DEFAULT_MARGIN :
+                       root.width-button.width-1*Const.DEFAULT_MARGIN
+            //x: icon.visible? icon.width+5 : 0
+
+            Rectangle {
+                id: bar
+                height: parent.height
+                width: 0
+                x:0
+                color: Const.DEFAULT_FOREGROUND_COLOR
+                state: "right"
+
+                states: [
+                    State {
+                        name: "right"
+                    },
+                    State {
+                        name: "left"
+                    },
+                    State {
+                        name: "progress"
+                    }
+                ]
+            }
+
+            Text {
+                id: caption
+                font.pixelSize: 25
+                anchors.centerIn: parent
+                //color: Const.DEFAULT_FOREGROUND_COLOR
+                text: root.label
+                width: bbar.width
+                elide: Text.ElideRight
+                horizontalAlignment: Text.AlignHCenter
+                color: "black"
+            }
         }
 
+        Button {
+            id: button
+            anchors.verticalCenter: parent.verticalCenter
+            iconSource: "images/close.png"
+            onButtonClicked: root.cancel(root.label)
+        }
     }
 
     function setProgres(progress) {
-        console.log("proggress = "+progress);
+        //console.log("proggress = "+progress);
         if(bar.state!="progress") {
             time.stop();
             bar.state = "progress"