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

View file

@ -157,6 +157,17 @@ ScanPopup::ScanPopup( QWidget * parent,
connect( &dictionaryBar, &DictionaryBar::showDictionaryInfo, this, &ScanPopup::showDictionaryInfo );
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;
if ( cfg.popupWindowGeometry.size() )
restoreGeometry( cfg.popupWindowGeometry );