summaryrefslogtreecommitdiff
path: root/SendFileView.qml
blob: 3af191a47abcba6c28bba26b0afc61405c430272 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
 * Copyright 2011 Intel Corporation.
 *
 * This program is licensed under the terms and conditions of the
 * Apache License, version 2.0.  The full text of the Apache License is at 
 * http://www.apache.org/licenses/LICENSE-2.0
 */

import Qt 4.7
import MeeGo.App.IM 0.1
import "constants.js" as Constants

Item {
    id: container

    width: itemsColumn.width
    height: itemsColumn.height

    signal fileSelected(string fileName);
    signal cancelled

    function hidePickers() {
        if (photoPicker != null) {
            photoPicker.hide();
        }
        if (videoPicker != null) {
            videoPicker.hide();
        }
        if (musicPicker != null) {
            musicPicker.hide();
        }
        if (contactsPicker != null) {
            contactsPicker.visible = false;
        }
    }

    onVisibleChanged: {
        // make sure we hide all pickers
        hidePickers();
    }

    Column {
        id: itemsColumn
        anchors.left: parent.left
        height: childrenRect.height
        width: 200

        Item {
            anchors.left: parent.left
            anchors.right: parent.right
            height: headerText.height + 10

            Text {
                id: headerText
                anchors.verticalCenter: parent.verticalCenter
                anchors.leftMargin: 10
                anchors.left: parent.left
                color: theme_fontColorNormal
                text: Constants.sendFileTitle
                font.pixelSize: theme_fontPixelSizeLarge
            }
        }

        MenuItemSeparator {
            header: true
        }

        MenuItem {
            id: photoItem
            text: Constants.sendFilePhoto

            onClicked: {
                createPhotoPicker();
                photoPicker.parent = container;
                photoPicker.show();
            }
        }

        MenuItemSeparator { }

        MenuItem {
            id: videoItem
            text: Constants.sendFileVideo

            onClicked: {
                createVideoPicker();
                videoPicker.parent = container;
                videoPicker.show()
            }
        }

        MenuItemSeparator { }

        MenuItem {
            id: musicItem
            text: Constants.sendFileMusic

            onClicked: {
                createMusicPicker();
                musicPicker.parent = container;
                musicPicker.show()
            }
        }

        MenuItemSeparator { }

        MenuItem {
            id: contactItem
            text: Constants.sendFileContact

            onClicked: {
                createContactsPicker();
                contactsPicker.show();
            }
        }
    }

    Connections {
        target: photoPicker
        onPhotoSelected: {
            container.fileSelected(uri.replace("file://", ""));
        }
    }

    Connections {
        target: videoPicker
        onVideoSelected: {
            container.fileSelected(uri.replace("file://", ""));
        }
    }

    Connections {
        target: musicPicker
        onSongSelected: {
            container.fileSelected(uri.replace("file://", ""));
        }
    }

    Connections {
        target: contactsPicker
        onContactSelected: {
            var filename = contact.name.firstName + "_" + contact.name.lastName;
            filename = filename.replace(" ", "_");
            filename = "/tmp/vcard_" +filename + ".vcf";
            createPeopleModel();
            peopleModel.exportContact(contact.guid.guid, filename);
            container.fileSelected(filename);
        }
        onCancelled: {
            container.cancelled();
        }
    }
}