21 import org.kde.plasma.core 0.1 as PlasmaCore
22 import org.kde.plasma.extras 0.1 as PlasmaExtra
23 import org.kde.plasma.components 0.1 as PlasmaComponents
24 import org.kde.plasma.mobilecomponents 0.1 as MobileComponents
25 import org.kde.qtextracomponents 0.1
26 import org.kde.okular 0.1 as Okular
36 property Item flickable: mainFlickable
37 property bool pageSwitchEnabled:
false
38 property alias document: mainPage.document
39 property alias pageNumber: mainPage.pageNumber
40 property Item pageItem: mainPage
43 if (wheel.modifiers == Qt.ControlModifier) {
44 var factor = wheel.delta > 0 ? 1.1 : 0.9
46 pageArea.oldDelegate.scale(mainPage.width / mainPage.implicitWidth,
true)
51 function scale(zoom, absolute) {
52 var newScale = absolute ? zoom : (mainPage.width / mainPage.implicitWidth) * zoom;
53 if (newScale < 0.3 || newScale > 3) {
57 if (imageMargin.zooming) {
59 mainPage.width = imageMargin.startWidth * zoom
60 mainPage.height = imageMargin.startHeight * zoom
61 }
else if (absolute) {
63 mainPage.width = mainPage.implicitWidth * zoom
64 mainPage.height = mainPage.implicitHeight * zoom
66 mainPage.width *= zoom
67 mainPage.height *= zoom
74 id: backgroundRectangle
75 x: -mainFlickable.contentX + mainPage.x
85 source:
"image://appbackgrounds/shadow-left"
86 fillMode:
Image.TileVertically
95 source:
"image://appbackgrounds/shadow-right"
96 fillMode:
Image.TileVertically
101 bottom: parent.bottom
108 property real ratio : width / height
111 height: parent.height
112 contentWidth: imageMargin.width
113 contentHeight: imageMargin.height
116 if (atXBeginning && contentX < 0) {
127 width: Math.max(mainFlickable.width + (pageSwitchEnabled ? 1: 0), mainPage.width)
128 height: Math.max(mainFlickable.height, mainPage.height)
130 property real startWidth
131 property real startHeight
134 property bool zooming:
false
136 startWidth = mainPage.width
137 startHeight = mainPage.height
139 startY = pinch.center.y
140 startX = pinch.center.x
141 pageArea.oldDelegate.visible =
false
144 var deltaWidth = mainPage.width < imageMargin.width ? ((startWidth * pinch.scale) - mainPage.width) : 0
145 var deltaHeight = mainPage.height < imageMargin.height ? ((startHeight * pinch.scale) - mainPage.height) : 0
146 if (root.scale(pinch.scale)) {
147 mainFlickable.contentY += pinch.previousCenter.y - pinch.center.y + startY * (pinch.scale - pinch.previousScale) - deltaHeight
148 mainFlickable.contentX += pinch.previousCenter.x - pinch.center.x + startX * (pinch.scale - pinch.previousScale) - deltaWidth
152 mainFlickable.returnToBounds()
153 pageArea.oldDelegate.scale(mainPage.width / mainPage.implicitWidth)
154 pageArea.oldDelegate.visible =
true
160 document: documentItem
161 flickable: mainFlickable
162 property real ratio: implicitWidth / implicitHeight
164 x: Math.round((parent.width - width) / 2)
165 y: Math.round((parent.height - height) / 2)
167 height: implicitHeight
172 source:
"bookmark.png"
175 right: backgroundRectangle.right
177 topMargin: mainPage.bookmarked ? -30 : -120
179 Behavior on anchors.topMargin {
190 onClicked: mainPage.bookmarked = !mainPage.bookmarked