Merge lp:~mhall119/ubuntu-docviewer-app/pdf-presentations into lp:ubuntu-docviewer-app

Proposed by Michael Hall
Status: Merged
Approved by: Stefano Verzegnassi
Approved revision: 264
Merged at revision: 262
Proposed branch: lp:~mhall119/ubuntu-docviewer-app/pdf-presentations
Merge into: lp:ubuntu-docviewer-app
Diff against target: 297 lines (+140/-14)
6 files modified
po/com.ubuntu.docviewer.pot (+17/-12)
src/app/qml/pdfView/PdfPresentation.qml (+106/-0)
src/app/qml/pdfView/PdfView.qml (+3/-0)
src/app/qml/pdfView/PdfViewDefaultHeader.qml (+7/-0)
src/app/qml/pdfView/PdfViewDelegate.qml (+6/-1)
src/app/qml/ubuntu-docviewer-app.qml (+1/-1)
To merge this branch: bzr merge lp:~mhall119/ubuntu-docviewer-app/pdf-presentations
Reviewer Review Type Date Requested Status
Jenkins Bot continuous-integration Approve
Stefano Verzegnassi Approve
Review via email: mp+282512@code.launchpad.net

Commit message

Add a basic presentation mode to PDF docments.

Description of the change

Adds a basic presentation mode to PDF docments.

To post a comment you must log in.
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
263. By Michael Hall

Fix header content positioning to remove gap on the left

Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Stefano Verzegnassi (verzegnassi-stefano) wrote :

Hi Michael, I will have a look at your MP tomorrow (14th Jan).

Don't mind the Jenkins error for now, since Autopilot tests have ATM some issue with the new configuration ("lxml" module is missing).

Revision history for this message
Stefano Verzegnassi (verzegnassi-stefano) wrote :

I found a few things that require a fix:

  * I'd prefer to use the new PageHeader, instead of the "old" page.head property.
    e.g. http://paste.ubuntu.com/14495479/

  * We'd probably need to display the page number of the current page.[1] In the code I posted above, it would be a matter of adding the "subtitle" property in the ListItemLayout.

  * I'm not sure of the background color. Shouldn't it be black?[1]

  * If the night-mode is active, it affects also the presentation view. It should be disabled when the user plays a presentation.

  * I've seen some strange output from PdfViewDelegate. Connections to the pinch area should be disabled when the component is used from the presentation view (e.g. using a bool).

  * The ShaderEffectSource in PdfViewDelegate should be disabled when in presentation mode, otherwise a blurry render of the page is visible after resizing the window[2]

  * Just a cosmetic fix, I'd use the "slideshow" icon, instead of "media-playback-start".

---

I've pushed the patch for these things in a separate branch:
    https://code.launchpad.net/~verzegnassi-stefano/ubuntu-docviewer-app/pdf-presentations-mp-review

I have still some doubt about the mouse/touch gestures.
While the "double-click-to-show-header" gesture looks good to me, I'm not sure about the "swipe-to-go-prev/next" touch gesture.
I'd probably prefer to split the mouseArea into three parts, as done in some Google application:
    https://drive.google.com/open?id=0By4kAplbFcE6QmJlR1ZydlVCSDA
Anyway, this is not important at the moment; I'm okay with the current solution.

Overall, your MP looks good, and it's pretty similar to how I was thinking of doing this. Big thumb up and thank you very much!

======

[1] My design proposal: https://drive.google.com/open?id=0By4kAplbFcE6MDNJMjBmNklVY28
     Current design: https://drive.google.com/open?id=0By4kAplbFcE6QWF4cXVfQm9uR28

[2] screenshot - https://drive.google.com/open?id=0By4kAplbFcE6RXh6Q2NELWlJbjg

review: Needs Fixing
264. By Stefano Verzegnassi

Suggested fixes from Stefano

Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Stefano Verzegnassi (verzegnassi-stefano) wrote :

LGTM!

Just a last question:
I saw you added a back action to Page.header.leadingActionBar.actions. Did you find some issue?

