~phablet-team/webbrowser-app/trunk

« back to all changes in this revision

Viewing changes to src/app/webbrowser/DownloadDelegate.qml

* Fix for issue where many tabs causes close button to overlap other
  tabs (LP: #1473630)
* When page has started, stopped, redirected or errored clear cache for
  history update - which prevents incorrect titles in being set
  (LP: #1603835)
* Add autopilot tests javascript dialogs to webbrowser and
  webapp-container - alertDialog, beforeUnloadDialog, confirmDialog and
  promptDialog (LP: #1633040)
* Add user-agent override to display the new twitter mobile interface
  (LP: #1577834)
* Improved startup time by 800ms by delaying QML compilation and making
  it asynchronous
* Replace chromium version in UA overrides at runtime, not at build
  time (LP: #1599695)
* Initial support for generating a snap package for webbrowser-app
  (LP: #1629009)
* Do not persist references to incognito downloads on disk
  (LP: #1625519)
* Increase test coverage (to 97.5%) for DownloadsModel (LP: #1534102)
* Various performance optimizations linked to load events
  (LP: #1611680)
* Ensure a tab is loaded when re-opened (LP: #1632246)
* Fix drag'n'drop of bookmarks within the new tab view (LP: #1584868)
* Work around a limitation in the sound and microphone policy groups
  to "fix" sound in yakkety an zesty (LP: #1632620)

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
    property var downloadManager
27
27
 
28
 
    property alias icon: mimeicon.name
 
28
    property string icon
29
29
    property alias image: thumbimage.source
30
30
    property alias title: title.text
31
31
    property alias url: url.text
33
33
    property bool incomplete: false
34
34
    property string downloadId
35
35
    property var download
36
 
    property int progress: download ? download.progress : 0
 
36
    readonly property int progress: download ? download.progress : 0
37
37
    property bool paused
 
38
    property alias incognito: incognitoIcon.visible
38
39
 
39
40
    divider.visible: false
40
41
 
41
42
    signal removed()
42
43
    signal cancelled()
43
44
 
44
 
    height: visible ? (incomplete ? (paused ? units.gu(13) : units.gu(10)) : units.gu(7)) : 0
 
45
    height: visible ? layout.height : 0
45
46
 
46
47
    QtObject {
47
48
        id: internal
60
61
    Component.onCompleted: internal.connectToDownloadObject()
61
62
    onDownloadManagerChanged: internal.connectToDownloadObject()
62
63
 
63
 
    Item {
64
 
        
65
 
        anchors {
66
 
            verticalCenter: parent.verticalCenter
67
 
            left: parent.left
68
 
            leftMargin: units.gu(2)
69
 
            right: parent.right
70
 
            rightMargin: units.gu(2)
71
 
        }
 
64
    SlotsLayout {
 
65
        id: layout
72
66
 
73
67
        Item {
74
 
            id: iconContainer
 
68
            SlotsLayout.position: SlotsLayout.Leading
75
69
            width: units.gu(3)
76
 
            height: width
77
 
            anchors.verticalCenter: parent.verticalCenter
78
 
            anchors.verticalCenterOffset: downloadDelegate.incomplete ? -units.gu(1) : 0
 
70
            height: units.gu(3)
79
71
 
80
72
            Image {
81
73
                id: thumbimage
82
74
                asynchronous: true
83
 
                width: parent.width
84
 
                height: parent.height
 
75
                anchors.fill: parent
85
76
                fillMode: Image.PreserveAspectFit
86
 
                sourceSize.width: parent.width
87
 
                sourceSize.height: parent.height
88
 
                anchors.verticalCenter: parent.verticalCenter
 
77
                sourceSize.width: width
 
78
                sourceSize.height: height
89
79
            }
90
80
 
91
81
            Image {
92
 
                id: mimeicon
93
82
                asynchronous: true
94
83
                anchors.fill: parent
95
84
                anchors.margins: units.gu(0.2)
96
 
                source: "image://theme/%1".arg(name != "" ? name : "save")
 
85
                source: "image://theme/%1".arg(downloadDelegate.icon || "save")
97
86
                visible: thumbimage.status !== Image.Ready
98
87
                cache: true
99
 
                property string name
100
 
            }
101
 
        }
102
 
 
103
 
        Item {
104
 
            anchors.top: iconContainer.top
105
 
            anchors.left: iconContainer.right
106
 
            anchors.leftMargin: units.gu(2)
107
 
            anchors.right: parent.right
108
 
 
109
 
            Column {
110
 
                id: detailsColumn
111
 
                width: parent.width - cancelColumn.width
112
 
                height: parent.height
113
 
 
114
 
                Label {
115
 
                    id: title
116
 
                    fontSize: "x-small"
117
 
                    color: "#5d5d5d"
118
 
                    elide: Text.ElideRight
119
 
                    width: parent.width
120
 
                }
121
 
 
122
 
                Label {
123
 
                    id: url
124
 
                    fontSize: "x-small"
125
 
                    color: "#5d5d5d"
126
 
                    elide: Text.ElideRight
127
 
                    width: parent.width
128
 
                }
129
 
 
130
 
                Item {
131
 
                    height: error.visible ? units.gu(1) : units.gu(2)
132
 
                    width: parent.width
133
 
                    visible: downloadDelegate.incomplete
134
 
                }
135
 
 
136
 
                Item {
137
 
                    id: error
138
 
                    visible: incomplete && download === undefined || errorMessage !== ""
139
 
                    height: units.gu(3)
140
 
                    width: parent.width
141
 
 
142
 
                    Icon {
143
 
                        id: errorIcon
144
 
                        width: units.gu(2)
145
 
                        height: width
146
 
                        anchors.verticalCenter: parent.verticalCenter
147
 
                        name: "dialog-warning-symbolic"
148
 
                        color: theme.palette.normal.negative
149
 
                    }
150
 
 
151
 
                    Label {
152
 
                        width: parent.width - errorIcon.width
153
 
                        anchors.left: errorIcon.right
154
 
                        anchors.leftMargin: units.gu(1)
155
 
                        anchors.verticalCenter: errorIcon.verticalCenter
156
 
                        fontSize: "x-small"
157
 
                        color: theme.palette.normal.negative
158
 
                        text: errorMessage !== "" ? errorMessage 
159
 
                                                  : (incomplete && download === undefined) ? i18n.tr("Download failed") 
160
 
                                                                                           : ""
161
 
                        elide: Text.ElideRight
162
 
                    }
163
 
                }
164
 
 
165
 
                IndeterminateProgressBar {
166
 
                    id: progressBar
167
 
                    width: parent.width
168
 
                    height: units.gu(0.5)
169
 
                    visible: downloadDelegate.incomplete && !error.visible
170
 
                    progress: downloadDelegate.progress
171
 
                    // Work around UDM bug #1450144
172
 
                    indeterminateProgress: downloadDelegate.progress < 0 || downloadDelegate.progress > 100
173
 
                }
174
 
            }
175
 
 
176
 
            Column {
177
 
                id: cancelColumn
178
 
                spacing: units.gu(1)
179
 
                anchors.top: detailsColumn.top
180
 
                anchors.left: detailsColumn.right
181
 
                anchors.leftMargin: units.gu(2)
182
 
                width: downloadDelegate.incomplete && !error.visible ? cancelButton.width + units.gu(2) : 0
183
 
 
184
 
                Button {
185
 
                    visible: downloadDelegate.incomplete && !error.visible
186
 
                    id: cancelButton
187
 
                    text: i18n.tr("Cancel")
188
 
                    onClicked: {
189
 
                        if (download) {
190
 
                            download.cancel()
191
 
                            cancelled()
192
 
                        }
193
 
                    }
194
 
                }
195
 
 
196
 
                Label {
197
 
                    visible: !progressBar.indeterminateProgress && downloadDelegate.incomplete
198
 
                                                                && !error.visible 
199
 
                                                                && !downloadDelegate.paused
200
 
                    width: cancelButton.width
201
 
                    horizontalAlignment: Text.AlignHCenter
202
 
                    fontSize: "x-small"
203
 
                    text: progressBar.progress + "%"
204
 
                }
205
 
 
206
 
                Button {
207
 
                    visible: downloadDelegate.paused
208
 
                    text: i18n.tr("Resume")
209
 
                    width: cancelButton.width
210
 
                    onClicked: {
211
 
                        if (download) {
212
 
                            download.resume()
213
 
                        }
214
 
                    }
215
 
                }
216
 
            }
217
 
 
218
 
        }
219
 
    }
220
 
 
221
 
    leadingActions: error.visible || !downloadDelegate.incomplete ? deleteActionList : null
 
88
            }
 
89
        }
 
90
 
 
91
        mainSlot: Column {
 
92
            Label {
 
93
                id: title
 
94
                fontSize: "x-small"
 
95
                color: "#5d5d5d"
 
96
                elide: Text.ElideRight
 
97
                anchors {
 
98
                    left: parent.left
 
99
                    right: parent.right
 
100
                }
 
101
            }
 
102
 
 
103
            Label {
 
104
                id: url
 
105
                fontSize: "x-small"
 
106
                color: "#5d5d5d"
 
107
                elide: Text.ElideRight
 
108
                anchors {
 
109
                    left: parent.left
 
110
                    right: parent.right
 
111
                }
 
112
            }
 
113
 
 
114
            Item {
 
115
                height: error.visible ? units.gu(1) : units.gu(2)
 
116
                anchors {
 
117
                    left: parent.left
 
118
                    right: parent.right
 
119
                }
 
120
                visible: incomplete
 
121
            }
 
122
 
 
123
            Item {
 
124
                id: error
 
125
                visible: (incomplete && (download === undefined)) || errorMessage
 
126
                height: units.gu(3)
 
127
                anchors {
 
128
                    left: parent.left
 
129
                    right: parent.right
 
130
                }
 
131
 
 
132
                Icon {
 
133
                    id: errorIcon
 
134
                    width: units.gu(2)
 
135
                    height: units.gu(2)
 
136
                    anchors.verticalCenter: parent.verticalCenter
 
137
                    name: "dialog-warning-symbolic"
 
138
                    color: theme.palette.normal.negative
 
139
                }
 
140
 
 
141
                Label {
 
142
                    anchors {
 
143
                        left: errorIcon.right
 
144
                        leftMargin: units.gu(1)
 
145
                        right: parent.right
 
146
                        verticalCenter: parent.verticalCenter
 
147
                    }
 
148
                    fontSize: "x-small"
 
149
                    color: theme.palette.normal.negative
 
150
                    text: errorMessage ||
 
151
                          ((incomplete && download === undefined) ? i18n.tr("Download failed") : "")
 
152
                    elide: Text.ElideRight
 
153
                }
 
154
            }
 
155
 
 
156
            IndeterminateProgressBar {
 
157
                id: progressBar
 
158
                anchors {
 
159
                    left: parent.left
 
160
                    right: parent.right
 
161
                }
 
162
                height: units.gu(0.5)
 
163
                visible: incomplete && !error.visible
 
164
                progress: downloadDelegate.progress
 
165
                // Work around UDM bug #1450144
 
166
                indeterminateProgress: progress < 0 || progress > 100
 
167
            }
 
168
        }
 
169
 
 
170
        Column {
 
171
            SlotsLayout.position: SlotsLayout.Trailing
 
172
            spacing: units.gu(1)
 
173
            width: (incomplete && !error.visible) ? cancelButton.width : 0
 
174
 
 
175
            Button {
 
176
                id: cancelButton
 
177
                visible: incomplete && !error.visible
 
178
                text: i18n.tr("Cancel")
 
179
                onClicked: {
 
180
                    if (download) {
 
181
                        download.cancel()
 
182
                        cancelled()
 
183
                    }
 
184
                }
 
185
            }
 
186
 
 
187
            Label {
 
188
                visible: !progressBar.indeterminateProgress && incomplete
 
189
                            && !error.visible && !paused
 
190
                width: cancelButton.width
 
191
                horizontalAlignment: Text.AlignHCenter
 
192
                fontSize: "x-small"
 
193
                // TRANSLATORS: %1 is the percentage of the download completed so far
 
194
                text: i18n.tr("%1%").arg(progressBar.progress)
 
195
            }
 
196
 
 
197
            Button {
 
198
                visible: paused
 
199
                text: i18n.tr("Resume")
 
200
                width: cancelButton.width
 
201
                onClicked: {
 
202
                    if (download) {
 
203
                        download.resume()
 
204
                    }
 
205
                }
 
206
            }
 
207
        }
 
208
    }
 
209
 
 
210
    Icon {
 
211
        id: incognitoIcon
 
212
        anchors {
 
213
            right: parent.right
 
214
            rightMargin: units.gu(2)
 
215
            bottom: parent.bottom
 
216
            bottomMargin: units.gu(1)
 
217
        }
 
218
        width: units.gu(2)
 
219
        height: units.gu(2)
 
220
        asynchronous: true
 
221
        name: "private-browsing"
 
222
    }
 
223
 
 
224
    leadingActions: error.visible || !incomplete ? deleteActionList : null
222
225
 
223
226
    ListItemActions {
224
227
        id: deleteActionList
226
229
            Action {
227
230
                objectName: "leadingAction.delete"
228
231
                iconName: "delete"
229
 
                enabled: error.visible || !downloadDelegate.incomplete
230
 
                onTriggered: error.visible ? downloadDelegate.cancelled() 
231
 
                                           : downloadDelegate.removed()
 
232
                enabled: error.visible || !incomplete
 
233
                onTriggered: error.visible ? cancelled() : removed()
232
234
            }
233
235
        ]
234
236
    }