diff --git a/samples/blackgui/mainwindow.cpp b/samples/blackgui/mainwindow.cpp index 97fa70fbb..27a163e99 100644 --- a/samples/blackgui/mainwindow.cpp +++ b/samples/blackgui/mainwindow.cpp @@ -35,7 +35,8 @@ MainWindow::MainWindow(GuiModes::WindowMode windowMode, QWidget *parent) : m_contextApplication(nullptr), m_contextNetwork(nullptr), m_contextVoice(nullptr), m_contextSettings(nullptr), // timers m_timerUpdateAtcStationsOnline(nullptr), m_timerUpdateAircraftsInRange(nullptr), m_timerUpdateUsers(nullptr), - m_timerCollectedCockpitUpdates(nullptr), m_timerContextWatchdog(nullptr), m_timerStatusBar(nullptr), + m_timerCollectedCockpitUpdates(nullptr), m_timerContextWatchdog(nullptr), + m_timerStatusBar(nullptr), m_timerAudioTests(nullptr), // context menus m_contextMenuAudio(nullptr), m_contextMenuStatusMessageList(nullptr), // status bar @@ -190,13 +191,16 @@ void MainWindow::toggleNetworkConnection() this->ui->lbl_StatusNetworkConnectedIcon->setPixmap(this->m_resPixmapConnectionConnecting); if (!this->m_contextNetwork->isConnected()) { - QString cs = this->ui->le_SettingsAircraftCallsign->text(); - if (cs.isEmpty()) + if (this->m_ownAircraft.getCallsign().isEmpty()) { this->displayStatusMessage(CStatusMessage::getValidationError("missing callsign")); return; } + // send latest aircraft to network/voice + this->m_contextNetwork->setOwnAircraft(this->m_ownAircraft); + if (this->m_contextVoiceAvailable) this->m_contextVoice->setOwnAircraft(this->m_ownAircraft); + // Login is based on setting current server INetwork::LoginMode mode = INetwork::LoginNormal; if (this->ui->rb_SettingsLoginStealthMode->isChecked()) @@ -209,6 +213,7 @@ void MainWindow::toggleNetworkConnection() mode = INetwork::LoginAsObserver; this->displayStatusMessage(CStatusMessage::getInfoMessage("login in observer mode")); } + msgs = this->m_contextNetwork->connectToNetwork(static_cast(mode)); } else diff --git a/samples/blackgui/mainwindow.h b/samples/blackgui/mainwindow.h index dec93cd8e..eab3f0fde 100644 --- a/samples/blackgui/mainwindow.h +++ b/samples/blackgui/mainwindow.h @@ -129,7 +129,8 @@ private: QTimer *m_timerUpdateUsers; /*!< timer for update of users */ QTimer *m_timerCollectedCockpitUpdates; /*!< collect cockpit updates over a short period before sending */ QTimer *m_timerContextWatchdog; /*!< core available? */ - QTimer *m_timerStatusBar; + QTimer *m_timerStatusBar; /*!< cleaning up status bar */ + QTimer *m_timerAudioTests; /*!< cleaning up status bar */ // pixmaps QPixmap m_resPixmapConnectionConnected; @@ -300,6 +301,11 @@ private: */ QString getSelcalCode() const; + /*! + * \brief Audio test updates (timer) for progressbar and fetching results + */ + void audioTestUpdate(); + private slots: // @@ -501,6 +507,9 @@ private slots: * \brief Test SELCAL (code valid? play tone) */ void testSelcal(); + + //! \brief start the MIC tests (Squelch) + void startAudioTest(); }; #pragma pop_macro("interface") diff --git a/samples/blackgui/mainwindow.ui b/samples/blackgui/mainwindow.ui index 9a5484a6e..084caea82 100644 --- a/samples/blackgui/mainwindow.ui +++ b/samples/blackgui/mainwindow.ui @@ -38,9 +38,19 @@ QWidget { color: white; /** font **/ } -QStatusBar { - background-color: darkslategray; -} + QProgressBar { + border: 1px solid green; + border-radius: 5px; + text-align: center; + padding: 0px; + height: 16px; + } + + QProgressBar::chunk { + background-color: darkblue; + width: 10px; + margin: 0.5px; + } #wi_CentralWidgetOutside { /** there is no opacity with background image, so we need semitransparent images **/ @@ -443,7 +453,7 @@ QStatusBar QLabel { QFrame::NoFrame - 0 + 7 @@ -553,8 +563,8 @@ QStatusBar QLabel { 0 0 - 326 - 267 + 86 + 59 @@ -1789,7 +1799,7 @@ QStatusBar QLabel { - 0 + 2 @@ -2160,7 +2170,7 @@ QStatusBar QLabel { - + 0 @@ -2178,37 +2188,62 @@ QStatusBar QLabel { 0 - - - - 125 - 16777215 - - - - Start MIC test - - - - - - - - 125 - 16777215 - - - - false - - - Start Squelch test - - + + + + + + 16777215 + 16777215 + + + + false + + + Start squelch test + + + + + + + + 16777215 + 16777215 + + + + Start microphone test + + + + + + + + Result + + + + + + + true + + + + + + + 0 + + + @@ -2852,8 +2887,6 @@ QStatusBar QLabel { le_SettingsIcaoType cb_SettingsAudioInputDevice cb_SettingsAudioOutputDevice - pb_VoiceStartMicTest - pb_VoiceStartSquelchTest hs_SettingsGuiOpacity hs_SettingsGuiAircraftRefreshTime hs_SettingsGuiAtcRefreshTime diff --git a/samples/blackgui/mainwindow_init.cpp b/samples/blackgui/mainwindow_init.cpp index d71282e18..20c1cf5c0 100644 --- a/samples/blackgui/mainwindow_init.cpp +++ b/samples/blackgui/mainwindow_init.cpp @@ -134,12 +134,13 @@ void MainWindow::init(GuiModes::CoreMode coreMode) this->ui->cb_CockpitSelcal1->addItems(BlackMisc::Aviation::CSelcal::codePairs()); this->ui->cb_CockpitSelcal2->addItems(BlackMisc::Aviation::CSelcal::codePairs()); - // timer + // timers if (this->m_timerUpdateAircraftsInRange == nullptr) this->m_timerUpdateAircraftsInRange = new QTimer(this); if (this->m_timerUpdateAtcStationsOnline == nullptr) this->m_timerUpdateAtcStationsOnline = new QTimer(this); if (this->m_timerUpdateUsers == nullptr) this->m_timerUpdateUsers = new QTimer(this); if (this->m_timerContextWatchdog == nullptr) this->m_timerContextWatchdog = new QTimer(this); if (this->m_timerCollectedCockpitUpdates == nullptr) this->m_timerCollectedCockpitUpdates = new QTimer(this); + if (this->m_timerAudioTests == nullptr) this->m_timerAudioTests = new QTimer(this); // context if (this->m_coreMode != GuiModes::CoreInGuiProcess) @@ -184,7 +185,7 @@ void MainWindow::init(GuiModes::CoreMode coreMode) this->ui->sb_MainStatusBar->addWidget(this->m_statusBarLabel, 1); } - // signal / slots + // signal / slots contexts / timers bool connect; this->connect(this->m_contextNetwork, &IContextNetwork::statusMessage, this, &MainWindow::displayStatusMessage); this->connect(this->m_contextNetwork, &IContextNetwork::statusMessages, this, &MainWindow::displayStatusMessages); @@ -198,6 +199,7 @@ void MainWindow::init(GuiModes::CoreMode coreMode) this->connect(this->m_timerUpdateUsers, &QTimer::timeout, this, &MainWindow::timerBasedUpdates); 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); // start timers, update timers will be started when network is connected this->m_timerContextWatchdog->start(2 * 1000); @@ -207,6 +209,7 @@ void MainWindow::init(GuiModes::CoreMode coreMode) // voice panel this->setAudioDeviceLists(); + this->ui->prb_SettingsAudioTestProgress->setVisible(false); // data this->initialDataReads(); @@ -301,6 +304,8 @@ void MainWindow::initGuiSignals() Q_ASSERT(connected); connected = this->connect(this->ui->cb_SettingsAudioOutputDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(audioDeviceSelected(int))); Q_ASSERT(connected); + this->connect(this->ui->pb_SettingsAudioMicrophoneTest, &QPushButton::clicked, this, &MainWindow::startAudioTest); + this->connect(this->ui->pb_SettingsAudioSquelchTest, &QPushButton::clicked, this, &MainWindow::startAudioTest); // ATC connected = this->connect(this->ui->le_AtcStationsOnlineMetar, SIGNAL(returnPressed()), this, SLOT(getMetar())); @@ -370,6 +375,7 @@ void MainWindow::stopUpdateTimers(bool disconnect) this->m_timerUpdateAircraftsInRange->stop(); this->m_timerUpdateAtcStationsOnline->stop(); this->m_timerUpdateUsers->stop(); + this->m_timerAudioTests->stop(); if (!disconnect) return; this->disconnect(this->m_timerUpdateAircraftsInRange); this->disconnect(this->m_timerUpdateAtcStationsOnline); diff --git a/samples/blackgui/mainwindow_voice.cpp b/samples/blackgui/mainwindow_voice.cpp index a27a4f030..af6b45367 100644 --- a/samples/blackgui/mainwindow_voice.cpp +++ b/samples/blackgui/mainwindow_voice.cpp @@ -145,3 +145,56 @@ void MainWindow::audioVolumes() this->m_ownAircraft.setCom2System(com2); this->m_contextVoice->setVolumes(this->m_ownAircraft.getCom1System(), this->m_ownAircraft.getCom2System()); } + +/* + * Start the voice tests + */ +void MainWindow::startAudioTest() +{ + if (!this->m_contextVoiceAvailable) + { + CStatusMessage m(CStatusMessage::TypeAudio, CStatusMessage::SeverityError, "voice context not available"); + this->displayStatusMessage(m); + return; + } + if (this->m_timerAudioTests->isActive()) + { + CStatusMessage m(CStatusMessage::TypeAudio, CStatusMessage::SeverityError, "test running, wait until completed"); + this->displayStatusMessage(m); + return; + } + + 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->ui->prb_SettingsAudioTestProgress->setValue(0); + if (sender == this->ui->pb_SettingsAudioMicrophoneTest) + { + this->m_contextVoice->runMicrophoneTest(); + this->ui->le_SettingsAudioTestActionAndResult->setText("Speak normally for 5 seconds"); + } + else if (sender == this->ui->pb_SettingsAudioSquelchTest) + { + this->m_contextVoice->runSquelchTest(); + this->ui->le_SettingsAudioTestActionAndResult->setText("Silence for 5 seconds"); + } + this->ui->prb_SettingsAudioTestProgress->setVisible(true); +} + +/* + * Start the voice tests + */ +void MainWindow::audioTestUpdate() +{ + int v = this->ui->prb_SettingsAudioTestProgress->value(); + if (v < 100) + { + this->ui->prb_SettingsAudioTestProgress->setValue(v + 10); + } + else + { + // fetch results + // TODO + this->m_timerAudioTests->stop(); + this->ui->prb_SettingsAudioTestProgress->setVisible(false); + } +}