New release 0.9.1-1
[ubi] / qml / ubi / components / File.qml
1 import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
2 import "../UIConstants.js" as Const
3
4
5 Item {
6     id: root
7     property alias name: label.text
8     property bool isDirectory: false
9     property variant properties: null
10     property string filename: ""
11     property int textMax: 27
12
13     state: mouseArea.pressed && !root.disabled ? "pressed" : "unpressed"
14
15     //width: box.width
16     height: box.height
17
18     signal clicked(variant prop)
19
20     /*Rectangle {
21         id: shadow
22         width: box.width
23         height: box.height
24         color: Const.SHADOW_COLOR;
25         radius: 10
26         x: Const.SHADOW_OFFSET;
27         y: Const.SHADOW_OFFSET;
28     }*/
29
30     Rectangle {
31         id: box
32         color: Const.TRANSPARENT
33         height: label.height+3*Const.DEFAULT_MARGIN
34         width: root.width
35     }
36
37     Rectangle {
38         width: box.width-2*Const.TEXT_MARGIN+2*Const.DEFAULT_MARGIN
39         height: box.height
40         x: box.x
41         y: box.y
42         //color: root.isDirectory ? "white" : "black"
43         color: Const.DEFAULT_DIALOG_FOREGROUND_COLOR
44         anchors.verticalCenter: box.verticalCenter
45         anchors.horizontalCenter: box.horizontalCenter
46         opacity: 0.4
47         radius: 10
48         visible: mouseArea.pressed
49     }
50
51     Image {
52         id: icon
53         width: 40
54         height: 40
55         x: Const.TEXT_MARGIN
56         source: root.isDirectory ? "../images/folder.png" : "../images/file-black.png"
57         sourceSize.width: width
58         sourceSize.height: height
59         anchors.verticalCenter: box.verticalCenter
60     }
61
62     Text {
63         id: label
64         x: Const.TEXT_MARGIN + icon.width + Const.DEFAULT_MARGIN
65         font.pixelSize: 30
66         color: root.isDirectory ? "white" : "black"
67         //color: "white"
68         elide: Text.ElideRight
69         wrapMode: Text.Wrap
70         width: root.width-x-Const.TEXT_MARGIN-Const.DEFAULT_MARGIN-arrow.width
71
72         //width: root.width
73         anchors.verticalCenter: box.verticalCenter
74         /*onTextChanged: {
75             if(text.length>root.textMax)
76                 root.name = text.substring(0,root.textMax-3)+"...";
77         }*/
78     }
79
80     Image {
81         id: arrow
82         width: 12
83         height: 20
84         anchors.right: box.right
85         anchors.margins: Const.TEXT_MARGIN
86         source: root.isDirectory ? "../images/arrow-frw.png" : "../images/arrow-frw-black.png"
87         sourceSize.width: width
88         sourceSize.height: height
89         anchors.verticalCenter: box.verticalCenter
90     }
91
92     MouseArea {
93         id: mouseArea
94         width: box.width
95         height: box.height
96         onClicked: {
97             root.clicked(root.properties);
98         }
99     }
100
101     /*states: [
102         State {
103             name: "unpressed"
104             PropertyChanges {target: shadow; x: Const.SHADOW_OFFSET}
105             PropertyChanges {target: shadow; y: Const.SHADOW_OFFSET}
106             PropertyChanges {target: box; x: 0}
107             PropertyChanges {target: box; y: 0}
108         },
109         State {
110             name: "pressed"
111             PropertyChanges {target: shadow; x: Const.SHADOW_OFFSET}
112             PropertyChanges {target: shadow; y: Const.SHADOW_OFFSET}
113             PropertyChanges {target: box; x: Const.SHADOW_OFFSET}
114             PropertyChanges {target: box; y: Const.SHADOW_OFFSET}
115         }
116     ]*/
117 }