Warning, /plasma/kdeplasma-addons/applets/comic/package/contents/ui/ImageWidget.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * SPDX-FileCopyrightText: 2012 Reza Fatahilah Shah <rshah0385@kireihana.com>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 import QtQuick 2.1
0008 import org.kde.plasma.components 3.0 as PlasmaComponents
0009 import org.kde.kquickcontrolsaddons 2.0
0010 
0011 PlasmaComponents.ScrollView {
0012     id: root
0013 
0014     width: comicPicture.nativeWidth
0015     height: comicPicture.nativeHeight
0016 
0017     property bool actualSize: false
0018     property bool isLeftToRight: true
0019     property bool isTopToBottom: true
0020 
0021     property alias image: comicPicture.image
0022 
0023     function calculateContentWidth() {
0024         return actualSize ? (comicPicture.nativeWidth > viewContainer.width ? comicPicture.nativeWidth : viewContainer.width) : viewContainer.width;
0025     }
0026 
0027     function calculateContentHeight() {
0028         return actualSize ? (comicPicture.nativeHeight > viewContainer.height ? comicPicture.nativeHeight : viewContainer.height) : viewContainer.height;
0029     }
0030 
0031     Flickable {
0032         id: viewContainer
0033 
0034         anchors.fill:parent
0035 
0036         contentWidth: comicPictureHolder.width
0037         contentHeight: comicPictureHolder.height
0038 
0039         clip: true
0040 
0041         Item {
0042             id: comicPictureHolder
0043 
0044             width: Math.max(comicPicture.width, viewContainer.width);
0045             height: Math.max(comicPicture.height, viewContainer.height);
0046 
0047             QImageItem {
0048                 id: comicPicture
0049 
0050                 anchors.centerIn: parent
0051 
0052                 width: actualSize ? comicPicture.nativeWidth : viewContainer.width
0053                 height: actualSize ? comicPicture.nativeHeight : viewContainer.height
0054 
0055                 onImageChanged: {
0056                     viewContainer.contentX = (root.isLeftToRight) ? 0 : ( viewContainer.contentWidth - viewContainer.width);
0057                     viewContainer.contentY = (root.isTopToBottom) ? 0 : ( viewContainer.contentHeight - viewContainer.height);
0058                 }
0059 
0060                 smooth: true
0061                 fillMode: QImageItem.PreserveAspectFit
0062             }
0063         }
0064     }
0065 }