Merge branch 'master' of https://github.com/goldendict/goldendict into goldendict-master

# Conflicts:
#	.travis.yml
#	articleview.cc
#	locale/ar_SA.ts
#	locale/ay_WI.ts
#	locale/be_BY.ts
#	locale/be_BY@latin.ts
#	locale/bg_BG.ts
#	locale/cs_CZ.ts
#	locale/de_DE.ts
#	locale/el_GR.ts
#	locale/eo_EO.ts
#	locale/es_AR.ts
#	locale/es_BO.ts
#	locale/es_ES.ts
#	locale/fa_IR.ts
#	locale/fi_FI.ts
#	locale/fr_FR.ts
#	locale/hi_IN.ts
#	locale/ie_001.ts
#	locale/it_IT.ts
#	locale/ja_JP.ts
#	locale/jb_JB.ts
#	locale/ko_KR.ts
#	locale/lt_LT.ts
#	locale/mk_MK.ts
#	locale/nl_NL.ts
#	locale/pl_PL.ts
#	locale/pt_BR.ts
#	locale/qu_WI.ts
#	locale/ru_RU.ts
#	locale/sk_SK.ts
#	locale/sq_AL.ts
#	locale/sr_SR.ts
#	locale/sv_SE.ts
#	locale/tg_TJ.ts
#	locale/tk_TM.ts
#	locale/tr_TR.ts
#	locale/uk_UA.ts
#	locale/vi_VN.ts
#	locale/zh_CN.ts
#	locale/zh_TW.ts
This commit is contained in:
Xiao YiFang 2022-07-10 12:39:12 +08:00
commit 5b4f112110
3 changed files with 37 additions and 2 deletions

View file

@ -197,6 +197,19 @@ QString dictionaryIdFromScrollTo( QString const & scrollTo )
return scrollTo.mid( scrollToPrefixLength );
}
QString searchStatusMessageNoMatches()
{
return ArticleView::tr( "Phrase not found" );
}
QString searchStatusMessage( int activeMatch, int matchCount )
{
Q_ASSERT( matchCount > 0 );
Q_ASSERT( activeMatch > 0 );
Q_ASSERT( activeMatch <= matchCount );
return ArticleView::tr( "%1 of %2 matches" ).arg( activeMatch ).arg( matchCount );
}
} // unnamed namespace
QString ArticleView::scrollToFromDictionaryId( QString const & dictionaryId )
@ -2552,7 +2565,9 @@ void ArticleView::highlightFTSResults()
if( ftsSearchMatchCase )
flags |= QWebEnginePage::FindCaseSensitively;
if( !allMatches.isEmpty() )
if( allMatches.isEmpty() )
ui.ftsSearchStatusLabel->setText( searchStatusMessageNoMatches() );
else
{
// highlightAllFtsOccurences( flags );
ui.definition->findText( allMatches.at( 0 ), flags );
@ -2561,8 +2576,11 @@ void ArticleView::highlightFTSResults()
// ui.definition->page()->runJavaScript(
// QString( "%1=window.getSelection().getRangeAt(0);_=0;" ).arg( rangeVarName ) );
// }
Q_ASSERT( ftsPosition == 0 );
ui.ftsSearchStatusLabel->setText( searchStatusMessage( 1, allMatches.size() ) );
}
ui.ftsSearchFrame->show();
ui.ftsSearchPrevious->setEnabled( false );
ui.ftsSearchNext->setEnabled( allMatches.size() > 1 );
@ -2609,6 +2627,7 @@ void ArticleView::performFtsFindOperation( bool backwards )
if( allMatches.isEmpty() )
{
ui.ftsSearchStatusLabel->setText( searchStatusMessageNoMatches() );
ui.ftsSearchNext->setEnabled( false );
ui.ftsSearchPrevious->setEnabled( false );
return;
@ -2670,7 +2689,10 @@ void ArticleView::performFtsFindOperation( bool backwards )
ui.ftsSearchPrevious->setEnabled(res);
});
}
#endif
ui.ftsSearchStatusLabel->setText( searchStatusMessage( ftsPosition + 1, allMatches.size() ) );
// Store new highlighted selection
// ui.definition->page()->
// runJavaScript( QString( "%1=window.getSelection().getRangeAt(0);_=0;" )

View file

@ -93,6 +93,9 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="ftsSearchStatusLabel"/>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">

View file

@ -246,7 +246,17 @@
<translation>&amp;Открыть ссылку</translation>
</message>
<message>
<location filename="../articleview.cc" line="1735"/>
<location filename="../articleview.cc" line="222"/>
<source>Phrase not found</source>
<translation>Ничего не найдено</translation>
</message>
<message>
<location filename="../articleview.cc" line="230"/>
<source>%1 of %2 matches</source>
<translation>%1 из %2 совпадений</translation>
</message>
<message>
<location filename="../articleview.cc" line="1810"/>
<source>Open Link in New &amp;Tab</source>
<translation>Открыть ссылку в новой &amp;вкладке</translation>
</message>