From d6e555f482e48ee5abfcb4f1a9f991af6f32a0d8 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sun, 27 Dec 2020 16:35:17 +0200 Subject: [PATCH] Reduce connectivity for VMainGraphicsView class. Use a signal instead of direct read of a main window to trigger zoom fit best. --- src/app/valentina/mainwindow.cpp | 1 + src/libs/vwidgets/vmaingraphicsview.cpp | 7 ++----- src/libs/vwidgets/vmaingraphicsview.h | 1 + 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 9677e92b3..40e8c89fd 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -503,6 +503,7 @@ void MainWindow::InitScenes() connect(ui->view, &VMainGraphicsView::MouseRelease, this, [this](){EndVisualization(true);}); connect(ui->view, &VMainGraphicsView::ScaleChanged, this, &MainWindow::ScaleChanged); + connect(ui->view, &VMainGraphicsView::ZoomFitBestCurrent, this, [this](){ZoomFitBestCurrent();}); QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding); policy.setHorizontalStretch(12); ui->view->setSizePolicy(policy); diff --git a/src/libs/vwidgets/vmaingraphicsview.cpp b/src/libs/vwidgets/vmaingraphicsview.cpp index 1e9a3c65a..480cdf400 100644 --- a/src/libs/vwidgets/vmaingraphicsview.cpp +++ b/src/libs/vwidgets/vmaingraphicsview.cpp @@ -55,7 +55,7 @@ #include "vmaingraphicsscene.h" #include "vsimplecurve.h" #include "vcontrolpointspline.h" -#include "../vmisc/vabstractvalapplication.h" +#include "../vmisc/vabstractapplication.h" #include "../vmisc/vsettings.h" #include "vabstractmainwindow.h" #include "global.h" @@ -645,10 +645,7 @@ void VMainGraphicsView::mouseDoubleClickEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton && qApp->Settings()->IsDoubleClickZoomFitBestCurrentPP()) { - if (VAbstractMainWindow *window = qobject_cast(qApp->getMainWindow())) - { - window->ZoomFitBestCurrent(); - } + emit ZoomFitBestCurrent(); } QGraphicsView::mouseDoubleClickEvent(event); diff --git a/src/libs/vwidgets/vmaingraphicsview.h b/src/libs/vwidgets/vmaingraphicsview.h index 09998a8ca..f6db798d2 100644 --- a/src/libs/vwidgets/vmaingraphicsview.h +++ b/src/libs/vwidgets/vmaingraphicsview.h @@ -149,6 +149,7 @@ signals: void MouseRelease(); void itemClicked(QGraphicsItem *item); void ScaleChanged(qreal scale); + void ZoomFitBestCurrent(); public slots: void Zoom(qreal scale); void ZoomIn();