diff --git a/tools/chatgui/src/radio_audio_engine.cpp b/tools/chatgui/src/radio_audio_engine.cpp index 125e5098..0a04ad9a 100644 --- a/tools/chatgui/src/radio_audio_engine.cpp +++ b/tools/chatgui/src/radio_audio_engine.cpp @@ -96,8 +96,8 @@ bool RadioAudioEngine::applySettings(const QMap& values) { } next[index] = it.value(); } - if (next == m_settings) return true; - if (!m_configPath.isEmpty()) { + if (next == m_settings && !m_active) return true; + if (next != m_settings && !m_configPath.isEmpty()) { QFile input(m_configPath); if (!input.open(QIODevice::ReadOnly)) { m_settingsError = QStringLiteral("Не удалось прочитать конфигурацию: %1").arg(input.errorString()); @@ -154,7 +154,8 @@ void RadioAudioEngine::postSettings(const std::array& values, bool apply } auto* engine = request->engine; auto snapshot = request->values; - QMetaObject::invokeMethod(engine, [engine, snapshot, success]() { + bool apply = request->apply; + QMetaObject::invokeMethod(engine, [engine, snapshot, success, apply]() { bool changed = engine->m_settings != snapshot; engine->m_settings = snapshot; engine->m_settingsReady = true; @@ -162,7 +163,7 @@ void RadioAudioEngine::postSettings(const std::array& values, bool apply if (!success) engine->m_settingsError = QStringLiteral("Ядро отклонило настройки рации"); DEBUG_INFO(DEBUG_CATEGORY_RADIO, "RadioAudio: settings applied=%d vad=%d threshold=%d hangover=%dms TX_AGC=%d " "TX_gain=%ddB VAD_gain=%ddB", success, snapshot[0], snapshot[1], snapshot[2], snapshot[3], snapshot[4], snapshot[5]); - if (changed && engine->m_active) engine->reconfigureCapture(); + if ((changed || apply) && engine->m_active) engine->reconfigureCapture(); emit engine->stateChanged(); }, Qt::QueuedConnection); request->~SettingsRequest(); @@ -176,6 +177,7 @@ void RadioAudioEngine::reconfigureCapture() { m_capture.close(); m_voice.stopCapture(); radio_audio_capture_stop(); + m_wantStereo = chat_setting_get_int(gui_bridge_get_inst(), "radio_capture_stereo", 0) != 0; updateState(); m_capture.retryNow(); recoverDevices(); diff --git a/tools/chatgui/src/radiopanel.cpp b/tools/chatgui/src/radiopanel.cpp index 870d8ab5..b149bed6 100644 --- a/tools/chatgui/src/radiopanel.cpp +++ b/tools/chatgui/src/radiopanel.cpp @@ -14,6 +14,7 @@ extern "C" { #include #include #include +#include #include RadioPanel::RadioPanel(QWidget* parent) : QWidget(parent) { @@ -30,6 +31,8 @@ RadioPanel::RadioPanel(QWidget* parent) : QWidget(parent) { for (auto* button : {m_input, m_output}) { button->setPopupMode(QToolButton::InstantPopup); button->setMenu(new QMenu(button)); + auto* group = new QActionGroup(button->menu()); + group->setExclusive(true); row->addWidget(button); connect(button->menu(), &QMenu::aboutToShow, this, [this, button]() { populateDevices(button, button == m_input); }); } @@ -95,8 +98,7 @@ void RadioPanel::updateState() { void RadioPanel::populateDevices(QToolButton* button, bool capture) { auto* menu = button->menu(); menu->clear(); - auto* group = new QActionGroup(menu); - group->setExclusive(true); + auto* group = menu->findChild(); QString selected = capture ? SoundManager::instance()->captureDevice() : SoundManager::instance()->playbackDevice(); auto add = [&](const QString& name, const QString& id) { auto* action = menu->addAction(name); diff --git a/tools/chatgui/src/settingsdialog.cpp b/tools/chatgui/src/settingsdialog.cpp index 443eb0f2..51a3e680 100644 --- a/tools/chatgui/src/settingsdialog.cpp +++ b/tools/chatgui/src/settingsdialog.cpp @@ -148,6 +148,7 @@ SettingsDialog::SettingsDialog(const QString& configPath, DbManager* db, UtunNod m_audioDevicePage = new AudioDeviceSettingsPage(db, recorder, m_pages); m_audioDevicePage->setConfigPath(m_configPath); + m_audioDevicePage->loadFromDb(); m_pages->addWidget(m_audioDevicePage); m_radioPage = new RadioSettingsPage(db, m_pages);