mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Merge branch 'Original' into Qt4x5
This commit is contained in:
commit
eee04266db
|
@ -519,10 +519,10 @@ void ArticleView::loadFinished( bool )
|
|||
{
|
||||
// Anchor found, jump to it
|
||||
|
||||
url.clear();
|
||||
url.setFragment( rx.cap( 0 ) );
|
||||
|
||||
ui.definition->page()->mainFrame()->evaluateJavaScript(
|
||||
QString( "window.location = \"%1\"" ).arg( QString::fromUtf8( url.toEncoded() ) ) );
|
||||
QString( "window.location.hash = \"%1\"" ).arg( QString::fromUtf8( url.toEncoded() ) ) );
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -530,9 +530,10 @@ void ArticleView::loadFinished( bool )
|
|||
}
|
||||
else
|
||||
{
|
||||
url.clear();
|
||||
url.setFragment( anchor );
|
||||
ui.definition->page()->mainFrame()->evaluateJavaScript(
|
||||
QString( "window.location = \"%1\"" ).arg( QString::fromUtf8( url.toEncoded() ) ) );
|
||||
QString( "window.location.hash = \"%1\"" ).arg( QString::fromUtf8( url.toEncoded() ) ) );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -545,6 +546,7 @@ void ArticleView::loadFinished( bool )
|
|||
|
||||
void ArticleView::handleTitleChanged( QString const & title )
|
||||
{
|
||||
if( !title.isEmpty() ) // Qt 5.x WebKit raise signal titleChanges(QString()) while navigation within page
|
||||
emit titleChanged( this, title );
|
||||
}
|
||||
|
||||
|
|
|
@ -322,7 +322,7 @@ quint32 LangCoder::guessId( const QString & lang )
|
|||
{
|
||||
for( GDLangCode const * lc = LangCodes; lc->code[ 0 ]; ++lc )
|
||||
{
|
||||
if ( lstr == QString( lc->lang ) )
|
||||
if ( lstr == ( lstr.size() == 3 ? QString( lc->code3 ) : QString( lc->lang ) ) )
|
||||
{
|
||||
// We've got a match
|
||||
return code2toInt( lc->code );
|
||||
|
|
26
mdx.cc
26
mdx.cc
|
@ -848,6 +848,32 @@ void MddResourceRequest::run()
|
|||
if ( Filetype::isNameOfCSS( u8ResourceName ) )
|
||||
{
|
||||
QString css = QString::fromUtf8( data.data(), data.size() );
|
||||
|
||||
// Correct some url's
|
||||
|
||||
QRegExp links( "url\\(\\s*(['\"]?)([^'\"]*)(['\"]?)\\s*\\)", Qt::CaseInsensitive, QRegExp::RegExp );
|
||||
QString id = QString::fromUtf8( dict.getId().c_str() );
|
||||
int pos = 0;
|
||||
for( ; ; )
|
||||
{
|
||||
pos = links.indexIn( css, pos );
|
||||
if( pos < 0 )
|
||||
break;
|
||||
QString url = links.cap( 2 );
|
||||
|
||||
if( url.indexOf( ":/" ) >= 0 )
|
||||
{
|
||||
// External link
|
||||
pos += links.cap().size();
|
||||
continue;
|
||||
}
|
||||
|
||||
QString newUrl = QString( "url(" ) + links.cap( 1 ) + "bres://"
|
||||
+ id + "/" + url + links.cap( 3 ) + ")";
|
||||
css.replace( pos, links.cap().size(), newUrl );
|
||||
pos += newUrl.size();
|
||||
}
|
||||
|
||||
dict.isolateCSS( css, ".mdict" );
|
||||
QByteArray bytes = css.toUtf8();
|
||||
data.resize( bytes.size() );
|
||||
|
|
|
@ -1549,7 +1549,7 @@ void StardictResourceRequest::run()
|
|||
|
||||
// Correct some url's
|
||||
|
||||
QRegExp links( "url\\(\\s*(['\"])([^'\"]*)(['\"])\\s*\\)");
|
||||
QRegExp links( "url\\(\\s*(['\"]?)([^'\"]*)(['\"]?)\\s*\\)", Qt::CaseInsensitive, QRegExp::RegExp );
|
||||
QString id = QString::fromUtf8( dict.getId().c_str() );
|
||||
int pos = 0;
|
||||
for( ; ; )
|
||||
|
|
Loading…
Reference in a new issue