~michael-sheldon/webbrowser-app/fix-1531179

« back to all changes in this revision

Viewing changes to src/app/webcontainer/ContentDownloadDialog.qml

  • Committer: CI Train Bot
  • Author(s): Michael Sheldon
  • Date: 2015-12-21 20:39:33 UTC
  • mfrom: (1106.3.119 implement-download-folder)
  • Revision ID: ci-train-bot@canonical.com-20151221203933-o2ijlcmhhyoi62wk
Add support for handling downloads internally within the browser. Fixes: #1354391
Approved by: Olivier Tilloy

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2014-2015 Canonical Ltd.
 
3
 *
 
4
 * This file is part of webbrowser-app.
 
5
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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/>.
 
17
 */
 
18
 
 
19
import QtQuick 2.4
 
20
import Ubuntu.Components 1.3
 
21
import Ubuntu.Components.Popups 1.3
 
22
import Ubuntu.Content 1.3
 
23
import webbrowsercommon.private 0.1
 
24
 
 
25
Component {
 
26
    PopupBase {
 
27
        id: downloadDialog
 
28
        objectName: "downloadDialog"
 
29
        anchors.fill: parent
 
30
        property var activeTransfer
 
31
        property var downloadId
 
32
        property var singleDownload
 
33
        property var mimeType
 
34
        property var filename
 
35
        property var icon: MimeDatabase.iconForMimetype(mimeType)
 
36
        property alias contentType: peerPicker.contentType
 
37
    
 
38
        ContentPeerModel {
 
39
            id: peerModel
 
40
            handler: ContentHandler.Destination
 
41
            contentType: downloadDialog.contentType
 
42
        }
 
43
    
 
44
        Rectangle {
 
45
            id: pickerRect
 
46
            anchors.fill: parent
 
47
            visible: true
 
48
            ContentPeerPicker {
 
49
                id: peerPicker
 
50
                handler: ContentHandler.Destination
 
51
                objectName: "contentPeerPicker"
 
52
                visible: parent.visible
 
53
    
 
54
                onPeerSelected: {
 
55
                    activeTransfer = peer.request()
 
56
                    activeTransfer.downloadId = downloadDialog.downloadId
 
57
                    activeTransfer.state = ContentTransfer.Downloading
 
58
                    PopupUtils.close(downloadDialog)
 
59
                }
 
60
    
 
61
                onCancelPressed: {
 
62
                    PopupUtils.close(downloadDialog)
 
63
                }
 
64
            }
 
65
        }
 
66
    }
 
67
}