27 #include <QMessageBox> 29 QgsRunProcess::QgsRunProcess(
const QString& action,
bool capture )
43 connect( mProcess, SIGNAL( error( QProcess::ProcessError ) ),
this, SLOT( processError( QProcess::ProcessError ) ) );
44 connect( mProcess, SIGNAL( readyReadStandardOutput() ),
this, SLOT( stdoutAvailable() ) );
45 connect( mProcess, SIGNAL( readyReadStandardError() ),
this, SLOT( stderrAvailable() ) );
49 connect( mProcess, SIGNAL( finished(
int, QProcess::ExitStatus ) ),
this, SLOT( processExit(
int, QProcess::ExitStatus ) ) );
54 mOutput->setTitle( action );
56 mOutput->showMessage(
false );
62 connect( mOutputObj, SIGNAL( destroyed() ),
this, SLOT( dialogGone() ) );
66 mProcess->start( action );
70 if ( ! mProcess->startDetached( action ) )
73 tr(
"Unable to run command\n%1" ).arg( action ),
74 QMessageBox::Ok, Qt::NoButton );
82 QgsRunProcess::~QgsRunProcess()
87 void QgsRunProcess::die()
95 QByteArray bytes( mProcess->readAllStandardOutput() );
97 QString line( codec->toUnicode( bytes ) );
100 mOutput->appendMessage( line );
105 QByteArray bytes( mProcess->readAllStandardOutput() );
107 QString line( codec->toUnicode( bytes ) );
110 mOutput->appendMessage(
"<font color=red>" + line +
"</font>" );
124 mOutput->appendMessage(
"<b>" + tr(
"Done" ) +
"</b>" );
144 disconnect( mProcess, SIGNAL( error( QProcess::ProcessError ) ),
this, SLOT( processError( QProcess::ProcessError ) ) );
145 disconnect( mProcess, SIGNAL( readyReadStandardOutput() ),
this, SLOT( stdoutAvailable() ) );
146 disconnect( mProcess, SIGNAL( readyReadStandardError() ),
this, SLOT( stderrAvailable() ) );
147 disconnect( mProcess, SIGNAL( finished(
int, QProcess::ExitStatus ) ),
this, SLOT( processExit(
int, QProcess::ExitStatus ) ) );
154 if ( err == QProcess::FailedToStart )
static QgsMessageOutput * createMessageOutput()
function that returns new class derived from QgsMessageOutput (don't forget to delete it then if show...
QTextCodec * codecForLocale()
virtual void setMessage(const QString &message, MessageType msgType)=0
set message, it won't be displayed until
void processError(QProcess::ProcessError)
StandardButton critical(QWidget *parent, const QString &title, const QString &text, QFlags< QMessageBox::StandardButton > buttons, StandardButton defaultButton)
void processExit(int, QProcess::ExitStatus)
Interface for showing messages from QGIS in GUI independent way.