+ do not filter events from modal message box if WaitCursor is instantiated
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5098 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
parent
8c515c381b
commit
110c879e58
|
@ -57,6 +57,19 @@ struct ProgressBarPrivate
|
|||
QTimer* delayShowTimer;
|
||||
int minimumDuration;
|
||||
int observeEventFilter;
|
||||
|
||||
bool isModalDialog(QObject* o) const
|
||||
{
|
||||
QWidget* parent = qobject_cast<QWidget*>(o);
|
||||
while (parent) {
|
||||
QMessageBox* dlg = qobject_cast<QMessageBox*>(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;
|
||||
|
|
|
@ -24,8 +24,9 @@
|
|||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <qapplication.h>
|
||||
# include <qdatetime.h>
|
||||
# include <QApplication>
|
||||
# include <QDateTime>
|
||||
# include <QMessageBox>
|
||||
# ifdef FC_OS_WIN32
|
||||
# include <windows.h>
|
||||
# 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<QWidget*>(o);
|
||||
while (parent) {
|
||||
QMessageBox* dlg = qobject_cast<QMessageBox*>(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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user