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:
@@ -588,6 +588,7 @@ void Application::importFrom(const char* FileName, const char* DocName, const ch
|
||||
void Application::exportTo(const char* FileName, const char* DocName, const char* Module)
|
||||
{
|
||||
WaitCursor wc;
|
||||
wc.setIgnoreEvents(WaitCursor::NoEvents);
|
||||
Base::FileInfo File(FileName);
|
||||
std::string te = File.extension();
|
||||
string unicodepath = Base::Tools::escapedUnicodeFromUtf8(File.filePath().c_str());
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#include "View3DInventor.h"
|
||||
#include "SplitView3DInventor.h"
|
||||
#include "ViewProvider.h"
|
||||
#include "WaitCursor.h"
|
||||
#include "WidgetFactory.h"
|
||||
#include "Workbench.h"
|
||||
#include "WorkbenchManager.h"
|
||||
@@ -1143,7 +1144,10 @@ PyObject* Application::sShowPreferences(PyObject * /*self*/, PyObject *args,PyOb
|
||||
Gui::Dialog::DlgPreferencesImp cDlg(getMainWindow());
|
||||
if (pstr)
|
||||
cDlg.activateGroupPage(QString::fromUtf8(pstr),idx);
|
||||
WaitCursor wc;
|
||||
wc.restoreCursor();
|
||||
cDlg.exec();
|
||||
wc.setWaitCursor();
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -78,6 +78,7 @@ public:
|
||||
void setIgnoreEvents(FilterEventsFlags flags = AllEvents);
|
||||
|
||||
private:
|
||||
FilterEventsFlags filter;
|
||||
static int instances;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user