From 72399472a1fa3676d49598dcb9f31c2f1c87ed1e Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 20 Apr 2018 09:35:13 +0300 Subject: [PATCH] Do zoom fit best current pattern piece only in Draw mode. --HG-- branch : develop --- src/app/valentina/mainwindow.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 2ffda6047..a13e517b5 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -1295,22 +1295,25 @@ void MainWindow::ClosedDialogInsertNode(int result) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ZoomFitBestCurrent() { - const QRectF rect = doc->ActiveDrawBoundingRect(); - if (rect.isEmpty()) + if(drawMode) { - return; + const QRectF rect = doc->ActiveDrawBoundingRect(); + if (rect.isEmpty()) + { + return; + } + + ui->view->fitInView(rect, Qt::KeepAspectRatio); + QTransform transform = ui->view->transform(); + + qreal factor = transform.m11(); + factor = qMax(factor, VMainGraphicsView::MinScale()); + factor = qMin(factor, VMainGraphicsView::MaxScale()); + + transform.setMatrix(factor, transform.m12(), transform.m13(), transform.m21(), factor, transform.m23(), + transform.m31(), transform.m32(), transform.m33()); + ui->view->setTransform(transform); } - - ui->view->fitInView(rect, Qt::KeepAspectRatio); - QTransform transform = ui->view->transform(); - - qreal factor = transform.m11(); - factor = qMax(factor, VMainGraphicsView::MinScale()); - factor = qMin(factor, VMainGraphicsView::MaxScale()); - - transform.setMatrix(factor, transform.m12(), transform.m13(), transform.m21(), factor, transform.m23(), - transform.m31(), transform.m32(), transform.m33()); - ui->view->setTransform(transform); } //---------------------------------------------------------------------------------------------------------------------