MCPcopy Create free account
hub / github.com/KDE/gwenview / DocumentView

Method DocumentView

lib/documentview/documentview.cpp:447–509  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

445};
446
447DocumentView::DocumentView(QGraphicsScene *scene)
448 : d(new DocumentViewPrivate)
449{
450 setFlag(ItemIsFocusable);
451 setFlag(ItemIsSelectable);
452 setFlag(ItemClipsChildrenToShape);
453
454 d->q = this;
455 d->mLoadingIndicator = nullptr;
456 d->mBirdEyeView = nullptr;
457 d->mCurrent = false;
458 d->mCompareMode = false;
459 d->controlWheelAccumulatedDelta = 0;
460 d->mDragStartPosition = QPointF(0, 0);
461 d->mDrag = nullptr;
462
463#ifndef GWENVIEW_NO_WAYLAND_GESTURES
464 if (QApplication::platformName() == QStringLiteral("wayland")) {
465 d->mWaylandGestures = new WaylandGestures();
466 connect(d->mWaylandGestures, &WaylandGestures::pinchGestureStarted, [this]() {
467 d->mWaylandGestures->setStartZoom(zoom());
468 });
469 connect(d->mWaylandGestures, &WaylandGestures::pinchZoomChanged, [this](double zoom) {
470 d->setZoom(zoom, d->cursorPosition());
471 });
472 }
473#endif
474
475 d->mTouch = new Touch(this);
476 setAcceptTouchEvents(true);
477 connect(d->mTouch, &Touch::doubleTapTriggered, this, &DocumentView::toggleFullScreenRequested);
478 connect(d->mTouch, &Touch::twoFingerTapTriggered, this, &DocumentView::contextMenuRequested);
479 connect(d->mTouch, &Touch::pinchGestureStarted, this, &DocumentView::setPinchParameter);
480 connect(d->mTouch, &Touch::pinchZoomTriggered, this, &DocumentView::zoomGesture);
481 connect(d->mTouch, &Touch::pinchRotateTriggered, this, &DocumentView::rotationsGesture);
482 connect(d->mTouch, &Touch::swipeRightTriggered, this, &DocumentView::swipeRight);
483 connect(d->mTouch, &Touch::swipeLeftTriggered, this, &DocumentView::swipeLeft);
484 connect(d->mTouch, &Touch::PanTriggered, this, &DocumentView::panGesture);
485 connect(d->mTouch, &Touch::tapHoldAndMovingTriggered, this, &DocumentView::startDragFromTouch);
486
487 // We use an opacity effect instead of using the opacity property directly, because the latter operates at
488 // the painter level, which means if you draw multiple layers in paint(), all layers get the specified
489 // opacity, resulting in all layers being visible when 0 < opacity < 1.
490 // QGraphicsEffects on the other hand, operate after all painting is done, therefore 'flattening' all layers.
491 // This is important for fade effects, where we don't want any background layers visible during the fade.
492 d->mOpacityEffect = new QGraphicsOpacityEffect(this);
493 d->mOpacityEffect->setOpacity(0);
494
495 // QTBUG-74963. QGraphicsOpacityEffect cause painting an image as non-highdpi.
496 if (qFuzzyCompare(qApp->devicePixelRatio(), 1.0) || QLibraryInfo::version() >= QVersionNumber(5, 12, 4))
497 setGraphicsEffect(d->mOpacityEffect);
498
499 scene->addItem(this);
500
501 d->setupHud();
502 d->setCurrentAdapter(new EmptyAdapter);
503
504 setAcceptDrops(true);

Callers

nothing calls this directly

Calls 10

zoomFunction · 0.85
setStartZoomMethod · 0.80
cursorPositionMethod · 0.80
setOpacityMethod · 0.80
devicePixelRatioMethod · 0.80
setCurrentAdapterMethod · 0.80
updateCaptionMethod · 0.80
setZoomMethod · 0.45
addItemMethod · 0.45
setupHudMethod · 0.45

Tested by

no test coverage detected