From e1075dfdf5ed11dcadb415b5058a7ca63a075ad9 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 25 Sep 2017 18:28:58 +0300 Subject: [PATCH] Fix zoom fit best current after adding new pattern piece. --HG-- branch : develop --- src/app/valentina/mainwindow.cpp | 7 ++++++- src/libs/vmisc/customevents.h | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) 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