From: vsv Date: Tue, 29 Jul 2014 08:55:02 +0000 (+0400) Subject: Set wait cursor on long operations X-Git-Tag: V_0.4.4~136^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4a01571745eb1da23d282fd2ad1567bdd01b796d;p=modules%2Fshaper.git Set wait cursor on long operations --- diff --git a/src/Events/Events_LongOp.cpp b/src/Events/Events_LongOp.cpp index 04fc6734e..ebfeb5677 100644 --- a/src/Events/Events_LongOp.cpp +++ b/src/Events/Events_LongOp.cpp @@ -48,3 +48,8 @@ void Events_LongOp::end(void* theSender) Events_Loop::loop()->send(anError); } } + +bool Events_LongOp::isPerformed() +{ + return !MY_SENDERS.empty(); +} diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 197b93eca..5cf57b2aa 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include @@ -136,6 +137,7 @@ void XGUI_Workshop::startApplication() aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED)); + aLoop->registerListener(this, Events_Loop::eventByName("LongOperation")); registerValidators(); activateModule(); @@ -224,8 +226,7 @@ XGUI_Workbench* XGUI_Workshop::addWorkbench(const QString& theName) void XGUI_Workshop::processEvent(const Events_Message* theMessage) { //A message to start feature creation received. - static Events_ID aFeatureLoadedId = Events_Loop::loop()->eventByName(EVENT_FEATURE_LOADED); - if (theMessage->eventID() == aFeatureLoadedId) { + if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_LOADED)) { const Config_FeatureMessage* aFeatureMsg = dynamic_cast(theMessage); if(!aFeatureMsg->isInternal()) { addFeature(aFeatureMsg); @@ -263,6 +264,14 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) return; } + if (theMessage->eventID() == Events_Loop::loop()->eventByName("LongOperation")) { + if (Events_LongOp::isPerformed()) + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + else + QApplication::restoreOverrideCursor(); + return; + } + //An operation passed by message. Start it, process and commit. if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OPERATION_LAUNCHED)) { const Config_PointerMessage* aPartSetMsg = dynamic_cast(theMessage);