SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Member Functions | Static Public Member Functions | Private Slots | Private Attributes | List of all members
Command Class Reference

#include <command.h>

Inherits QObject.

Public Member Functions

 Command ()
 
 Command (const Command &command)
 
 ~Command ()
 
void resetToDefaults ()
 
QByteArray serialize () const
 
bool deserialize (const QByteArray &data)
 
void setCommand (const QString &command)
 
const QString & getCommand () const
 
void setArgString (const QString &argString)
 
const QString & getArgString () const
 
void setGroup (const QString &group)
 
const QString & getGroup () const
 
void setDescription (const QString &description)
 
const QString & getDescription () const
 
void setKey (Qt::Key key)
 
Qt::Key getKey () const
 
void setKeyModifiers (Qt::KeyboardModifiers keyModifiers)
 
Qt::KeyboardModifiers getKeyModifiers () const
 
void setAssociateKey (bool associate)
 
bool getAssociateKey () const
 
void setRelease (bool release)
 
bool getRelease () const
 
QString getKeyLabel () const
 
void run (const QString &apiAddress, int apiPort, int deviceSetIndex)
 
void kill ()
 
QProcess::ProcessState getLastProcessState () const
 
bool getLastProcessError (QProcess::ProcessError &error) const
 
bool getLastProcessExit (int &exitCode, QProcess::ExitStatus &exitStatus) const
 
const QString & getLastProcessLog () const
 
uint64_t getLastProcessStartTimestampms () const
 
uint64_t getLastProcessFinishTimestampms () const
 
const QString & getLastProcessCommandLine () const
 
qint64 getLastProcessPid () const
 

Static Public Member Functions

static bool commandCompare (const Command *c1, Command *c2)
 

Private Slots

void processStateChanged (QProcess::ProcessState newState)
 
void processError (QProcess::ProcessError error)
 
void processFinished (int exitCode, QProcess::ExitStatus exitStatus)
 

Private Attributes

QString m_group
 
QString m_description
 
QString m_command
 
QString m_argString
 
Qt::Key m_key
 
Qt::KeyboardModifiers m_keyModifiers
 
bool m_associateKey
 
bool m_release
 
QProcess * m_currentProcess
 
QProcess::ProcessState m_currentProcessState
 
bool m_isInError
 
QProcess::ProcessError m_currentProcessError
 
bool m_hasExited
 
int m_currentProcessExitCode
 
QProcess::ExitStatus m_currentProcessExitStatus
 
QString m_log
 
uint64_t m_currentProcessStartTimeStampms
 
uint64_t m_currentProcessFinishTimeStampms
 
QString m_currentProcessCommandLine
 
qint64 m_currentProcessPid
 

Detailed Description

Definition at line 31 of file command.h.

Constructor & Destructor Documentation

◆ Command() [1/2]

Command::Command ( )

Definition at line 27 of file command.cpp.

References m_currentProcessFinishTimeStampms, m_currentProcessStartTimeStampms, and resetToDefaults().

27  :
28  m_currentProcess(nullptr),
29  m_currentProcessState(QProcess::NotRunning),
30  m_isInError(false),
31  m_currentProcessError(QProcess::UnknownError),
32  m_hasExited(false),
34  m_currentProcessExitStatus(QProcess::NormalExit),
36 {
39 
41 }
QProcess::ExitStatus m_currentProcessExitStatus
Definition: command.h:109
QProcess * m_currentProcess
Definition: command.h:103
qint64 m_currentProcessPid
Definition: command.h:114
void resetToDefaults()
Definition: command.cpp:81
uint64_t m_currentProcessFinishTimeStampms
Definition: command.h:112
bool m_isInError
Definition: command.h:105
bool m_hasExited
Definition: command.h:107
QProcess::ProcessState m_currentProcessState
Definition: command.h:104
QProcess::ProcessError m_currentProcessError
Definition: command.h:106
uint64_t m_currentProcessStartTimeStampms
Definition: command.h:111
int m_currentProcessExitCode
Definition: command.h:108
+ Here is the call graph for this function:

◆ Command() [2/2]

