Merge lp:~verzegnassi-stefano/ubuntu-docviewer-app/uitk13-lok-page into lp:ubuntu-docviewer-app
- uitk13-lok-page
- Merge into lo-viewer
Status: | Merged |
---|---|
Approved by: | Roman Shchekin |
Approved revision: | 321 |
Merged at revision: | 326 |
Proposed branch: | lp:~verzegnassi-stefano/ubuntu-docviewer-app/uitk13-lok-page |
Merge into: | lp:ubuntu-docviewer-app |
Diff against target: |
548 lines (+207/-204) 4 files modified
src/app/qml/common/ViewerPage.qml (+32/-3) src/app/qml/loView/KeybHelper.js (+23/-47) src/app/qml/loView/LOViewDefaultHeader.qml (+41/-55) src/app/qml/loView/LOViewPage.qml (+111/-99) |
To merge this branch: | bzr merge lp:~verzegnassi-stefano/ubuntu-docviewer-app/uitk13-lok-page |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jenkins Bot | continuous-integration | Approve | |
Roman Shchekin | Needs Information | ||
Review via email: mp+290048@code.launchpad.net |
Commit message
* WORKAROUND: make the lok-viewer header static (avoid unpredictable binding)
* Use new PageHeader and ScrollView components
* UI: Show an empty header when loading LibreOffice
Description of the change
* WORKAROUND: make the lok-viewer header static (avoid unpredictable binding)
* Use new PageHeader and ScrollView components
* UI: Show an empty header when loading LibreOffice
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote : | # |
Roman Shchekin (mrqtros) wrote : | # |
See inline comments!
Stefano Verzegnassi (verzegnassi-stefano) wrote : | # |
> Haha, are you enjoyed deleting this code? ;)
Ahah, you can be sure of it! :)
> Why did you switch it [PageHeader.
I was having trouble in setting the anchors for the content of the ViewerPage[1], and the LibreOffice Viewer had strange bindings that were causing a continuous flickering and reloading of the document content, every time the header was changing its status (i.e. visible/hidden).
I spent some time on it again (after you review), and now it seems to behave correctly. Pushing the new commit...
[1] We load LOViewPage asynchronously, but the loading logic is placed in a different file.
- 321. By Stefano Verzegnassi
-
Fixed flickable
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:321
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | === modified file 'src/app/qml/common/ViewerPage.qml' | |||
2 | --- src/app/qml/common/ViewerPage.qml 2015-11-30 12:12:10 +0000 | |||
3 | +++ src/app/qml/common/ViewerPage.qml 2016-03-30 11:10:56 +0000 | |||
4 | @@ -1,5 +1,5 @@ | |||
5 | 1 | /* | 1 | /* |
7 | 2 | * Copyright (C) 2015 Stefano Verzegnassi <verzegnassi.stefano@gmail.com> | 2 | * Copyright (C) 2015, 2016 Stefano Verzegnassi <verzegnassi.stefano@gmail.com> |
8 | 3 | * | 3 | * |
9 | 4 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
10 | 5 | * it under the terms of the GNU General Public License as published by | 5 | * it under the terms of the GNU General Public License as published by |
11 | @@ -35,7 +35,21 @@ | |||
12 | 35 | 35 | ||
13 | 36 | Loader { | 36 | Loader { |
14 | 37 | id: contentLoader | 37 | id: contentLoader |
16 | 38 | anchors.fill: parent | 38 | anchors { |
17 | 39 | left: parent.left | ||
18 | 40 | right: parent.right | ||
19 | 41 | bottom: parent.bottom | ||
20 | 42 | |||
21 | 43 | top: { | ||
22 | 44 | if (!viewerPage.header) | ||
23 | 45 | return parent.top | ||
24 | 46 | |||
25 | 47 | if (!viewerPage.header.flickable) | ||
26 | 48 | return viewerPage.header.bottom | ||
27 | 49 | else | ||
28 | 50 | return parent.top | ||
29 | 51 | } | ||
30 | 52 | } | ||
31 | 39 | 53 | ||
32 | 40 | asynchronous: true | 54 | asynchronous: true |
33 | 41 | sourceComponent: viewerPage.contents | 55 | sourceComponent: viewerPage.contents |
34 | @@ -45,7 +59,22 @@ | |||
35 | 45 | 59 | ||
36 | 46 | Item { | 60 | Item { |
37 | 47 | id: splashScreenItem | 61 | id: splashScreenItem |
39 | 48 | anchors.fill: parent | 62 | |
40 | 63 | anchors { | ||
41 | 64 | left: parent.left | ||
42 | 65 | right: parent.right | ||
43 | 66 | bottom: parent.bottom | ||
44 | 67 | |||
45 | 68 | top: { | ||
46 | 69 | if (!viewerPage.header) | ||
47 | 70 | return parent.top | ||
48 | 71 | |||
49 | 72 | if (!viewerPage.header.flickable) | ||
50 | 73 | return viewerPage.header.bottom | ||
51 | 74 | else | ||
52 | 75 | return parent.top | ||
53 | 76 | } | ||
54 | 77 | } | ||
55 | 49 | 78 | ||
56 | 50 | visible: contentLoader.status != Loader.Ready | 79 | visible: contentLoader.status != Loader.Ready |
57 | 51 | enabled: visible | 80 | enabled: visible |
58 | 52 | 81 | ||
59 | === modified file 'src/app/qml/loView/KeybHelper.js' | |||
60 | --- src/app/qml/loView/KeybHelper.js 2015-12-14 00:40:55 +0000 | |||
61 | +++ src/app/qml/loView/KeybHelper.js 2016-03-30 11:10:56 +0000 | |||
62 | @@ -1,5 +1,5 @@ | |||
63 | 1 | /* | 1 | /* |
65 | 2 | * Copyright (C) 2015 Stefano Verzegnassi | 2 | * Copyright (C) 2015, 2016 Stefano Verzegnassi |
66 | 3 | * | 3 | * |
67 | 4 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
68 | 5 | * it under the terms of the GNU General Public License as published by | 5 | * it under the terms of the GNU General Public License as published by |
69 | @@ -14,83 +14,59 @@ | |||
70 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
71 | 15 | */ | 15 | */ |
72 | 16 | 16 | ||
73 | 17 | // Here we handle all the key events that are not | ||
74 | 18 | // recognised by UITK ScrollView | ||
75 | 19 | |||
76 | 17 | function parseEvent(event) { | 20 | function parseEvent(event) { |
77 | 18 | var pixelDiff = 5; | ||
78 | 19 | |||
79 | 20 | var view = loPage.contentItem.loView | 21 | var view = loPage.contentItem.loView |
80 | 21 | var isPresentation = view.document.documentType === LibreOffice.Document.PresentationDocument | 22 | var isPresentation = view.document.documentType === LibreOffice.Document.PresentationDocument |
81 | 22 | 23 | ||
82 | 23 | if (event.key == Qt.Key_PageUp) { | 24 | if (event.key == Qt.Key_PageUp) { |
84 | 24 | if (isPresentation) | 25 | if (isPresentation) { |
85 | 25 | view.currentPart -= 1 | 26 | view.currentPart -= 1 |
89 | 26 | else | 27 | event.accepted = true |
90 | 27 | view.moveView("vertical", -view.height) | 28 | } |
88 | 28 | |||
91 | 29 | return; | 29 | return; |
92 | 30 | } | 30 | } |
93 | 31 | 31 | ||
94 | 32 | if (event.key == Qt.Key_PageDown) { | 32 | if (event.key == Qt.Key_PageDown) { |
96 | 33 | if (isPresentation) | 33 | if (isPresentation) { |
97 | 34 | view.currentPart += 1 | 34 | view.currentPart += 1 |
101 | 35 | else | 35 | event.accepted = true |
102 | 36 | view.moveView("vertical", view.height) | 36 | } |
100 | 37 | |||
103 | 38 | return; | 37 | return; |
104 | 39 | } | 38 | } |
105 | 40 | 39 | ||
106 | 41 | if (event.key == Qt.Key_Home) { | 40 | if (event.key == Qt.Key_Home) { |
110 | 42 | if (event.modifiers & Qt.ControlModifier) { | 41 | if (event.modifiers & Qt.ControlModifier) |
108 | 43 | view.contentX = 0 | ||
109 | 44 | view.contentY = 0 | ||
111 | 45 | view.currentPart = 0 | 42 | view.currentPart = 0 |
116 | 46 | } else { | 43 | |
117 | 47 | view.contentX = 0 | 44 | event.accepted = false |
118 | 48 | view.contentY = 0 | 45 | return |
115 | 49 | } | ||
119 | 50 | } | 46 | } |
120 | 51 | 47 | ||
121 | 52 | if (event.key == Qt.Key_End) { | 48 | if (event.key == Qt.Key_End) { |
126 | 53 | if (event.modifiers & Qt.ControlModifier) { | 49 | if (event.modifiers & Qt.ControlModifier) |
123 | 54 | view.contentX = view.contentWidth - view.width | ||
124 | 55 | view.contentY = view.contentHeight - view.height | ||
125 | 56 | console.log(view.currentPart, view.document.partsCount - 1) | ||
127 | 57 | view.currentPart = view.document.partsCount - 1 | 50 | view.currentPart = view.document.partsCount - 1 |
128 | 58 | } else { | ||
129 | 59 | view.contentX = view.contentWidth - view.width | ||
130 | 60 | view.contentY = view.contentHeight - view.height | ||
131 | 61 | } | ||
132 | 62 | } | ||
133 | 63 | 51 | ||
152 | 64 | if (event.key == Qt.Key_Up) { | 52 | event.accepted = false |
153 | 65 | view.moveView("vertical", -pixelDiff) | 53 | return |
136 | 66 | return; | ||
137 | 67 | } | ||
138 | 68 | |||
139 | 69 | if (event.key == Qt.Key_Down) { | ||
140 | 70 | view.moveView("vertical", pixelDiff) | ||
141 | 71 | return; | ||
142 | 72 | } | ||
143 | 73 | |||
144 | 74 | if (event.key == Qt.Key_Left) { | ||
145 | 75 | view.moveView("horizontal", -pixelDiff) | ||
146 | 76 | return; | ||
147 | 77 | } | ||
148 | 78 | |||
149 | 79 | if (event.key == Qt.Key_Right) { | ||
150 | 80 | view.moveView("horizontal", pixelDiff) | ||
151 | 81 | return; | ||
154 | 82 | } | 54 | } |
155 | 83 | 55 | ||
156 | 84 | if (event.key == Qt.Key_Plus) { | 56 | if (event.key == Qt.Key_Plus) { |
157 | 85 | if (event.modifiers & Qt.ControlModifier) { | 57 | if (event.modifiers & Qt.ControlModifier) { |
159 | 86 | view.zoomFactor = Math.max(4.0, view.zoomFactor + 0.25) | 58 | view.setZoom(Math.min(view.zoomSettings.maximumZoom, view.zoomSettings.zoomFactor + 0.25)) |
160 | 87 | } | 59 | } |
161 | 60 | |||
162 | 61 | return | ||
163 | 88 | } | 62 | } |
164 | 89 | 63 | ||
165 | 90 | if (event.key == Qt.Key_Minus) { | 64 | if (event.key == Qt.Key_Minus) { |
166 | 91 | if (event.modifiers & Qt.ControlModifier) { | 65 | if (event.modifiers & Qt.ControlModifier) { |
168 | 92 | view.zoomFactor = Math.min(0.5, view.zoomFactor - 0.25) | 66 | view.setZoom(Math.max(view.zoomSettings.minimumZoom, view.zoomSettings.zoomFactor - 0.25)) |
169 | 93 | } | 67 | } |
170 | 68 | |||
171 | 69 | return | ||
172 | 94 | } | 70 | } |
173 | 95 | 71 | ||
174 | 96 | 72 | ||
175 | 97 | 73 | ||
176 | === modified file 'src/app/qml/loView/LOViewDefaultHeader.qml' | |||
177 | --- src/app/qml/loView/LOViewDefaultHeader.qml 2015-11-30 12:12:10 +0000 | |||
178 | +++ src/app/qml/loView/LOViewDefaultHeader.qml 2016-03-30 11:10:56 +0000 | |||
179 | @@ -1,5 +1,5 @@ | |||
180 | 1 | /* | 1 | /* |
182 | 2 | * Copyright (C) 2014-2015 Canonical, Ltd. | 2 | * Copyright (C) 2014-2016 Canonical, Ltd. |
183 | 3 | * | 3 | * |
184 | 4 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
185 | 5 | * it under the terms of the GNU General Public License as published by | 5 | * it under the terms of the GNU General Public License as published by |
186 | @@ -16,68 +16,55 @@ | |||
187 | 16 | 16 | ||
188 | 17 | import QtQuick 2.4 | 17 | import QtQuick 2.4 |
189 | 18 | import Ubuntu.Components 1.3 | 18 | import Ubuntu.Components 1.3 |
190 | 19 | import QtQuick.Layouts 1.1 | ||
191 | 20 | import Ubuntu.Components.Popups 1.3 | 19 | import Ubuntu.Components.Popups 1.3 |
192 | 21 | import DocumentViewer.LibreOffice 1.0 as LibreOffice | 20 | import DocumentViewer.LibreOffice 1.0 as LibreOffice |
193 | 22 | import DocumentViewer 1.0 | 21 | import DocumentViewer 1.0 |
194 | 23 | 22 | ||
238 | 24 | PageHeadState { | 23 | PageHeader { |
239 | 25 | id: rootItem | 24 | id: defaultHeader |
240 | 26 | 25 | ||
241 | 27 | property Page targetPage | 26 | property var targetPage |
242 | 28 | head: targetPage.head | 27 | |
243 | 29 | 28 | contents: ListItemLayout { | |
244 | 30 | contents: RowLayout { | 29 | anchors.centerIn: parent |
245 | 31 | anchors.fill: parent | 30 | |
246 | 32 | anchors.rightMargin: units.gu(2) | 31 | title { |
247 | 33 | spacing: units.gu(1) | 32 | elide: Text.ElideMiddle |
248 | 34 | 33 | font.weight: Font.DemiBold | |
249 | 35 | Column { | 34 | text: defaultHeader.title |
250 | 36 | id: layout | 35 | } |
251 | 37 | Layout.fillWidth: true | 36 | |
252 | 38 | 37 | subtitle { | |
253 | 39 | Label { | 38 | textSize: Label.Small |
254 | 40 | anchors { left: parent.left; right: parent.right } | 39 | text: { |
255 | 41 | elide: Text.ElideMiddle | 40 | if (!targetPage.contentItem) |
256 | 42 | font.weight: Font.DemiBold | 41 | return i18n.tr("Loading...") |
257 | 43 | text: targetPage.title | 42 | |
258 | 44 | } | 43 | switch(targetPage.contentItem.loDocument.documentType) { |
259 | 45 | Label { | 44 | case LibreOffice.Document.TextDocument: |
260 | 46 | anchors { left: parent.left; right: parent.right } | 45 | return i18n.tr("LibreOffice text document") |
261 | 47 | elide: Text.ElideMiddle | 46 | case LibreOffice.Document.SpreadsheetDocument: |
262 | 48 | textSize: Label.Small | 47 | return i18n.tr("LibreOffice spread sheet") |
263 | 49 | text: { | 48 | case LibreOffice.Document.PresentationDocument: |
264 | 50 | if (!targetPage.contentItem) | 49 | return i18n.tr("LibreOffice presentation") |
265 | 51 | return i18n.tr("Loading...") | 50 | case LibreOffice.Document.DrawingDocument: |
266 | 52 | 51 | return i18n.tr("LibreOffice Draw document") | |
267 | 53 | switch(targetPage.contentItem.loDocument.documentType) { | 52 | case LibreOffice.Document.OtherDocument: |
268 | 54 | case 0: | 53 | return i18n.tr("Unknown LibreOffice document") |
269 | 55 | return i18n.tr("LibreOffice text document") | 54 | default: |
270 | 56 | case 1: | 55 | return i18n.tr("Unknown type document") |
228 | 57 | return i18n.tr("LibreOffice spread sheet") | ||
229 | 58 | case 2: | ||
230 | 59 | return i18n.tr("LibreOffice presentation") | ||
231 | 60 | case 3: | ||
232 | 61 | return i18n.tr("LibreOffice Draw document") | ||
233 | 62 | case 4: | ||
234 | 63 | return i18n.tr("Unknown LibreOffice document") | ||
235 | 64 | default: | ||
236 | 65 | return i18n.tr("Unknown type document") | ||
237 | 66 | } | ||
271 | 67 | } | 56 | } |
272 | 68 | } | 57 | } |
273 | 69 | } | 58 | } |
274 | 70 | 59 | ||
275 | 71 | ZoomSelector { | 60 | ZoomSelector { |
279 | 72 | Layout.preferredWidth: units.gu(12) | 61 | SlotsLayout.position: SlotsLayout.Trailing |
277 | 73 | Layout.preferredHeight: units.gu(4) | ||
278 | 74 | |||
280 | 75 | view: targetPage.contentItem.loView | 62 | view: targetPage.contentItem.loView |
281 | 76 | visible: targetPage.contentItem && (DocumentViewer.desktopMode || mainView.wideWindow) | 63 | visible: targetPage.contentItem && (DocumentViewer.desktopMode || mainView.wideWindow) |
282 | 77 | } | 64 | } |
283 | 78 | } | 65 | } |
284 | 79 | 66 | ||
286 | 80 | actions: [ | 67 | trailingActionBar.actions: [ |
287 | 81 | Action { | 68 | Action { |
288 | 82 | // FIXME: Autopilot test broken... seems not to detect we're now using an ActionBar since the switch to UITK 1.3 | 69 | // FIXME: Autopilot test broken... seems not to detect we're now using an ActionBar since the switch to UITK 1.3 |
289 | 83 | objectName: "gotopage" | 70 | objectName: "gotopage" |
290 | @@ -86,12 +73,11 @@ | |||
291 | 86 | visible: targetPage.contentItem.loDocument.documentType == LibreOffice.Document.TextDocument | 73 | visible: targetPage.contentItem.loDocument.documentType == LibreOffice.Document.TextDocument |
292 | 87 | 74 | ||
293 | 88 | onTriggered: { | 75 | onTriggered: { |
300 | 89 | PopupUtils.open( | 76 | var popupSettings = { |
301 | 90 | Qt.resolvedUrl("LOViewGotoDialog.qml"), | 77 | view: targetPage.contentItem.loView |
302 | 91 | targetPage, | 78 | } |
303 | 92 | { | 79 | |
304 | 93 | view: targetPage.contentItem.loView | 80 | PopupUtils.open(Qt.resolvedUrl("LOViewGotoDialog.qml"), targetPage, popupSettings) |
299 | 94 | }) | ||
305 | 95 | } | 81 | } |
306 | 96 | }, | 82 | }, |
307 | 97 | 83 | ||
308 | 98 | 84 | ||
309 | === modified file 'src/app/qml/loView/LOViewPage.qml' | |||
310 | --- src/app/qml/loView/LOViewPage.qml 2016-02-03 21:35:53 +0000 | |||
311 | +++ src/app/qml/loView/LOViewPage.qml 2016-03-30 11:10:56 +0000 | |||
312 | @@ -1,5 +1,5 @@ | |||
313 | 1 | /* | 1 | /* |
315 | 2 | * Copyright (C) 2013-2015 Canonical, Ltd. | 2 | * Copyright (C) 2013-2016 Canonical, Ltd. |
316 | 3 | * | 3 | * |
317 | 4 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
318 | 5 | * it under the terms of the GNU General Public License as published by | 5 | * it under the terms of the GNU General Public License as published by |
319 | @@ -32,9 +32,7 @@ | |||
320 | 32 | property bool isTextDocument: loPage.contentItem && (loPage.contentItem.loDocument.documentType === LibreOffice.Document.TextDocument) | 32 | property bool isTextDocument: loPage.contentItem && (loPage.contentItem.loDocument.documentType === LibreOffice.Document.TextDocument) |
321 | 33 | property bool isSpreadsheet: loPage.contentItem && (loPage.contentItem.loDocument.documentType === LibreOffice.Document.SpreadsheetDocument) | 33 | property bool isSpreadsheet: loPage.contentItem && (loPage.contentItem.loDocument.documentType === LibreOffice.Document.SpreadsheetDocument) |
322 | 34 | 34 | ||
326 | 35 | title: DocumentViewer.getFileBaseNameFromPath(file.path); | 35 | header: defaultHeader |
324 | 36 | flickable: isTextDocument ? loPage.contentItem.loView : null | ||
325 | 37 | |||
327 | 38 | splashScreen: Splashscreen { } | 36 | splashScreen: Splashscreen { } |
328 | 39 | 37 | ||
329 | 40 | content: FocusScope { | 38 | content: FocusScope { |
330 | @@ -137,96 +135,102 @@ | |||
331 | 137 | color: "#f5f5f5" | 135 | color: "#f5f5f5" |
332 | 138 | } | 136 | } |
333 | 139 | 137 | ||
337 | 140 | LibreOffice.Viewer { | 138 | ScrollView { |
335 | 141 | id: loView | ||
336 | 142 | objectName: "loView" | ||
338 | 143 | anchors.fill: parent | 139 | anchors.fill: parent |
339 | 144 | 140 | ||
384 | 145 | documentPath: file.path | 141 | // We need to set some custom event handler. |
385 | 146 | 142 | // Forward the key events to the Viewer and | |
386 | 147 | function updateContentSize(tgtScale) { | 143 | // fallback to the ScrollView handlers if the |
387 | 148 | zoomSettings.zoomFactor = tgtScale | 144 | // event hasn't been accepted. |
388 | 149 | } | 145 | Keys.forwardTo: loView |
389 | 150 | 146 | Keys.priority: Keys.AfterItem | |
390 | 151 | // Keyboard events | 147 | |
391 | 152 | focus: true | 148 | LibreOffice.Viewer { |
392 | 153 | Keys.onPressed: KeybHelper.parseEvent(event) | 149 | id: loView |
393 | 154 | 150 | objectName: "loView" | |
350 | 155 | Component.onCompleted: { | ||
351 | 156 | // WORKAROUND: Fix for wrong grid unit size | ||
352 | 157 | flickDeceleration = 1500 * units.gridUnit / 8 | ||
353 | 158 | maximumFlickVelocity = 2500 * units.gridUnit / 8 | ||
354 | 159 | loPageContent.forceActiveFocus() | ||
355 | 160 | } | ||
356 | 161 | |||
357 | 162 | onErrorChanged: { | ||
358 | 163 | var errorString; | ||
359 | 164 | |||
360 | 165 | switch(error) { | ||
361 | 166 | case LibreOffice.Error.LibreOfficeNotFound: | ||
362 | 167 | errorString = i18n.tr("LibreOffice binaries not found.") | ||
363 | 168 | break; | ||
364 | 169 | case LibreOffice.Error.LibreOfficeNotInitialized: | ||
365 | 170 | errorString = i18n.tr("Error while loading LibreOffice.") | ||
366 | 171 | break; | ||
367 | 172 | case LibreOffice.Error.DocumentNotLoaded: | ||
368 | 173 | errorString = i18n.tr("Document not loaded.\nThe requested document may be corrupt or protected by a password.") | ||
369 | 174 | break; | ||
370 | 175 | } | ||
371 | 176 | |||
372 | 177 | if (errorString) { | ||
373 | 178 | loPage.pageStack.pop() | ||
374 | 179 | |||
375 | 180 | // We create the dialog in the MainView, so that it isn't | ||
376 | 181 | // initialized by 'loPage' and keep on working after the | ||
377 | 182 | // page is destroyed. | ||
378 | 183 | mainView.showErrorDialog(errorString); | ||
379 | 184 | } | ||
380 | 185 | } | ||
381 | 186 | |||
382 | 187 | ScalingMouseArea { | ||
383 | 188 | id: mouseArea | ||
394 | 189 | anchors.fill: parent | 151 | anchors.fill: parent |
435 | 190 | targetFlickable: loView | 152 | |
436 | 191 | onTotalScaleChanged: targetFlickable.updateContentSize(totalScale) | 153 | documentPath: file.path |
437 | 192 | 154 | ||
438 | 193 | thresholdZoom: minimumZoom + (maximumZoom - minimumZoom) * 0.75 | 155 | Keys.onPressed: KeybHelper.parseEvent(event) |
439 | 194 | maximumZoom: { | 156 | |
440 | 195 | if (DocumentViewer.desktopMode || mainView.wideWindow) | 157 | function updateContentSize(tgtScale) { |
441 | 196 | return 3.0 | 158 | zoomSettings.zoomFactor = tgtScale |
442 | 197 | 159 | } | |
443 | 198 | return minimumZoom * 3 | 160 | |
444 | 199 | } | 161 | Component.onCompleted: { |
445 | 200 | minimumZoom: { | 162 | // WORKAROUND: Fix for wrong grid unit size |
446 | 201 | if (DocumentViewer.desktopMode || mainView.wideWindow) | 163 | flickDeceleration = 1500 * units.gridUnit / 8 |
447 | 202 | return loView.zoomSettings.minimumZoom | 164 | maximumFlickVelocity = 2500 * units.gridUnit / 8 |
448 | 203 | 165 | loPageContent.forceActiveFocus() | |
449 | 204 | switch(loView.document.documentType) { | 166 | } |
450 | 205 | case LibreOffice.Document.TextDocument: | 167 | |
451 | 206 | return loView.zoomSettings.valueFitToWidthZoom | 168 | onErrorChanged: { |
452 | 207 | case LibreOffice.Document.PresentationDocument: | 169 | var errorString; |
453 | 208 | return loView.zoomSettings.valueAutomaticZoom | 170 | |
454 | 209 | default: | 171 | switch(error) { |
455 | 210 | return loView.zoomSettings.minimumZoom | 172 | case LibreOffice.Error.LibreOfficeNotFound: |
456 | 211 | } | 173 | errorString = i18n.tr("LibreOffice binaries not found.") |
457 | 212 | } | 174 | break; |
458 | 213 | 175 | case LibreOffice.Error.LibreOfficeNotInitialized: | |
459 | 214 | Binding { | 176 | errorString = i18n.tr("Error while loading LibreOffice.") |
460 | 215 | target: mouseArea | 177 | break; |
461 | 216 | property: "zoomValue" | 178 | case LibreOffice.Error.DocumentNotLoaded: |
462 | 217 | value: loView.zoomSettings.zoomFactor | 179 | errorString = i18n.tr("Document not loaded.\nThe requested document may be corrupt or protected by a password.") |
463 | 218 | } | 180 | break; |
464 | 219 | } | 181 | } |
465 | 220 | 182 | ||
466 | 221 | Scrollbar { flickableItem: loView; parent: loView.parent } | 183 | if (errorString) { |
467 | 222 | Scrollbar { flickableItem: loView; parent: loView.parent; align: Qt.AlignBottom } | 184 | loPage.pageStack.pop() |
468 | 223 | 185 | ||
469 | 224 | Label { | 186 | // We create the dialog in the MainView, so that it isn't |
470 | 225 | anchors.centerIn: parent | 187 | // initialized by 'loPage' and keep on working after the |
471 | 226 | parent: loPage | 188 | // page is destroyed. |
472 | 227 | textSize: Label.Large | 189 | mainView.showErrorDialog(errorString); |
473 | 228 | text: i18n.tr("This sheet has no content.") | 190 | } |
474 | 229 | visible: loPage.isSpreadsheet && loView.contentWidth <= 0 && loView.contentHeight <= 0 | 191 | } |
475 | 192 | |||
476 | 193 | ScalingMouseArea { | ||
477 | 194 | id: mouseArea | ||
478 | 195 | anchors.fill: parent | ||
479 | 196 | targetFlickable: loView | ||
480 | 197 | onTotalScaleChanged: targetFlickable.updateContentSize(totalScale) | ||
481 | 198 | |||
482 | 199 | thresholdZoom: minimumZoom + (maximumZoom - minimumZoom) * 0.75 | ||
483 | 200 | maximumZoom: { | ||
484 | 201 | if (DocumentViewer.desktopMode || mainView.wideWindow) | ||
485 | 202 | return 3.0 | ||
486 | 203 | |||
487 | 204 | return minimumZoom * 3 | ||
488 | 205 | } | ||
489 | 206 | minimumZoom: { | ||
490 | 207 | if (DocumentViewer.desktopMode || mainView.wideWindow) | ||
491 | 208 | return loView.zoomSettings.minimumZoom | ||
492 | 209 | |||
493 | 210 | switch(loView.document.documentType) { | ||
494 | 211 | case LibreOffice.Document.TextDocument: | ||
495 | 212 | return loView.zoomSettings.valueFitToWidthZoom | ||
496 | 213 | case LibreOffice.Document.PresentationDocument: | ||
497 | 214 | return loView.zoomSettings.valueAutomaticZoom | ||
498 | 215 | default: | ||
499 | 216 | return loView.zoomSettings.minimumZoom | ||
500 | 217 | } | ||
501 | 218 | } | ||
502 | 219 | |||
503 | 220 | Binding { | ||
504 | 221 | target: mouseArea | ||
505 | 222 | property: "zoomValue" | ||
506 | 223 | value: loView.zoomSettings.zoomFactor | ||
507 | 224 | } | ||
508 | 225 | } | ||
509 | 226 | |||
510 | 227 | Label { | ||
511 | 228 | anchors.centerIn: parent | ||
512 | 229 | parent: loPage | ||
513 | 230 | textSize: Label.Large | ||
514 | 231 | text: i18n.tr("This sheet has no content.") | ||
515 | 232 | visible: loPage.isSpreadsheet && loView.contentWidth <= 0 && loView.contentHeight <= 0 | ||
516 | 233 | } | ||
517 | 230 | } | 234 | } |
518 | 231 | } | 235 | } |
519 | 232 | } | 236 | } |
520 | @@ -265,12 +269,20 @@ | |||
521 | 265 | } | 269 | } |
522 | 266 | } | 270 | } |
523 | 267 | 271 | ||
532 | 268 | // *** HEADER *** | 272 | |
533 | 269 | state: "default" | 273 | /*** Headers ***/ |
534 | 270 | states: [ | 274 | |
535 | 271 | LOViewDefaultHeader { | 275 | LOViewDefaultHeader { |
536 | 272 | name: "default" | 276 | id: defaultHeader |
537 | 273 | targetPage: loPage | 277 | visible: loPage.loaded |
538 | 274 | } | 278 | title: DocumentViewer.getFileBaseNameFromPath(file.path); |
539 | 275 | ] | 279 | flickable: isTextDocument ? loPage.contentItem.loView : null |
540 | 280 | targetPage: loPage | ||
541 | 281 | } | ||
542 | 282 | |||
543 | 283 | PageHeader { | ||
544 | 284 | id: loadingHeader | ||
545 | 285 | visible: !loPage.loaded | ||
546 | 286 | // When we're still loading LibreOffice, show an empty header | ||
547 | 287 | } | ||
548 | 276 | } | 288 | } |
PASSED: Continuous integration, rev:320 /core-apps- jenkins. ubuntu. com/job/ docviewer- app-ci/ 261/ /core-apps- jenkins. ubuntu. com/job/ generic- update- mp/811/ console
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild: /core-apps- jenkins. ubuntu. com/job/ docviewer- app-ci/ 261/rebuild
https:/