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 | Private Slots | Private Member Functions | Private Attributes | List of all members
CommandOutputDialog Class Reference

#include <commandoutputdialog.h>

Inherits QDialog.

+ Collaboration diagram for CommandOutputDialog:

Public Member Functions

 CommandOutputDialog (Command &command, QWidget *parent=0)
 
 ~CommandOutputDialog ()
 
void fromCommand (const Command &command)
 

Private Slots

void on_processRefresh_toggled (bool checked)
 
void on_processKill_toggled (bool checked)
 

Private Member Functions

void refresh ()
 
void setErrorText (const QProcess::ProcessError &processError)
 
void setExitText (const QProcess::ExitStatus &processExit)
 

Private Attributes

Ui::CommandOutputDialog * ui
 
Commandm_command
 

Detailed Description

Definition at line 32 of file commandoutputdialog.h.

Constructor & Destructor Documentation

◆ CommandOutputDialog()

CommandOutputDialog::CommandOutputDialog ( Command command,
QWidget *  parent = 0 
)
explicit

Definition at line 24 of file commandoutputdialog.cpp.

References refresh(), and ui.

24  :
25  QDialog(parent),
26  ui(new Ui::CommandOutputDialog),
27  m_command(command)
28 {
29  ui->setupUi(this);
30  refresh();
31 }
Ui::CommandOutputDialog * ui
+ Here is the call graph for this function:

◆ ~CommandOutputDialog()

CommandOutputDialog::~CommandOutputDialog ( )

Definition at line 33 of file commandoutputdialog.cpp.

References ui.

34 {
35  delete ui;
36 }
Ui::CommandOutputDialog * ui

Member Function Documentation

◆ fromCommand()

void CommandOutputDialog::fromCommand ( const Command command)

◆ on_processKill_toggled

void CommandOutputDialog::on_processKill_toggled ( bool  checked)
privateslot

Definition at line 160 of file commandoutputdialog.cpp.

References Command::kill(), m_command, and ui.

161 {
162  if (checked)
163  {
164  m_command.kill();
165  ui->processKill->setChecked(false);
166  }
167 }
void kill()
Definition: command.cpp:209
Ui::CommandOutputDialog * ui
+ Here is the call graph for this function:

◆ on_processRefresh_toggled

void CommandOutputDialog::on_processRefresh_toggled ( bool  checked)
privateslot

Definition at line 151 of file commandoutputdialog.cpp.

References refresh(), and ui.

152 {
153  if (checked)
154  {
155  refresh();
156  ui->processRefresh->setChecked(false);
157  }
158 }
Ui::CommandOutputDialog * ui
+ Here is the call graph for this function:

◆ refresh()

void CommandOutputDialog::refresh ( )
private

Definition at line 38 of file commandoutputdialog.cpp.

References arg(), Command::getLastProcessCommandLine(), Command::getLastProcessError(), Command::getLastProcessExit(), Command::getLastProcessFinishTimestampms(), Command::getLastProcessLog(), Command::getLastProcessPid(), Command::getLastProcessStartTimestampms(), Command::getLastProcessState(), m_command, setErrorText(), setExitText(), and ui.

Referenced by CommandOutputDialog(), and on_processRefresh_toggled().

