1/* 2 * SPDX-FileCopyrightText: 2012 Reza Fatahilah Shah <rshah0385@kireihana.com> 3 * 4 * SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 7import QtQuick 2.1 8import org.kde.plasma.core 2.0 as PlasmaCore 9import org.kde.plasma.extras 2.0 as PlasmaExtras 10import org.kde.kquickcontrolsaddons 2.0 11 12PlasmaExtras.ScrollArea { 13 id: root 14 15 width: comicPicture.nativeWidth 16 height: comicPicture.nativeHeight 17 18 property bool actualSize: false 19 property bool isLeftToRight: true 20 property bool isTopToBottom: true 21 22 property alias image: comicPicture.image 23 24 function calculateContentWidth() { 25 return actualSize ? (comicPicture.nativeWidth > viewContainer.width ? comicPicture.nativeWidth : viewContainer.width) : viewContainer.width; 26 } 27 28 function calculateContentHeight() { 29 return actualSize ? (comicPicture.nativeHeight > viewContainer.height ? comicPicture.nativeHeight : viewContainer.height) : viewContainer.height; 30 } 31 32 Flickable { 33 id: viewContainer 34 35 anchors.fill:parent 36 37 contentWidth: comicPictureHolder.width 38 contentHeight: comicPictureHolder.height 39 40 clip: true 41 42 Item { 43 id: comicPictureHolder 44 45 width: Math.max(comicPicture.width, viewContainer.width); 46 height: Math.max(comicPicture.height, viewContainer.height); 47 48 QImageItem { 49 id: comicPicture 50 51 anchors.centerIn: parent 52 53 width: actualSize ? comicPicture.nativeWidth : viewContainer.width 54 height: actualSize ? comicPicture.nativeHeight : viewContainer.height 55 56 onImageChanged: { 57 viewContainer.contentX = (root.isLeftToRight) ? 0 : ( viewContainer.contentWidth - viewContainer.width); 58 viewContainer.contentY = (root.isTopToBottom) ? 0 : ( viewContainer.contentHeight - viewContainer.height); 59 } 60 61 smooth: true 62 fillMode: QImageItem.PreserveAspectFit 63 } 64 } 65 } 66} 67