From f9bc111159bf3d7eff96d471ec36af90d7dac18f Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 24 Aug 2022 19:01:26 +0300 Subject: [PATCH] Optimize ::ShowDialog method. --- .../vtools/dialogs/tools/dialogalongline.cpp | 21 +++++++------------ .../vtools/dialogs/tools/dialogbisector.cpp | 21 +++++++------------ .../vtools/dialogs/tools/dialogcutarc.cpp | 21 +++++++------------ .../vtools/dialogs/tools/dialogcutspline.cpp | 21 +++++++------------ .../dialogs/tools/dialogcutsplinepath.cpp | 21 +++++++------------ .../vtools/dialogs/tools/dialognormal.cpp | 21 +++++++------------ .../tools/dialogpointfromcircleandtangent.cpp | 21 +++++++------------ .../dialogs/tools/dialogpointofcontact.cpp | 21 +++++++------------ .../dialogs/tools/dialogshoulderpoint.cpp | 21 +++++++------------ 9 files changed, 63 insertions(+), 126 deletions(-) diff --git a/src/libs/vtools/dialogs/tools/dialogalongline.cpp b/src/libs/vtools/dialogs/tools/dialogalongline.cpp index 6bd1bb55b..0bafeb90a 100644 --- a/src/libs/vtools/dialogs/tools/dialogalongline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogalongline.cpp @@ -351,17 +351,6 @@ void DialogAlongLine::ShowDialog(bool click) return; } - auto FinishCreating = [this]() - { - vis->SetMode(Mode::Show); - vis->RefreshGeometry(); - - emit ToolTip(QString()); - - setModal(true); - show(); - }; - if (click) { // The check need to ignore first release of mouse button. @@ -389,11 +378,15 @@ void DialogAlongLine::ShowDialog(bool click) } SetFormula(QString::number(FromPixel(len, *data->GetPatternUnit()))); - - FinishCreating(); } - FinishCreating(); + vis->SetMode(Mode::Show); + vis->RefreshGeometry(); + + emit ToolTip(QString()); + + setModal(true); + show(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogbisector.cpp b/src/libs/vtools/dialogs/tools/dialogbisector.cpp index bc7058319..0d0611d8d 100644 --- a/src/libs/vtools/dialogs/tools/dialogbisector.cpp +++ b/src/libs/vtools/dialogs/tools/dialogbisector.cpp @@ -351,17 +351,6 @@ void DialogBisector::ShowDialog(bool click) return; } - auto FinishCreating = [this]() - { - vis->SetMode(Mode::Show); - vis->RefreshGeometry(); - - emit ToolTip(QString()); - - setModal(true); - show(); - }; - if (click) { // The check need to ignore first release of mouse button. @@ -396,11 +385,15 @@ void DialogBisector::ShowDialog(bool click) } SetFormula(QString::number(FromPixel(len, *data->GetPatternUnit()))); - - FinishCreating(); } - FinishCreating(); + vis->SetMode(Mode::Show); + vis->RefreshGeometry(); + + emit ToolTip(QString()); + + setModal(true); + show(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogcutarc.cpp b/src/libs/vtools/dialogs/tools/dialogcutarc.cpp index 1eadc46eb..fd9b7dd02 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutarc.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutarc.cpp @@ -366,17 +366,6 @@ void DialogCutArc::ShowDialog(bool click) return; } - auto FinishCreating = [this]() - { - vis->SetMode(Mode::Show); - vis->RefreshGeometry(); - - emit ToolTip(QString()); - - setModal(true); - show(); - }; - if (click) { // The check need to ignore first release of mouse button. @@ -397,9 +386,13 @@ void DialogCutArc::ShowDialog(bool click) { SetFormula(QString::number(FromPixel(len, *data->GetPatternUnit()))); } - - FinishCreating(); } - FinishCreating(); + vis->SetMode(Mode::Show); + vis->RefreshGeometry(); + + emit ToolTip(QString()); + + setModal(true); + show(); } diff --git a/src/libs/vtools/dialogs/tools/dialogcutspline.cpp b/src/libs/vtools/dialogs/tools/dialogcutspline.cpp index ecac6d4b2..4ec959573 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutspline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutspline.cpp @@ -366,17 +366,6 @@ void DialogCutSpline::ShowDialog(bool click) return; } - auto FinishCreating = [this]() - { - vis->SetMode(Mode::Show); - vis->RefreshGeometry(); - - emit ToolTip(QString()); - - setModal(true); - show(); - }; - if (click) { // The check need to ignore first release of mouse button. @@ -397,9 +386,13 @@ void DialogCutSpline::ShowDialog(bool click) { SetFormula(QString::number(FromPixel(len, *data->GetPatternUnit()))); } - - FinishCreating(); } - FinishCreating(); + vis->SetMode(Mode::Show); + vis->RefreshGeometry(); + + emit ToolTip(QString()); + + setModal(true); + show(); } diff --git a/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp b/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp index 566179fee..16205fe19 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp @@ -366,17 +366,6 @@ void DialogCutSplinePath::ShowDialog(bool click) return; } - auto FinishCreating = [this]() - { - vis->SetMode(Mode::Show); - vis->RefreshGeometry(); - - emit ToolTip(QString()); - - setModal(true); - show(); - }; - if (click) { // The check need to ignore first release of mouse button. @@ -398,9 +387,13 @@ void DialogCutSplinePath::ShowDialog(bool click) { SetFormula(QString::number(FromPixel(len, *data->GetPatternUnit()))); } - - FinishCreating(); } - FinishCreating(); + vis->SetMode(Mode::Show); + vis->RefreshGeometry(); + + emit ToolTip(QString()); + + setModal(true); + show(); } diff --git a/src/libs/vtools/dialogs/tools/dialognormal.cpp b/src/libs/vtools/dialogs/tools/dialognormal.cpp index 2a80c9f4f..ef4a893e3 100644 --- a/src/libs/vtools/dialogs/tools/dialognormal.cpp +++ b/src/libs/vtools/dialogs/tools/dialognormal.cpp @@ -429,17 +429,6 @@ void DialogNormal::ShowDialog(bool click) return; } - auto FinishCreating = [this]() - { - vis->SetMode(Mode::Show); - vis->RefreshGeometry(); - - emit ToolTip(QString()); - - setModal(true); - show(); - }; - if (click) { // The check need to ignore first release of mouse button. @@ -468,9 +457,13 @@ void DialogNormal::ShowDialog(bool click) } SetFormula(QString::number(FromPixel(len, *data->GetPatternUnit()))); - - FinishCreating(); } - FinishCreating(); + vis->SetMode(Mode::Show); + vis->RefreshGeometry(); + + emit ToolTip(QString()); + + setModal(true); + show(); } diff --git a/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp b/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp index 79db426c5..1b5a52364 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp @@ -208,17 +208,6 @@ void DialogPointFromCircleAndTangent::ShowDialog(bool click) return; } - auto FinishCreating = [this]() - { - vis->SetMode(Mode::Show); - vis->RefreshGeometry(); - - emit ToolTip(QString()); - - setModal(true); - show(); - }; - if (click) { // The check need to ignore first release of mouse button. @@ -236,11 +225,15 @@ void DialogPointFromCircleAndTangent::ShowDialog(bool click) QLineF line = QLineF(static_cast(*center), scene->getScenePos()); SetCircleRadius(QString::number(FromPixel(line.length(), *data->GetPatternUnit()))); - - FinishCreating(); } - FinishCreating(); + vis->SetMode(Mode::Show); + vis->RefreshGeometry(); + + emit ToolTip(QString()); + + setModal(true); + show(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp b/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp index 3c3cc8ea6..35e5818f6 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp @@ -189,17 +189,6 @@ void DialogPointOfContact::ShowDialog(bool click) return; } - auto FinishCreating = [this]() - { - vis->SetMode(Mode::Show); - vis->RefreshGeometry(); - - emit ToolTip(QString()); - - setModal(true); - show(); - }; - if (click) { // The check need to ignore first release of mouse button. @@ -218,11 +207,15 @@ void DialogPointOfContact::ShowDialog(bool click) QLineF line(static_cast(*center), scene->getScenePos()); SetRadius(QString::number(FromPixel(line.length(), *data->GetPatternUnit()))); - - FinishCreating(); } - FinishCreating(); + vis->SetMode(Mode::Show); + vis->RefreshGeometry(); + + emit ToolTip(QString()); + + setModal(true); + show(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp b/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp index a7c966fb6..5c34f79c3 100644 --- a/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp +++ b/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp @@ -449,17 +449,6 @@ void DialogShoulderPoint::ShowDialog(bool click) return; } - auto FinishCreating = [this]() - { - vis->SetMode(Mode::Show); - vis->RefreshGeometry(); - - emit ToolTip(QString()); - - setModal(true); - show(); - }; - if (click) { // The check need to ignore first release of mouse button. @@ -476,9 +465,13 @@ void DialogShoulderPoint::ShowDialog(bool click) const QSharedPointer p3 = data->GeometricObject(GetP3()); QLineF line(static_cast(*p3), scene->getScenePos()); SetFormula(QString::number(FromPixel(line.length(), *data->GetPatternUnit()))); - - FinishCreating(); } - FinishCreating(); + vis->SetMode(Mode::Show); + vis->RefreshGeometry(); + + emit ToolTip(QString()); + + setModal(true); + show(); }