X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetEditor.cpp;h=41ec508e2a08183e489992dd97107f6d718d4934;hb=ced1c42d80f02b1efa749ecdf35e620dcca4d9cc;hp=334c50492d4eff3a9bbeb042f8eb1fc206517318;hpb=c24c2f94491145b9c2cbd0be6c6bc3d157bca9bb;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetEditor.cpp b/src/ModuleBase/ModuleBase_WidgetEditor.cpp index 334c50492..41ec508e2 100644 --- a/src/ModuleBase/ModuleBase_WidgetEditor.cpp +++ b/src/ModuleBase/ModuleBase_WidgetEditor.cpp @@ -35,7 +35,8 @@ ModuleBase_WidgetEditor::ModuleBase_WidgetEditor(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId) - : ModuleBase_WidgetDoubleValue(theParent, theData, theParentId) +: ModuleBase_WidgetDoubleValue(theParent, theData, theParentId), + myXPosition(-1), myYPosition(-1) { } @@ -61,12 +62,17 @@ void ModuleBase_WidgetEditor::editedValue(double& outValue, QString& outText) aLay->addWidget(anEditor); - anEditor->setFocus(); + ModuleBase_Tools::setFocus(anEditor, "ModuleBase_WidgetEditor::editedValue"); anEditor->selectAll(); - QObject::connect(anEditor, SIGNAL(editingFinished()), &aDlg, SLOT(accept())); + QObject::connect(anEditor, SIGNAL(enterReleased()), &aDlg, SLOT(accept())); - aDlg.move(QCursor::pos()); + QPoint aPoint = QCursor::pos(); + if (myXPosition >= 0 && myYPosition >= 0) + aPoint = QPoint(myXPosition, myYPosition); + + aDlg.move(aPoint); aDlg.exec(); + outText = anEditor->text(); bool isDouble; double aValue = outText.toDouble(&isDouble); @@ -78,23 +84,17 @@ void ModuleBase_WidgetEditor::editedValue(double& outValue, QString& outText) bool ModuleBase_WidgetEditor::focusTo() { - // nds: it seems, that the timer is not necessary anymore - - // We can not launch here modal process for value editing because - // it can be called on other focusOutWidget event and will block it - //QTimer::singleShot(1, this, SLOT(showPopupEditor())); - showPopupEditor(); - return true; } -void ModuleBase_WidgetEditor::showPopupEditor() +void ModuleBase_WidgetEditor::showPopupEditor(const bool theSendSignals) { // we need to emit the focus in event manually in order to save the widget as an active // in the property panel before the mouse leave event happens in the viewer. The module // ask an active widget and change the feature visualization if the widget is not the current one. - emit focusInWidget(this); + if (theSendSignals) + emit focusInWidget(this); // nds: it seems, that the envents processing is not necessary anymore // White while all events will be processed @@ -110,8 +110,21 @@ void ModuleBase_WidgetEditor::showPopupEditor() } else { ModuleBase_Tools::setSpinText(mySpinBox, aText); } - emit valuesChanged(); - // the focus leaves the control automatically by the Enter/Esc event - // it is processed in operation manager - //emit focusOutWidget(this); + if (theSendSignals) { + emit valuesChanged(); + // the focus leaves the control automatically by the Enter/Esc event + // it is processed in operation manager + //emit focusOutWidget(this); + + if (!myIsEditing) + emit enterClicked(this); + } + else + storeValue(); +} + +void ModuleBase_WidgetEditor::setCursorPosition(const int theX, const int theY) +{ + myXPosition = theX; + myYPosition = theY; }