From ab214cfb05d5c4fa83046aa4ae1867aa6f088998 Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Sun, 3 Nov 2024 14:16:46 +0800 Subject: [PATCH] 1 --- src/article_maker.cc | 9 +++++++-- src/common/globalbroadcaster.hh | 2 +- src/dict/dictionary.hh | 3 ++- src/dict/website.cc | 2 +- src/ui/mainwindow.cc | 1 + 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/article_maker.cc b/src/article_maker.cc index debd7c8e..56b07772 100644 --- a/src/article_maker.cc +++ b/src/article_maker.cc @@ -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; } } diff --git a/src/common/globalbroadcaster.hh b/src/common/globalbroadcaster.hh index ff8ef705..36c262b6 100644 --- a/src/common/globalbroadcaster.hh +++ b/src/common/globalbroadcaster.hh @@ -47,7 +47,7 @@ signals: void indexingDictionary( QString ); - void websiteDictionary( QString ); + void websiteDictionary( QString, QString ); }; #endif // GLOBAL_GLOBALBROADCASTER_H diff --git a/src/dict/dictionary.hh b/src/dict/dictionary.hh index abc52f36..3fe9a7c7 100644 --- a/src/dict/dictionary.hh +++ b/src/dict/dictionary.hh @@ -35,7 +35,8 @@ enum Property { Author, Copyright, Description, - Email + Email, + Url, }; DEF_EX( Ex, "Dictionary error", std::exception ) diff --git a/src/dict/website.cc b/src/dict/website.cc index ddb3433b..186ed342 100644 --- a/src/dict/website.cc +++ b/src/dict/website.cc @@ -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; } diff --git a/src/ui/mainwindow.cc b/src/ui/mainwindow.cc index 229f9eaf..a279e0ed 100644 --- a/src/ui/mainwindow.cc +++ b/src/ui/mainwindow.cc @@ -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 ) );