Update WWW
[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 Item {
5     id: root
6     property alias name: label.text
7     property alias description: details.text
8     property bool isDirectory: false
9     property bool isPhoto: false
10     property bool isPublic: false
11     property variant properties: null
12     property string filename: ""
13     property int textMax: 27
14
15     state: mouseArea.pressed && !root.disabled ? "pressed" : "unpressed"
16
17     //width: parent.width
18     height: box.height
19
20     signal clicked(variant prop)
21
22     /*Rectangle {
23         id: shadow
24         width: box.width
25         height: box.height
26         color: Const.SHADOW_COLOR;
27         radius: 10
28         x: Const.SHADOW_OFFSET;
29         y: Const.SHADOW_OFFSET;
30     }*/
31
32     Rectangle {
33         id: box
34         color: Const.TRANSPARENT
35         height: label.height+4*Const.DEFAULT_MARGIN
36         width: root.width
37     }
38
39     /*Rectangle {
40         color: Const.DEFAULT_FOREGROUND_COLOR
41         height: 1
42         anchors.bottom: box.bottom;
43         anchors.left: box.left;
44         anchors.right: box.right;
45     }*/
46
47     Rectangle {
48         id: boxShadow
49         //width: box.width-2*Const.TEXT_MARGIN+2*Const.DEFAULT_MARGIN
50         width: box.width
51         height: box.height
52         y: 5
53         //color: root.isDirectory ? "white" : "black"
54         color: Const.DEFAULT_DIALOG_FOREGROUND_COLOR
55         //anchors.verticalCenter: box.verticalCenter
56         anchors.horizontalCenter: box.horizontalCenter
57         opacity: 0.4
58         //radius: 10
59         visible: mouseArea.pressed
60     }
61
62     /*Line {
63         width: box.width-2*Const.TEXT_MARGIN
64         anchors.bottom: boxShadow.bottom
65         anchors.horizontalCenter: box.horizontalCenter
66     }*/
67
68
69     Image {
70         id: icon
71         width: 50
72         height: 50
73         x: Const.TEXT_MARGIN-5
74         source: root.isDirectory ? "../images/folder.png" :
75                                    root.isPhoto ? "../images/photo.png" :
76                                                   "../images/document.png"
77         sourceSize.width: width
78         sourceSize.height: height
79         anchors.verticalCenter: box.verticalCenter
80     }
81
82     Text {
83         id: label
84         x: Const.TEXT_MARGIN + icon.width + 2*Const.DEFAULT_MARGIN
85         font.pixelSize: 30
86         color: Const.DEFAULT_FOREGROUND_COLOR
87         elide: Text.ElideRight
88         wrapMode: Text.Wrap
89         width: root.isPublic ?
90                    root.width-x-Const.TEXT_MARGIN-3*Const.DEFAULT_MARGIN-arrow.width-publicIcon.width :
91                    root.width-x-Const.TEXT_MARGIN-1*Const.DEFAULT_MARGIN-arrow.width
92         anchors.verticalCenter: box.verticalCenter
93     }
94
95     Text {
96         id: details
97         x: Const.TEXT_MARGIN + icon.width + 2*Const.DEFAULT_MARGIN
98         font.pixelSize: 18
99         font.italic: true
100         color: "black"
101         elide: Text.ElideRight
102         wrapMode: Text.Wrap
103         width: root.width-x-Const.TEXT_MARGIN-2*Const.DEFAULT_MARGIN-arrow.width
104         y: box.height-height+3
105     }
106
107     Image {
108         id: publicIcon
109         width: 50
110         height: 50
111         anchors.right: arrow.left
112         anchors.margins: Const.DEFAULT_MARGIN
113         source: "../images/internet.png"
114         sourceSize.width: width
115         sourceSize.height: height
116         anchors.verticalCenter: box.verticalCenter
117         visible: root.isPublic
118     }
119
120     Image {
121         id: arrow
122         width: 30
123         height: 30
124         anchors.right: box.right
125         anchors.margins: Const.TEXT_MARGIN
126         source: "../images/next.png"
127         sourceSize.width: width
128         sourceSize.height: height
129         anchors.verticalCenter: box.verticalCenter
130     }
131
132     MouseArea {
133         id: mouseArea
134         width: box.width
135         height: box.height
136         onClicked: {
137             root.clicked(root.properties);
138         }
139     }
140
141     /*states: [
142         State {
143             name: "unpressed"
144             PropertyChanges {target: shadow; x: Const.SHADOW_OFFSET}
145             PropertyChanges {target: shadow; y: Const.SHADOW_OFFSET}
146             PropertyChanges {target: box; x: 0}
147             PropertyChanges {target: box; y: 0}
148         },
149         State {
150             name: "pressed"
151             PropertyChanges {target: shadow; x: Const.SHADOW_OFFSET}
152             PropertyChanges {target: shadow; y: Const.SHADOW_OFFSET}
153             PropertyChanges {target: box; x: Const.SHADOW_OFFSET}
154             PropertyChanges {target: box; y: Const.SHADOW_OFFSET}
155         }
156     ]*/
157 }