26 #include <QMessageBox> 
   28 QgsRunProcess::QgsRunProcess( 
const QString& action, 
bool capture )
 
   29     : mProcess( NULL ), mOutput( NULL )
 
   37   mProcess = 
new QProcess;
 
   41     connect( mProcess, SIGNAL( error( QProcess::ProcessError ) ), 
this, SLOT( processError( QProcess::ProcessError ) ) );
 
   42     connect( mProcess, SIGNAL( readyReadStandardOutput() ), 
this, SLOT( stdoutAvailable() ) );
 
   43     connect( mProcess, SIGNAL( readyReadStandardError() ), 
this, SLOT( stderrAvailable() ) );
 
   47     connect( mProcess, SIGNAL( finished( 
int, QProcess::ExitStatus ) ), 
this, SLOT( processExit( 
int, QProcess::ExitStatus ) ) );
 
   52     mOutput->setTitle( action );
 
   54     mOutput->showMessage( 
false ); 
 
   57     QObject* mOutputObj = 
dynamic_cast<QObject *
>( mOutput );
 
   60       connect( mOutputObj, SIGNAL( destroyed() ), 
this, SLOT( dialogGone() ) );
 
   64     mProcess->start( action );
 
   68     if ( ! mProcess->startDetached( action ) ) 
 
   70       QMessageBox::critical( 0, 
tr( 
"Action" ),
 
   71                              tr( 
"Unable to run command\n%1" ).arg( action ),
 
   72                              QMessageBox::Ok, Qt::NoButton );
 
   80 QgsRunProcess::~QgsRunProcess()
 
   85 void QgsRunProcess::die()
 
   93   QString line( mProcess->readAllStandardOutput() );
 
  101   QString line( mProcess->readAllStandardError() );
 
  104   mOutput->
appendMessage( 
"<font color=red>" + line + 
"</font>" );
 
  138   disconnect( mProcess, SIGNAL( error( QProcess::ProcessError ) ), 
this, SLOT( 
processError( QProcess::ProcessError ) ) );
 
  139   disconnect( mProcess, SIGNAL( readyReadStandardOutput() ), 
this, SLOT( 
stdoutAvailable() ) );
 
  140   disconnect( mProcess, SIGNAL( readyReadStandardError() ), 
this, SLOT( 
stderrAvailable() ) );
 
  141   disconnect( mProcess, SIGNAL( finished( 
int, QProcess::ExitStatus ) ), 
this, SLOT( 
processExit( 
int, QProcess::ExitStatus ) ) );
 
  148   if ( err == QProcess::FailedToStart )
 
  157     QgsDebugMsg( 
"Got error: " + QString( 
"%d" ).arg( err ) );