Commit 19f49e21 authored by Guillaume Pasero's avatar Guillaume Pasero

ENH: add 1s timer to show return status of otbgui application

parent 37a80cc7
......@@ -19,6 +19,7 @@
#define otbWrapperQtWidgetModel_h
#include <QtGui>
#include <QTimer>
#ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829 //tag=QT4-boost-compatibility
#include "otbWrapperApplication.h"
#include "otbQtLogOutput.h"
......@@ -162,6 +163,8 @@ private slots:
*/
void OnApplicationExecutionDone( int status );
void TimerDone();
private:
QtWidgetModel(const QtWidgetModel&); //purposely not implemented
void operator=(const QtWidgetModel&); //purposely not implemented
......@@ -171,6 +174,8 @@ private:
QtLogOutput::Pointer m_LogOutput;
bool m_IsRunning;
QTimer *m_Timer;
};
......
......@@ -54,6 +54,7 @@ public slots:
private slots:
void UpdateMessageAfterExecuteClicked();
void UpdateMessageAfterExecution(int status);
void UpdateMessageAfterApplicationReady(bool val);
signals:
......
......@@ -40,6 +40,16 @@ QtWidgetModel
// Attach log output to the Application logger
m_Application->GetLogger()->SetTimeStampFormat(itk::LoggerBase::HUMANREADABLE);
m_Application->GetLogger()->AddLogOutput(m_LogOutput);
m_Timer = new QTimer(this);
m_Timer->setSingleShot(true);
m_Timer->setInterval(1000);
QObject::connect(
m_Timer,
SIGNAL( timeout() ),
this,
SLOT( TimerDone() )
);
}
QtWidgetModel::~QtWidgetModel()
......@@ -99,16 +109,21 @@ void
QtWidgetModel
::OnApplicationExecutionDone( int status )
{
m_IsRunning = false;
// For the progressReport to close the Progress widget
// and the GUI to update message
emit SetProgressReportDone( status );
// start timer
m_Timer->start();
}
void
QtWidgetModel
::TimerDone()
{
m_IsRunning = false;
// Require GUI update.
NotifyUpdate();
// For the view to activate the button "Execute"
emit SetApplicationReady( true );
// For the progressReport to close the Progress widget
emit SetProgressReportDone( status );
}
void
......
......@@ -61,6 +61,7 @@ void QtWidgetView::CreateGui()
m_Message = new QLabel("<center><font color=\"#FF0000\">Select parameters</font></center>");
connect( m_Model, SIGNAL(SetApplicationReady(bool)), this, SLOT(UpdateMessageAfterApplicationReady(bool)) );
connect( m_Model, SIGNAL(SetProgressReportDone(int)), this, SLOT(UpdateMessageAfterExecution(int)) );
mainLayout->addWidget(m_Message);
QtWidgetSimpleProgressReport * progressReport = new QtWidgetSimpleProgressReport(m_Model);
......@@ -86,10 +87,22 @@ void QtWidgetView::UpdateMessageAfterExecuteClicked()
m_Message->setText("<center><font color=\"#FF0000\">Running</font></center>");
}
void QtWidgetView::UpdateMessageAfterExecution(int status)
{
if (status >= 0)
{
m_Message->setText("<center><font color=\"#00A000\">DONE</font></center>");
}
else
{
m_Message->setText("<center><font color=\"#FF0000\">FAILED !</font></center>");
}
}
void QtWidgetView::UpdateMessageAfterApplicationReady( bool val )
{
if(val == true)
m_Message->setText("<center><font color=\"#00FF00\">Ready to run</font></center>");
m_Message->setText("<center><font color=\"#00A000\">Ready to run</font></center>");
else
m_Message->setText("<center><font color=\"#FF0000\">Select parameters</font></center>");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment