Le lundi 9 février 2015, 14:11:02 Leonardo Zide a écrit :
> The function that was causing problems because it was
> deprecated is QWheelEvent::orientation(), I was checking if
> the orientation is vertical and it didn't return that
> correctly after 5.2.
Oh yes, I missed the deleted lines in r.1765!
(Darn, svn diff is very really slow!
I’m too used to git’s speed ;oP)
I understand it better now: orientation() is an ORed value of
Horizontal and Vertical. With the new angleDelta() function
returning both H and V deltas, orientation() now always returns
Horizontal|Vertical (not a value you might expect with actual
wheels).
> I'll do some tests on Qt5 when I have a chance but if your
> patch works I'll add something like that to the code (the
> accumulator can't be static because there are multiple
> widgets).
Of course. static’s really not good OO coding. I used it to
quickly test the idea. Not that adding a member would have been
a lot less quick... Indeed, attached: a little bit better patch
(just providing it to not let the crappy one be my last word:
that’s not rocket science and just rewriting it in your own
style will take you more time than writing it from scratch :o).
Thanks,
--
Sylvain Sauvage
Index: qt/lc_qglwidget.cpp
===================================================================
--- qt/lc_qglwidget.cpp (révision 1777)
+++ qt/lc_qglwidget.cpp (copie de travail)
@@ -114,7 +114,7 @@
}
lcQGLWidget::lcQGLWidget(QWidget *parent, lcQGLWidget *share, lcGLWidget *owner, bool view)
- : QGLWidget(parent, share)
+ : QGLWidget(parent, share), mDeltaAcc(0)
{
widget = owner;
widget->mWidget = this;
@@ -313,14 +313,17 @@
widget->mInputState.Alt = (event->modifiers() & Qt::AltModifier) != 0;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0))
- int numDegrees = event->angleDelta().y() / 8;
+ mDeltaAcc += event->angleDelta().y() / 8;
#else
- int numDegrees = event->delta() / 8;
+ mDeltaAcc += event->delta() / 8;
#endif
- int numSteps = numDegrees / 15;
+ if (mDeltaAcc >= 15 || mDeltaAcc <= -15)
+ {
+ int numSteps = mDeltaAcc / 15;
+ widget->OnMouseWheel(numSteps);
+ mDeltaAcc = 0;
+ }
- widget->OnMouseWheel(numSteps);
-
event->accept();
}
Index: qt/lc_qglwidget.h
===================================================================
--- qt/lc_qglwidget.h (révision 1777)
+++ qt/lc_qglwidget.h (copie de travail)
@@ -28,6 +28,7 @@
QTimer mUpdateTimer;
protected:
+ int mDeltaAcc;
void initializeGL();
void resizeGL(int x, int h);
void paintGL();_______________________________________________
Leocad mailing list
[email protected]
https://list.gerf.org/listinfo/leocad