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