improvements of wait cursor

make filtering of modal dialogs working with Qt5
save/restore filter flags
don't filter events for File > Export
when using showPreferences don't show wait cursor
This commit is contained in:
wmayer
2017-10-22 19:49:56 +02:00
parent 769e93973c
commit 3499ac62f9
4 changed files with 19 additions and 0 deletions

View File

@@ -32,6 +32,10 @@
# endif
#endif
#if QT_VERSION >= 0x050000
# include <QWindow>
#endif
#include "WaitCursor.h"
using namespace Gui;
@@ -100,6 +104,13 @@ void WaitCursorP::setIgnoreEvents(WaitCursor::FilterEventsFlags flags)
bool WaitCursorP::isModalDialog(QObject* o) const
{
QWidget* parent = qobject_cast<QWidget*>(o);
#if QT_VERSION >= 0x050000
if (!parent) {
QWindow* window = qobject_cast<QWindow*>(o);
if (window)
parent = QWidget::find(window->winId());
}
#endif
while (parent) {
QMessageBox* dlg = qobject_cast<QMessageBox*>(parent);
if (dlg && dlg->isModal())
@@ -144,6 +155,7 @@ WaitCursor::WaitCursor()
{
if (instances++ == 0)
setWaitCursor();
filter = WaitCursorP::getInstance()->ignoreEvents();
}
/** Restores the last cursor again. */
@@ -151,6 +163,7 @@ WaitCursor::~WaitCursor()
{
if (--instances == 0)
restoreCursor();
WaitCursorP::getInstance()->setIgnoreEvents(filter);
}
/**