return false;
}
-bool ModuleBase_Operation::keyReleased(const int theKey)
-{
- // Do nothing...
- return false;
-}
-
/// Returns True if the current operation works with the given object (feature or result)
virtual bool hasObject(ObjectPtr theObj) const;
- virtual bool keyReleased(const int theKey);
+ virtual void keyReleased(const int theKey) {};
+
+ virtual void activateNextToCurrentWidget() {};
public slots:
/// Slots which listen the mode widget activation
aList.append(mySpinBox);
return aList;
}
-
-bool ModuleBase_WidgetDoubleValue::eventFilter(QObject *theObject, QEvent *theEvent)
-{
- if (theObject == mySpinBox) {
- if (theEvent->type() == QEvent::KeyRelease) {
- QKeyEvent* aKeyEvent = (QKeyEvent*) theEvent;
- if (aKeyEvent && (aKeyEvent->key() == Qt::Key_Return ||
- aKeyEvent->key() == Qt::Key_Enter)) {
- emit focusOutWidget(this);
- }
- emit keyReleased((QKeyEvent*) theEvent);
- return true;
- }
- }
- return ModuleBase_ModelWidget::eventFilter(theObject, theEvent);
-}
-
return myContainer;
}
- /// Process key release envent on the widget spin box controls
- /// \param theObject the object where the event happens
- /// \param theEvent the processed event
- virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
-
public slots:
/// Delayed value chnged: when user starts typing something,
// it gives him a 0,5 second to finish typing, when sends valueChnaged() signal
return aControls;
}
-bool ModuleBase_WidgetPoint2D::eventFilter(QObject *theObject, QEvent *theEvent)
-{
- if (theObject == myXSpin || theObject == myYSpin) {
- if (theEvent->type() == QEvent::KeyRelease) {
- QKeyEvent* aKeyEvent = (QKeyEvent*) theEvent;
- if (aKeyEvent && (aKeyEvent->key() == Qt::Key_Return ||
- aKeyEvent->key() == Qt::Key_Enter)) {
- emit focusOutWidget(this);
- }
- emit keyReleased((QKeyEvent*) theEvent);
- return true;
- }
- }
- return ModuleBase_ModelWidget::eventFilter(theObject, theEvent);
-}
-
bool ModuleBase_WidgetPoint2D::initFromPrevious(ObjectPtr theObject)
{
if (myOptionParam.length() == 0)
/// \return a control list
virtual QList<QWidget*> getControls() const;
- /// Process key release envent on the widget spin box controls
- /// \param theObject the object where the event happens
- /// \param theEvent the processed event
- virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
-
bool initFromPrevious(ObjectPtr theObject);
signals:
myTextLine->setText("");
}
-//********************************************************************
-bool ModuleBase_WidgetSelector::eventFilter(QObject* theObj, QEvent* theEvent)
-{
- if (theObj == myTextLine) {
- //if (theEvent->type() == QEvent::Polish) {
- // myActivateBtn->setChecked(myActivateOnStart);
- // onSelectionChanged();
- //}
- }
- return ModuleBase_ModelWidget::eventFilter(theObj, theEvent);
-}
-
//********************************************************************
void ModuleBase_WidgetSelector::enableOthersControls(bool toEnable) const
{
/// Activate or deactivate selection
void activateSelection(bool toActivate);
- protected:
- bool eventFilter(QObject* theObj, QEvent* theEvent);
-
private slots:
void onSelectionChanged();
}
}
-bool PartSet_OperationFeatureCreate::keyReleased(const int theKey)
+void PartSet_OperationFeatureCreate::keyReleased(const int theKey)
{
switch (theKey) {
case Qt::Key_Return:
}
}
break;
- case Qt::Key_Escape: {
- if (!commit()) {
- abort();
- }
- }
- break;
default:
break;
}
- return true;
+}
+
+void PartSet_OperationFeatureCreate::activateNextToCurrentWidget()
+{
+ emit activateNextWidget(myActiveWidget);
}
void PartSet_OperationFeatureCreate::startOperation()
virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
/// Processes the key pressed in the view
/// \param theKey a key value
- virtual bool keyReleased(const int theKey);
+ virtual void keyReleased(const int theKey);
+
+ virtual void activateNextToCurrentWidget();
public slots:
/// Slots which listen the mode widget activation
}
}
-bool PartSet_OperationFeatureEdit::keyReleased(const int theKey)
-{
- if (theKey == Qt::Key_Return || theKey == Qt::Key_Enter) {
- commit();
- return true;
- }
- return PartSet_OperationSketchBase::keyReleased(theKey);
-}
-
void PartSet_OperationFeatureEdit::startOperation()
{
PartSet_OperationSketchBase::startOperation();
const std::list<ModuleBase_ViewerPrs>& theSelected,
const std::list<ModuleBase_ViewerPrs>& theHighlighted);
- /// Processes the key pressed in the view
- /// \param theKey a key value
- virtual bool keyReleased(const int theKey);
-
protected:
/// \brief Virtual method called when operation is started
/// Virtual method called when operation started (see start() method for more description)
return result;
}
+bool XGUI_OperationMgr::eventFilter(QObject *theObject, QEvent *theEvent)
+{
+ if (theEvent->type() == QEvent::KeyRelease) {
+ QKeyEvent* aKeyEvent = dynamic_cast<QKeyEvent*>(theEvent);
+ if(aKeyEvent) {
+ onKeyReleased(aKeyEvent);
+ return true;
+ }
+ }
+ return QObject::eventFilter(theObject, theEvent);
+}
+
bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation)
{
if (!canStartOperation(theOperation))
validateOperation(currentOperation());
}
-bool XGUI_OperationMgr::eventFilter(QObject *theObject, QEvent *theEvent)
-{
- if (theEvent->type() == QEvent::KeyRelease) {
- QKeyEvent* aKeyEvent = dynamic_cast<QKeyEvent*>(theEvent);
- // 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
- if(aKeyEvent) {
- onKeyReleased(aKeyEvent);
- return true;
- }
- }
- return QObject::eventFilter(theObject, theEvent);
-}
-
-void XGUI_OperationMgr::commitOperation()
+bool XGUI_OperationMgr::commitOperation()
{
if (validateOperation(currentOperation())) {
onCommitOperation();
+ return true;
}
+ return false;
}
void XGUI_OperationMgr::resumeOperation(ModuleBase_Operation* theOperation)
void XGUI_OperationMgr::onCommitOperation()
{
ModuleBase_Operation* anOperation = currentOperation();
- anOperation->onWidgetActivated(NULL);
if (anOperation)
anOperation->commit();
}
bool XGUI_OperationMgr::canAbortOperation()
{
ModuleBase_Operation* anOperation = currentOperation();
+ if(operationsCount() > 1) //in case of nested (sketch) operation no confirmation needed
+ return true;
if (anOperation && anOperation->isModified()) {
QString aMessage = tr("%1 operation will be aborted.").arg(anOperation->id());
int anAnswer = QMessageBox::question(qApp->activeWindow(),
void XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent)
{
+ // Let the manager decide what to do with the given key combination.
ModuleBase_Operation* anOperation = currentOperation();
- if (anOperation) {
- bool isFinished = anOperation->keyReleased(theEvent->key());
- if(isFinished)
- return;
+ if(anOperation) {
+ anOperation->activateNextToCurrentWidget();
}
- // Let the manager decide what to do with the given key combination.
+ bool isRestart = false;
switch (theEvent->key()) {
- case Qt::Key_Escape:
+ case Qt::Key_Escape: {
onAbortOperation();
+ }
break;
case Qt::Key_Return:
- case Qt::Key_Enter:
+ case Qt::Key_Enter: {
commitOperation();
+ }
break;
default:
break;
}
+ if(anOperation)
+ anOperation->keyReleased(theEvent->key());
}
void XGUI_OperationMgr::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
protected:
/// Commits the current operatin if it is valid
- void commitOperation();
+ bool commitOperation();
/// Sets the current operation or NULL
/// \param theOperation the started operation
/// \param isCheckBeforeStart the flag whether to check whether the operation can be started
/// Returns true if the operation can be aborted
bool canAbortOperation();
- 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.
- void onOperationStopped();
-
+ public slots:
/// SLOT, that is called by the key in the property panel is clicked.
/// \param theName the attribute name
/// \param theEvent the mouse event
/// \param theWidget an activated widget
void onWidgetActivated(ModuleBase_ModelWidget* theWidget);
+ 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.
+ void onOperationStopped();
+
private:
typedef QList<ModuleBase_Operation*> Operations; ///< definition for a list of operations
Operations myOperations; ///< a stack of started operations. The active operation is on top,
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(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*)));
connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)), this,
SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
void cleanContent();
- protected:
virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
public slots:
connect(aOkBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onCommitOperation()));
QPushButton* aCancelBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
connect(aCancelBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onAbortOperation()));
-//TODO(sbh): KeyReleasedProblem
connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)), myOperationMgr,
SLOT(onKeyReleased(QKeyEvent*)));
-
connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), myOperationMgr,
SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
connect(myOperationMgr, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*)), myPropertyPanel,