diff options
| author | 2024-08-02 14:17:53 +0200 | |
|---|---|---|
| committer | 2024-08-02 14:17:53 +0200 | |
| commit | 1a1db4926d490f81f79ae42b6cf4b850afbaf7df (patch) | |
| tree | 517df2ef6e641aa15197dca596e9d04afbe033a9 /src/modules/options/OptionsWidget_sound.cpp | |
| parent | Add support for "Monospace" control code (ASCII 0x11). By now just ignore it.... (diff) | |
| download | KVIrc-1a1db4926d490f81f79ae42b6cf4b850afbaf7df.tar.gz KVIrc-1a1db4926d490f81f79ae42b6cf4b850afbaf7df.tar.bz2 KVIrc-1a1db4926d490f81f79ae42b6cf4b850afbaf7df.zip | |
Misc fixes to sound module related to autodetect (#2669)
* Sound options: don't immediately save changes when sound system gets autodetected; fix #2667
* If the config-saved sound system is not available anymore, force an autodetect; fix #2668
* Fix "qt" sound system under qt6 and unify the code path for Qt5.
* If phonon is available, prefer it over "qt" sound system (the latter can only play wav files)
* Nuke support for aRts (KDE2/3 sound server) and ESD (Gnome sound server before 2009)
* Sound module: replace SoundEffect with QmediaPlayer to support more file formats. Adjust the priority of "qt" sound system in autodetect
* Convert to smart pointers
* Sound options: force an autodetect if the current sound system is not valid
Diffstat (limited to 'src/modules/options/OptionsWidget_sound.cpp')
| -rw-r--r-- | src/modules/options/OptionsWidget_sound.cpp | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/src/modules/options/OptionsWidget_sound.cpp b/src/modules/options/OptionsWidget_sound.cpp index 4b84b3e41..f7d481f7e 100644 --- a/src/modules/options/OptionsWidget_sound.cpp +++ b/src/modules/options/OptionsWidget_sound.cpp @@ -195,8 +195,15 @@ void OptionsWidget_soundGeneral::soundAutoDetect() g_pApp->setOverrideCursor(Qt::WaitCursor); - m->ctrl("detectSoundSystem", nullptr); soundFillBox(); + QString szSoundSystem; + if(m->ctrl("detectSoundSystem", &szSoundSystem) && !KviQString::equalCI(szSoundSystem, "null")) + { + int idx = m_pSoundSystemBox->findText(szSoundSystem); + if(idx > -1) { + m_pSoundSystemBox->setCurrentIndex(idx); + } + } g_pApp->restoreOverrideCursor(); } @@ -222,30 +229,28 @@ void OptionsWidget_soundGeneral::soundFillBox() KviModule * m = g_pModuleManager->getModule("snd"); if(!m || !m->ctrl("getAvailableSoundSystems", &l)) - goto disable; + { + m_pSoundSystemBox->clear(); + m_pSoundSystemBox->setEnabled(false); + m_pSoundTestButton->setEnabled(false); + m_pSoundAutoDetectButton->setEnabled(false); + return; + } m_pSoundSystemBox->clear(); + m_pSoundSystemBox->addItems(l); - for(const auto& it : l) - m_pSoundSystemBox->addItem(it); - - cnt = m_pSoundSystemBox->count(); - for(i = 0; i < cnt; i++) - { - QString t = m_pSoundSystemBox->itemText(i); - if(KviQString::equalCI(t, KVI_OPTION_STRING(KviOption_stringSoundSystem))) - { - m_pSoundSystemBox->setCurrentIndex(i); - break; - } + int idx = m_pSoundSystemBox->findText(KVI_OPTION_STRING(KviOption_stringSoundSystem)); + if(idx == -1) { + // the previously used sound system doesn't exist anymore, force an autodetect + g_pApp->setOverrideCursor(Qt::WaitCursor); + QString szSoundSystem; + m->ctrl("detectSoundSystem", &szSoundSystem); + g_pApp->restoreOverrideCursor(); + idx = m_pSoundSystemBox->findText(szSoundSystem); } - return; -disable: - m_pSoundSystemBox->clear(); - m_pSoundSystemBox->setEnabled(false); - m_pSoundTestButton->setEnabled(false); - m_pSoundAutoDetectButton->setEnabled(false); + m_pSoundSystemBox->setCurrentIndex(idx); } void OptionsWidget_soundGeneral::mediaFillBox() |
