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