summaryrefslogtreecommitdiffstats
path: root/demos/declarative/flickr/mobile/ImageDetails.qml
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-09-06 03:44:28 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-09-06 03:44:28 (GMT)
commitda6b87c691f37e4417ff526d863a7dec652e9189 (patch)
tree936a93cfea5a8c004504044e4be35b31f3e9b0c4 /demos/declarative/flickr/mobile/ImageDetails.qml
parentc235e347b53500b6534a3e2c1cacc05d7160f98f (diff)
downloadQt-da6b87c691f37e4417ff526d863a7dec652e9189.zip
Qt-da6b87c691f37e4417ff526d863a7dec652e9189.tar.gz
Qt-da6b87c691f37e4417ff526d863a7dec652e9189.tar.bz2
Ensure slider is updated when screen size changes.
Task-number: QT-3718
Diffstat (limited to 'demos/declarative/flickr/mobile/ImageDetails.qml')
-rw-r--r--demos/declarative/flickr/mobile/ImageDetails.qml22
1 files changed, 20 insertions, 2 deletions
diff --git a/demos/declarative/flickr/mobile/ImageDetails.qml b/demos/declarative/flickr/mobile/ImageDetails.qml
index ff902ce..7441ecc 100644
--- a/demos/declarative/flickr/mobile/ImageDetails.qml
+++ b/demos/declarative/flickr/mobile/ImageDetails.qml
@@ -104,6 +104,24 @@ Flipable {
id: flickable; anchors.fill: parent; clip: true
contentWidth: imageContainer.width; contentHeight: imageContainer.height
+ function updateMinimumScale() {
+ if (bigImage.status == Image.Ready && bigImage.width != 0) {
+ slider.minimum = Math.min(flickable.width / bigImage.width, flickable.height / bigImage.height);
+ if (bigImage.width * slider.value > flickable.width) {
+ var xoff = (flickable.width/2 + flickable.contentX) * slider.value / prevScale;
+ flickable.contentX = xoff - flickable.width/2;
+ }
+ if (bigImage.height * slider.value > flickable.height) {
+ var yoff = (flickable.height/2 + flickable.contentY) * slider.value / prevScale;
+ flickable.contentY = yoff - flickable.height/2;
+ }
+ prevScale = slider.value;
+ }
+ }
+
+ onWidthChanged: updateMinimumScale()
+ onHeightChanged: updateMinimumScale()
+
Item {
id: imageContainer
width: Math.max(bigImage.width * bigImage.scale, flickable.width);
@@ -114,8 +132,8 @@ Flipable {
anchors.centerIn: parent; smooth: !flickable.movingVertically
onStatusChanged : {
// Default scale shows the entire image.
- if (status == Image.Ready && width != 0) {
- slider.minimum = Math.min(flickable.width / width, flickable.height / height);
+ if (bigImage.status == Image.Ready && bigImage.width != 0) {
+ slider.minimum = Math.min(flickable.width / bigImage.width, flickable.height / bigImage.height);
prevScale = Math.min(slider.minimum, 1);
slider.value = prevScale;
}