2
* Copyright (C) 2012-2014 Canonical, Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
import Ubuntu.Components 1.1
19
import Ubuntu.Components.Popups 1.0 as Popups
20
import Ubuntu.Content 0.1 as ContentHub
25
property var importDialog: null
27
signal pictureReceived(string pictureUrl)
29
function requestNewPicture()
31
if (!root.importDialog) {
32
root.importDialog = PopupUtils.open(contentHubDialog, root)
34
console.warn("Import dialog already running")
44
property alias activeTransfer: signalConnections.target
52
ContentHub.ContentPeerPicker {
56
visible: dialogue.done
57
contentType: ContentHub.ContentType.Pictures
58
handler: ContentHub.ContentHandler.Source
61
peer.selectionType = ContentHub.ContentTransfer.Single
62
dialogue.activeTransfer = peer.request()
66
PopupUtils.close(root.importDialog)
74
target: dialogue.activeTransfer
76
var done = ((dialogue.activeTransfer.state === ContentHub.ContentTransfer.Charged) ||
77
(dialogue.activeTransfer.state === ContentHub.ContentTransfer.Aborted))
79
if (dialogue.activeTransfer.state === ContentHub.ContentTransfer.Charged) {
81
if (dialogue.activeTransfer.items.length > 0) {
82
root.pictureReceived(dialogue.activeTransfer.items[0].url)
92
// WORKAROUND: Work around for application becoming insensitive to touch events
93
// if the dialog is dismissed while the application is inactive.
94
// Just listening for changes to Qt.application.active doesn't appear
95
// to be enough to resolve this, so it seems that something else needs
96
// to be happening first. As such there's a potential for a race
97
// condition here, although as yet no problem has been encountered.
105
if(Qt.application.active) {
106
PopupUtils.close(root.importDialog)
111
Component.onDestruction: root.importDialog = null