diff --git a/src/Gui/ProgressBar.cpp b/src/Gui/ProgressBar.cpp index fcf50fcb3..129860a4a 100644 --- a/src/Gui/ProgressBar.cpp +++ b/src/Gui/ProgressBar.cpp @@ -57,6 +57,19 @@ struct ProgressBarPrivate QTimer* delayShowTimer; int minimumDuration; int observeEventFilter; + + bool isModalDialog(QObject* o) const + { + QWidget* parent = qobject_cast(o); + while (parent) { + QMessageBox* dlg = qobject_cast(parent); + if (dlg && dlg->isModal()) + return true; + parent = parent->parentWidget(); + } + + return false; + } }; } @@ -465,6 +478,8 @@ bool ProgressBar::eventFilter(QObject* o, QEvent* e) // do a system beep and ignore the event case QEvent::MouseButtonPress: { + if (d->isModalDialog(o)) + return false; QApplication::beep(); return true; } break; diff --git a/src/Gui/WaitCursor.cpp b/src/Gui/WaitCursor.cpp index f91209a25..6b9d670e7 100644 --- a/src/Gui/WaitCursor.cpp +++ b/src/Gui/WaitCursor.cpp @@ -24,8 +24,9 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include +# include +# include +# include # ifdef FC_OS_WIN32 # include # endif @@ -45,6 +46,7 @@ public: protected: bool eventFilter(QObject*, QEvent*); + bool isModalDialog(QObject* o) const; private: WaitCursorP(); // Disable constructor @@ -89,18 +91,35 @@ void WaitCursorP::setIgnoreEvents(WaitCursor::FilterEventsFlags flags) this->flags = flags; } -bool WaitCursorP::eventFilter(QObject*, QEvent* e) +bool WaitCursorP::isModalDialog(QObject* o) const +{ + QWidget* parent = qobject_cast(o); + while (parent) { + QMessageBox* dlg = qobject_cast(parent); + if (dlg && dlg->isModal()) + return true; + parent = parent->parentWidget(); + } + + return false; +} + +bool WaitCursorP::eventFilter(QObject* o, QEvent* e) { // Note: This might cause problems when we want to open a modal dialog at the lifetime // of a WaitCursor instance because the incoming events are still filtered. if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) { + if (isModalDialog(o)) + return false; if (this->flags & WaitCursor::KeyEvents) return true; } if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonRelease || e->type() == QEvent::MouseButtonDblClick) { + if (isModalDialog(o)) + return false; if (this->flags & WaitCursor::MouseEvents) return true; }