Merge lp:~michael-sheldon/webbrowser-app/fix-1531179 into lp:webbrowser-app

Proposed by Michael Sheldon
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 1318
Merged at revision: 1325
Proposed branch: lp:~michael-sheldon/webbrowser-app/fix-1531179
Merge into: lp:webbrowser-app
Diff against target: 181 lines (+73/-31)
3 files modified
src/app/webbrowser/Browser.qml (+38/-29)
src/app/webbrowser/DownloadsPage.qml (+9/-2)
src/app/webbrowser/Thumbnailer.qml (+26/-0)
To merge this branch: bzr merge lp:~michael-sheldon/webbrowser-app/fix-1531179
Reviewer Review Type Date Requested Status
Olivier Tilloy Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+281650@code.launchpad.net

Commit message

Dynamically load the thumbnailer image provider if it's available, otherwise fallback to mimetype images

Description of the change

Dynamically load the thumbnailer image provider if it's available, otherwise fallback to mimetype images

To post a comment you must log in.
Revision history for this message
Olivier Tilloy (osomon) wrote :

LGTM, thanks for working promptly on this.

One minor suggestion: in Thumbnailer.qml, instead of importing QtQuick and instantiating a visual item, you could import QtQml and instantiate a more lightweight QtObject.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

Just tested on a fresh xenial desktop install, and this is not sufficient to make webbrowser-app start. See https://bugs.launchpad.net/ubuntu/+source/webbrowser-app/+bug/1531179/comments/3.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1316. By Michael Sheldon

Only display the downloads page if both UDM and content-hub bindings are available

1317. By Michael Sheldon

Merge changes

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

Looks good to me. A couple of minor suggestions:

  - "id: downloadsLoader" is unnecessary, in onLoaded you can directly refer to item

  - a Loader is a FocusScope, so "downloadsLoader.item.focus = true" should not be needed

In fact for consistency it would be better if the FocusScope with id 'downloadsContainer' was made a Loader (like bookmarksViewLoader, historyViewLoader, and settingsViewLoader).

1318. By Michael Sheldon

Convert downloadsContainer FocusScope into a Loader for consistency with other views

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

