2
* Copyright 2014-2015 Canonical Ltd.
4
* This file is part of webbrowser-app.
6
* webbrowser-app is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 3.
10
* webbrowser-app is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
import Ubuntu.Components 1.3
21
import Ubuntu.Components.Popups 1.3 as Popups
22
import Ubuntu.Content 1.3
23
import "../MimeTypeMapper.js" as MimeTypeMapper
28
objectName: "contentPickerDialog"
30
// Set the parent at construction time, instead of letting show()
31
// set it later on, which for some reason results in the size of
32
// the dialog not being updated.
33
parent: QuickUtils.rootItem(this)
35
property var activeTransfer
42
activeTransfer: picker.activeTransfer
49
contentType: ContentType.All
50
handler: ContentHandler.Source
53
if (model.allowMultipleFiles) {
54
peer.selectionType = ContentTransfer.Multiple
56
peer.selectionType = ContentTransfer.Single
58
picker.activeTransfer = peer.request()
59
stateChangeConnection.target = picker.activeTransfer
69
id: stateChangeConnection
72
if (picker.activeTransfer.state === ContentTransfer.Charged) {
73
var selectedItems = []
74
for(var i in picker.activeTransfer.items) {
75
selectedItems.push(String(picker.activeTransfer.items[i].url).replace("file://", ""))
77
model.accept(selectedItems)
82
Component.onCompleted: {
83
if(acceptTypes.length === 1) {
84
var contentType = MimeTypeMapper.mimeTypeToContentType(acceptTypes[0])
85
if(contentType == ContentType.Unknown) {
86
// If we don't recognise the type, allow uploads from any app
87
contentType = ContentType.All
89
peerPicker.contentType = contentType
91
peerPicker.contentType = ContentType.All