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 ) {
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(
wordStd,
altsVector,

View file

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

View file

@ -713,6 +713,10 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
&GlobalBroadcaster::indexingDictionary,
this,
&MainWindow::showFTSIndexingName );
connect( GlobalBroadcaster::instance(),
&GlobalBroadcaster::websiteDictionary,
this,
&MainWindow::openWebsiteInNewTab );
connect( &GlobalBroadcaster::instance()->pronounce_engine,
&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 )
{
// Reset table header to original headword

View file

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