LGTM, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/webbrowser/Browser.qml'
2--- src/app/webbrowser/Browser.qml 2015-12-22 18:15:49 +0000
3+++ src/app/webbrowser/Browser.qml 2016-01-07 13:43:20 +0000
4@@ -172,7 +172,7 @@
5
6 FocusScope {
7 anchors.fill: parent
8- visible: !settingsViewLoader.active && !historyViewLoader.active && !bookmarksViewLoader.active && !downloadsContainer.visible
9+ visible: !settingsViewLoader.active && !historyViewLoader.active && !bookmarksViewLoader.active && !downloadsViewLoader.active
10
11 FocusScope {
12 id: tabContainer
13@@ -544,7 +544,7 @@
14 objectName: "downloads"
15 text: i18n.tr("Downloads")
16 iconName: "save"
17- enabled: downloadHandlerLoader.status == Loader.Ready
18+ enabled: downloadHandlerLoader.status == Loader.Ready && contentHandlerLoader.status == Loader.Ready
19 onTriggered: {
20 currentWebview.showDownloadsPage()
21 }
22@@ -924,26 +924,36 @@
23 }
24 }
25
26- FocusScope {
27- id: downloadsContainer
28+ Loader {
29+ id: downloadsViewLoader
30
31- visible: children.length > 0
32 anchors.fill: parent
33-
34- Component {
35- id: downloadsComponent
36-
37- DownloadsPage {
38- anchors.fill: parent
39- focus: true
40- downloadsModel: browser.downloadsModel
41- onDone: destroy()
42- Keys.onEscapePressed: {
43- destroy()
44- internal.resetFocus()
45- }
46- }
47- }
48+ active: false
49+ source: "DownloadsPage.qml"
50+
51+ onStatusChanged: {
52+ if (status == Loader.Ready) {
53+ item.downloadsModel = browser.downloadsModel
54+ item.forceActiveFocus()
55+ } else {
56+ internal.resetFocus()
57+ }
58+ }
59+
60+ Keys.onEscapePressed: active = false
61+
62+ onActiveChanged: {
63+ if (active) {
64+ forceActiveFocus()
65+ }
66+ }
67+
68+ Connections {
69+ target: downloadsViewLoader.item
70+
71+ onDone: downloadsViewLoader.active = false
72+ }
73+
74 }
75
76 TabsModel {
77@@ -1307,8 +1317,8 @@
78 }
79
80 function showDownloadsPage() {
81- downloadsContainer.focus = true
82- return downloadsComponent.createObject(downloadsContainer)
83+ downloadsViewLoader.active = true
84+ return downloadsViewLoader.item
85 }
86
87 function startDownload(downloadId, download, mimeType) {
88@@ -1989,7 +1999,7 @@
89 KeyboardShortcut {
90 modifiers: Qt.ControlModifier
91 key: Qt.Key_J
92- enabled: chrome.visible && !downloadsContainer.visible
93+ enabled: chrome.visible && !downloadsViewLoader.active
94 onTriggered: currentWebview.showDownloadsPage()
95 }
96
97@@ -2019,12 +2029,11 @@
98 target: contentHandlerLoader.item
99 onExportFromDownloads: {
100 if (downloadHandlerLoader.status == Loader.Ready) {
101- downloadsContainer.focus = true
102- var downloadPage = downloadsComponent.createObject(downloadsContainer)
103- downloadPage.mimetypeFilter = mimetypeFilter
104- downloadPage.activeTransfer = transfer
105- downloadPage.multiSelect = multiSelect
106- downloadPage.pickingMode = true
107+ downloadsViewLoader.active = true
108+ downloadsViewLoader.item.mimetypeFilter = mimetypeFilter
109+ downloadsViewLoader.item.activeTransfer = transfer
110+ downloadsViewLoader.item.multiSelect = multiSelect
111+ downloadsViewLoader.item.pickingMode = true
112 }
113 }
114 }
115
116=== modified file 'src/app/webbrowser/DownloadsPage.qml'
117--- src/app/webbrowser/DownloadsPage.qml 2015-12-16 10:11:46 +0000
118+++ src/app/webbrowser/DownloadsPage.qml 2016-01-07 13:43:20 +0000
119@@ -20,7 +20,6 @@
120 import Qt.labs.settings 1.0
121 import Ubuntu.Components 1.3
122 import Ubuntu.Components.Popups 1.0
123-import Ubuntu.Thumbnailer 0.1
124 import Ubuntu.Content 1.3
125 import Ubuntu.Web 0.2
126 import webbrowserapp.private 0.1
127@@ -46,6 +45,11 @@
128
129 signal done()
130
131+ Loader {
132+ id: thumbnailLoader
133+ source: "Thumbnailer.qml"
134+ }
135+
136 Rectangle {
137 anchors.fill: parent
138 color: "#fbfbfb"
139@@ -166,7 +170,10 @@
140 downloadId: model.downloadId
141 title: model.filename ? model.filename : model.url.toString().split('/').pop().split('?').shift()
142 url: model.url
143- image: model.complete && (model.mimetype.indexOf("image") === 0 || model.mimetype.indexOf("video") === 0) ? "image://thumbnailer/file://" + model.path : ""
144+ image: model.complete && thumbnailLoader.status == Loader.Ready
145+ && (model.mimetype.indexOf("image") === 0
146+ || model.mimetype.indexOf("video") === 0)
147+ ? "image://thumbnailer/file://" + model.path : ""
148 icon: MimeDatabase.iconForMimetype(model.mimetype)
149 incomplete: !model.complete
150 selectMode: downloadsItem.selectMode || downloadsItem.pickingMode
151
152=== added file 'src/app/webbrowser/Thumbnailer.qml'
153--- src/app/webbrowser/Thumbnailer.qml 1970-01-01 00:00:00 +0000
154+++ src/app/webbrowser/Thumbnailer.qml 2016-01-07 13:43:20 +0000
155@@ -0,0 +1,26 @@
156+/*
157+ * Copyright 2016 Canonical Ltd.
158+ *
159+ * This file is part of webbrowser-app.
160+ *
161+ * webbrowser-app is free software; you can redistribute it and/or modify
162+ * it under the terms of the GNU General Public License as published by
163+ * the Free Software Foundation; version 3.
164+ *
165+ * webbrowser-app is distributed in the hope that it will be useful,
166+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
167+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
168+ * GNU General Public License for more details.
169+ *
170+ * You should have received a copy of the GNU General Public License
171+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
172+ */
173+
174+import QtQml 2.0
175+import Ubuntu.Thumbnailer 0.1
176+
177+/* Because Thumbnailer isn't in the main repository the webbrowser can't
178+ depend on it. We use this file to dynamically load the thumbnailer image
179+ provider if it's installed. */
180+
181+QtObject { }

Subscribers

People subscribed via source and target branches

to status/vote changes: