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
|
#include "mainwindow.h"
#include "MessageBox.hpp"
#include <QProcess>
#include <QStringList>
#include <QSplashScreen>
#include <QStatusBar>
#include <QTimer>
void MainWindow::showSoundInError(const QString& errorMsg)
{
if (m_splash && m_splash->isVisible ()) m_splash->hide ();
MessageBox::critical_message (this, tr ("Error in Sound Input"), errorMsg);
}
void MainWindow::showSoundOutError(const QString& errorMsg)
{
noteTxStopReason (TxEvidence::TxStopReason::Error);
if (m_splash && m_splash->isVisible ()) m_splash->hide ();
MessageBox::critical_message (this, tr ("Error in Sound Output"), errorMsg);
}
void MainWindow::showStatusMessage(const QString& statusMsg)
{
statusBar()->showMessage(statusMsg, 5000);
}
bool MainWindow::subProcessFailed (QProcess * process, int exit_code, QProcess::ExitStatus status)
{
if (m_valid && (exit_code || QProcess::NormalExit != status))
{
QStringList arguments;
for (auto argument: process->arguments ())
{
if (argument.contains (' ')) argument = '"' + argument + '"';
arguments << argument;
}
if (m_splash && m_splash->isVisible ()) m_splash->hide ();
MessageBox::critical_message (this, tr ("Subprocess Error")
, tr ("Subprocess failed with exit code %1")
.arg (exit_code)
, tr ("Running: %1\n%2")
.arg (process->program () + ' ' + arguments.join (' '))
.arg (QString {process->readAllStandardError()}));
return true;
}
return false;
}
void MainWindow::subProcessError (QProcess * process, QProcess::ProcessError)
{
if (m_valid)
{
QStringList arguments;
for (auto argument: process->arguments ())
{
if (argument.contains (' ')) argument = '"' + argument + '"';
arguments << argument;
}
if (m_splash && m_splash->isVisible ()) m_splash->hide ();
MessageBox::critical_message (this, tr ("Subprocess error")
, tr ("Running: %1\n%2")
.arg (process->program () + ' ' + arguments.join (' '))
.arg (process->errorString ()));
m_valid = false; // ensures exit if still constructing
QTimer::singleShot (0, this, SLOT (close ()));
}
}
|