/// The signal about key release on the control, that corresponds to the attribute
/// \param theAttributeName a name of the attribute
/// \param theEvent key release event
- void keyReleased(const std::string& theAttributeName, QKeyEvent* theEvent);
+ void keyReleased(QKeyEvent* theEvent);
/// The signal about the widget is lost focus
/// \param theWidget the model base widget
void focusOutWidget(ModuleBase_ModelWidget* theWidget);
}
return false;
}
+
+void ModuleBase_Operation::keyReleased(const int theKey)
+{
+ // Do nothing...
+}
+
/// Stores a custom value in model.
void storeCustomValue();
- virtual void keyReleased(std::string theName, QKeyEvent* theEvent)
- {
- }
- ;
-
/// Sets the operation feature
void setEditingFeature(FeaturePtr theFeature);
/// Returns True if the current operation works with the given object (feature or result)
virtual bool hasObject(ObjectPtr theObj) const;
+ virtual void keyReleased(const int theKey);
+
public slots:
/// Slots which listen the mode widget activation
/// \param theWidget the model widget
if (theObject == mySpinBox) {
if (theEvent->type() == QEvent::KeyRelease) {
QKeyEvent* aKeyEvent = (QKeyEvent*) theEvent;
- if (aKeyEvent && aKeyEvent->key() == Qt::Key_Return) {
+ if (aKeyEvent && (aKeyEvent->key() == Qt::Key_Return ||
+ aKeyEvent->key() == Qt::Key_Enter)) {
emit focusOutWidget(this);
}
- emit keyReleased(attributeID(), (QKeyEvent*) theEvent);
+ emit keyReleased((QKeyEvent*) theEvent);
return true;
}
}
myGroupBox = new QGroupBox(QString::fromStdString(theData->getProperty(CONTAINER_PAGE_NAME)),
theParent);
QGridLayout* aGroupLay = new QGridLayout(myGroupBox);
- aGroupLay->setContentsMargins(0, 0, 0, 0);
+ aGroupLay->setContentsMargins(2, 0, 2, 0);
aGroupLay->setColumnStretch(1, 1);
{
QLabel* aLabel = new QLabel(myGroupBox);
if (theObject == myXSpin || theObject == myYSpin) {
if (theEvent->type() == QEvent::KeyRelease) {
QKeyEvent* aKeyEvent = (QKeyEvent*) theEvent;
- if (aKeyEvent && aKeyEvent->key() == Qt::Key_Return) {
+ if (aKeyEvent && (aKeyEvent->key() == Qt::Key_Return ||
+ aKeyEvent->key() == Qt::Key_Enter)) {
emit focusOutWidget(this);
}
- emit keyReleased(attributeID(), (QKeyEvent*) theEvent);
+ emit keyReleased((QKeyEvent*) theEvent);
return true;
}
}
myWorkshop->viewer()->fitAll();
}
-void PartSet_Module::onLaunchOperation(std::string theName, ObjectPtr theObject)
+void PartSet_Module::onRestartOperation(std::string theName, ObjectPtr theObject)
{
FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
- if (!aFeature) {
- qDebug("Warning! Restart operation without feature!");
- return;
- }
- ModuleBase_Operation* anOperation = createOperation(theName.c_str(),
- aFeature ? aFeature->getKind() : "");
+
+ std::string aKind = aFeature ? aFeature->getKind() : "";
+ ModuleBase_Operation* anOperation = createOperation(theName, aKind);
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
if (aPreviewOp) {
XGUI_Selection* aSelection = myWorkshop->selector()->selection();
std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
aPreviewOp->initFeature(aFeature);
aPreviewOp->initSelection(aSelected, aHighlighted);
- } else {
+ } else if (aFeature) {
anOperation->setEditingFeature(aFeature);
//Deactivate result of current feature in order to avoid its selection
XGUI_Displayer* aDisplayer = myWorkshop->displayer();
ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
FeaturePtr aSketch;
PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
- if (aPrevOp)
+ if (aPrevOp) {
aSketch = aPrevOp->sketch();
- if (PartSet_OperationFeatureCreate::canProcessKind(theCmdId))
+ }
+ if (PartSet_OperationFeatureCreate::canProcessKind(theCmdId)) {
anOperation = new PartSet_OperationFeatureCreate(theCmdId.c_str(), this, aSketch);
- else if (theCmdId == PartSet_OperationFeatureEditMulti::Type())
+ } else if (theCmdId == PartSet_OperationFeatureEditMulti::Type()) {
anOperation = new PartSet_OperationFeatureEditMulti(theCmdId.c_str(), this, aSketch);
- else if (theCmdId == PartSet_OperationFeatureEdit::Type())
+ } else if (theCmdId == PartSet_OperationFeatureEdit::Type()) {
anOperation = new PartSet_OperationFeatureEdit(theCmdId.c_str(), this, aSketch);
+ }
}
if (!anOperation) {
if (aPreviewOp) {
connect(aPreviewOp, SIGNAL(featureConstructed(ObjectPtr, int)), this,
SLOT(onFeatureConstructed(ObjectPtr, int)));
- connect(aPreviewOp, SIGNAL(launchOperation(std::string, ObjectPtr)), this,
- SLOT(onLaunchOperation(std::string, ObjectPtr)));
+ connect(aPreviewOp, SIGNAL(restartRequired(std::string, ObjectPtr)), this,
+ SLOT(onRestartOperation(std::string, ObjectPtr)));
connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)), this,
SLOT(onMultiSelectionEnabled(bool)));
//}
//if (aFeature) {
- onLaunchOperation(theFeature->getKind(), theFeature);
+ onRestartOperation(theFeature->getKind(), theFeature);
updateCurrentPreview(theFeature->getKind());
//}
// }
/// SLOT, to fit all current viewer
void onFitAllView();
- void onLaunchOperation(std::string theName, ObjectPtr theFeature);
+ void onRestartOperation(std::string theName, ObjectPtr theFeature);
/// SLOT, to switch on/off the multi selection in the viewer
/// \param theEnabled the enabled state
}
}
-void PartSet_OperationFeatureCreate::keyReleased(std::string theName, QKeyEvent* theEvent)
-{
- int aKeyType = theEvent->key();
- // the second point should be activated by any modification in the property panel
- if (!theName.empty()) {
- //setPointSelectionMode(myFeaturePrs->getNextMode(theName), false);
- }
- keyReleased(theEvent->key());
-}
-
void PartSet_OperationFeatureCreate::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
{
myActiveWidget = theWidget;
void PartSet_OperationFeatureCreate::keyReleased(const int theKey)
{
switch (theKey) {
- case Qt::Key_Return: {
+ case Qt::Key_Return:
+ case Qt::Key_Enter: {
if (commit()) {
// it start a new line creation at a free point
- restartOperation(feature()->getKind(), FeaturePtr());
+ restartOperation(feature()->getKind());
}
}
break;
abort();
}
}
+ break;
default:
break;
}
/// \param theKey a key value
virtual void keyReleased(const int theKey);
- virtual void keyReleased(std::string theName, QKeyEvent* theEvent);
-
public slots:
/// Slots which listen the mode widget activation
/// \param theWidget the model widget
void PartSet_OperationFeatureEdit::keyReleased(const int theKey)
{
- if (theKey == Qt::Key_Return) {
+ if (theKey == Qt::Key_Return || theKey == Qt::Key_Enter) {
commit();
} else
PartSet_OperationSketchBase::keyReleased(theKey);
bool toAbort = true;
if (isModified()) {
int anAnswer = QMessageBox::question(
- qApp->activeWindow(), tr("Cancel operation"),
- tr("Operation %1 will be cancelled. Continue?").arg(id()), QMessageBox::Yes,
+ qApp->activeWindow(),
+ tr("Cancel operation"),
+ tr("Do you want to cancel %1 operation?").arg(id()),
+ QMessageBox::Yes,
QMessageBox::No);
toAbort = (anAnswer == QMessageBox::Yes);
}
}
}
-void PartSet_OperationSketchBase::keyReleased(std::string theName, QKeyEvent* theEvent)
-{
- keyReleased(theEvent->key());
-}
-
void PartSet_OperationSketchBase::restartOperation(const std::string& theType, ObjectPtr theFeature)
{
FeaturePtr aFeature = ModelAPI_Feature::feature(theFeature);
QStringList aNested = this->nestedFeatures();
if (!aNested.isEmpty()) {
if (aNested.contains(QString(aFeature->getKind().c_str())))
- emit launchOperation(theType, theFeature);
+ emit restartRequired(theType, theFeature);
else
return;
}
}
- emit launchOperation(theType, theFeature);
+ emit restartRequired(theType, theFeature);
}
/// \param theKey a key value
virtual void keyReleased(const int theKey);
- virtual void keyReleased(std::string theName, QKeyEvent* theEvent);
-
/// Emits a signal about the operation start. This signal has an information about the feature.
/// If the provided feature is empty, the current operation feature is used.
/// \param theType a type of an operation started
/// signal about the request to launch operation
/// theName the operation name
/// theFeature the operation argument
- void launchOperation(std::string theName, ObjectPtr theFeature);
+ void restartRequired(std::string theName, ObjectPtr theFeature);
/// Signal about the feature construing is finished
/// \param theFeature the result feature
} else if (theEvent->type() == QEvent::KeyRelease) {
QKeyEvent* aEvent = (QKeyEvent*) theEvent;
switch (aEvent->key()) {
- case Qt::Key_Return: // Accept current input
+ case Qt::Key_Return:
+ case Qt::Key_Enter: // Accept current input
closeDocNameEditing(true);
break;
case Qt::Key_Escape: // Cancel the input
if (aKeyEvent && aKeyEvent->key() == Qt::Key_Escape) {
// TODO: this is Escape button processing when the property panel has empty content,
// but the operation should be stopped by the Enter has been clicked
- onKeyReleased("", aKeyEvent);
+ onKeyReleased(aKeyEvent);
return true;
}
}
}
}
-void XGUI_OperationMgr::onKeyReleased(const std::string& theName, QKeyEvent* theEvent)
+void XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent)
{
ModuleBase_Operation* anOperation = currentOperation();
if (anOperation)
- anOperation->keyReleased(theName, theEvent);
+ anOperation->keyReleased(theEvent->key());
}
void XGUI_OperationMgr::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
/// SLOT, that is called by the key in the property panel is clicked.
/// \param theName the attribute name
/// \param theEvent the mouse event
- void onKeyReleased(const std::string& theName, QKeyEvent* theEvent);
+ void onKeyReleased(QKeyEvent* theEvent);
/// SLOT, that reacts to the widget activation
/// \param theWidget an activated widget
void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets)
{
myWidgets = theWidgets;
+ if (theWidgets.empty()) return;
- if (!theWidgets.empty()) {
- QList<ModuleBase_ModelWidget*>::const_iterator anIt = theWidgets.begin(), aLast =
- theWidgets.end();
- for (; anIt != aLast; anIt++) {
- connect(*anIt, SIGNAL(keyReleased(const std::string&, QKeyEvent*)), this,
- SIGNAL(keyReleased(const std::string&, QKeyEvent*)));
+ QList<ModuleBase_ModelWidget*>::const_iterator anIt = theWidgets.begin(), aLast =
+ theWidgets.end();
+ for (; anIt != aLast; anIt++) {
+ //TODO(sbh): Think how to connect prop panle hotkeys and operations mgr
+ connect(*anIt, SIGNAL(keyReleased(QKeyEvent*)), this,
+ SIGNAL(keyReleased(QKeyEvent*)));
- connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)), this,
- SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
+ connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)), this,
+ SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
- //connect(*anIt, SIGNAL(activated(ModuleBase_ModelWidget*)),
- // this, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)));
+ //connect(*anIt, SIGNAL(activated(ModuleBase_ModelWidget*)),
+ // this, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)));
- ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast<ModuleBase_WidgetPoint2D*>(*anIt);
- if (aPointWidget)
- connect(aPointWidget, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this,
- SIGNAL(storedPoint2D(ObjectPtr, const std::string&)));
- }
- ModuleBase_ModelWidget* aLastWidget = theWidgets.last();
- if (aLastWidget) {
- QList<QWidget*> aControls = aLastWidget->getControls();
- if (!aControls.empty()) {
- QWidget* aLastControl = aControls.last();
+ ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast<ModuleBase_WidgetPoint2D*>(*anIt);
+ if (aPointWidget)
+ connect(aPointWidget, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this,
+ SIGNAL(storedPoint2D(ObjectPtr, const std::string&)));
+ }
+ ModuleBase_ModelWidget* aLastWidget = theWidgets.last();
+ if (aLastWidget) {
+ QList<QWidget*> aControls = aLastWidget->getControls();
+ if (!aControls.empty()) {
+ QWidget* aLastControl = aControls.last();
- QPushButton* anOkBtn = findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
- QPushButton* aCancelBtn = findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
+ QPushButton* anOkBtn = findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
+ QPushButton* aCancelBtn = findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
- setTabOrder(aLastControl, anOkBtn);
- setTabOrder(anOkBtn, aCancelBtn);
- }
+ setTabOrder(aLastControl, anOkBtn);
+ setTabOrder(anOkBtn, aCancelBtn);
}
- onActivateNextWidget(0);
}
+ onActivateNextWidget(NULL);
}
const QList<ModuleBase_ModelWidget*>& XGUI_PropertyPanel::modelWidgets() const
if (theObject == anOkBtn || theObject == aCancelBtn) {
if (theEvent->type() == QEvent::KeyRelease) {
QKeyEvent* aKeyEvent = (QKeyEvent*) theEvent;
- if (aKeyEvent && aKeyEvent->key() == Qt::Key_Return) {
+ if (aKeyEvent && (aKeyEvent->key() == Qt::Key_Return ||
+ aKeyEvent->key() == Qt::Key_Enter)) {
// TODO: this is enter button processing when the focus is on "Apply" or "Cancel" buttons
- emit keyReleased("", (QKeyEvent*) theEvent);
+ //emit keyReleased("", (QKeyEvent*) theEvent);
return true;
}
}
signals:
/// The signal about key release on the control, that corresponds to the attribute
- /// \param theAttributeName a name of the attribute
/// \param theEvent key release event
- void keyReleased(const std::string& theAttributeName, QKeyEvent* theEvent);
+ void keyReleased(QKeyEvent* theEvent);
/// The signal about the widget activation
/// \param theWidget the activated widget
void widgetActivated(ModuleBase_ModelWidget* theWidget);
connect(aOkBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onCommitOperation()));
QPushButton* aCancelBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
connect(aCancelBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onAbortOperation()));
-
- connect(myPropertyPanel, SIGNAL(keyReleased(const std::string&, QKeyEvent*)), myOperationMgr,
- SLOT(onKeyReleased(const std::string&, QKeyEvent*)));
+//TODO(sbh): KeyReleasedProblem
+ connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)), myOperationMgr,
+ SLOT(onKeyReleased(QKeyEvent*)));
connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), myOperationMgr,
SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));