Changeset View
Changeset View
Standalone View
Standalone View
src/app/qml/viewers/ImageBrowser.qml
Context not available. | |||||
113 | if (flick.interactive) { | 113 | if (flick.interactive) { | ||
---|---|---|---|---|---|
114 | flick.resizeContent(imageWidth, imageHeight, {x: imageWidth/2, y: imageHeight/2}); | 114 | flick.resizeContent(imageWidth, imageHeight, {x: imageWidth/2, y: imageHeight/2}); | ||
115 | } else { | 115 | } else { | ||
116 | flick.resizeContent(imageWidth * 2, imageHeight * 2, {x: mouse.x, y: mouse.y}); | 116 | flick.resizeContent(imageWidth * 2, imageHeight * 2, Qt.point(mouse.x, mouse.y)); | ||
117 | } | 117 | } | ||
118 | } | 118 | } | ||
119 | } | 119 | } | ||
120 | | ||||
121 | // Setup for all the entries. | ||||
122 | property QtObject currentPageObject: { | ||||
123 | if (model.index===0) { | ||||
124 | currentPageObject = root.model.acbfData.metaData.bookInfo.coverpage(); | ||||
125 | } else if (model.index > 0) { | ||||
126 | currentPageObject = root.model.acbfData.body.page(model.index-1); | ||||
127 | } | ||||
128 | } | ||||
129 | property real muliplier: isTall? (paintedHeight / implicitHeight): (paintedWidth / implicitWidth); | ||||
130 | property int offsetX: (width-paintedWidth)/2; | ||||
131 | property int offsetY: (height-paintedHeight)/2; | ||||
132 | | ||||
133 | function focusOnFrame(index) { | ||||
134 | if (index>-1) { | ||||
135 | var frameBounds = image.currentPageObject.frame(index).bounds; | ||||
136 | var frameMultiplier = image.implicitWidth/frameBounds.width; | ||||
137 | //Check if the height of the final frame is higher than the contentHeight | ||||
138 | //When we're using a *fit to with scheme. | ||||
139 | if ((frameBounds.height/frameBounds.width)*contentWidth > contentHeight) { | ||||
140 | frameMultiplier = image.implicitHeight/frameBounds.height; | ||||
141 | frameMultiplier = frameMultiplier * (contentHeight/image.paintedHeight); | ||||
142 | } else { | ||||
143 | frameMultiplier = frameMultiplier * (contentWidth/image.paintedWidth); | ||||
144 | } | ||||
145 | flick.resizeContent(imageWidth * frameMultiplier, imageHeight * frameMultiplier, Qt.point(0,0)); | ||||
146 | var frameRect = Qt.rect(image.muliplier * frameBounds.x + image.offsetX, | ||||
147 | image.muliplier * frameBounds.y+ image.offsetY, | ||||
148 | image.muliplier * frameBounds.width, | ||||
149 | image.muliplier * frameBounds.height); | ||||
150 | flick.contentX = frameRect.x - (flick.width-frameRect.width)/2; | ||||
151 | flick.contentY = frameRect.y - (flick.height-frameRect.height)/2; | ||||
152 | } | ||||
153 | } | ||||
154 | | ||||
155 | function nextFrame() { | ||||
156 | if (image.totalFrames > 0 && image.currentFrame+1 < image.totalFrames) { | ||||
157 | image.currentFrame++; | ||||
158 | } else { | ||||
159 | root.goNextPage(); | ||||
160 | image.currentFrame = -1; | ||||
161 | } | ||||
162 | } | ||||
163 | | ||||
164 | function previousFrame() { | ||||
165 | if (image.totalFrames > 0 && image.currentFrame-1 > -1) { | ||||
166 | image.currentFrame--; | ||||
167 | } else { | ||||
168 | root.goPreviousPage(); | ||||
169 | image.currentFrame = -1; | ||||
170 | } | ||||
171 | } | ||||
172 | | ||||
173 | property int totalFrames: image.currentPageObject? image.currentPageObject.framePointStrings.length: 0; | ||||
174 | property int currentFrame: -1; | ||||
175 | onCurrentFrameChanged: focusOnFrame(currentFrame); | ||||
176 | | ||||
177 | Repeater { | ||||
178 | model: image.currentPageObject? image.currentPageObject.framePointStrings: 0; | ||||
179 | Rectangle { | ||||
180 | id: frame; | ||||
181 | x: image.muliplier * image.currentPageObject.frame(index).bounds.x + image.offsetX; | ||||
182 | y: image.muliplier * image.currentPageObject.frame(index).bounds.y + image.offsetY; | ||||
183 | width: { | ||||
184 | image.muliplier * image.currentPageObject.frame(index).bounds.width; | ||||
185 | } | ||||
186 | height: image.muliplier * image.currentPageObject.frame(index).bounds.height; | ||||
187 | color: "blue"; | ||||
188 | opacity: 0; | ||||
189 | MouseArea { | ||||
190 | anchors.fill: parent; | ||||
191 | onClicked: startToggleControls(); | ||||
192 | preventStealing: true; | ||||
193 | onDoubleClicked: { | ||||
194 | abortToggleControls(); | ||||
195 | if (flick.interactive && image.currentFrame == index) { | ||||
196 | flick.resizeContent(imageWidth, imageHeight, {x: imageWidth/2, y: imageHeight/2}); | ||||
197 | image.currentFrame = -1; | ||||
198 | } else { | ||||
199 | image.currentFrame = index; | ||||
200 | mouse.accepted; | ||||
201 | } | ||||
202 | } | ||||
203 | } | ||||
204 | } | ||||
205 | } | ||||
206 | | ||||
120 | MouseArea { | 207 | MouseArea { | ||
121 | anchors { | 208 | anchors { | ||
122 | top: parent.top; | 209 | top: parent.top; | ||
Context not available. | |||||
124 | bottom: parent.bottom; | 211 | bottom: parent.bottom; | ||
125 | } | 212 | } | ||
126 | width: parent.width / 6; | 213 | width: parent.width / 6; | ||
127 | onClicked: root.goPreviousPage(); | 214 | preventStealing: true; | ||
215 | onClicked: image.previousFrame(); | ||||
128 | } | 216 | } | ||
129 | MouseArea { | 217 | MouseArea { | ||
130 | anchors { | 218 | anchors { | ||
Context not available. | |||||
133 | bottom: parent.bottom; | 221 | bottom: parent.bottom; | ||
134 | } | 222 | } | ||
135 | width: parent.width / 6; | 223 | width: parent.width / 6; | ||
136 | onClicked: root.goNextPage(); | 224 | preventStealing: true; | ||
225 | onClicked: image.nextFrame(); | ||||
137 | } | 226 | } | ||
138 | } | 227 | } | ||
139 | } | 228 | } | ||
Context not available. |