MCPcopy Create free account
hub / github.com/YACReader/yacreader / wheelEventTrackpad

Method wheelEventTrackpad

YACReader/viewer.cpp:820–872  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

818}
819
820void Viewer::wheelEventTrackpad(QWheelEvent *event)
821{
822 auto delta = event->pixelDelta();
823
824 // Treat pixel-based scrolling as direct manipulation, not as an animation target.
825 horizontalScroller->stop();
826 verticalScroller->stop();
827
828 // Apply delta to horizontal scrollbar
829 if (delta.x() != 0) {
830 int newHorizontalValue = horizontalScrollBar()->value() - delta.x();
831 horizontalScrollBar()->setValue(newHorizontalValue);
832 }
833
834 // Apply delta to vertical scrollbar
835 if (delta.y() != 0) {
836 int newVerticalValue = verticalScrollBar()->value() - delta.y();
837 verticalScrollBar()->setValue(newVerticalValue);
838 }
839
840 if (continuousScroll) {
841 return;
842 }
843
844 auto turnPageOnScroll = !Configuration::getConfiguration().getDoNotTurnPageOnScroll();
845 auto getUseSingleScrollStepToTurnPage = Configuration::getConfiguration().getUseSingleScrollStepToTurnPage();
846
847 if ((delta.y() < 0) && (verticalScrollBar()->sliderPosition() == verticalScrollBar()->maximum()) && turnPageOnScroll) {
848 if (wheelStop || getUseSingleScrollStepToTurnPage || verticalScrollBar()->maximum() == verticalScrollBar()->minimum()) {
849 if (getMovement(event) == Forward) {
850 next();
851 event->accept();
852 wheelStop = false;
853 }
854 return;
855 } else {
856 wheelStop = true;
857 }
858 } else {
859 if ((delta.y() > 0) && (verticalScrollBar()->sliderPosition() == verticalScrollBar()->minimum()) && turnPageOnScroll) {
860 if (wheelStop || getUseSingleScrollStepToTurnPage || verticalScrollBar()->maximum() == verticalScrollBar()->minimum()) {
861 if (getMovement(event) == Backward) {
862 prev();
863 event->accept();
864 wheelStop = false;
865 }
866 return;
867 } else {
868 wheelStop = true;
869 }
870 }
871 }
872}
873
874void Viewer::resizeEvent(QResizeEvent *event)
875{

Callers

nothing calls this directly

Calls 4

setValueMethod · 0.80
stopMethod · 0.45

Tested by

no test coverage detected