mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
fixes #123 by displaying the Audio test in the GUI
* added methods to get results in context * added signal to indicate audio test completed * updated GUI to display results * changed test run methods to non-const to be consistent with voice lib * Logic in GUI to avoid parallel / interfering tests * Fixed wrong Q_ASSERT message and QTimer::singleShot in voice_vatlib.cpp
This commit is contained in:
@@ -22,7 +22,7 @@ MainWindow::MainWindow(GuiModes::WindowMode windowMode, QWidget *parent) :
|
||||
QMainWindow(parent, windowMode == GuiModes::WindowFrameless ? (Qt::Window | Qt::FramelessWindowHint) : Qt::Tool),
|
||||
ui(new Ui::MainWindow),
|
||||
m_infoWindow(nullptr),
|
||||
m_init(false), m_windowMode(windowMode),
|
||||
m_init(false), m_windowMode(windowMode), m_audioTestRunning(NoAudioTest),
|
||||
// misc
|
||||
m_dBusConnection("dummy"),
|
||||
// table view models
|
||||
|
||||
@@ -95,11 +95,19 @@ protected:
|
||||
MainPageSettings = 7
|
||||
};
|
||||
|
||||
enum AudioTest
|
||||
{
|
||||
NoAudioTest,
|
||||
SquelchTest,
|
||||
MicrophoneTest
|
||||
};
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::MainWindow> ui;
|
||||
CInfoWindow *m_infoWindow;
|
||||
bool m_init;
|
||||
GuiModes::WindowMode m_windowMode;
|
||||
AudioTest m_audioTestRunning;
|
||||
QDBusConnection m_dBusConnection;
|
||||
|
||||
// the table view models
|
||||
|
||||
@@ -1799,7 +1799,7 @@ QStatusBar QLabel {
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tb_Settings">
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tb_SettingsTrafficNetwork">
|
||||
<attribute name="title">
|
||||
@@ -2230,13 +2230,6 @@ QStatusBar QLabel {
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLineEdit" name="le_SettingsAudioTestActionAndResult">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QProgressBar" name="prb_SettingsAudioTestProgress">
|
||||
<property name="value">
|
||||
@@ -2244,6 +2237,19 @@ QStatusBar QLabel {
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QPlainTextEdit" name="pte_SettingsAudioTestActionAndResult">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@@ -200,6 +200,7 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
|
||||
this->connect(this->m_timerContextWatchdog, &QTimer::timeout, this, &MainWindow::timerBasedUpdates);
|
||||
this->connect(this->m_timerCollectedCockpitUpdates, &QTimer::timeout, this, &MainWindow::sendCockpitUpdates);
|
||||
this->connect(this->m_timerAudioTests, &QTimer::timeout, this, &MainWindow::audioTestUpdate);
|
||||
connect = this->connect(this->m_contextVoice, &IContextVoice::audioTestCompleted, this, &MainWindow::audioTestUpdate);
|
||||
|
||||
// start timers, update timers will be started when network is connected
|
||||
this->m_timerContextWatchdog->start(2 * 1000);
|
||||
|
||||
@@ -165,19 +165,24 @@ void MainWindow::startAudioTest()
|
||||
}
|
||||
|
||||
QObject *sender = QObject::sender();
|
||||
this->m_timerAudioTests->start(625); // I let this run for 10*625ms, so there is enough overhead to really complete it
|
||||
this->m_timerAudioTests->start(600); // I let this run for <x>ms, so there is enough overhead to really complete it
|
||||
this->ui->prb_SettingsAudioTestProgress->setValue(0);
|
||||
this->ui->pte_SettingsAudioTestActionAndResult->clear();
|
||||
if (sender == this->ui->pb_SettingsAudioMicrophoneTest)
|
||||
{
|
||||
this->m_audioTestRunning = MicrophoneTest;
|
||||
this->m_contextVoice->runMicrophoneTest();
|
||||
this->ui->le_SettingsAudioTestActionAndResult->setText("Speak normally for 5 seconds");
|
||||
this->ui->pte_SettingsAudioTestActionAndResult->appendPlainText("Speak normally for 5 seconds");
|
||||
}
|
||||
else if (sender == this->ui->pb_SettingsAudioSquelchTest)
|
||||
{
|
||||
this->m_audioTestRunning = SquelchTest;
|
||||
this->m_contextVoice->runSquelchTest();
|
||||
this->ui->le_SettingsAudioTestActionAndResult->setText("Silence for 5 seconds");
|
||||
this->ui->pte_SettingsAudioTestActionAndResult->appendPlainText("Silence for 5 seconds");
|
||||
}
|
||||
this->ui->prb_SettingsAudioTestProgress->setVisible(true);
|
||||
this->ui->pb_SettingsAudioMicrophoneTest->setEnabled(false);
|
||||
this->ui->pb_SettingsAudioSquelchTest->setEnabled(false);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -186,15 +191,39 @@ void MainWindow::startAudioTest()
|
||||
void MainWindow::audioTestUpdate()
|
||||
{
|
||||
int v = this->ui->prb_SettingsAudioTestProgress->value();
|
||||
if (v < 100)
|
||||
QObject *sender = this->sender();
|
||||
|
||||
if (v < 100 && (sender == m_timerAudioTests))
|
||||
{
|
||||
// timer update, increasing progress
|
||||
this->ui->prb_SettingsAudioTestProgress->setValue(v + 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
// fetch results
|
||||
// TODO
|
||||
this->m_timerAudioTests->stop();
|
||||
this->ui->prb_SettingsAudioTestProgress->setValue(100);
|
||||
if (sender == m_timerAudioTests) return; // just timer update
|
||||
|
||||
// getting here we assume the audio test finished signal
|
||||
// fetch results
|
||||
this->ui->pte_SettingsAudioTestActionAndResult->clear();
|
||||
if (this->m_contextVoiceAvailable)
|
||||
{
|
||||
if (this->m_audioTestRunning == SquelchTest)
|
||||
{
|
||||
double s = this->m_contextVoice->getSquelchValue();
|
||||
this->ui->pte_SettingsAudioTestActionAndResult->appendPlainText(QString::number(s));
|
||||
}
|
||||
else if (this->m_audioTestRunning == MicrophoneTest)
|
||||
{
|
||||
QString m = this->m_contextVoice->getMicrophoneTestResult();
|
||||
this->ui->pte_SettingsAudioTestActionAndResult->appendPlainText(m);
|
||||
}
|
||||
}
|
||||
this->m_audioTestRunning = NoAudioTest;
|
||||
this->m_timerAudioTests->stop();
|
||||
this->ui->pb_SettingsAudioMicrophoneTest->setEnabled(true);
|
||||
this->ui->pb_SettingsAudioSquelchTest->setEnabled(true);
|
||||
this->ui->prb_SettingsAudioTestProgress->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user