| 64 | } |
| 65 | |
| 66 | void PostLaunchCommand::on_state(LoggedProcess::State state) |
| 67 | { |
| 68 | auto getError = [&]() |
| 69 | { |
| 70 | return tr("Post-Launch command failed with code %1.\n\n").arg(m_process.exitCode()); |
| 71 | }; |
| 72 | switch(state) |
| 73 | { |
| 74 | case LoggedProcess::Aborted: |
| 75 | case LoggedProcess::Crashed: |
| 76 | case LoggedProcess::FailedToStart: |
| 77 | { |
| 78 | auto error = getError(); |
| 79 | emit logLine(error, MessageLevel::Fatal); |
| 80 | emitFailed(error); |
| 81 | return; |
| 82 | } |
| 83 | case LoggedProcess::Finished: |
| 84 | { |
| 85 | if(m_process.exitCode() != 0) |
| 86 | { |
| 87 | auto error = getError(); |
| 88 | emit logLine(error, MessageLevel::Fatal); |
| 89 | emitFailed(error); |
| 90 | } |
| 91 | else |
| 92 | { |
| 93 | emit logLine(tr("Post-Launch command ran successfully.\n\n"), MessageLevel::Launcher); |
| 94 | emitSucceeded(); |
| 95 | } |
| 96 | } |
| 97 | default: |
| 98 | break; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | void PostLaunchCommand::setWorkingDirectory(const QString &wd) |
| 103 | { |