Parcourir la source

very basic logic to react on CANCELED and EXIT

ivowolf il y a 14 ans
Parent
commit
db9958e6e4
1 fichiers modifiés avec 22 ajouts et 0 suppressions
  1. 22 0
      Plugins/org.commontk.dah.exampleapp/ctkExampleDicomAppLogic.cpp

+ 22 - 0
Plugins/org.commontk.dah.exampleapp/ctkExampleDicomAppLogic.cpp

@@ -27,6 +27,7 @@
 #include <QRect>
 #include <QDebug>
 #include <QPushButton>
+#include <QApplication>
 
 ctkExampleDicomAppLogic::ctkExampleDicomAppLogic()
   : hostTracker(ctkExampleDicomAppPlugin::getPluginContext())
@@ -97,6 +98,27 @@ void ctkExampleDicomAppLogic::changeState(int anewstate)
   {
     do_something();
   }
+
+  if (newstate == ctkDicomAppHosting::CANCELED)
+  {
+    qDebug() << "  Received changeState(CANCELED) ... now releasing all resources and afterwards changing to state IDLE.";
+    qDebug() << "  Changing to state IDLE.";
+    try
+    {
+      getHostInterface()->notifyStateChanged(ctkDicomAppHosting::IDLE);
+    }
+    catch (const std::runtime_error& e)
+    {
+      qCritical() << e.what();
+      return;
+    }
+  }
+
+  if (newstate == ctkDicomAppHosting::EXIT)
+  {
+    qDebug() << "  Received changeState(EXIT) ... exiting.";
+    qApp->quit();
+  }
 }
 
 bool ctkExampleDicomAppLogic::notifyDataAvailable(ctkDicomAppHosting::AvailableData data, bool lastData)