else if (theEvent->type() == QEvent::KeyPress) {
QKeyEvent* aKeyEvent = dynamic_cast<QKeyEvent*>(theEvent);
myOperationMgr->setSHIFTPressed(aKeyEvent->modifiers() & Qt::ShiftModifier);
+ switch (aKeyEvent->key()) {
+ case Qt::Key_Escape:
+ isAccepted = myOperationMgr->onKeyPressed(theObject, aKeyEvent);
+ break;
+ default:
+ break;
+ }
}
}
if (!isAccepted)
XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent,
ModuleBase_IWorkshop* theWorkshop)
-: QObject(theParent), myWorkshop(theWorkshop), mySHIFTPressed(false)
+: QObject(theParent), myWorkshop(theWorkshop), mySHIFTPressed(false), myActiveMessageBox(0)
{
/// we need to install filter to the application in order to react to 'Delete' key button
/// this key can not be a short cut for a corresponded action because we need to set
ModuleBase_Operation* anOperation = currentOperation();
bool isAccepted = false;
switch (theEvent->key()) {
- case Qt::Key_Escape: {
- ModuleBase_Operation* aOperation = currentOperation();
- if (aOperation) {
- onAbortOperation();
- isAccepted = true;
- }
- }
- break;
case Qt::Key_Tab:
case Qt::Key_Backtab:
{
return isAccepted;
}
+bool XGUI_OperationMgr::onKeyPressed(QObject *theObject, QKeyEvent* theEvent)
+{
+ // Let the manager decide what to do with the given key combination.
+ ModuleBase_Operation* anOperation = currentOperation();
+ bool isAccepted = false;
+ switch (theEvent->key()) {
+ case Qt::Key_Escape: {
+ // processing in message box
+ if (myActiveMessageBox)
+ {
+ myActiveMessageBox->reject();
+ isAccepted = true;
+ }
+ // processing in the active widget
+ ModuleBase_Operation* aOperation = currentOperation();
+ if (!isAccepted && aOperation) {
+ ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
+ ModuleBase_ModelWidget* anActiveWgt = aPanel->activeWidget();
+ if (anActiveWgt)
+ isAccepted = anActiveWgt && anActiveWgt->processEscape();
+ }
+ // default Escape button functionality
+ if (!isAccepted && aOperation) {
+ onAbortOperation();
+ isAccepted = true;
+ }
+ }
+ break;
+ }
+ return isAccepted;
+}
+
bool XGUI_OperationMgr::onProcessEnter(QObject* theObject)
{
bool isAccepted = false;
}
return isPPChild;
}
+
+QMessageBox* XGUI_OperationMgr::createMessageBox(const QString& theMessage)
+{
+ QMessageBox * aMessageBox = new QMessageBox(QMessageBox::Question,
+ QObject::tr("Abort operation"), theMessage, QMessageBox::Ok | QMessageBox::Cancel,
+ qApp->activeWindow());
+ aMessageBox->setDefaultButton(QMessageBox::Cancel);
+ aMessageBox->setEscapeButton(QMessageBox::No); // operation manager should process Esc key
+
+ return aMessageBox;
+}
\ No newline at end of file