fixes 0003222: Invert zoom setting is not respected in paper/page mode
This commit is contained in:
@@ -42,7 +42,7 @@
|
||||
#include <GraphicsViewZoom.h>
|
||||
|
||||
GraphicsViewZoom::GraphicsViewZoom(QGraphicsView* view)
|
||||
: QObject(view), _view(view)
|
||||
: QObject(view), _view(view), m_invert_zoom(false)
|
||||
{
|
||||
_view->viewport()->installEventFilter(this);
|
||||
_view->setMouseTracking(true);
|
||||
@@ -80,7 +80,9 @@ bool GraphicsViewZoom::eventFilter(QObject *object, QEvent *event) {
|
||||
QWheelEvent* wheel_event = static_cast<QWheelEvent*>(event);
|
||||
if (QApplication::keyboardModifiers() == _modifiers) {
|
||||
if (wheel_event->orientation() == Qt::Vertical) {
|
||||
double angle = wheel_event->delta();
|
||||
double angle = -wheel_event->delta();
|
||||
if (m_invert_zoom)
|
||||
angle = -angle;
|
||||
double factor = qPow(_zoom_factor_base, angle);
|
||||
gentle_zoom(factor);
|
||||
return true;
|
||||
|
||||
@@ -78,11 +78,15 @@ public:
|
||||
void gentle_zoom(double factor);
|
||||
void set_modifiers(Qt::KeyboardModifiers modifiers);
|
||||
void set_zoom_factor_base(double value);
|
||||
void set_zoom_inverted(bool on) {
|
||||
m_invert_zoom = on;
|
||||
}
|
||||
|
||||
private:
|
||||
QGraphicsView* _view;
|
||||
Qt::KeyboardModifiers _modifiers;
|
||||
double _zoom_factor_base;
|
||||
bool m_invert_zoom;
|
||||
QPointF target_scene_pos, target_viewport_pos;
|
||||
bool eventFilter(QObject* object, QEvent* event);
|
||||
};
|
||||
|
||||
@@ -169,6 +169,11 @@ GraphvizView::GraphvizView(App::Document & _doc, QWidget* parent)
|
||||
zoomer->set_modifiers(Qt::NoModifier);
|
||||
view->show();
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/View");
|
||||
bool on = hGrp->GetBool("InvertZoom", true);
|
||||
zoomer->set_zoom_inverted(on);
|
||||
|
||||
// Set central widget to view
|
||||
setCentralWidget(view);
|
||||
|
||||
|
||||
@@ -337,7 +337,7 @@ void View3DInventor::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M
|
||||
_viewer->navigationStyle()->setResetCursorPosition(on);
|
||||
}
|
||||
else if (strcmp(Reason,"InvertZoom") == 0) {
|
||||
bool on = rGrp.GetBool("InvertZoom", false);
|
||||
bool on = rGrp.GetBool("InvertZoom", true);
|
||||
_viewer->navigationStyle()->setZoomInverted(on);
|
||||
}
|
||||
else if (strcmp(Reason,"ZoomAtCursor") == 0) {
|
||||
|
||||
@@ -260,7 +260,7 @@ DrawingView::DrawingView(Gui::Document* doc, QWidget* parent)
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/View");
|
||||
bool on = hGrp->GetBool("InvertZoom", false);
|
||||
bool on = hGrp->GetBool("InvertZoom", true);
|
||||
m_view->setZoomInverted(on);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,10 @@ ImageView::ImageView(QWidget* parent)
|
||||
// Create the actions, menus and toolbars
|
||||
createActions();
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/View");
|
||||
_invertZoom = hGrp->GetBool("InvertZoom", true);
|
||||
|
||||
// connect other slots
|
||||
connect(_pGLImageBox, SIGNAL(drawGraphics()), this, SLOT(drawGraphics()));
|
||||
}
|
||||
@@ -475,6 +479,9 @@ void ImageView::wheelEvent(QWheelEvent * cEvent)
|
||||
|
||||
// Zoom around centrally displayed image point
|
||||
int numTicks = cEvent->delta() / 120;
|
||||
if (_invertZoom)
|
||||
numTicks = -numTicks;
|
||||
|
||||
int ICx, ICy;
|
||||
_pGLImageBox->getCentrePoint(ICx, ICy);
|
||||
_pGLImageBox->setZoomFactor(_pGLImageBox->getZoomFactor() / pow(2.0, (double)numTicks), true, ICx, ICy);
|
||||
|
||||
@@ -128,6 +128,7 @@ protected:
|
||||
bool _statusBarEnabled;
|
||||
bool _mouseEventsEnabled;
|
||||
bool _ignoreCloseEvent;
|
||||
bool _invertZoom;
|
||||
};
|
||||
|
||||
} // namespace ImageViewGui
|
||||
|
||||
@@ -913,7 +913,7 @@ void GraphicsView3D::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M
|
||||
_viewer->navigationStyle()->setResetCursorPosition(on);
|
||||
}
|
||||
else if (strcmp(Reason,"InvertZoom") == 0) {
|
||||
bool on = rGrp.GetBool("InvertZoom", false);
|
||||
bool on = rGrp.GetBool("InvertZoom", true);
|
||||
_viewer->navigationStyle()->setZoomInverted(on);
|
||||
}
|
||||
else if (strcmp(Reason,"ZoomAtCursor") == 0) {
|
||||
|
||||
Reference in New Issue
Block a user