~timo-jyrinki/gallery-app/allow_translating_date_strings

« back to all changes in this revision

Viewing changes to rc/qml/MediaViewer/SingleMediaViewer.qml

  • Committer: CI Train Bot
  • Author(s): Arthur Mello
  • Date: 2015-03-18 16:37:27 UTC
  • mfrom: (1116.3.42 gallery-app-fix_1425563)
  • Revision ID: ci-train-bot@canonical.com-20150318163727-wnhsac5rmg2f8qco
Do not update PhotoViewer Image sourceSize everytime the app is resized on devices.
That way we will not flicker the image everytime we toggle fullscreen
Animate Image resize Fixes: #1425563

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    id: viewer
29
29
    property bool pinchInProgress: zoomPinchArea.active
30
30
    property var mediaSource
31
 
    property real maxDimension
 
31
    property real maxDimension: 0.
32
32
    property bool showThumbnail: true
33
33
 
34
34
    property bool isVideo: mediaSource.type === MediaSource.Video
35
35
    property bool userInteracting: pinchInProgress || flickable.sizeScale != 1.0
36
36
    property bool fullyZoomed: flickable.sizeScale == zoomPinchArea.maximumZoom
37
37
    property bool fullyUnzoomed: flickable.sizeScale == zoomPinchArea.minimumZoom
 
38
    property bool animateMediaOnHeight: false
38
39
 
39
40
    property alias paintedHeight: image.paintedHeight
40
41
    property alias paintedWidth: image.paintedWidth
41
42
 
42
43
    signal clicked()
43
44
 
 
45
    onHeightChanged: {
 
46
        if (height > viewer.maxDimension)
 
47
            viewer.maxDimension = height;
 
48
    }
 
49
 
 
50
    onWidthChanged: {
 
51
        if (width > viewer.maxDimension)
 
52
            viewer.maxDimension = width;
 
53
    }
 
54
 
44
55
    function zoomIn(centerX, centerY, factor) {
45
56
        flickable.scaleCenterX = centerX / (flickable.sizeScale * flickable.width);
46
57
        flickable.scaleCenterY = centerY / (flickable.sizeScale * flickable.height);
131
142
                    }
132
143
                }
133
144
 
 
145
                Behavior on height {
 
146
                    enabled: viewer.animateMediaOnHeight 
 
147
                    UbuntuNumberAnimation {}
 
148
                }
 
149
 
134
150
                Image {
135
151
                    id: image
136
152
                    anchors.fill: parent
159
175
                        width: width
160
176
                        height: height
161
177
                    }
 
178
                    opacity: status == Image.Ready ? 1.0 : 0.0
162
179
                    fillMode: Image.PreserveAspectFit
163
180
                }
164
181
            }
174
191
            }
175
192
 
176
193
            MouseArea {
 
194
                id: viewerMouseArea
177
195
                anchors.fill: parent
 
196
                property bool eventAccepted: false
 
197
 
178
198
                onDoubleClicked: {
 
199
                    if (viewerMouseArea.eventAccepted)
 
200
                        return;
 
201
 
179
202
                    clickTimer.stop();
 
203
                    viewer.animateMediaOnHeight = false
 
204
 
180
205
                    if (viewer.ListView.view.moving) {
181
206
                        // FIXME: workaround for Qt bug specific to touch:
182
207
                        // doubleClicked is received even though the MouseArea
193
218
                        zoomOut();
194
219
                    }
195
220
                }
196
 
                onClicked: clickTimer.start()
 
221
                onClicked: {
 
222
                    viewerMouseArea.eventAccepted = false
 
223
                    clickTimer.start()
 
224
                }
197
225
 
198
226
                Timer {
199
227
                    id: clickTimer
200
 
                    interval: 20
201
 
                    onTriggered: viewer.clicked()
 
228
                    interval: 200 
 
229
                    onTriggered: {
 
230
                        viewerMouseArea.eventAccepted = true
 
231
                        viewer.animateMediaOnHeight = true
 
232
                        viewer.clicked()
 
233
                    }
202
234
                }
203
235
            }
204
236