Merge lp:~mrqtros/ubuntu-docviewer-app/ubuntu-docviewer-app-zoom-final into lp:ubuntu-docviewer-app

Proposed by Roman Shchekin
Status: Merged
Approved by: Stefano Verzegnassi
Approved revision: 200
Merged at revision: 204
Proposed branch: lp:~mrqtros/ubuntu-docviewer-app/ubuntu-docviewer-app-zoom-final
Merge into: lp:ubuntu-docviewer-app
Diff against target: 248 lines (+126/-54)
3 files modified
po/com.ubuntu.docviewer.pot (+6/-6)
src/app/qml/common/ScalingPinchArea.qml (+55/-0)
src/app/qml/loView/LOViewPage.qml (+65/-48)
To merge this branch: bzr merge lp:~mrqtros/ubuntu-docviewer-app/ubuntu-docviewer-app-zoom-final
Reviewer Review Type Date Requested Status
Alan Pope 🍺🐧🐱 πŸ¦„ (community) Approve
Stefano Verzegnassi Approve
Jenkins Bot continuous-integration Approve
Review via email: mp+278248@code.launchpad.net

Commit message

Zoom in LO.

Description of the change

Zoom in LO.

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)
200. By Roman Shchekin

Resolved conflict.

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

I left 4 diff comments.
They are just a few small notes, your changes look good to me.

Tested on desktop, with both Ubuntu.Layouts modes. I didn't see any regression (cannot test touch events on my PC though).

Tested on the BQ, and works greatly as expected!

Nice work, Roman!

review: Approve
Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

This is looking great.

One thing I noticed though is the zoom dropdown is always fixed on "Automatic (Fit width)" even if you choose another zoom level, or zoom in or out with the buttons. This means if you change the zoom level, you can never re-choose "Fit Width) because it thinks it's already ticked.

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

> One thing I noticed though is the zoom dropdown is always fixed on "Automatic
> (Fit width)" even if you choose another zoom level, or zoom in or out with the
> buttons. This means if you change the zoom level, you can never re-choose "Fit
> Width) because it thinks it's already ticked.

Honestly, I've missed that. Thanks!

Just had a look at it, it's not a bug introduced by this MP.

I've checked if the Viewer properly set the zoom mode to Manual when a "custom" (i.e. user-specified) value is set, and it does.

It's rather a bug in the ZoomSelector, from line 126:

selectedIndex: {
    if (loPageContentLoader.item.loView.zoomMode == LibreOffice.View.FitToWidth)
        return 0

    for (var i=0; i<textField.values.length; i++) {
        if (values[i] == loView.zoomFactor) {
            return i
        }
    }

    return -1
}

It returns:
    ReferenceError: loView is not defined

The 'for' loop in the code does not return any index, since the comparison between values[i] and loView.zoomFactor is never executed.
For that reason, the first entry in the ZoomSelector ("Automatic (Fit width)") is always selected.

I didn't take care of the current code of the ZoomSelector, since it was already planned to be replaced with some properly designed code.

This bug is already fixed in the UITK 1.3 branch, since it introduces the new ZoomSelector.

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

Anyway, and that's for sure, the work on zooming is not completed by this MP.

We still have three relevant things to do:

1) Add the double-tap-to-(un)zoom gesture.

2) Properly define the zoom behaviour (minimum zoom, maximum zoom, default value) for the following three form factors:
        - Touch device with screen.width < units.gu(80) - a.k.a. phones
        - Touch device with screen.width > units.gu(80) - a.k.a. tablet
        - Desktop
   We should also take care that the three types of documents we support through LibreOffice (Text, Spreadsheet and Presentation) have some different requirement.
   I started to have a look at this, but it needs to be planned accurately.

   In particular on phones we should limit the minimum zoom to the value set by the "Fit to width" zoom (e.g. Text document).

3) Introduce two new zoom modes: "Fit to Height" and "Automatic".
   "Automatic" mode should be a mix of "Fit to Height" and "Fit to Width". We need it in order to ensure that slides of presentation documents will be always fully visible, no matter which is the size/ratio of the application window.

Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

Great! Looks good so far!

