26 connect(mProcess, SIGNAL(stateChanged(QProcess::ProcessState)),
this, SLOT(processStateChanged(QProcess::ProcessState)));
27 connect(mProcess, SIGNAL(error(QProcess::ProcessError)),
this, SLOT(processError(QProcess::ProcessError)));
28 connect(mProcess, SIGNAL(finished(
int, QProcess::ExitStatus)),
this, SLOT(processFinished(
int, QProcess::ExitStatus)));
29 connect(mProcess, SIGNAL(readyRead()),
this, SLOT(processReadyRead()));
34 disconnect(mProcess, SIGNAL(stateChanged(QProcess::ProcessState)),
this, SLOT(processStateChanged(QProcess::ProcessState)));
35 disconnect(mProcess, SIGNAL(error(QProcess::ProcessError)),
this, SLOT(processError(QProcess::ProcessError)));
36 disconnect(mProcess, SIGNAL(finished(
int, QProcess::ExitStatus)),
this, SLOT(processFinished(
int, QProcess::ExitStatus)));
37 disconnect(mProcess, SIGNAL(readyRead()),
this, SLOT(processReadyRead()));
40 void ProcessReporter::processReadyRead()
42 report(QString(mProcess->readAllStandardOutput()));
45 void ProcessReporter::processStateChanged(QProcess::ProcessState newState)
47 if (newState == QProcess::Running)
49 report(QString(
"%1 started.").arg(mName));
51 if (newState == QProcess::NotRunning)
53 report(QString(
"%1 stopped.").arg(mName));
55 if (newState == QProcess::Starting)
57 report(QString(
"%1 starting.").arg(mName));
61 void ProcessReporter::processError(QProcess::ProcessError error)
64 msg += QString(
"%1 reported an error: ").arg(mName);
68 case QProcess::FailedToStart:
69 msg +=
"Failed to start";
71 case QProcess::Crashed:
74 case QProcess::Timedout:
77 case QProcess::WriteError:
80 case QProcess::ReadError:
83 case QProcess::UnknownError:
84 msg +=
"Unknown Error";
87 msg +=
"Invalid error";
93 void ProcessReporter::processFinished(
int exitCode, QProcess::ExitStatus exitStatus)
95 QString msg = QString(
"%1 exited with exit status %3. (%1 last exit code was %4.)").arg(mName).arg(exitStatus).arg(exitCode);