diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index a63c9a0c7..2f86f60e9 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -294,7 +294,8 @@ void MainWindow::AddPP(const QString &PPName) // Show best for new PP VMainGraphicsView::NewSceneRect(ui->view->scene(), ui->view); - ZoomFitBestCurrent(); + //ZoomFitBestCurrent(); + QApplication::postEvent(this, new FitBestCurrentEvent()); ui->actionNewDraw->setEnabled(true); helpLabel->setText(""); @@ -1446,6 +1447,10 @@ void MainWindow::customEvent(QEvent *event) { qApp->getUndoStack()->undo(); } + else if (event->type() == FIT_BEST_CURRENT_EVENT) + { + ZoomFitBestCurrent(); + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vmisc/customevents.h b/src/libs/vmisc/customevents.h index c230cd3a3..b3b8cfcb1 100644 --- a/src/libs/vmisc/customevents.h +++ b/src/libs/vmisc/customevents.h @@ -32,7 +32,7 @@ #include #include -enum CustomEventType { UndoEventType = 1, LiteParseEventType = 2 }; +enum CustomEventType { UndoEventType = 1, LiteParseEventType = 2, FitBestCurrentEventType = 3 }; // Define undo event identifier const QEvent::Type UNDO_EVENT = static_cast(QEvent::User + CustomEventType::UndoEventType); @@ -59,4 +59,17 @@ public: virtual ~LiteParseEvent() =default; }; +const QEvent::Type FIT_BEST_CURRENT_EVENT = static_cast(QEvent::User + + CustomEventType::FitBestCurrentEventType); + +class FitBestCurrentEvent : public QEvent +{ +public: + FitBestCurrentEvent() + : QEvent(FIT_BEST_CURRENT_EVENT) + {} + + virtual ~FitBestCurrentEvent() =default; +}; + #endif // CUSTOMEVENTS_H