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