In theory, PageStack automatically appends the action when the page is pushed into the stack (at least, that's what I see on rc-proposed and my vivid+overlay desktop).

review: Approve
Revision history for this message
Michael Hall (mhall119) wrote :

In theory it does, but in practice it wasn't. I think it might be because the new PageHeader is looking for an AdaptivePageLayout rather than a PageStack. Whatever caused it to not appear, this would force it back.

Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'po/com.ubuntu.docviewer.pot'
2--- po/com.ubuntu.docviewer.pot 2015-12-27 12:10:06 +0000
3+++ po/com.ubuntu.docviewer.pot 2016-01-14 13:48:25 +0000
4@@ -8,7 +8,7 @@
5 msgstr ""
6 "Project-Id-Version: \n"
7 "Report-Msgid-Bugs-To: \n"
8-"POT-Creation-Date: 2015-12-27 13:06+0100\n"
9+"POT-Creation-Date: 2016-01-14 08:46-0500\n"
10 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
11 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
12 "Language-Team: LANGUAGE <LL@li.org>\n"
13@@ -42,7 +42,7 @@
14
15 #: ../src/app/qml/common/DetailsPage.qml:26
16 #: ../src/app/qml/loView/LOViewDefaultHeader.qml:107
17-#: ../src/app/qml/pdfView/PdfViewDefaultHeader.qml:83
18+#: ../src/app/qml/pdfView/PdfViewDefaultHeader.qml:90
19 #: ../src/app/qml/textView/TextViewDefaultHeader.qml:69
20 msgid "Details"
21 msgstr ""
22@@ -189,33 +189,33 @@
23
24 #. TRANSLATORS: %1 refers to a time formatted as Locale.ShortFormat (e.g. hh:mm). It depends on system settings.
25 #. http://qt-project.org/doc/qt-4.8/qlocale.html#FormatType-enum
26-#: ../src/app/qml/documentPage/DocumentListDelegate.qml:100
27+#: ../src/app/qml/documentPage/DocumentListDelegate.qml:103
28 #, qt-format
29 msgid "Today, %1"
30 msgstr ""
31
32 #. TRANSLATORS: %1 refers to a time formatted as Locale.ShortFormat (e.g. hh:mm). It depends on system settings.
33 #. http://qt-project.org/doc/qt-4.8/qlocale.html#FormatType-enum
34-#: ../src/app/qml/documentPage/DocumentListDelegate.qml:105
35+#: ../src/app/qml/documentPage/DocumentListDelegate.qml:108
36 #, qt-format
37 msgid "Yesterday, %1"
38 msgstr ""
39
40 #. TRANSLATORS: this is a datetime formatting string,
41 #. see http://qt-project.org/doc/qt-5/qml-qtqml-date.html#details for valid expressions.
42-#: ../src/app/qml/documentPage/DocumentListDelegate.qml:112
43-#: ../src/app/qml/documentPage/DocumentListDelegate.qml:131
44+#: ../src/app/qml/documentPage/DocumentListDelegate.qml:115
45+#: ../src/app/qml/documentPage/DocumentListDelegate.qml:134
46 msgid "yyyy/MM/dd hh:mm"
47 msgstr ""
48
49 #. TRANSLATORS: this is a datetime formatting string,
50 #. see http://qt-project.org/doc/qt-5/qml-qtqml-date.html#details for valid expressions.
51-#: ../src/app/qml/documentPage/DocumentListDelegate.qml:125
52+#: ../src/app/qml/documentPage/DocumentListDelegate.qml:128
53 msgid "dddd, hh:mm"
54 msgstr ""
55
56 #: ../src/app/qml/documentPage/DocumentPage.qml:23
57-#: /tmp/ubuntu-docviewer-app-build/po/com.ubuntu.docviewer.desktop.in.in.h:3
58+#: /home/mhall/projects/Ubuntu/coreapps/ubuntu-docviewer-app-build/po/com.ubuntu.docviewer.desktop.in.in.h:3
59 msgid "Documents"
60 msgstr ""
61
62@@ -342,13 +342,13 @@
63 msgstr ""
64
65 #: ../src/app/qml/loView/LOViewDefaultHeader.qml:100
66-#: ../src/app/qml/pdfView/PdfViewDefaultHeader.qml:77
67+#: ../src/app/qml/pdfView/PdfViewDefaultHeader.qml:84
68 #: ../src/app/qml/textView/TextViewDefaultHeader.qml:63
69 msgid "Disable night mode"
70 msgstr ""
71
72 #: ../src/app/qml/loView/LOViewDefaultHeader.qml:100
73-#: ../src/app/qml/pdfView/PdfViewDefaultHeader.qml:77
74+#: ../src/app/qml/pdfView/PdfViewDefaultHeader.qml:84
75 #: ../src/app/qml/textView/TextViewDefaultHeader.qml:63
76 msgid "Enable night mode"
77 msgstr ""
78@@ -403,6 +403,7 @@
79
80 #. TRANSLATORS: the first argument (%1) refers to the page currently shown on the screen,
81 #. while the second one (%2) refers to the total pages count.
82+#: ../src/app/qml/pdfView/PdfPresentation.qml:51
83 #: ../src/app/qml/pdfView/PdfView.qml:35
84 #, qt-format
85 msgid "Page %1 of %2"
86@@ -412,6 +413,10 @@
87 msgid "Go to page..."
88 msgstr ""
89
90+#: ../src/app/qml/pdfView/PdfViewDefaultHeader.qml:78
91+msgid "Presentation"
92+msgstr ""
93+
94 #: ../src/app/qml/pdfView/PdfViewGotoDialog.qml:26
95 msgid "Go to page"
96 msgstr ""
97@@ -439,10 +444,10 @@
98 msgid "copy %1"
99 msgstr ""
100
101-#: /tmp/ubuntu-docviewer-app-build/po/com.ubuntu.docviewer.desktop.in.in.h:1
102+#: /home/mhall/projects/Ubuntu/coreapps/ubuntu-docviewer-app-build/po/com.ubuntu.docviewer.desktop.in.in.h:1
103 msgid "Document Viewer"
104 msgstr ""
105
106-#: /tmp/ubuntu-docviewer-app-build/po/com.ubuntu.docviewer.desktop.in.in.h:2
107+#: /home/mhall/projects/Ubuntu/coreapps/ubuntu-docviewer-app-build/po/com.ubuntu.docviewer.desktop.in.in.h:2
108 msgid "documents;viewer;pdf;reader;"
109 msgstr ""
110
111=== added file 'src/app/qml/pdfView/PdfPresentation.qml'
112--- src/app/qml/pdfView/PdfPresentation.qml 1970-01-01 00:00:00 +0000
113+++ src/app/qml/pdfView/PdfPresentation.qml 2016-01-14 13:48:25 +0000
114@@ -0,0 +1,106 @@
115+/*
116+ * Copyright (C) 2013-2015 Canonical, Ltd.
117+ *
118+ * This program is free software; you can redistribute it and/or modify
119+ * it under the terms of the GNU General Public License as published by
120+ * the Free Software Foundation; version 3.
121+ *
122+ * This program is distributed in the hope that it will be useful,
123+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
124+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
125+ * GNU General Public License for more details.
126+ *
127+ * You should have received a copy of the GNU General Public License
128+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
129+ */
130+
131+import QtQuick 2.4
132+import Ubuntu.Components 1.3
133+import DocumentViewer 1.0
134+import DocumentViewer.PDF 1.0 as PDF
135+
136+Page {
137+ id: pdfPage
138+ property var poppler
139+ property bool isPresentation: true
140+ anchors.fill: parent
141+ title: DocumentViewer.getFileBaseNameFromPath(poppler.path)
142+ focus: true
143+
144+ header: PageHeader {
145+ visible: false
146+ leadingActionBar.actions: [
147+ Action {
148+ iconName: "back"
149+ text: "Back"
150+ onTriggered: pageStack.pop()
151+ }
152+ ]
153+ contents: ListItemLayout {
154+ anchors.centerIn: parent
155+ title {
156+ font.weight: Font.DemiBold
157+ textSize: Label.Large
158+ text: pdfPage.title
159+ color: pdfPage.header.__styleInstance.foregroundColor
160+ }
161+ subtitle {
162+ textSize: Label.Medium
163+ // TRANSLATORS: the first argument (%1) refers to the page currently shown on the screen,
164+ // while the second one (%2) refers to the total pages count.
165+ text: i18n.tr("Page %1 of %2").arg(pdfView.currentIndex + 1).arg(pdfView.count)
166+ color: pdfPage.header.__styleInstance.foregroundColor
167+ }
168+ }
169+
170+ StyleHints {
171+ backgroundColor: "#BF000000"
172+ foregroundColor: "white"
173+ }
174+ }
175+
176+ ListView {
177+ id: pdfView
178+ anchors.fill: parent
179+ focus: true
180+
181+ orientation: Qt.Horizontal;
182+ snapMode: ListView.SnapOneItem
183+ highlightRangeMode: ListView.StrictlyEnforceRange
184+ highlightFollowsCurrentItem: true
185+ highlightMoveDuration: 0
186+ boundsBehavior: Flickable.StopAtBounds
187+ cacheBuffer: width
188+
189+ model: poppler
190+ delegate: PdfViewDelegate {
191+ presentationMode: true
192+ width: pdfPage.width
193+ height: pdfPage.height
194+ color: "black"
195+ Component.onDestruction: window.releaseResources()
196+ }
197+ Component.onCompleted: pdfPage.forceActiveFocus()
198+
199+ MouseArea {
200+ anchors.fill: parent
201+ onDoubleClicked: pdfPage.header.visible = !pdfPage.header.visible
202+ }
203+ }
204+
205+ Keys.onPressed: {
206+ if (event.key == Qt.Key_Escape) { pageStack.pop(); return; }
207+ if (event.key == Qt.Key_Home) { pdfView.positionViewAtBeginning(); return; }
208+ if (event.key == Qt.Key_End) { pdfView.positionViewAtEnd(); return; }
209+
210+ if (event.key == Qt.Key_Right || event.key == Qt.Key_PageDown) {
211+ pdfView.incrementCurrentIndex();
212+ return;
213+ }
214+ if (event.key == Qt.Key_Left || event.key == Qt.Key_PageUp) {
215+ pdfView.decrementCurrentIndex();
216+ return;
217+ }
218+ }
219+}
220+
221
222=== modified file 'src/app/qml/pdfView/PdfView.qml'
223--- src/app/qml/pdfView/PdfView.qml 2015-12-26 18:27:13 +0000
224+++ src/app/qml/pdfView/PdfView.qml 2016-01-14 13:48:25 +0000
225@@ -42,6 +42,9 @@
226 // Reset night mode shader settings when closing the page
227 // Component.onDestruction: mainView.nightModeEnabled = false
228
229+ Keys.onPressed: {
230+ if (event.key == Qt.Key_F5) { pageStack.push(Qt.resolvedUrl("./PdfPresentation.qml"), {'poppler': poppler}); }
231+ }
232 Rectangle {
233 // Since UITK 1.3, the MainView background is white.
234 // We need to set a different color, otherwise pages
235
236=== modified file 'src/app/qml/pdfView/PdfViewDefaultHeader.qml'
237--- src/app/qml/pdfView/PdfViewDefaultHeader.qml 2015-11-13 21:19:46 +0000
238+++ src/app/qml/pdfView/PdfViewDefaultHeader.qml 2016-01-14 13:48:25 +0000
239@@ -73,6 +73,13 @@
240 },
241
242 Action {
243+ objectName:"presentationmode"
244+ iconName: "slideshow"
245+ text: i18n.tr("Presentation")
246+ onTriggered: pageStack.push(Qt.resolvedUrl("./PdfPresentation.qml"), {'poppler': poppler})
247+ },
248+
249+ Action {
250 iconName: "night-mode"
251 text: mainView.nightModeEnabled ? i18n.tr("Disable night mode") : i18n.tr("Enable night mode")
252 onTriggered: mainView.nightModeEnabled = !mainView.nightModeEnabled
253
254=== modified file 'src/app/qml/pdfView/PdfViewDelegate.qml'
255--- src/app/qml/pdfView/PdfViewDelegate.qml 2015-10-19 13:00:11 +0000
256+++ src/app/qml/pdfView/PdfViewDelegate.qml 2016-01-14 13:48:25 +0000
257@@ -21,6 +21,7 @@
258
259 property int index: model.index
260 property bool _previewFetched: false
261+ property bool presentationMode: false
262
263 property alias status: pageImg.status
264
265@@ -47,8 +48,12 @@
266
267 source: "image://poppler" + (index % poppler.providersNumber) + "/page/" + index;
268 sourceSize.width: pdfPage.width
269+ fillMode: Image.PreserveAspectFit
270
271 onStatusChanged: {
272+ if (presentationMode)
273+ return;
274+
275 // This is supposed to run the first time PdfViewDelegate gets the page rendering.
276 if (!_previewFetched) {
277 if (status == Image.Ready) {
278@@ -82,7 +87,7 @@
279 // Because of this, we have multiple callings to ImageProvider while zooming.
280 // Just avoid it.
281 Connections {
282- target: pinchy
283+ target: !presentationMode ? pinchy : null
284
285 onPinchStarted: _zoomTimer.stop();
286 onPinchUpdated: {
287
288=== modified file 'src/app/qml/ubuntu-docviewer-app.qml'
289--- src/app/qml/ubuntu-docviewer-app.qml 2015-11-30 12:12:10 +0000
290+++ src/app/qml/ubuntu-docviewer-app.qml 2016-01-14 13:48:25 +0000
291@@ -204,5 +204,5 @@
292
293 property bool nightModeEnabled: false
294 layer.effect: NightModeShader {}
295- layer.enabled: nightModeEnabled && (pageStack.depth > 1)
296+ layer.enabled: nightModeEnabled && (pageStack.depth > 1) && !pageStack.currentPage.isPresentation
297 }

Subscribers

People subscribed via source and target branches