Merge branch 'staged' into dev

This commit is contained in:
Xiao YiFang 2022-05-19 22:17:08 +08:00
commit 1660b0d176
11 changed files with 62 additions and 99 deletions

View file

@ -6,7 +6,6 @@ html
body
{
background: white;
font-size: 13px;
}
.gdarticle

View file

@ -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;

View file

@ -87,7 +87,6 @@ a:hover
.gdactivearticle .gddictname
{
font-size: 13px;
font-weight: normal;
margin: -6px;
margin-bottom: 5px;

View file

@ -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#"],

View file

@ -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;
@ -2758,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 );
}

View file

@ -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

27
dsl.cc
View file

@ -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;
}
}

View file

@ -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 );
}
}

View file

@ -71,7 +71,8 @@ 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:

4
mdx.cc
View file

@ -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 )

View file

@ -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(