Command::Command ( const Command command)

Definition at line 43 of file command.cpp.

References m_currentProcessFinishTimeStampms, and m_currentProcessStartTimeStampms.

43  :
44  QObject(),
45  m_group(command.m_group),
47  m_command(command.m_command),
48  m_argString(command.m_argString),
49  m_key(command.m_key),
52  m_release(command.m_release),
53  m_currentProcess(nullptr),
54  m_currentProcessState(QProcess::NotRunning),
55  m_isInError(false),
56  m_currentProcessError(QProcess::UnknownError),
57  m_hasExited(false),
59  m_currentProcessExitStatus(QProcess::NormalExit),
61 {
64 }
QString m_group
Definition: command.h:95
QProcess::ExitStatus m_currentProcessExitStatus
Definition: command.h:109
QString m_description
Definition: command.h:96
QString m_argString
Definition: command.h:98
Qt::Key m_key
Definition: command.h:99
QProcess * m_currentProcess
Definition: command.h:103
qint64 m_currentProcessPid
Definition: command.h:114
uint64_t m_currentProcessFinishTimeStampms
Definition: command.h:112
bool m_release
Definition: command.h:102
bool m_isInError
Definition: command.h:105
bool m_hasExited
Definition: command.h:107
QString m_command
Definition: command.h:97
QProcess::ProcessState m_currentProcessState
Definition: command.h:104
Qt::KeyboardModifiers m_keyModifiers
Definition: command.h:100
QProcess::ProcessError m_currentProcessError
Definition: command.h:106
uint64_t m_currentProcessStartTimeStampms
Definition: command.h:111
bool m_associateKey
Definition: command.h:101
int m_currentProcessExitCode
Definition: command.h:108

◆ ~Command()

Command::~Command ( )

Definition at line 66 of file command.cpp.

References m_currentProcess, processError(), processFinished(), and processStateChanged().

