1. The enter is processed by enterClicked() only because operation manager do not receive this signal in SALOME mode
2. Sketcher Renetrant manager should not restart internal edit and create new feature if it is started.
/// \param theEvent key release event
void keyReleased(QKeyEvent* theEvent);
+ /// The signal is emitted if the enter is clicked in the control of the widget
+ void enterClicked();
+
/// The signal about the widget is get focus
/// \param theWidget the model base widget
void focusInWidget(ModuleBase_ModelWidget* theWidget);
ModuleBase_WidgetEditor::ModuleBase_WidgetEditor(QWidget* theParent,
const Config_WidgetAPI* theData,
const std::string& theParentId)
- : ModuleBase_WidgetDoubleValue(theParent, theData, theParentId)
+: ModuleBase_WidgetDoubleValue(theParent, theData, theParentId),
+ myIsKeyReleasedEmitted(false)
{
}
ModuleBase_ParamSpinBox* anEditor = new ModuleBase_ParamSpinBox(&aDlg);
anEditor->enableKeyPressEvent(true);
if (!myIsEditing) {
- connect(anEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*)));
+ connect(anEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SLOT(onKeyReleased(QKeyEvent*)));
}
anEditor->setMinimum(0);
aDlg.exec();
if (!myIsEditing) {
- disconnect(anEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*)));
+ disconnect(anEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SLOT(onKeyReleased(QKeyEvent*)));
}
outText = anEditor->text();
void ModuleBase_WidgetEditor::showPopupEditor()
{
+ myIsKeyReleasedEmitted = false;
+
// 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.
// the focus leaves the control automatically by the Enter/Esc event
// it is processed in operation manager
//emit focusOutWidget(this);
+
+ if (myIsKeyReleasedEmitted)
+ emit enterClicked();
+}
+
+void ModuleBase_WidgetEditor::onKeyReleased(QKeyEvent* theEvent)
+{
+ myIsKeyReleasedEmitted = true;
}
/// Shous popup window under cursor for data editing
void showPopupEditor();
+protected slots:
+ void onKeyReleased(QKeyEvent* theEvent);
+
private:
void editedValue(double& outValue, QString& outText);
///< the kinds of possible features
QStringList myFeatureKinds;
+
+ bool myIsKeyReleasedEmitted;
};
#endif
bool PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePreviousAttributeID)
{
bool isDone = false;
+ /// this is workaround for ModuleBase_WidgetEditor, used in SALOME mode. Sometimes key enter
+ /// event comes two times, so we should not start another internal edit operation
+ /// the Apply button becomes disabled becase the second additional internal feature is created
+ if (myIsInternalEditOperation)
+ return true;
+
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
(myWorkshop->currentOperation());
switch (theEvent->key()) {
case Qt::Key_Return:
case Qt::Key_Enter: {
- ModuleBase_Operation* aOperation = currentOperation();
+ isAccepted = onProcessEnter();
+ /*ModuleBase_Operation* aOperation = currentOperation();
ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget();
if (!aActiveWgt || !aActiveWgt->processEnter()) {
else
isAccepted = false;
}
- }
+ }*/
}
break;
case Qt::Key_N:
return isAccepted;
}
+bool XGUI_OperationMgr::onProcessEnter()
+{
+ bool isAccepted = true;
+ ModuleBase_Operation* aOperation = currentOperation();
+ ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
+ ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget();
+ if (!aActiveWgt || !aActiveWgt->processEnter()) {
+ if (!myWorkshop->module()->processEnter(aActiveWgt ? aActiveWgt->attributeID() : "")) {
+ ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(currentOperation());
+ if (!aFOperation || myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty()) {
+ emit keyEnterReleased();
+ commitOperation();
+ }
+ else
+ isAccepted = false;
+ }
+ }
+ return isAccepted;
+}
+
XGUI_Workshop* XGUI_OperationMgr::workshop() const
{
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
/// \param theEvent the mouse event
bool onKeyReleased(QKeyEvent* theEvent);
+ /// The functionaly, that should be done by enter click
+ /// Fistly the active widget processes it, then module. If no one do not
+ /// process it, the current operation is committed
+ bool onProcessEnter();
+
protected slots:
/// Slot that is called by an operation stop. Removes the stopped operation form the stack.
/// If there is a suspended operation, restart it.
this, SLOT(activateNextWidget(ModuleBase_ModelWidget*)));
connect(aWidget, SIGNAL(keyReleased(QKeyEvent*)),
this, SIGNAL(keyReleased(QKeyEvent*)));
+ connect(aWidget, SIGNAL(enterClicked()),
+ this, SIGNAL(enterClicked()));
+
}
}
*/
virtual void activateWidget(ModuleBase_ModelWidget* theWidget);
+signals:
+ void enterClicked();
+
protected:
/// Makes the widget active, deactivate the previous, activate and hightlight the given one
/// \param theWidget a widget
connect(aCancelAct, SIGNAL(triggered()), myOperationMgr, SLOT(onAbortOperation()));
connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)),
myOperationMgr, SLOT(onKeyReleased(QKeyEvent*)));
+
+ connect(myPropertyPanel, SIGNAL(enterClicked()),
+ myOperationMgr, SLOT(onProcessEnter()));
//connect(myOperationMgr, SIGNAL(validationStateChanged(bool)),
// this, SLOT(onValidationStateChanged(bool)));
}