Changeset View
Changeset View
Standalone View
Standalone View
libs/flake/KoCanvasControllerWidget.cpp
Show First 20 Lines • Show All 478 Lines • ▼ Show 20 Line(s) | 478 | { | |||
---|---|---|---|---|---|
479 | d->zoomWithWheel = zoom; | 479 | d->zoomWithWheel = zoom; | ||
480 | } | 480 | } | ||
481 | 481 | | |||
482 | void KoCanvasControllerWidget::setVastScrolling(qreal factor) | 482 | void KoCanvasControllerWidget::setVastScrolling(qreal factor) | ||
483 | { | 483 | { | ||
484 | d->vastScrollingFactor = factor; | 484 | d->vastScrollingFactor = factor; | ||
485 | } | 485 | } | ||
486 | 486 | | |||
487 | QPointF KoCanvasControllerWidget::currentCursorPosition() const | ||||
488 | { | ||||
489 | QWidget *canvasWidget = d->canvas->canvasWidget(); | ||||
490 | const KoViewConverter *converter = d->canvas->viewConverter(); | ||||
491 | return converter->viewToDocument(canvasWidget->mapFromGlobal(QCursor::pos()) + d->canvas->canvasController()->documentOffset() - canvasWidget->pos()); | ||||
492 | } | ||||
493 | | ||||
487 | void KoCanvasControllerWidget::pan(const QPoint &distance) | 494 | void KoCanvasControllerWidget::pan(const QPoint &distance) | ||
488 | { | 495 | { | ||
489 | QPoint sourcePoint = scrollBarValue(); | 496 | QPoint sourcePoint = scrollBarValue(); | ||
490 | setScrollBarValue(sourcePoint + distance); | 497 | setScrollBarValue(sourcePoint + distance); | ||
491 | } | 498 | } | ||
492 | 499 | | |||
493 | void KoCanvasControllerWidget::setPreferredCenter(const QPointF &viewPoint) | 500 | void KoCanvasControllerWidget::setPreferredCenter(const QPointF &viewPoint) | ||
494 | { | 501 | { | ||
Show All 31 Lines | 532 | { | |||
526 | d->viewportWidget->handleDragMoveEvent(event); | 533 | d->viewportWidget->handleDragMoveEvent(event); | ||
527 | } | 534 | } | ||
528 | 535 | | |||
529 | void KoCanvasControllerWidget::dragLeaveEvent(QDragLeaveEvent *event) | 536 | void KoCanvasControllerWidget::dragLeaveEvent(QDragLeaveEvent *event) | ||
530 | { | 537 | { | ||
531 | d->viewportWidget->handleDragLeaveEvent(event); | 538 | d->viewportWidget->handleDragLeaveEvent(event); | ||
532 | } | 539 | } | ||
533 | 540 | | |||
534 | void KoCanvasControllerWidget::keyPressEvent(QKeyEvent *event) | | |||
535 | { | | |||
536 | KoToolManager::instance()->priv()->switchToolByShortcut(event); | | |||
537 | } | | |||
538 | | ||||
539 | void KoCanvasControllerWidget::wheelEvent(QWheelEvent *event) | 541 | void KoCanvasControllerWidget::wheelEvent(QWheelEvent *event) | ||
540 | { | 542 | { | ||
541 | if (d->zoomWithWheel != ((event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier)) { | 543 | if (d->zoomWithWheel != ((event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier)) { | ||
542 | const qreal zoomCoeff = event->delta() > 0 ? sqrt(2.0) : sqrt(0.5); | 544 | const qreal zoomCoeff = event->delta() > 0 ? sqrt(2.0) : sqrt(0.5); | ||
543 | zoomRelativeToPoint(event->pos(), zoomCoeff); | 545 | zoomRelativeToPoint(event->pos(), zoomCoeff); | ||
544 | 546 | | |||
545 | event->accept(); | 547 | event->accept(); | ||
546 | } else | 548 | } else | ||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |