ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #06310
[Merge] lp:~verzegnassi-stefano/ubuntu-docviewer-app/fix-1521386 into lp:ubuntu-docviewer-app
Stefano Verzegnassi has proposed merging lp:~verzegnassi-stefano/ubuntu-docviewer-app/fix-1521386 into lp:ubuntu-docviewer-app.
Commit message:
[loviewer] PartsView: Ensure that items next to the current item are always visible
Requested reviews:
Ubuntu Document Viewer Developers (ubuntu-docviewer-dev)
Related bugs:
Bug #1521386 in Ubuntu Document Viewer App: "PartsView: Ensure that items next to the current item are always visible"
https://bugs.launchpad.net/ubuntu-docviewer-app/+bug/1521386
For more details, see:
https://code.launchpad.net/~verzegnassi-stefano/ubuntu-docviewer-app/fix-1521386/+merge/279049
[loviewer] PartsView: Ensure that items next to the current item are always visible
--
Your team Ubuntu Document Viewer Developers is requested to review the proposed merge of lp:~verzegnassi-stefano/ubuntu-docviewer-app/fix-1521386 into lp:ubuntu-docviewer-app.
=== modified file 'src/app/qml/loView/PartsView.qml'
--- src/app/qml/loView/PartsView.qml 2015-11-13 21:35:22 +0000
+++ src/app/qml/loView/PartsView.qml 2015-11-30 23:16:42 +0000
@@ -19,6 +19,9 @@
import QtQuick.Layouts 1.1
import DocumentViewer.LibreOffice 1.0 as LibreOffice
+// TODO: If we'll be planning to reorganise QML components, consider to provide
+// delegates in some separate documents.
+
ListView {
id: view
objectName: "view"
@@ -32,17 +35,36 @@
property bool isWide: width > units.gu(24)
currentIndex: view.model ? loView.document.currentPart : -1
- highlightMoveDuration: UbuntuAnimation.SnapDuration
-
- delegate: (orientation == ListView.Vertical) ? verticalDelegate : horizontalDelegate
+
+ // Ensure that items next to current item are always visible (and then
+ // clickable) without the need of extra interaction from the user.
+ // FIXME: If the current item is out the visible area, the 'highlightMove'
+ // animation shouldn't be fully performed, but applied from the first visible
+ // item instead. This actually seems to be a limitation of ListView itself.
+ highlightRangeMode: ListView.ApplyRange
+ highlightMoveDuration: UbuntuAnimation.FastDuration
+ preferredHighlightBegin: internal.isVerticalView ? (view.height - internal.verticalItemHeight) * 0.5
+ : (view.width - internal.horizontalItemWidth) * 0.5
+ preferredHighlightEnd: internal.isVerticalView ? (view.height - internal.verticalItemHeight) * 0.5
+ : (view.width - internal.horizontalItemWidth) * 0.5
+
+ delegate: internal.isVerticalView ? verticalDelegate : horizontalDelegate
+
+ Component.onCompleted: {
+ // WORKAROUND: Fix for wrong grid unit size
+ flickDeceleration = 1500 * units.gridUnit / 8
+ maximumFlickVelocity = 2500 * units.gridUnit / 8
+ }
Component {
id: verticalDelegate
ListItem {
id: delegate
- width: parent.width
- height: units.gu(16)
+
+ // Defined at the end of this document
+ width: internal.verticalItemWidth
+ height: internal.verticalItemHeight
color: (loView.document.currentPart === model.index) ? theme.palette.selected.background
: "transparent"
@@ -98,7 +120,10 @@
ListItem {
id: delegate
- height: parent.height; width: height
+
+ // Defined at the end of this document
+ width: internal.horizontalItemWidth
+ height: internal.horizontalItemHeight
color: (loView.document.currentPart === model.index) ? theme.palette.selected.background
: "transparent"
@@ -137,6 +162,16 @@
QtObject {
id: internal
+ readonly property bool isVerticalView: view.orientation == ListView.Vertical
+
+ // Vertical delegate size
+ readonly property int verticalItemWidth: view.width
+ readonly property int verticalItemHeight: units.gu(16)
+
+ // Horizontal delegate size
+ readonly property int horizontalItemWidth: horizontalItemHeight
+ readonly property int horizontalItemHeight: view.height
+
function delegate_onClicked(index) {
loView.document.currentPart = index
Follow ups