39 {
40  ui->commandText->setText(m_command.getLastProcessCommandLine());
41  ui->processPid->setText(QString("%1").arg(m_command.getLastProcessPid()));
42 
44  ui->startTime->setText(("..."));
45  }
46  else
47  {
48  QDateTime dt = QDateTime::fromMSecsSinceEpoch(m_command.getLastProcessStartTimestampms());
49  QString dateStr = dt.toString("yyyy-MM-dd HH:mm:ss.zzz");
50  ui->startTime->setText(dateStr);
51  }
52 
54  ui->endTime->setText(("..."));
55  }
56  else
57  {
58  QDateTime dt = QDateTime::fromMSecsSinceEpoch(m_command.getLastProcessFinishTimestampms());
59  QString dateStr = dt.toString("yyyy-MM-dd HH:mm:ss.zzz");
60  ui->endTime->setText(dateStr);
61  }
62 
63  ui->runningState->setChecked(m_command.getLastProcessState() == QProcess::Running);
64  QProcess::ProcessError processError;
65 
66  if (m_command.getLastProcessStartTimestampms() == 0) // not started
67  {
68  ui->errorText->setText("...");
69  ui->exitCode->setText("-");
70  ui->exitText->setText("...");
71  ui->runningState->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
72  }
73  else if (m_command.getLastProcessState() != QProcess::NotRunning) // running
74  {
75  ui->errorText->setText("...");
76  ui->runningState->setStyleSheet("QToolButton { background-color : orange; }");
77  }
78  else // finished
79  {
80  if (m_command.getLastProcessError(processError)) // finished
81  {
82  ui->runningState->setStyleSheet("QToolButton { background-color : red; }");
83  setErrorText(processError);
84  }
85  else
86  {
87  ui->runningState->setStyleSheet("QToolButton { background-color : green; }");
88  ui->errorText->setText("No error");
89  }
90 
91  int processExitCode;
92  QProcess::ExitStatus processExitStatus;
93 
94  if (m_command.getLastProcessExit(processExitCode, processExitStatus))
95  {
96  ui->exitCode->setText(QString("%1").arg(processExitCode));
97  setExitText(processExitStatus);
98  }
99  else
100  {
101  ui->exitCode->setText("-");
102  ui->exitText->setText("...");
103  }
104  }
105 
106  ui->logEdit->setPlainText(m_command.getLastProcessLog());
107 }
void setErrorText(const QProcess::ProcessError &processError)
QProcess::ProcessState getLastProcessState() const
Definition: command.cpp:218
uint64_t getLastProcessFinishTimestampms() const
Definition: command.h:68
const QString & getLastProcessCommandLine() const
Definition: command.h:69
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
qint64 getLastProcessPid() const
Definition: command.h:70
uint64_t getLastProcessStartTimestampms() const
Definition: command.h:67
const QString & getLastProcessLog() const
Definition: command.cpp:243
void setExitText(const QProcess::ExitStatus &processExit)
Ui::CommandOutputDialog * ui
bool getLastProcessError(QProcess::ProcessError &error) const
Definition: command.cpp:223
bool getLastProcessExit(int &exitCode, QProcess::ExitStatus &exitStatus) const
Definition: command.cpp:232
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setErrorText()

void CommandOutputDialog::setErrorText ( const QProcess::ProcessError &  processError)
private

Definition at line 109 of file commandoutputdialog.cpp.

References ui.

Referenced by refresh().

110 {
111  switch(processError)
112  {
113  case QProcess::FailedToStart:
114  ui->errorText->setText("Failed to start");
115  break;
116  case QProcess::Crashed:
117  ui->errorText->setText("Crashed");
118  break;
119  case QProcess::Timedout:
120  ui->errorText->setText("Timed out");
121  break;
122  case QProcess::WriteError:
123  ui->errorText->setText("Write error");
124  break;
125  case QProcess::ReadError:
126  ui->errorText->setText("Read error");
127  break;
128  case QProcess::UnknownError:
129  default:
130  ui->errorText->setText("Unknown error");
131  break;
132  }
133 }
Ui::CommandOutputDialog * ui
+ Here is the caller graph for this function:

◆ setExitText()

void CommandOutputDialog::setExitText ( const QProcess::ExitStatus &  processExit)
private

Definition at line 135 of file commandoutputdialog.cpp.

References ui.

Referenced by refresh().

136 {
137  switch(processExit)
138  {
139  case QProcess::NormalExit:
140  ui->exitText->setText("Normal exit");
141  break;
142  case QProcess::CrashExit:
143  ui->exitText->setText("Program crashed");
144  break;
145  default:
146  ui->exitText->setText("Unknown state");
147  break;
148  }
149 }
Ui::CommandOutputDialog * ui
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_command

Command& CommandOutputDialog::m_command
private

Definition at line 43 of file commandoutputdialog.h.

Referenced by on_processKill_toggled(), and refresh().

◆ ui

Ui::CommandOutputDialog* CommandOutputDialog::ui
private

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