review: Approve

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-10-31 20:37:19 +0000
3+++ po/com.ubuntu.docviewer.pot 2015-11-21 19:45:28 +0000
4@@ -8,7 +8,7 @@
5 msgstr ""
6 "Project-Id-Version: \n"
7 "Report-Msgid-Bugs-To: \n"
8-"POT-Creation-Date: 2015-10-31 23:16+0300\n"
9+"POT-Creation-Date: 2015-11-21 22:13+0300\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@@ -245,7 +245,7 @@
14
15 #: ../src/app/qml/documentPage/DocumentPageSearchHeader.qml:27
16 #: ../src/app/qml/loView/LOViewDefaultHeader.qml:70
17-#: ../src/app/qml/loView/LOViewPage.qml:191
18+#: ../src/app/qml/loView/LOViewPage.qml:208
19 #: ../src/app/qml/pdfView/PdfViewDefaultHeader.qml:61
20 #: ../src/app/qml/textView/TextViewDefaultHeader.qml:61
21 msgid "Back"
22@@ -378,8 +378,8 @@
23 msgid "GO!"
24 msgstr ""
25
26-#: ../src/app/qml/loView/LOViewPage.qml:34
27-#: ../src/app/qml/loView/LOViewPage.qml:189
28+#: ../src/app/qml/loView/LOViewPage.qml:35
29+#: ../src/app/qml/loView/LOViewPage.qml:206
30 msgid "Slides"
31 msgstr ""
32
33@@ -458,10 +458,10 @@
34 msgid "copy %1"
35 msgstr ""
36
37-#: /home/qtros/dev/ubuntu-docviewer-app-render-engine-tuning-build/po/com.ubuntu.docviewer.desktop.in.in.h:1
38+#: /home/qtros/dev/build-ubuntu-docviewer-app-zoom-final-UbuntuSDK_for_armhf_GCC_ubuntu_sdk_15_04_vivid-Default/po/com.ubuntu.docviewer.desktop.in.in.h:1
39 msgid "Document Viewer"
40 msgstr ""
41
42-#: /home/qtros/dev/ubuntu-docviewer-app-render-engine-tuning-build/po/com.ubuntu.docviewer.desktop.in.in.h:2
43+#: /home/qtros/dev/build-ubuntu-docviewer-app-zoom-final-UbuntuSDK_for_armhf_GCC_ubuntu_sdk_15_04_vivid-Default/po/com.ubuntu.docviewer.desktop.in.in.h:2
44 msgid "documents;viewer;pdf;reader;"
45 msgstr ""
46
47=== added file 'src/app/qml/common/ScalingPinchArea.qml'
48--- src/app/qml/common/ScalingPinchArea.qml 1970-01-01 00:00:00 +0000
49+++ src/app/qml/common/ScalingPinchArea.qml 2015-11-21 19:45:28 +0000
50@@ -0,0 +1,55 @@
51+import QtQuick 2.4
52+
53+PinchArea {
54+ id: pinchArea
55+
56+ property var targetFlickable: null
57+ property real totalScale: 1
58+
59+ onPinchUpdated: {
60+ pinchUpdatedHandler(pinch)
61+ }
62+ onPinchFinished: {
63+ pinchFinishedHandler()
64+ }
65+
66+ // ------------------------ Desktop DEBUG
67+
68+// MouseArea {
69+// id: testMa
70+// anchors.fill: parent
71+// visible: Qt.platform.os == "linux"
72+// z: 19
73+// acceptedButtons: Qt.RightButton
74+
75+// property int touchPointY
76+// property int touchPointX
77+// onPressed: {
78+// touchPointY = mouse.y
79+// touchPointX = mouse.x
80+// }
81+// onPositionChanged: {
82+// var sc = (1 + (mouse.y - touchPointY) / 200)
83+// pinchUpdatedHandler({"center" : { "x" : mouse.x, "y" : mouse.y }, "scale" : sc })
84+// }
85+// onReleased: {
86+// pinchFinishedHandler()
87+// }
88+// }
89+
90+ // ------------------------ Desktop DEBUG end
91+
92+ function pinchUpdatedHandler(pinch) {
93+ targetFlickable.scale = pinch.scale
94+ }
95+
96+ function pinchFinishedHandler() {
97+ var pt = pinchArea.mapFromItem(targetFlickable, -targetFlickable.contentX , -targetFlickable.contentY )
98+ // console.log("pinchFinishedHandler", -myItem.contentX, -myItem.contentY, Math.round(pt.x), Math.round(pt.y))
99+ targetFlickable.contentX = -pt.x
100+ targetFlickable.contentY = -pt.y
101+
102+ totalScale = targetFlickable.scale * totalScale
103+ targetFlickable.scale = 1
104+ }
105+}
106
107=== modified file 'src/app/qml/loView/LOViewPage.qml'
108--- src/app/qml/loView/LOViewPage.qml 2015-11-13 17:31:09 +0000
109+++ src/app/qml/loView/LOViewPage.qml 2015-11-21 19:45:28 +0000
110@@ -22,6 +22,7 @@
111 import "../upstreamComponents"
112
113 import "../common/utils.js" as Utils
114+import "../common"
115 import "KeybHelper.js" as KeybHelper
116
117 PageWithBottomEdge {
118@@ -113,7 +114,7 @@
119 }
120
121 ItemLayout {
122- item: "loView"
123+ item: "pinchArea"
124 anchors.fill: parent
125
126 // Keyboard events
127@@ -139,58 +140,74 @@
128 }
129 ]
130
131- LibreOffice.Viewer {
132- id: loView
133- objectName: "loView"
134- Layouts.item: "loView"
135+ ScalingPinchArea {
136+ id: pinchArea
137+ objectName: "pinchArea"
138+ Layouts.item: "pinchArea"
139+
140+ targetFlickable: loView
141+ onTotalScaleChanged: targetFlickable.updateContentSize(totalScale)
142+
143 anchors {
144- left: parent.left
145- right: parent.right
146 top: parent.top
147+ left: parent.left
148+ right: parent.right
149 bottom: bottomBar.top
150 }
151
152- clip: true
153- documentPath: file.path
154-
155- // Keyboard events
156- focus: true
157- Keys.onPressed: KeybHelper.parseEvent(event)
158-
159- Component.onCompleted: {
160- // WORKAROUND: Fix for wrong grid unit size
161- flickDeceleration = 1500 * units.gridUnit / 8
162- maximumFlickVelocity = 2500 * units.gridUnit / 8
163- loPageContent.forceActiveFocus()
164- }
165-
166- onErrorChanged: {
167- var errorString;
168-
169- switch(error) {
170- case LibreOffice.Error.LibreOfficeNotFound:
171- errorString = i18n.tr("LibreOffice binaries not found.")
172- break;
173- case LibreOffice.Error.LibreOfficeNotInitialized:
174- errorString = i18n.tr("Error while loading LibreOffice.")
175- break;
176- case LibreOffice.Error.DocumentNotLoaded:
177- errorString = i18n.tr("Document not loaded.\nThe requested document may be corrupt.")
178- break;
179- }
180-
181- if (errorString) {
182- loPage.pageStack.pop()
183-
184- // We create the dialog in the MainView, so that it isn't
185- // initialized by 'loPage' and keep on working after the
186- // page is destroyed.
187- mainView.showErrorDialog(errorString);
188- }
189- }
190-
191- Scrollbar { flickableItem: loView; parent: loView.parent }
192- Scrollbar { flickableItem: loView; parent: loView.parent; align: Qt.AlignBottom }
193+ LibreOffice.Viewer {
194+ id: loView
195+ objectName: "loView"
196+ Layouts.item: "loView"
197+
198+ anchors.fill: parent
199+
200+ clip: true
201+ documentPath: file.path
202+
203+ // Keyboard events
204+ focus: true
205+ Keys.onPressed: KeybHelper.parseEvent(event)
206+
207+ Component.onCompleted: {
208+ // WORKAROUND: Fix for wrong grid unit size
209+ flickDeceleration = 1500 * units.gridUnit / 8
210+ maximumFlickVelocity = 2500 * units.gridUnit / 8
211+ loPageContent.forceActiveFocus()
212+ }
213+
214+ function updateContentSize(tgtScale) {
215+ zoomFactor = tgtScale
216+ }
217+
218+ onErrorChanged: {
219+ var errorString;
220+
221+ switch(error) {
222+ case LibreOffice.Error.LibreOfficeNotFound:
223+ errorString = i18n.tr("LibreOffice binaries not found.")
224+ break;
225+ case LibreOffice.Error.LibreOfficeNotInitialized:
226+ errorString = i18n.tr("Error while loading LibreOffice.")
227+ break;
228+ case LibreOffice.Error.DocumentNotLoaded:
229+ errorString = i18n.tr("Document not loaded.\nThe requested document may be corrupt.")
230+ break;
231+ }
232+
233+ if (errorString) {
234+ loPage.pageStack.pop()
235+
236+ // We create the dialog in the MainView, so that it isn't
237+ // initialized by 'loPage' and keep on working after the
238+ // page is destroyed.
239+ mainView.showErrorDialog(errorString);
240+ }
241+ }
242+
243+ Scrollbar { flickableItem: loView; parent: loView.parent }
244+ Scrollbar { flickableItem: loView; parent: loView.parent; align: Qt.AlignBottom }
245+ }
246 }
247
248 // TODO: When we'll have to merge this with the zooming branch, replace this

Subscribers

People subscribed via source and target branches