Changeset View
Changeset View
Standalone View
Standalone View
components/ViewController.cpp
Show First 20 Lines • Show All 277 Lines • ▼ Show 20 Line(s) | |||||
278 | 278 | | |||
279 | bool ViewController::event(QEvent* event) | 279 | bool ViewController::event(QEvent* event) | ||
280 | { | 280 | { | ||
281 | switch(static_cast<int>(event->type())) { | 281 | switch(static_cast<int>(event->type())) { | ||
282 | case ViewModeSwitchEvent::AboutToSwitchViewModeEvent: { | 282 | case ViewModeSwitchEvent::AboutToSwitchViewModeEvent: { | ||
283 | ViewModeSynchronisationObject* syncObject = static_cast<ViewModeSwitchEvent*>(event)->synchronisationObject(); | 283 | ViewModeSynchronisationObject* syncObject = static_cast<ViewModeSwitchEvent*>(event)->synchronisationObject(); | ||
284 | 284 | | |||
285 | if (d->canvasController) { | 285 | if (d->canvasController) { | ||
286 | syncObject->documentOffset = d->canvasController->documentOffset(); | 286 | syncObject->scrollBarValue = d->canvasController->documentOffset(); | ||
287 | syncObject->zoomLevel = zoom(); | 287 | syncObject->zoomLevel = zoom(); | ||
288 | syncObject->activeToolId = KoToolManager::instance()->activeToolId(); | 288 | syncObject->activeToolId = KoToolManager::instance()->activeToolId(); | ||
289 | syncObject->shapes = d->canvasController->canvas()->shapeManager()->shapes(); | 289 | syncObject->shapes = d->canvasController->canvas()->shapeManager()->shapes(); | ||
290 | syncObject->currentIndex = d->view->document()->currentIndex(); | ||||
290 | syncObject->initialized = true; | 291 | syncObject->initialized = true; | ||
291 | } | 292 | } | ||
292 | 293 | | |||
293 | return true; | 294 | return true; | ||
294 | } | 295 | } | ||
295 | case ViewModeSwitchEvent::SwitchedToTouchModeEvent: { | 296 | case ViewModeSwitchEvent::SwitchedToTouchModeEvent: { | ||
296 | ViewModeSynchronisationObject* syncObject = static_cast<ViewModeSwitchEvent*>(event)->synchronisationObject(); | 297 | ViewModeSynchronisationObject* syncObject = static_cast<ViewModeSwitchEvent*>(event)->synchronisationObject(); | ||
297 | 298 | | |||
298 | if (d->canvasController && syncObject->initialized) { | 299 | if (d->canvasController && syncObject->initialized) { | ||
299 | d->canvasController->canvas()->shapeManager()->setShapes(syncObject->shapes); | 300 | d->canvasController->canvas()->shapeManager()->setShapes(syncObject->shapes); | ||
300 | 301 | | |||
301 | KoToolManager::instance()->switchToolRequested("PageToolFactory_ID"); | 302 | KoToolManager::instance()->switchToolRequested("PageToolFactory_ID"); | ||
302 | qApp->processEvents(); | 303 | qApp->processEvents(); | ||
303 | 304 | | |||
304 | setZoom(syncObject->zoomLevel); | 305 | setZoom(syncObject->zoomLevel); | ||
305 | 306 | | |||
306 | qApp->processEvents(); | 307 | qApp->processEvents(); | ||
307 | emit d->canvasController->proxyObject->moveDocumentOffset(syncObject->documentOffset); | 308 | if(syncObject->scrollBarValue.isNull()) { | ||
309 | d->view->document()->setCurrentIndex(syncObject->currentIndex); | ||||
310 | } | ||||
311 | else { | ||||
312 | d->canvasController->setScrollBarValue(syncObject->scrollBarValue); | ||||
313 | } | ||||
314 | emit d->view->document()->requestViewUpdate(); | ||||
308 | } | 315 | } | ||
309 | 316 | | |||
310 | return true; | 317 | return true; | ||
311 | } | 318 | } | ||
312 | } | 319 | } | ||
313 | return QQuickItem::event(event); | 320 | return QQuickItem::event(event); | ||
314 | } | 321 | } | ||
315 | 322 | | |||
▲ Show 20 Lines • Show All 185 Lines • Show Last 20 Lines |