This commit is contained in:
YiFang Xiao 2024-11-03 14:16:46 +08:00
parent c00239a1b1
commit ab214cfb05
5 changed files with 12 additions and 5 deletions

View file

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

View file

@ -47,7 +47,7 @@ signals:
void indexingDictionary( QString );
void websiteDictionary( QString );
void websiteDictionary( QString, QString );
};
#endif // GLOBAL_GLOBALBROADCASTER_H

View file

@ -35,7 +35,8 @@ enum Property {
Author,
Copyright,
Description,
Email
Email,
Url,
};
DEF_EX( Ex, "Dictionary error", std::exception )

View file

@ -54,7 +54,7 @@ public:
map< Property, string > getProperties() noexcept override
{
map< Property, string > properties;
properties.insert( { Property::Url, urlTemplate_ } );
properties.insert( { Property::Url, urlTemplate.toStdString() } );
return properties;
}

View file

@ -4371,6 +4371,7 @@ void MainWindow::openWebsiteInNewTab( QString const & name, QString const & url
auto view = new QWebEngineView( this );
view->load( QUrl( url ) );
int index = cfg.preferences.newTabsOpenAfterCurrentOne ? ui.tabWidget->currentIndex() + 1 : ui.tabWidget->count();
ui.tabWidget->insertTab( index, view, escaped );
mruList.append( dynamic_cast< QWidget * >( view ) );