f459cb3b3d31c3a6d167cf3bf2d189602fe74d8b
[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: box
26         color: Const.TRANSPARENT
27         height: label.height+4*Const.DEFAULT_MARGIN
28         width: root.width
29     }
30
31     Rectangle {
32         id: boxShadow
33         width: box.width
34         height: box.height
35         y: 5
36         color: Const.DEFAULT_DIALOG_FOREGROUND_COLOR
37         anchors.horizontalCenter: box.horizontalCenter
38         opacity: 0.4
39         visible: mouseArea.pressed
40     }
41
42     /*Line {
43         width: box.width-2*Const.TEXT_MARGIN
44         anchors.bottom: boxShadow.bottom
45         anchors.horizontalCenter: box.horizontalCenter
46     }*/
47
48
49     Image {
50         id: icon
51         width: 60
52         height: 60
53         x: Const.TEXT_MARGIN-5
54         source: root.isDirectory ? "../images/folder.png" :
55                 root.isPhoto ? "../images/photo.png" :
56                 root.isMusic ? "../images/music.png" :
57                 root.isVideo ? "../images/video.png" : "../images/document.png"
58         sourceSize.width: width
59         sourceSize.height: height
60         anchors.verticalCenter: box.verticalCenter
61     }
62
63     Text {
64         id: label
65         x: Const.TEXT_MARGIN + icon.width + 2*Const.DEFAULT_MARGIN
66         font.pixelSize: 30
67         color: Const.DEFAULT_FOREGROUND_COLOR
68         elide: Text.ElideRight
69         //wrapMode: Text.Wrap
70         width: root.isPublic ?
71                    root.width-x-Const.TEXT_MARGIN-3*Const.DEFAULT_MARGIN-arrow.width-publicIcon.width :
72                    root.width-x-Const.TEXT_MARGIN-1*Const.DEFAULT_MARGIN-arrow.width
73         anchors.verticalCenter: box.verticalCenter
74     }
75
76     Text {
77         id: details
78         x: Const.TEXT_MARGIN + icon.width + 2*Const.DEFAULT_MARGIN
79         font.pixelSize: 18
80         font.italic: true
81         color: "black"
82         elide: Text.ElideRight
83         wrapMode: Text.Wrap
84         width: root.width-x-Const.TEXT_MARGIN-2*Const.DEFAULT_MARGIN-arrow.width
85         y: box.height-height+3
86     }
87
88     Image {
89         id: publicIcon
90         width: 50
91         height: 50
92         anchors.right: arrow.left
93         anchors.margins: Const.DEFAULT_MARGIN
94         source: "../images/internet.png"
95         sourceSize.width: width
96         sourceSize.height: height
97         anchors.verticalCenter: box.verticalCenter
98         visible: root.isPublic
99     }
100
101     Image {
102         id: arrow
103         width: 30
104         height: 30
105         anchors.right: box.right
106         anchors.margins: Const.DEFAULT_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 }