]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Set wait cursor on long operations
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 29 Jul 2014 08:55:02 +0000 (12:55 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 29 Jul 2014 08:55:02 +0000 (12:55 +0400)
src/Events/Events_LongOp.cpp
src/XGUI/XGUI_Workshop.cpp

index 04fc6734e2d0e19df013377db89ee509ed4f87a4..ebfeb5677f764ef9826d85d8e4d68c6cfa639389 100644 (file)
@@ -48,3 +48,8 @@ void Events_LongOp::end(void* theSender)
     Events_Loop::loop()->send(anError);
   }
 }
+
+bool Events_LongOp::isPerformed()
+{
+  return !MY_SENDERS.empty();
+}
index 197b93eca1c73c690d3a210ac5ccb2ea18735a77..5cf57b2aabedd86da81bea8d71135418680bfb3c 100644 (file)
@@ -37,6 +37,7 @@
 
 #include <Events_Loop.h>
 #include <Events_Error.h>
+#include <Events_LongOp.h>
 
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_Operation.h>
@@ -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<const Config_FeatureMessage*>(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<const Config_PointerMessage*>(theMessage);