From 0bd724b313b145084c1c6c7e836d7fe4e354176f Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Thu, 19 May 2022 08:29:50 +0800 Subject: [PATCH 1/7] opt:web font preference ,set a default valut to empty --- preferences.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/preferences.cc b/preferences.cc index 46705bf2..357e652a 100644 --- a/preferences.cc +++ b/preferences.cc @@ -380,6 +380,8 @@ Config::Preferences Preferences::getPreferences() //bypass the first default if(ui.fontFamilies->currentIndex()>0) p.webFontFamily = ui.fontFamilies->currentText(); + else + p.webFontFamily = ""; p.helpLanguage = ui.helpLanguage->itemData( From 15d9104f2c964e3cdb4a51eafabd5f3da2f10d4f Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Thu, 19 May 2022 20:28:52 +0800 Subject: [PATCH 2/7] fix : fulltext search will crash close issue #69 --- articleview.cc | 57 +++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/articleview.cc b/articleview.cc index 06fba01b..665bfd37 100644 --- a/articleview.cc +++ b/articleview.cc @@ -2482,34 +2482,6 @@ void ArticleView::highlightFTSResults() { closeSearch(); - const QUrl & url = ui.definition->url(); - - bool ignoreDiacritics = Utils::Url::hasQueryItem( url, "ignore_diacritics" ); - - QString regString = Utils::Url::queryItemValue( url, "regexp" ); - if( ignoreDiacritics ) - regString = gd::toQString( Folding::applyDiacriticsOnly( gd::toWString( regString ) ) ); - else - regString = regString.remove( AccentMarkHandler::accentMark() ); - - QRegularExpression regexp; - if( Utils::Url::hasQueryItem( url, "wildcards" ) ) - regexp.setPattern( wildcardsToRegexp( regString ) ); - else - regexp.setPattern( regString ); - - QRegularExpression::PatternOptions patternOptions = - QRegularExpression::DotMatchesEverythingOption | QRegularExpression::UseUnicodePropertiesOption | - QRegularExpression::MultilineOption | QRegularExpression::InvertedGreedinessOption; - if( !Utils::Url::hasQueryItem( url, "matchcase" ) ) - patternOptions |= QRegularExpression::CaseInsensitiveOption; - regexp.setPatternOptions( patternOptions ); - - if( regexp.pattern().isEmpty() || !regexp.isValid() ) - return; - - sptr< AccentMarkHandler > marksHandler = ignoreDiacritics ? new DiacriticsHandler : new AccentMarkHandler; - // Clear any current selection if( ui.definition->selectedText().size() ) { @@ -2519,6 +2491,33 @@ void ArticleView::highlightFTSResults() ui.definition->page()->toPlainText( [ & ]( const QString pageText ) { + const QUrl & url = ui.definition->url(); + + bool ignoreDiacritics = Utils::Url::hasQueryItem( url, "ignore_diacritics" ); + + QString regString = Utils::Url::queryItemValue( url, "regexp" ); + if( ignoreDiacritics ) + regString = gd::toQString( Folding::applyDiacriticsOnly( gd::toWString( regString ) ) ); + else + regString = regString.remove( AccentMarkHandler::accentMark() ); + + QRegularExpression regexp; + if( Utils::Url::hasQueryItem( url, "wildcards" ) ) + regexp.setPattern( wildcardsToRegexp( regString ) ); + else + regexp.setPattern( regString ); + + QRegularExpression::PatternOptions patternOptions = + QRegularExpression::DotMatchesEverythingOption | QRegularExpression::UseUnicodePropertiesOption | + QRegularExpression::MultilineOption | QRegularExpression::InvertedGreedinessOption; + if( !Utils::Url::hasQueryItem( url, "matchcase" ) ) + patternOptions |= QRegularExpression::CaseInsensitiveOption; + regexp.setPatternOptions( patternOptions ); + + if( regexp.pattern().isEmpty() || !regexp.isValid() ) + return; + sptr< AccentMarkHandler > marksHandler = ignoreDiacritics ? new DiacriticsHandler : new AccentMarkHandler; + marksHandler->setText( pageText ); QRegularExpressionMatchIterator it = regexp.globalMatch( marksHandler->normalizedText() ); @@ -2547,7 +2546,7 @@ void ArticleView::highlightFTSResults() ftsSearchMatchCase = Utils::Url::hasQueryItem( url, "matchcase" ); - QWebEnginePage::FindFlags flags( 0 ); + QWebEnginePage::FindFlags flags( QWebEnginePage::FindBackward ); if( ftsSearchMatchCase ) flags |= QWebEnginePage::FindCaseSensitively; From c0e3767f832d0305128621df9edd62f4b753d61d Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Thu, 19 May 2022 20:37:11 +0800 Subject: [PATCH 3/7] opt: format code and remove default constructor --- articleview.cc | 19 +++++++------------ articleview.hh | 17 ++++++++--------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/articleview.cc b/articleview.cc index 665bfd37..635e03b6 100644 --- a/articleview.cc +++ b/articleview.cc @@ -2757,21 +2757,16 @@ void ResourceToSaveHandler::downloadFinished() } } -ArticleViewAgent::ArticleViewAgent(QObject *parent) - : QObject{parent} +ArticleViewAgent::ArticleViewAgent( ArticleView * articleView ) : QObject( articleView ), articleView( articleView ) { - } -ArticleViewAgent::ArticleViewAgent(ArticleView *articleView) - : articleView(articleView) + +void ArticleViewAgent::onJsActiveArticleChanged( QString const & id ) { - + articleView->onJsActiveArticleChanged( id ); } -void ArticleViewAgent::onJsActiveArticleChanged(QString const & id){ - articleView->onJsActiveArticleChanged(id); -} - -void ArticleViewAgent::linkClickedInHtml(QUrl const & url){ - articleView->linkClickedInHtml(url); +void ArticleViewAgent::linkClickedInHtml( QUrl const & url ) +{ + articleView->linkClickedInHtml( url ); } diff --git a/articleview.hh b/articleview.hh index a7c501ab..487993c9 100644 --- a/articleview.hh +++ b/articleview.hh @@ -433,18 +433,17 @@ private: class ArticleViewAgent : public QObject { - Q_OBJECT - ArticleView* articleView; - public: - explicit ArticleViewAgent(QObject *parent = nullptr); - ArticleViewAgent(ArticleView* articleView); + Q_OBJECT + ArticleView * articleView; - signals: +public: + ArticleViewAgent( ArticleView * articleView ); - public slots: - Q_INVOKABLE void onJsActiveArticleChanged(QString const & id); - Q_INVOKABLE void linkClickedInHtml( QUrl const & ); +signals: +public slots: + Q_INVOKABLE void onJsActiveArticleChanged( QString const & id ); + Q_INVOKABLE void linkClickedInHtml( QUrl const & ); }; #endif From 7071bc5aa24a03f771efb80bb45d4681237e3181 Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Thu, 19 May 2022 20:42:46 +0800 Subject: [PATCH 4/7] fix : revert original ensureInitDone() logic --- mdx.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mdx.cc b/mdx.cc index b19558f5..757de69f 100644 --- a/mdx.cc +++ b/mdx.cc @@ -315,8 +315,8 @@ public: virtual void setFTSParameters( Config::FullTextSearch const & fts ) { -// if( ensureInitDone().size() ) -// return; + if( ensureInitDone().size() ) + return; can_FTS = fts.enabled && !fts.disabledTypes.contains( "MDICT", Qt::CaseInsensitive ) From e9acba53832dd65146e128a9e9431d8e02d2ad75 Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Thu, 19 May 2022 20:53:23 +0800 Subject: [PATCH 5/7] opt: dsl dictionary use lambda function instead of Runnable class --- dsl.cc | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/dsl.cc b/dsl.cc index 410b8a9d..6991e053 100644 --- a/dsl.cc +++ b/dsl.cc @@ -345,29 +345,6 @@ DslDictionary::~DslDictionary() //////// DslDictionary::deferredInit() -class DslDeferredInitRunnable: public QRunnable -{ - DslDictionary & dictionary; - QSemaphore & hasExited; - -public: - - DslDeferredInitRunnable( DslDictionary & dictionary_, - QSemaphore & hasExited_ ): - dictionary( dictionary_ ), hasExited( hasExited_ ) - {} - - ~DslDeferredInitRunnable() - { - hasExited.release(); - } - - virtual void run() - { - dictionary.doDeferredInit(); - } -}; - void DslDictionary::deferredInit() { if ( !Utils::AtomicInt::loadAcquire( deferredInitDone ) ) @@ -379,9 +356,7 @@ void DslDictionary::deferredInit() if ( !deferredInitRunnableStarted ) { - QThreadPool::globalInstance()->start( - new DslDeferredInitRunnable( *this, deferredInitRunnableExited ), - -1000 ); + QThreadPool::globalInstance()->start( [ this ]() { this->doDeferredInit(); }, -1000 ); deferredInitRunnableStarted = true; } } From 3390e73501f556edfcc7470f42e63f2d990c7943 Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Thu, 19 May 2022 21:04:31 +0800 Subject: [PATCH 6/7] opt: refactor the editdictionary's save method --- editdictionaries.cc | 11 ++++------- editdictionaries.hh | 5 +++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/editdictionaries.cc b/editdictionaries.cc index 0cce9843..79b17a32 100644 --- a/editdictionaries.cc +++ b/editdictionaries.cc @@ -88,14 +88,14 @@ void EditDictionaries::editGroup( unsigned id ) } } -void EditDictionaries::save() +void EditDictionaries::save( bool rebuildGroups ) { Config::Groups newGroups = groups->getGroups(); Config::Group newOrder = orderAndProps->getCurrentDictionaryOrder(); Config::Group newInactive = orderAndProps->getCurrentInactiveDictionaries(); - if ( isSourcesChanged() ) - acceptChangedSources( false ); + if( isSourcesChanged() ) + acceptChangedSources( rebuildGroups ); if ( origCfg.groups != newGroups || origCfg.dictionaryOrder != newOrder || origCfg.inactiveDictionaries != newInactive ) @@ -171,10 +171,7 @@ void EditDictionaries::rescanSources() void EditDictionaries::buttonBoxClicked( QAbstractButton * button ) { if (ui.buttons->buttonRole(button) == QDialogButtonBox::ApplyRole) { - if ( isSourcesChanged() ) { - acceptChangedSources( true ); - } - save(); + save( true ); } } diff --git a/editdictionaries.hh b/editdictionaries.hh index 9fa18e88..a2488d95 100644 --- a/editdictionaries.hh +++ b/editdictionaries.hh @@ -71,8 +71,9 @@ private: void acceptChangedSources( bool rebuildGroups ); - void save(); - + //the rebuildGroups was an initative,means to build the group if possible. + void save( bool rebuildGroups = false ); + private: Config::Class & cfg; From b47004aba00046e82f2b08d4d9d58b9c4d296a2f Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Thu, 19 May 2022 22:13:49 +0800 Subject: [PATCH 7/7] opt: remove body default 13 px font-size, use chrome's instead --- article-style-st-babylon.css | 1 - article-style-st-lingvo.css | 2 -- article-style-st-modern.css | 1 - article-style.css | 15 +++++++-------- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/article-style-st-babylon.css b/article-style-st-babylon.css index 9eff7175..73fbdf65 100644 --- a/article-style-st-babylon.css +++ b/article-style-st-babylon.css @@ -6,7 +6,6 @@ html body { background: white; - font-size: 13px; } .gdarticle diff --git a/article-style-st-lingvo.css b/article-style-st-lingvo.css index b2e47958..8da59179 100644 --- a/article-style-st-lingvo.css +++ b/article-style-st-lingvo.css @@ -40,7 +40,6 @@ a:hover .gddictname { - font-size: 13px; font-weight: normal; float: right; @@ -58,7 +57,6 @@ a:hover .gdactivearticle .gddictname { - font-size: 13px; font-weight: normal; float: right; diff --git a/article-style-st-modern.css b/article-style-st-modern.css index 1a72ccd7..e37e784b 100644 --- a/article-style-st-modern.css +++ b/article-style-st-modern.css @@ -87,7 +87,6 @@ a:hover .gdactivearticle .gddictname { - font-size: 13px; font-weight: normal; margin: -6px; margin-bottom: 5px; diff --git a/article-style.css b/article-style.css index e0e54be7..16ce7887 100644 --- a/article-style.css +++ b/article-style.css @@ -5,7 +5,6 @@ body { background: #fefdeb; font-family: Tahoma, Verdana, "Lucida Sans Unicode", sans-serif; - font-size: 13px; } /* This stylesheet is used to highligh current selection when doing a search. @@ -611,15 +610,15 @@ div.xdxf .epwing_narrow_font { - width: 7px; - height: 13px; + width: 0.5em; + height: 1em; vertical-align: -15%; } .epwing_wide_font { - width: 13px; - height: 13px; + width: 1em; + height: 1em; vertical-align: -15%; } @@ -1600,7 +1599,7 @@ in the bottom-right corner of the content area */ .mwiki #bodyContent a.external, .mwiki #bodyContent a[href ^="gopher://"] { background: url(external.png) center right no-repeat; - padding-right: 13px; + padding-right: 1em; } .mwiki #bodyContent a[href ^="https://"], .mwiki .link-https { @@ -1636,7 +1635,7 @@ in the bottom-right corner of the content area */ .mwiki #bodyContent a.external[href $=".wma"], .mwiki #bodyContent a.external[href $=".WMA"], .mwiki .link-audio { background: url("audio.png") center right no-repeat; - padding-right: 13px; + padding-right: 1em; } .mwiki #bodyContent a.external[href $=".ogm"], .mwiki #bodyContent a.external[href $=".OGM"], .mwiki #bodyContent a.external[href $=".avi"], .mwiki #bodyContent a.external[href $=".AVI"], @@ -1644,7 +1643,7 @@ in the bottom-right corner of the content area */ .mwiki #bodyContent a.external[href $=".mpg"], .mwiki #bodyContent a.external[href $=".MPG"], .mwiki .link-video { background: url("video.png") center right no-repeat; - padding-right: 13px; + padding-right: 1em; } .mwiki #bodyContent a.external[href $=".pdf"], .mwiki #bodyContent a.external[href $=".PDF"], .mwiki #bodyContent a.external[href *=".pdf#"], .mwiki #bodyContent a.external[href *=".PDF#"],