fix: auto pronounce audio does not play

This commit is contained in:
YiFang Xiao 2024-06-14 21:38:51 +08:00
parent caf6424ec8
commit 710c07f05f
2 changed files with 16 additions and 11 deletions

View file

@ -705,18 +705,12 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
&PronounceEngine::emitAudio, &PronounceEngine::emitAudio,
this, this,
[ this ]( auto audioUrl ) { [ this ]( auto audioUrl ) {
if ( !isActiveWindow() )
return;
auto view = getCurrentArticleView(); auto view = getCurrentArticleView();
if ( ( cfg.preferences.pronounceOnLoadMain || cfg.preferences.pronounceOnLoadPopup ) && view != nullptr ) { if ( ( cfg.preferences.pronounceOnLoadMain ) && view != nullptr ) {
if ( cfg.preferences.pronounceOnLoadPopup ) {
if ( !scanPopup || !scanPopup->isActiveWindow() ) view->openLink( QUrl::fromEncoded( audioUrl.toUtf8() ), {} );
return;
view->openLink( QUrl::fromEncoded( audioUrl.toUtf8() ), {} );
}
else if ( cfg.preferences.pronounceOnLoadMain ) {
if ( scanPopup && scanPopup->isActiveWindow() )
return;
view->openLink( QUrl::fromEncoded( audioUrl.toUtf8() ), {} );
}
} }
} ); } );
applyProxySettings(); applyProxySettings();

View file

@ -157,6 +157,17 @@ ScanPopup::ScanPopup( QWidget * parent,
connect( &dictionaryBar, &DictionaryBar::showDictionaryInfo, this, &ScanPopup::showDictionaryInfo ); connect( &dictionaryBar, &DictionaryBar::showDictionaryInfo, this, &ScanPopup::showDictionaryInfo );
connect( &dictionaryBar, &DictionaryBar::openDictionaryFolder, this, &ScanPopup::openDictionaryFolder ); connect( &dictionaryBar, &DictionaryBar::openDictionaryFolder, this, &ScanPopup::openDictionaryFolder );
connect( &GlobalBroadcaster::instance()->pronounce_engine,
&PronounceEngine::emitAudio,
this,
[ this ]( auto audioUrl ) {
if ( !isActiveWindow() )
return;
if ( cfg.preferences.pronounceOnLoadPopup ) {
definition->openLink( QUrl::fromEncoded( audioUrl.toUtf8() ), {} );
}
} );
pinnedGeometry = cfg.popupWindowGeometry; pinnedGeometry = cfg.popupWindowGeometry;
if ( cfg.popupWindowGeometry.size() ) if ( cfg.popupWindowGeometry.size() )
restoreGeometry( cfg.popupWindowGeometry ); restoreGeometry( cfg.popupWindowGeometry );