From 09441a8b727a107778824f9041947eab9f20e790 Mon Sep 17 00:00:00 2001 From: xiaoyifang Date: Sun, 3 Oct 2021 19:28:26 +0800 Subject: [PATCH] found in dictionaries list widgets --- article_netmgr.cc | 8 +++--- articleview.cc | 65 ++++++++++++++++++++++++++++++++++++---------- goldendict.vcxproj | 2 +- 3 files changed, 56 insertions(+), 19 deletions(-) diff --git a/article_netmgr.cc b/article_netmgr.cc index 5bab747d..3236a5ea 100644 --- a/article_netmgr.cc +++ b/article_netmgr.cc @@ -290,12 +290,10 @@ QNetworkReply * ArticleNetworkAccessManager::createRequest( Operation op, #endif } -#if QT_VERSION >= 0x050300 // Qt 5.3+ + return op == QNetworkAccessManager::GetOperation || op == QNetworkAccessManager::HeadOperation ? new AllowFrameReply( reply ) : reply; -#else - return reply; -#endif + } sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource( @@ -550,11 +548,11 @@ void BlockedNetworkReply::finishedSlot() LocalSchemeHandler::LocalSchemeHandler(ArticleNetworkAccessManager& articleNetMgr):mManager(articleNetMgr){ } + void LocalSchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob) { QUrl url = requestJob->requestUrl(); - QNetworkRequest request; request.setUrl( url ); diff --git a/articleview.cc b/articleview.cc index 10f3db3f..6f1de4c0 100644 --- a/articleview.cc +++ b/articleview.cc @@ -701,7 +701,21 @@ unsigned ArticleView::getGroup( QUrl const & url ) QStringList ArticleView::getArticlesList() { //todo dictid - return QStringList() << getCurrentArticle(); + QStringList dictList; + for (unsigned i = 0; i < allDictionaries.size(); i++) + { + dictList.append( allDictionaries[i]->getId().c_str()); + + } + + QStringList mutedDictionaries = getMutedDictionaries(Instances::Group::AllGroupId); + for (int i=0;ipage(), "gdArticleContents" ) // .toString().trimmed().split( ' ', QString::SkipEmptyParts ); } @@ -760,19 +774,7 @@ void ArticleView::setCurrentArticle( QString const & id, bool moveToIt ) ui.definition->page()->runJavaScript(script); onJsActiveArticleChanged(id); -// if ( getArticlesList().contains( id.mid( 7 ) ) ) -// { -// //gdArticleContents - -// if ( moveToIt ) -// ui.definition->page()->runJavaScript( QString( "document.getElementById('%1').scrollIntoView(true);" ).arg( id ) ); - -// //todo -// ui.definition->setProperty("currentArticle",id); -// ui.definition->page()->runJavaScript( -// QString( "gdMakeArticleActive( '%1' );" ).arg( id.mid( 7 ) ) ); -// } ui.definition->setProperty("currentArticle",id); } @@ -1074,6 +1076,43 @@ QString ArticleView::getMutedForGroup( unsigned group ) return QString(); } +QStringList ArticleView::getMutedDictionaries(unsigned group) +{ + if (dictionaryBarToggled && dictionaryBarToggled->isChecked()) + { + // Dictionary bar is active -- mute the muted dictionaries + Instances::Group const* groupInstance = groups.findGroup(group); + + // Find muted dictionaries for current group + Config::Group const* grp = cfg.getGroup(group); + Config::MutedDictionaries const* mutedDictionaries; + if (group == Instances::Group::AllGroupId||!grp) + mutedDictionaries = popupView ? &cfg.popupMutedDictionaries : &cfg.mutedDictionaries; + else + mutedDictionaries = grp ? (popupView ? &grp->popupMutedDictionaries : &grp->mutedDictionaries) : 0; + if (!mutedDictionaries) + return QStringList(); + + QStringList mutedDicts; + + if (groupInstance) + { + for (unsigned x = 0; x < groupInstance->dictionaries.size(); ++x) + { + QString id = QString::fromStdString( + groupInstance->dictionaries[x]->getId()); + + if (mutedDictionaries->contains(id)) + mutedDicts.append(id); + } + } + + return mutedDicts; + } + + return QStringList(); +} + void ArticleView::linkHovered ( const QString & link ) { QString msg; diff --git a/goldendict.vcxproj b/goldendict.vcxproj index b3fc2274..07b50e8d 100644 --- a/goldendict.vcxproj +++ b/goldendict.vcxproj @@ -316,7 +316,7 @@ - .;winlibs\include;qtsingleapplication\src;D:\Qt\5.15.2\msvc2019_64\include;D:\Qt\5.15.2\msvc2019_64\include\QtWebEngineWidgets;D:\Qt\5.15.2\msvc2019_64\include\QtQuick;D:\Qt\5.15.2\msvc2019_64\include\QtMultimediaWidgets;D:\Qt\5.15.2\msvc2019_64\include\QtOpenGL;D:\Qt\5.15.2\msvc2019_64\include\QtPrintSupport;D:\Qt\5.15.2\msvc2019_64\include\QtSvg;D:\Qt\5.15.2\msvc2019_64\include\QtWebEngine;D:\Qt\5.15.2\msvc2019_64\include\QtQml;D:\Qt\5.15.2\msvc2019_64\include\QtMultimedia;D:\Qt\5.15.2\msvc2019_64\include\QtWidgets;D:\Qt\5.15.2\msvc2019_64\include\QtSensors;D:\Qt\5.15.2\msvc2019_64\include\QtNetwork;D:\Qt\5.15.2\msvc2019_64\include\QtXml;D:\Qt\5.15.2\msvc2019_64\include\QtGui;D:\Qt\5.15.2\msvc2019_64\include\QtANGLE;D:\Qt\5.15.2\msvc2019_64\include\QtCore;build;..\..\Qt\Qt5.1.0-msvc2012\5.1.0\msvc2012\mkspecs\win32-msvc2012;%(AdditionalIncludeDirectories) + .;winlibs\include;qtsingleapplication\src;D:\Qt\5.15.2\msvc2019_64\include\QtWebEngineCore;D:\Qt\5.15.2\msvc2019_64\include;D:\Qt\5.15.2\msvc2019_64\include\QtWebEngineWidgets;D:\Qt\5.15.2\msvc2019_64\include\QtQuick;D:\Qt\5.15.2\msvc2019_64\include\QtMultimediaWidgets;D:\Qt\5.15.2\msvc2019_64\include\QtOpenGL;D:\Qt\5.15.2\msvc2019_64\include\QtPrintSupport;D:\Qt\5.15.2\msvc2019_64\include\QtSvg;D:\Qt\5.15.2\msvc2019_64\include\QtWebEngine;D:\Qt\5.15.2\msvc2019_64\include\QtQml;D:\Qt\5.15.2\msvc2019_64\include\QtMultimedia;D:\Qt\5.15.2\msvc2019_64\include\QtWidgets;D:\Qt\5.15.2\msvc2019_64\include\QtSensors;D:\Qt\5.15.2\msvc2019_64\include\QtNetwork;D:\Qt\5.15.2\msvc2019_64\include\QtXml;D:\Qt\5.15.2\msvc2019_64\include\QtGui;D:\Qt\5.15.2\msvc2019_64\include\QtANGLE;D:\Qt\5.15.2\msvc2019_64\include\QtCore;build;..\..\Qt\Qt5.1.0-msvc2012\5.1.0\msvc2012\mkspecs\win32-msvc2012;%(AdditionalIncludeDirectories) -Zm200 -w34100 -w34189 %(AdditionalOptions) false ProgramDatabase