From 229f3ed67d85637be934d4881948a7a659b97ff5 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 26 May 2015 16:58:34 +0300 Subject: [PATCH] Lock/unlock the "Apply" button by mouse enter/leave the viewer view port. Scenarios: 1. issue #487, 2. start translate operation in the sketch. Select the 1st, the end point. The "Apply" was not valid. --- src/PartSet/PartSet_WidgetPoint2d.cpp | 30 +++++++++++++++++++-------- src/PartSet/PartSet_WidgetPoint2d.h | 7 +++++-- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 1bdd8dc03..add40ce6a 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -6,6 +6,7 @@ #include "PartSet_WidgetPoint2d.h" #include +#include #include #include @@ -213,12 +214,17 @@ void PartSet_WidgetPoint2D::activateCustom() this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*))); connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)), this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*))); - connect(aViewer, SIGNAL(leaveViewPort()), this, SLOT(onLeaveViewPort())); + connect(aViewer, SIGNAL(enterViewPort()), this, SLOT(onLockValidating())); + connect(aViewer, SIGNAL(leaveViewPort()), this, SLOT(onUnlockValidating())); QIntList aModes; aModes << TopAbs_VERTEX; aModes << TopAbs_EDGE; myWorkshop->moduleConnector()->activateSubShapesSelection(aModes); + + PartSet_Module* aModule = dynamic_cast(myWorkshop->module()); + if (aModule->isMouseOverWindow()) + onLockValidating(); } void PartSet_WidgetPoint2D::deactivate() @@ -228,10 +234,11 @@ void PartSet_WidgetPoint2D::deactivate() this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*))); disconnect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)), this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*))); - disconnect(aViewer, SIGNAL(leaveViewPort()), this, SLOT(onLeaveViewPort())); + disconnect(aViewer, SIGNAL(enterViewPort()), this, SLOT(onLockValidating())); + disconnect(aViewer, SIGNAL(leaveViewPort()), this, SLOT(onUnlockValidating())); myWorkshop->moduleConnector()->deactivateSubShapesSelection(); - myWorkshop->operationMgr()->setLockValidating(false); + onUnlockValidating(); } bool PartSet_WidgetPoint2D::getPoint2d(const Handle(V3d_View)& theView, @@ -340,11 +347,6 @@ void PartSet_WidgetPoint2D::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEv { if (isEditingMode()) return; - myWorkshop->operationMgr()->setLockValidating(true); - // the Ok button should be disabled in the property panel by moving the mouse point in the viewer - // this leads that the user does not try to click Ok and it avoids an incorrect situation that the - // line is moved to the cursor to the Ok button - myWorkshop->operationMgr()->setApplyEnabled(false); gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView()); @@ -353,7 +355,17 @@ void PartSet_WidgetPoint2D::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEv setPoint(aX, anY); } -void PartSet_WidgetPoint2D::onLeaveViewPort() +void PartSet_WidgetPoint2D::onLockValidating() +{ + XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr(); + anOperationMgr->setLockValidating(true); + // the Ok button should be disabled in the property panel by moving the mouse point in the viewer + // this leads that the user does not try to click Ok and it avoids an incorrect situation that the + // line is moved to the cursor to the Ok button + anOperationMgr->setApplyEnabled(false); +} + +void PartSet_WidgetPoint2D::onUnlockValidating() { // it is important to restore the validity state in the property panel after leaving the // view port. Unlock the validating. diff --git a/src/PartSet/PartSet_WidgetPoint2d.h b/src/PartSet/PartSet_WidgetPoint2d.h index 07e33c759..dc47f2d7a 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.h +++ b/src/PartSet/PartSet_WidgetPoint2d.h @@ -106,8 +106,11 @@ protected slots: /// \param theEvent a mouse event void onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent); - /// Process mouse leave view port to update validity state of the property panel - void onLeaveViewPort(); + // Set lock validating in the operation manager. Set apply is disabled + void onLockValidating(); + + // Set unlock validating in the operation manager. Call method to update the apply state. + void onUnlockValidating(); protected: /// Saves the internal parameters to the given feature -- 2.30.2