-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphpqt5runcontrol.cpp
More file actions
76 lines (64 loc) · 2.22 KB
/
Copy pathphpqt5runcontrol.cpp
File metadata and controls
76 lines (64 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "phpqt5runcontrol.h"
#include "phpqt5runconfiguration.h"
#include <projectexplorer/runnables.h>
#include <utils/qtcprocess.h>
#include <utils/outputformat.h>
#include <QDir>
using namespace ProjectExplorer;
using namespace Utils;
namespace PHPQt5 {
PHPQt5RunControl::PHPQt5RunControl(PHPQt5RunConfiguration *rc, Core::Id mode)
: RunControl(rc, mode)
, m_running(false)
, m_runnable(rc->runnable().as<StandardRunnable>())
{
connect(&m_applicationLauncher, &ApplicationLauncher::appendMessage,
this, &PHPQt5RunControl::slotAppendMessage);
connect(&m_applicationLauncher, &ApplicationLauncher::processStarted,
this, &PHPQt5RunControl::processStarted);
connect(&m_applicationLauncher, &ApplicationLauncher::processExited,
this, &PHPQt5RunControl::processExited);
connect(&m_applicationLauncher, &ApplicationLauncher::bringToForegroundRequested,
this, &RunControl::bringApplicationToForeground);
}
void PHPQt5RunControl::start()
{
emit started();
m_running = true;
m_applicationLauncher.start(m_runnable);
setApplicationProcessHandle(ProcessHandle(m_applicationLauncher.applicationPID()));
}
ProjectExplorer::RunControl::StopResult PHPQt5RunControl::stop()
{
m_applicationLauncher.stop();
return StoppedSynchronously;
}
bool PHPQt5RunControl::isRunning() const
{
return m_running;
}
void PHPQt5RunControl::processStarted()
{
// Console processes only know their pid after being started
setApplicationProcessHandle(ProcessHandle(m_applicationLauncher.applicationPID()));
}
void PHPQt5RunControl::processExited(int exitCode, QProcess::ExitStatus status)
{
m_running = false;
setApplicationProcessHandle(ProcessHandle());
QString msg;
if (status == QProcess::CrashExit) {
msg = tr("%1 crashed")
.arg(QDir::toNativeSeparators(m_runnable.executable));
} else {
msg = tr("%1 exited with code %2")
.arg(QDir::toNativeSeparators(m_runnable.executable)).arg(exitCode);
}
appendMessage(msg + QLatin1Char('\n'), NormalMessageFormat);
emit finished();
}
void PHPQt5RunControl::slotAppendMessage(const QString &err, OutputFormat format)
{
appendMessage(err, format);
}
}