This commit is contained in:
xiaoyifang 2024-11-02 11:50:29 +08:00 committed by YiFang Xiao
parent 9e99389cc3
commit 0d89c4ab56
4 changed files with 27 additions and 0 deletions

View file

@ -513,6 +513,15 @@ void ArticleRequest::altSearchFinished()
for ( const auto & activeDict : activeDicts ) { for ( const auto & activeDict : activeDicts ) {
try { try {
// if the dictionary is website dictionary and openinNewTab is enabled, emit a signal.
if ( GlobalBroadcaster::instance()->getPreference()->openWebsiteInNewTab ) {
if ( activeDict->getFeature() == Dictionary::WebSite ) {
//todo ,replace the word with actual url
emit GlobalBroadcaster::instance() -> websiteDictionary( word,url );
continue;
}
}
sptr< Dictionary::DataRequest > r = activeDict->getArticle( sptr< Dictionary::DataRequest > r = activeDict->getArticle(
wordStd, wordStd,
altsVector, altsVector,

View file

@ -46,6 +46,8 @@ signals:
void dictionaryClear( ActiveDictIds ad ); void dictionaryClear( ActiveDictIds ad );
void indexingDictionary( QString ); void indexingDictionary( QString );
void websiteDictionary( QString );
}; };
#endif // GLOBAL_GLOBALBROADCASTER_H #endif // GLOBAL_GLOBALBROADCASTER_H

View file

@ -713,6 +713,10 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
&GlobalBroadcaster::indexingDictionary, &GlobalBroadcaster::indexingDictionary,
this, this,
&MainWindow::showFTSIndexingName ); &MainWindow::showFTSIndexingName );
connect( GlobalBroadcaster::instance(),
&GlobalBroadcaster::websiteDictionary,
this,
&MainWindow::openWebsiteInNewTab );
connect( &GlobalBroadcaster::instance()->pronounce_engine, connect( &GlobalBroadcaster::instance()->pronounce_engine,
&PronounceEngine::emitAudio, &PronounceEngine::emitAudio,
@ -4361,6 +4365,17 @@ void MainWindow::showFTSIndexingName( QString const & name )
} }
} }
void MainWindow::openWebsiteInNewTab( QString const & name,QString const & url )
{
QString escaped = Utils::escapeAmps( name );
auto view = new QWebEngineView(this);
view->load(QUrl(url));
ui.tabWidget->insertTab( index, view, escaped );
mruList.append( dynamic_cast< QWidget * >( view ) );
}
QString MainWindow::unescapeTabHeader( QString const & header ) QString MainWindow::unescapeTabHeader( QString const & header )
{ {
// Reset table header to original headword // Reset table header to original headword

View file

@ -293,6 +293,7 @@ private slots:
void openDictionaryFolder( QString const & id ); void openDictionaryFolder( QString const & id );
void showFTSIndexingName( QString const & name ); void showFTSIndexingName( QString const & name );
void openWebsiteInNewTab( QString const & name,QString const & url );
void handleAddToFavoritesButton(); void handleAddToFavoritesButton();