This commit is contained in:
YiFang Xiao 2024-11-03 15:19:32 +08:00
parent ab214cfb05
commit e07e730a09
3 changed files with 14 additions and 7 deletions

View file

@ -516,13 +516,15 @@ void ArticleRequest::altSearchFinished()
// if the dictionary is website dictionary and openinNewTab is enabled, emit a signal.
if ( GlobalBroadcaster::instance()->getPreference()->openWebsiteInNewTab ) {
if ( ( activeDict->getFeatures() | Dictionary::WebSite ) == Dictionary::WebSite ) {
//todo ,replace the word with actual url
//replace the word,and get the actual requested url
string url = activeDict->getProperties()[ Dictionary::Property::Url ];
if ( url.empty() ) {
continue;
}
QString requestUrl = Utils::WebSite::urlReplaceWord( QString::fromStdString( url ), word );
emit GlobalBroadcaster::instance()
-> websiteDictionary( QString::fromStdString( activeDict->getName() ), QString::fromStdString( url ) );
-> websiteDictionary( QString::fromStdString( activeDict->getName() ), requestUrl );
continue;
}
}

View file

@ -316,7 +316,7 @@ void WebSiteArticleRequest::requestFinished( QNetworkReply * r )
sptr< DataRequest > WebSiteDictionary::getArticle( wstring const & str,
vector< wstring > const & /*alts*/,
wstring const & context,
wstring const & /*context*/,
bool /*ignoreDiacritics*/ )
{
QString urlString = Utils::WebSite::urlReplaceWord( QString( urlTemplate ), QString::fromStdU32String( str ) );
@ -330,14 +330,14 @@ sptr< DataRequest > WebSiteDictionary::getArticle( wstring const & str,
QUrl url( urlString );
GlobalBroadcaster::instance()->addWhitelist( url.host() );
QString encodeUrl = encodeUrl = urlString;
const QString & encodeUrl = urlString;
if ( GlobalBroadcaster::instance()->getPreference()->openWebSiteInNewTab ) {
if ( GlobalBroadcaster::instance()->getPreference()->openWebsiteInNewTab ) {
result += string( "<div><span>this website dictionary is opened in the new tab</span></div>" );
}
else {
fmt::format_to( std::back_inserter( result ),
R"(<iframe id="gdexpandframe-{}" src="{}"
R"(<iframe id="gdexpandframe-{}" src="{}"
onmouseover="processIframeMouseOver('gdexpandframe-{}');"
onmouseout="processIframeMouseOut();" scrolling="no"
style="overflow:visible; width:100%; display:block; border:none;"

View file

@ -2182,7 +2182,12 @@ void MainWindow::updateBackForwardButtons()
void MainWindow::updatePronounceAvailability()
{
if ( ui.tabWidget->count() > 0 ) {
getCurrentArticleView()->hasSound( [ this ]( bool has ) {
ArticleView * pView = getCurrentArticleView();
if ( pView == nullptr ) {
return;
}
pView->hasSound( [ this ]( bool has ) {
navPronounce->setEnabled( has );
} );
}