[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdeplasma-addons/rshah/comicqml] applets/comic/package/contents/ui: center the image if the image c
From:       Reza Shah <rshah0385 () kireihana ! com>
Date:       2012-10-27 9:47:47
Message-ID: 20121027094747.2D170A60A6 () git ! kde ! org
[Download RAW message or body]

Git commit c96ac83b88d3988839568f033f205de59f235ce6 by Reza Shah.
Committed on 27/10/2012 at 11:45.
Pushed by rshah into branch 'rshah/comicqml'.

center the image if the image can be drawn without clipping.

M  +1    -1    applets/comic/package/contents/ui/ComicCentralView.qml
M  +15   -5    applets/comic/package/contents/ui/ImageWidget.qml

http://commits.kde.org/kdeplasma-addons/c96ac83b88d3988839568f033f205de59f2=
35ce6

diff --git a/applets/comic/package/contents/ui/ComicCentralView.qml b/apple=
ts/comic/package/contents/ui/ComicCentralView.qml
index 37f3ca8..53e036a 100644
--- a/applets/comic/package/contents/ui/ComicCentralView.qml
+++ b/applets/comic/package/contents/ui/ComicCentralView.qml
@@ -49,7 +49,7 @@ Rectangle {
         id: comicImage
         image: comicApplet.comicData.image
         tooltipText: comicApplet.comicData.additionalText
-        fullView: comicApplet.showActualSize
+        actualSize: comicApplet.showActualSize
         anchors { =

             left: arrowLeft.visible ? arrowLeft.right : root.left
             right: arrowRight.visible ? arrowRight.left : root.right
diff --git a/applets/comic/package/contents/ui/ImageWidget.qml b/applets/co=
mic/package/contents/ui/ImageWidget.qml
index b82b63d..0577e4d 100644
--- a/applets/comic/package/contents/ui/ImageWidget.qml
+++ b/applets/comic/package/contents/ui/ImageWidget.qml
@@ -24,7 +24,7 @@ import org.kde.qtextracomponents 0.1
 PlasmaExtras.ScrollArea {
     id: imageWidget
     property alias image: comicPicture.image
-    property bool fullView: false
+    property bool actualSize: false
     property alias tooltipText: tooltip.mainText
 =

     width: comicPicture.nativeWidth
@@ -34,13 +34,15 @@ PlasmaExtras.ScrollArea {
         id: viewContainer
         anchors.fill:parent
 =

-        contentWidth: fullView ? comicPicture.nativeWidth : viewContainer.=
width
-        contentHeight: fullView ? comicPicture.nativeHeight : viewContaine=
r.height
+        contentWidth: calculateContentWidth()
+        contentHeight: calculateContentHeight()
         clip: true
-        =

+
         QImageItem {
             id: comicPicture
-            anchors.fill: parent
+            width: actualSize ? comicPicture.nativeWidth : viewContainer.w=
idth
+            height: actualSize ? comicPicture.nativeHeight : viewContainer=
.height
+            anchors.centerIn: parent
             smooth: true
             fillMode: QImageItem.PreserveAspectFit
 =

@@ -98,4 +100,12 @@ PlasmaExtras.ScrollArea {
             }
         }
     }
+
+    function calculateContentWidth() {
+        return actualSize ? (comicPicture.nativeWidth > viewContainer.widt=
h ? comicPicture.nativeWidth : viewContainer.width) : viewContainer.width
+    }
+
+    function calculateContentHeight() {
+        return actualSize ? (comicPicture.nativeHeight > viewContainer.hei=
ght ? comicPicture.nativeHeight : viewContainer.height) : viewContainer.hei=
ght
+    }
 }
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic