Browse Source

ENH: display application state change messages in the gui

Marco Nolden 14 years ago
parent
commit
389ae79d04

+ 8 - 8
Applications/ctkExampleHost/ctkHostAppExampleWidget.cpp

@@ -2,6 +2,7 @@
 #include "ui_ctkHostAppExampleWidget.h"
 #include "ctkDicomExampleHost.h"
 #include "ctkDicomAppService.h"
+#include <ctkDicomWG23TypesHelper.h>
 
 #include <QDebug>
 #include <QFileDialog>
@@ -20,6 +21,8 @@ ctkHostAppExampleWidget::ctkHostAppExampleWidget(QWidget *parent) :
     connect(&this->host->getAppProcess(),SIGNAL(error(QProcess::ProcessError)),SLOT(appProcessError(QProcess::ProcessError)));
     connect(&this->host->getAppProcess(),SIGNAL(stateChanged(QProcess::ProcessState)),SLOT(appProcessStateChanged(QProcess::ProcessState)));
     connect(ui->placeholderFrame,SIGNAL(resized()),SLOT(placeholderResized()));
+    connect(this->host,SIGNAL( stateChangeReceived(ctkDicomWG23::State)),SLOT(appStateChanged(ctkDicomWG23::State)));
+
   }
 
 
@@ -73,14 +76,6 @@ void ctkHostAppExampleWidget::setAppFileName(QString name)
   }
 }
 
-
-
-
-
-
-
-
-
 void ctkHostAppExampleWidget::appProcessError(QProcess::ProcessError error)
 {
   if (error == QProcess::Crashed)
@@ -121,3 +116,8 @@ void ctkHostAppExampleWidget::placeholderResized()
   qDebug() << "resized";
   //ui->placeholderFrame->printPosition();
 }
+
+void ctkHostAppExampleWidget::appStateChanged(ctkDicomWG23::State state)
+{
+   ui->statusLabel->setText(ctkDicomSoapState::toStringValue(state));
+}

+ 2 - 0
Applications/ctkExampleHost/ctkHostAppExampleWidget.h

@@ -4,6 +4,7 @@
 #include <QWidget>
 #include <QProcess>
 
+#include <ctkDicomWG23Types.h>
 
 class ctkDicomExampleHost;
 
@@ -27,6 +28,7 @@ public slots:
     void stopButtonClicked();
     void appProcessError(QProcess::ProcessError error);
     void appProcessStateChanged(QProcess::ProcessState state);
+    void appStateChanged(ctkDicomWG23::State state);
 
     void placeholderResized();
 

+ 7 - 2
Plugins/org.commontk.dicom.examplehost/ctkDicomExampleHost.cpp

@@ -1,8 +1,13 @@
 #include "ctkDicomExampleHost.h"
+#include "ctkDicomWG23TypesHelper.h"
+
 #include <QProcess>
 #include <QtDebug>
 
-ctkDicomExampleHost::ctkDicomExampleHost(QWidget* placeholderWidget, int hostPort, int appPort) : placeholderWidget(placeholderWidget),ctkDicomAbstractHost(hostPort, appPort)
+ctkDicomExampleHost::ctkDicomExampleHost(QWidget* placeholderWidget, int hostPort, int appPort) :
+    ctkDicomAbstractHost(hostPort, appPort),
+    placeholderWidget(placeholderWidget),
+    applicationState(ctkDicomWG23::IDLE)
 {
 }
 
@@ -34,7 +39,7 @@ QRect ctkDicomExampleHost::getAvailableScreen(const QRect& preferredScreen){
 
 
 void ctkDicomExampleHost::notifyStateChanged(ctkDicomWG23::State state){
-    qDebug()<< "new state received:"<< static_cast<int>(state);
+    qDebug()<< "new state received:"<< ctkDicomSoapState::toStringValue(state);
     emit stateChangedReceived(state);
 }
 

+ 1 - 1
Plugins/org.commontk.dicom.examplehost/ctkDicomExampleHost.h

@@ -29,7 +29,7 @@ signals:
 protected:
     QProcess appProcess;
     QWidget* placeholderWidget;
-
+    ctkDicomWG23::State applicationState;
 };
 
 #endif // CTKDICOMEXAMPLEHOST_H