67 {
68  if (m_currentProcess)
69  {
70 #if QT_VERSION < 0x051000
71  disconnect(m_currentProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
72 #else
73  disconnect(m_currentProcess, SIGNAL(errorOccurred(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
74 #endif
75  disconnect(m_currentProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(processFinished(int, QProcess::ExitStatus)));
76  disconnect(m_currentProcess, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(processStateChanged(QProcess::ProcessState)));
77  m_currentProcess->deleteLater();
78  }
79 }
void processFinished(int exitCode, QProcess::ExitStatus exitStatus)
Definition: command.cpp:282
void processError(QProcess::ProcessError error)
Definition: command.cpp:258
QProcess * m_currentProcess
Definition: command.h:103
void processStateChanged(QProcess::ProcessState newState)
Definition: command.cpp:248
+ Here is the call graph for this function:

Member Function Documentation

◆ commandCompare()

static bool Command::commandCompare ( const Command c1,
Command c2 
)
inlinestatic

Definition at line 72 of file command.h.

References m_description, m_group, m_key, and m_release.

Referenced by MainSettings::sortCommands().

73  {
74  if (c1->m_group != c2->m_group)
75  {
76  return c1->m_group < c2->m_group;
77  }
78  else
79  {
80  if (c1->m_description != c2->m_description) {
81  return c1->m_description < c2->m_description;
82  }
83  else
84  {
85  if (c1->m_key != c2->m_key) {
86  return c1->m_key < c2->m_key;
87  } else {
88  return c1->m_release;
89  }
90  }
91  }
92  }
QString m_group
Definition: command.h:95
QString m_description
Definition: command.h:96
Qt::Key m_key
Definition: command.h:99
bool m_release
Definition: command.h:102
+ Here is the caller graph for this function:

◆ deserialize()

bool Command::deserialize ( const QByteArray &  data)

Definition at line 110 of file command.cpp.

References SimpleDeserializer::getVersion(), SimpleDeserializer::isValid(), m_argString, m_associateKey, m_command, m_description, m_group, m_key, m_keyModifiers, m_release, SimpleDeserializer::readBool(), SimpleDeserializer::readS32(), SimpleDeserializer::readString(), and resetToDefaults().

Referenced by MainSettings::load().

111 {
112  SimpleDeserializer d(data);
113 
114  if (!d.isValid())
115  {
116  resetToDefaults();
117  return false;
118  }
119 
120  if (d.getVersion() == 1)
121  {
122  int tmpInt;
123 
124  d.readString(1, &m_group, "default");
125  d.readString(2, &m_description, "no name");
126  d.readString(3, &m_command, "");
127  d.readString(4, &m_argString, "");
128  d.readS32(5, &tmpInt, 0);
129  m_key = static_cast<Qt::Key>(tmpInt);
130  d.readS32(6, &tmpInt, 0);
131  m_keyModifiers = static_cast<Qt::KeyboardModifiers>(tmpInt);
132  d.readBool(7, &m_associateKey, false);
133  d.readBool(8, &m_release, false);
134 
135  return true;
136  }
137  else
138  {
139  resetToDefaults();
140  return false;
141  }
142 }
QString m_group
Definition: command.h:95
QString m_description
Definition: command.h:96
QString m_argString
Definition: command.h:98
Qt::Key m_key
Definition: command.h:99
void resetToDefaults()
Definition: command.cpp:81
bool m_release
Definition: command.h:102
QString m_command
Definition: command.h:97
Qt::KeyboardModifiers m_keyModifiers
Definition: command.h:100
bool m_associateKey
Definition: command.h:101
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getArgString()

const QString& Command::getArgString ( ) const
inline

Definition at line 46 of file command.h.

Referenced by EditCommandDialog::fromCommand().

46 { return m_argString; }
QString m_argString
Definition: command.h:98
+ Here is the caller graph for this function:

◆ getAssociateKey()

bool Command::getAssociateKey ( ) const
inline

Definition at line 56 of file command.h.

Referenced by MainWindow::addCommandToTree(), MainWindow::commandKeyPressed(), and EditCommandDialog::fromCommand().

56 { return m_associateKey; }
bool m_associateKey
Definition: command.h:101
+ Here is the caller graph for this function:

◆ getCommand()

const QString& Command::getCommand ( ) const
inline

Definition at line 44 of file command.h.

Referenced by EditCommandDialog::fromCommand().

44 { return m_command; }
QString m_command
Definition: command.h:97
+ Here is the caller graph for this function:

◆ getDescription()

const QString& Command::getDescription ( ) const
inline

Definition at line 50 of file command.h.

Referenced by MainWindow::addCommandToTree(), EditCommandDialog::fromCommand(), and MainWindow::on_commandDelete_clicked().

50 { return m_description; }
QString m_description
Definition: command.h:96
+ Here is the caller graph for this function:

◆ getGroup()

const QString& Command::getGroup ( ) const
inline

Definition at line 48 of file command.h.

Referenced by MainWindow::addCommandToTree(), EditCommandDialog::fromCommand(), MainWindow::on_commandEdit_clicked(), and MainWindow::on_commandRun_clicked().

48 { return m_group; }
QString m_group
Definition: command.h:95
+ Here is the caller graph for this function:

◆ getKey()

Qt::Key Command::getKey ( ) const
inline

Definition at line 52 of file command.h.

Referenced by MainWindow::commandKeyPressed(), and EditCommandDialog::fromCommand().

52 { return m_key; }
Qt::Key m_key
Definition: command.h:99
+ Here is the caller graph for this function:

◆ getKeyLabel()

QString Command::getKeyLabel ( ) const

Definition at line 144 of file command.cpp.

References m_key, and m_keyModifiers.

Referenced by MainWindow::addCommandToTree().

145 {
146  if (m_key == 0)
147  {
148  return "";
149  }
150  else if (m_keyModifiers != Qt::NoModifier)
151  {
152  QString altGrStr = m_keyModifiers & Qt::GroupSwitchModifier ? "Gr " : "";
153  int maskedModifiers = (m_keyModifiers & 0x3FFFFFFF) + ((m_keyModifiers & 0x40000000)>>3);
154  return altGrStr + QKeySequence(maskedModifiers, m_key).toString();
155  }
156  else
157  {
158  return QKeySequence(m_key).toString();
159  }
160 }
Qt::Key m_key
Definition: command.h:99
Qt::KeyboardModifiers m_keyModifiers
Definition: command.h:100
+ Here is the caller graph for this function:

◆ getKeyModifiers()

Qt::KeyboardModifiers Command::getKeyModifiers ( ) const
inline

Definition at line 54 of file command.h.

Referenced by MainWindow::commandKeyPressed(), and EditCommandDialog::fromCommand().

54 { return m_keyModifiers; }
Qt::KeyboardModifiers m_keyModifiers
Definition: command.h:100
+ Here is the caller graph for this function:

◆ getLastProcessCommandLine()

const QString& Command::getLastProcessCommandLine ( ) const
inline

Definition at line 69 of file command.h.

Referenced by CommandOutputDialog::refresh().

QString m_currentProcessCommandLine
Definition: command.h:113
+ Here is the caller graph for this function:

◆ getLastProcessError()

bool Command::getLastProcessError ( QProcess::ProcessError &  error) const

Definition at line 223 of file command.cpp.

References m_currentProcessError, and m_isInError.

Referenced by CommandOutputDialog::refresh().

224 {
225  if (m_isInError) {
226  error = m_currentProcessError;
227  }
228 
229  return m_isInError;
230 }
bool m_isInError
Definition: command.h:105
QProcess::ProcessError m_currentProcessError
Definition: command.h:106
+ Here is the caller graph for this function:

◆ getLastProcessExit()

bool Command::getLastProcessExit ( int &  exitCode,
QProcess::ExitStatus &  exitStatus 
) const

Definition at line 232 of file command.cpp.

References m_currentProcessExitCode, m_currentProcessExitStatus, and m_hasExited.

Referenced by CommandOutputDialog::refresh().

233 {
234  if (m_hasExited)
235  {
236  exitCode = m_currentProcessExitCode;
237  exitStatus = m_currentProcessExitStatus;
238  }
239 
240  return m_hasExited;
241 }
QProcess::ExitStatus m_currentProcessExitStatus
Definition: command.h:109
bool m_hasExited
Definition: command.h:107
int m_currentProcessExitCode
Definition: command.h:108
+ Here is the caller graph for this function:

◆ getLastProcessFinishTimestampms()

uint64_t Command::getLastProcessFinishTimestampms ( ) const
inline

Definition at line 68 of file command.h.

Referenced by CommandOutputDialog::refresh().

uint64_t m_currentProcessFinishTimeStampms
Definition: command.h:112
+ Here is the caller graph for this function:

◆ getLastProcessLog()

const QString & Command::getLastProcessLog ( ) const

Definition at line 243 of file command.cpp.

References m_log.

Referenced by CommandOutputDialog::refresh().

244 {
245  return m_log;
246 }
QString m_log
Definition: command.h:110
+ Here is the caller graph for this function:

◆ getLastProcessPid()

qint64 Command::getLastProcessPid ( ) const
inline

Definition at line 70 of file command.h.

Referenced by CommandOutputDialog::refresh().

70 { return m_currentProcessPid; }
qint64 m_currentProcessPid
Definition: command.h:114
+ Here is the caller graph for this function:

◆ getLastProcessStartTimestampms()

uint64_t Command::getLastProcessStartTimestampms ( ) const
inline

Definition at line 67 of file command.h.

Referenced by CommandOutputDialog::refresh().

uint64_t m_currentProcessStartTimeStampms
Definition: command.h:111
+ Here is the caller graph for this function:

◆ getLastProcessState()

QProcess::ProcessState Command::getLastProcessState ( ) const

Definition at line 218 of file command.cpp.

References m_currentProcessState.

Referenced by CommandOutputDialog::refresh().

219 {
220  return m_currentProcessState;
221 }
QProcess::ProcessState m_currentProcessState
Definition: command.h:104
+ Here is the caller graph for this function:

◆ getRelease()

bool Command::getRelease ( ) const
inline

Definition at line 58 of file command.h.

Referenced by MainWindow::addCommandToTree(), MainWindow::commandKeyPressed(), and EditCommandDialog::fromCommand().

58 { return m_release; }
bool m_release
Definition: command.h:102
+ Here is the caller graph for this function:

◆ kill()

void Command::kill ( )

Definition at line 209 of file command.cpp.

References m_currentProcess, and m_currentProcessPid.

Referenced by CommandOutputDialog::on_processKill_toggled().

210 {
211  if (m_currentProcess)
212  {
213  qDebug("Command::kill: %lld", m_currentProcessPid);
214  m_currentProcess->kill();
215  }
216 }
QProcess * m_currentProcess
Definition: command.h:103
qint64 m_currentProcessPid
Definition: command.h:114
+ Here is the caller graph for this function:

◆ processError

void Command::processError ( QProcess::ProcessError  error)
privateslot

Definition at line 258 of file command.cpp.

References m_currentProcess, m_currentProcessError, m_currentProcessFinishTimeStampms, m_currentProcessState, m_isInError, m_log, TimeUtil::nowms(), processFinished(), and processStateChanged().

Referenced by processFinished(), run(), and ~Command().

259 {
260  //qDebug("Command::processError: %d state: %d", error, m_currentProcessState);
262  m_currentProcessError = error;
263  m_isInError = true;
264 
265  if (m_currentProcessState == QProcess::NotRunning)
266  {
267  m_log = m_currentProcess->readAllStandardOutput();
268 
269 #if QT_VERSION < 0x051000
270  disconnect(m_currentProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
271 #else
272  disconnect(m_currentProcess, SIGNAL(errorOccurred(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
273 #endif
274  disconnect(m_currentProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(processFinished(int, QProcess::ExitStatus)));
275  disconnect(m_currentProcess, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(processStateChanged(QProcess::ProcessState)));
276 
277  m_currentProcess->deleteLater(); // make sure other threads can still access it until all events have been processed
278  m_currentProcess = nullptr; // for this thread it can assume it was deleted
279  }
280 }
void processFinished(int exitCode, QProcess::ExitStatus exitStatus)
Definition: command.cpp:282
void processError(QProcess::ProcessError error)
Definition: command.cpp:258
QProcess * m_currentProcess
Definition: command.h:103
uint64_t m_currentProcessFinishTimeStampms
Definition: command.h:112
void processStateChanged(QProcess::ProcessState newState)
Definition: command.cpp:248
bool m_isInError
Definition: command.h:105
QProcess::ProcessState m_currentProcessState
Definition: command.h:104
QProcess::ProcessError m_currentProcessError
Definition: command.h:106
static uint64_t nowms()
returns the current epoch in milliseconds
Definition: timeutil.cpp:20
QString m_log
Definition: command.h:110
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processFinished

void Command::processFinished ( int  exitCode,
QProcess::ExitStatus  exitStatus 
)
privateslot

Definition at line 282 of file command.cpp.

References m_currentProcess, m_currentProcessExitCode, m_currentProcessExitStatus, m_currentProcessFinishTimeStampms, m_hasExited, m_log, TimeUtil::nowms(), processError(), and processStateChanged().

Referenced by processError(), run(), and ~Command().

283 {
284  //qDebug("Command::processFinished: (%d) %d", exitCode, exitStatus);
286  m_currentProcessExitCode = exitCode;
287  m_currentProcessExitStatus = exitStatus;
288  m_hasExited = true;
289  m_log = m_currentProcess->readAllStandardOutput();
290 
291 #if QT_VERSION < 0x051000
292  disconnect(m_currentProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
293 #else
294  disconnect(m_currentProcess, SIGNAL(errorOccurred(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
295 #endif
296  disconnect(m_currentProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(processFinished(int, QProcess::ExitStatus)));
297  disconnect(m_currentProcess, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(processStateChanged(QProcess::ProcessState)));
298 
299  m_currentProcess->deleteLater(); // make sure other threads can still access it until all events have been processed
300  m_currentProcess = nullptr; // for this thread it can assume it was deleted
301 }
QProcess::ExitStatus m_currentProcessExitStatus
Definition: command.h:109
void processFinished(int exitCode, QProcess::ExitStatus exitStatus)
Definition: command.cpp:282
void processError(QProcess::ProcessError error)
Definition: command.cpp:258
QProcess * m_currentProcess
Definition: command.h:103
uint64_t m_currentProcessFinishTimeStampms
Definition: command.h:112
void processStateChanged(QProcess::ProcessState newState)
Definition: command.cpp:248
bool m_hasExited
Definition: command.h:107
static uint64_t nowms()
returns the current epoch in milliseconds
Definition: timeutil.cpp:20
QString m_log
Definition: command.h:110
int m_currentProcessExitCode
Definition: command.h:108
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processStateChanged

void Command::processStateChanged ( QProcess::ProcessState  newState)
privateslot

Definition at line 248 of file command.cpp.

References m_currentProcess, m_currentProcessPid, and m_currentProcessState.

Referenced by processError(), processFinished(), run(), and ~Command().

249 {
250  //qDebug("Command::processStateChanged: %d", newState);
251  if (newState == QProcess::Running) {
252  m_currentProcessPid = m_currentProcess->processId();
253  }
254 
255  m_currentProcessState = newState;
256 }
QProcess * m_currentProcess
Definition: command.h:103
qint64 m_currentProcessPid
Definition: command.h:114
QProcess::ProcessState m_currentProcessState
Definition: command.h:104
+ Here is the caller graph for this function:

◆ resetToDefaults()

void Command::resetToDefaults ( )

Definition at line 81 of file command.cpp.

References m_argString, m_associateKey, m_command, m_description, m_group, m_key, m_keyModifiers, and m_release.

Referenced by Command(), and deserialize().

82 {
83  m_group = "default";
84  m_description = "no name";
85  m_command = "";
86  m_argString = "";
87  m_key = static_cast<Qt::Key>(0);
88  m_keyModifiers = Qt::NoModifier;
89  m_associateKey = false;
90  m_release = false;
91 }
QString m_group
Definition: command.h:95
QString m_description
Definition: command.h:96
QString m_argString
Definition: command.h:98
Qt::Key m_key
Definition: command.h:99
bool m_release
Definition: command.h:102
QString m_command
Definition: command.h:97
Qt::KeyboardModifiers m_keyModifiers
Definition: command.h:100
bool m_associateKey
Definition: command.h:101
+ Here is the caller graph for this function:

◆ run()

void Command::run ( const QString &  apiAddress,
int  apiPort,
int  deviceSetIndex 
)

Definition at line 162 of file command.cpp.

References m_argString, m_command, m_currentProcess, m_currentProcessCommandLine, m_currentProcessStartTimeStampms, m_hasExited, m_isInError, TimeUtil::nowms(), processError(), processFinished(), and processStateChanged().

Referenced by MainWindow::commandKeyPressed(), and MainWindow::on_commandRun_clicked().

163 {
164  if (m_currentProcess)
165  {
166  qWarning("Command::run: process already running");
167  return;
168  }
169 
170  QString args = m_argString;
171 
172  if (m_argString.contains("%1"))
173  {
174  args = args.arg(apiAddress);
175  }
176 
177  if (m_argString.contains("%2"))
178  {
179  args.replace("%2", "%1");
180  args = args.arg(apiPort);
181  }
182 
183  if (m_argString.contains("%3"))
184  {
185  args.replace("%3", "%1");
186  args = args.arg(deviceSetIndex);
187  }
188 
189  m_currentProcessCommandLine = QString("%1 %2").arg(m_command).arg(args);
190  qDebug("Command::run: %s", qPrintable(m_currentProcessCommandLine));
191 
192  m_currentProcess = new QProcess(this);
193  m_isInError = false;
194  m_hasExited = false;
195 
196 #if QT_VERSION < 0x051000
197  connect(m_currentProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
198 #else
199  connect(m_currentProcess, SIGNAL(errorOccurred(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
200 #endif
201  connect(m_currentProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(processFinished(int, QProcess::ExitStatus)));
202  connect(m_currentProcess, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(processStateChanged(QProcess::ProcessState)));
203 
204  m_currentProcess->setProcessChannelMode(QProcess::MergedChannels);
207 }
void processFinished(int exitCode, QProcess::ExitStatus exitStatus)
Definition: command.cpp:282
QString m_argString
Definition: command.h:98
void processError(QProcess::ProcessError error)
Definition: command.cpp:258
QProcess * m_currentProcess
Definition: command.h:103
QString m_currentProcessCommandLine
Definition: command.h:113
void processStateChanged(QProcess::ProcessState newState)
Definition: command.cpp:248
bool m_isInError
Definition: command.h:105
bool m_hasExited
Definition: command.h:107
QString m_command
Definition: command.h:97
uint64_t m_currentProcessStartTimeStampms
Definition: command.h:111
static uint64_t nowms()
returns the current epoch in milliseconds
Definition: timeutil.cpp:20
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

QByteArray Command::serialize ( ) const

Definition at line 93 of file command.cpp.

References SimpleSerializer::final(), m_argString, m_associateKey, m_command, m_description, m_group, m_key, m_keyModifiers, m_release, SimpleSerializer::writeBool(), SimpleSerializer::writeS32(), and SimpleSerializer::writeString().

94 {
95  SimpleSerializer s(1);
96 
97  s.writeString(1, m_group);
98  s.writeString(2, m_description);
99  s.writeString(3, m_command);
100  s.writeString(4, m_argString);
101  s.writeS32(5, (int) m_key);
102  s.writeS32(6, (int) m_keyModifiers);
103  s.writeBool(7, m_associateKey);
104  s.writeBool(8, m_release);
105 
106  return s.final();
107 }
QString m_group
Definition: command.h:95
QString m_description
Definition: command.h:96
QString m_argString
Definition: command.h:98
Qt::Key m_key
Definition: command.h:99
bool m_release
Definition: command.h:102
QString m_command
Definition: command.h:97
Qt::KeyboardModifiers m_keyModifiers
Definition: command.h:100
bool m_associateKey
Definition: command.h:101
+ Here is the call graph for this function:

◆ setArgString()

void Command::setArgString ( const QString &  argString)
inline

Definition at line 45 of file command.h.

Referenced by EditCommandDialog::toCommand().

45 { m_argString = argString; }
QString m_argString
Definition: command.h:98
+ Here is the caller graph for this function:

◆ setAssociateKey()

void Command::setAssociateKey ( bool  associate)
inline

Definition at line 55 of file command.h.

Referenced by EditCommandDialog::toCommand().

55 { m_associateKey = associate; }
bool m_associateKey
Definition: command.h:101
+ Here is the caller graph for this function:

◆ setCommand()

void Command::setCommand ( const QString &  command)
inline

Definition at line 43 of file command.h.

Referenced by EditCommandDialog::toCommand().

43 { m_command = command; }
QString m_command
Definition: command.h:97
+ Here is the caller graph for this function:

◆ setDescription()

void Command::setDescription ( const QString &  description)
inline

Definition at line 49 of file command.h.

Referenced by MainWindow::on_commandNew_clicked(), and EditCommandDialog::toCommand().

49 { m_description = description; }
QString m_description
Definition: command.h:96
+ Here is the caller graph for this function:

◆ setGroup()

void Command::setGroup ( const QString &  group)
inline

Definition at line 47 of file command.h.

Referenced by MainWindow::on_commandNew_clicked(), MainSettings::renameCommandGroup(), and EditCommandDialog::toCommand().

47 { m_group = group; }
QString m_group
Definition: command.h:95
+ Here is the caller graph for this function:

◆ setKey()

void Command::setKey ( Qt::Key  key)
inline

Definition at line 51 of file command.h.

Referenced by EditCommandDialog::toCommand().

51 { m_key = key; }
Qt::Key m_key
Definition: command.h:99
+ Here is the caller graph for this function:

◆ setKeyModifiers()

void Command::setKeyModifiers ( Qt::KeyboardModifiers  keyModifiers)
inline

Definition at line 53 of file command.h.

Referenced by EditCommandDialog::toCommand().

53 { m_keyModifiers = keyModifiers; }
Qt::KeyboardModifiers m_keyModifiers
Definition: command.h:100
+ Here is the caller graph for this function:

◆ setRelease()

void Command::setRelease ( bool  release)
inline

Definition at line 57 of file command.h.

Referenced by EditCommandDialog::toCommand().

57 { m_release = release; }
bool m_release
Definition: command.h:102
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_argString

QString Command::m_argString
private

Definition at line 98 of file command.h.

Referenced by deserialize(), resetToDefaults(), run(), and serialize().

◆ m_associateKey

bool Command::m_associateKey
private

Definition at line 101 of file command.h.

Referenced by deserialize(), resetToDefaults(), and serialize().

◆ m_command

QString Command::m_command
private

Definition at line 97 of file command.h.

Referenced by deserialize(), resetToDefaults(), run(), and serialize().

◆ m_currentProcess

QProcess* Command::m_currentProcess
private

Definition at line 103 of file command.h.

Referenced by kill(), processError(), processFinished(), processStateChanged(), run(), and ~Command().

◆ m_currentProcessCommandLine

QString Command::m_currentProcessCommandLine
private

Definition at line 113 of file command.h.

Referenced by run().

◆ m_currentProcessError

QProcess::ProcessError Command::m_currentProcessError
private

Definition at line 106 of file command.h.

Referenced by getLastProcessError(), and processError().

◆ m_currentProcessExitCode

int Command::m_currentProcessExitCode
private

Definition at line 108 of file command.h.

Referenced by getLastProcessExit(), and processFinished().

◆ m_currentProcessExitStatus

QProcess::ExitStatus Command::m_currentProcessExitStatus
private

Definition at line 109 of file command.h.

Referenced by getLastProcessExit(), and processFinished().

◆ m_currentProcessFinishTimeStampms

uint64_t Command::m_currentProcessFinishTimeStampms
private

Definition at line 112 of file command.h.

Referenced by Command(), processError(), and processFinished().

◆ m_currentProcessPid

qint64 Command::m_currentProcessPid
private

Definition at line 114 of file command.h.

Referenced by kill(), and processStateChanged().

◆ m_currentProcessStartTimeStampms

uint64_t Command::m_currentProcessStartTimeStampms
private

Definition at line 111 of file command.h.

Referenced by Command(), and run().

◆ m_currentProcessState

QProcess::ProcessState Command::m_currentProcessState
private

Definition at line 104 of file command.h.

Referenced by getLastProcessState(), processError(), and processStateChanged().

◆ m_description

QString Command::m_description
private

Definition at line 96 of file command.h.

Referenced by commandCompare(), deserialize(), resetToDefaults(), and serialize().

◆ m_group

QString Command::m_group
private

Definition at line 95 of file command.h.

Referenced by commandCompare(), deserialize(), resetToDefaults(), and serialize().

◆ m_hasExited

bool Command::m_hasExited
private

Definition at line 107 of file command.h.

Referenced by getLastProcessExit(), processFinished(), and run().

◆ m_isInError

bool Command::m_isInError
private

Definition at line 105 of file command.h.

Referenced by getLastProcessError(), processError(), and run().

◆ m_key

Qt::Key Command::m_key
private

Definition at line 99 of file command.h.

Referenced by commandCompare(), deserialize(), getKeyLabel(), resetToDefaults(), and serialize().

◆ m_keyModifiers

Qt::KeyboardModifiers Command::m_keyModifiers
private

Definition at line 100 of file command.h.

Referenced by deserialize(), getKeyLabel(), resetToDefaults(), and serialize().

◆ m_log

QString Command::m_log
private

Definition at line 110 of file command.h.

Referenced by getLastProcessLog(), processError(), and processFinished().

◆ m_release

bool Command::m_release
private

Definition at line 102 of file command.h.

Referenced by commandCompare(), deserialize(), resetToDefaults(), and serialize().


The documentation for this class was generated from the following files: