mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-12-17 23:04:06 +00:00
fix wiki's audio playing
This commit is contained in:
parent
6199fd3bb5
commit
8df4179c6a
17
mediawiki.cc
17
mediawiki.cc
|
@ -9,6 +9,7 @@
|
||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include "dprintf.hh"
|
#include "dprintf.hh"
|
||||||
|
#include "audiolink.hh"
|
||||||
|
|
||||||
namespace MediaWiki {
|
namespace MediaWiki {
|
||||||
|
|
||||||
|
@ -181,7 +182,8 @@ class MediaWikiArticleRequest: public MediaWikiDataRequestSlots
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MediaWikiArticleRequest( wstring const & word, vector< wstring > const & alts,
|
MediaWikiArticleRequest( wstring const & word, vector< wstring > const & alts,
|
||||||
QString const & url, QNetworkAccessManager & mgr );
|
QString const & url, QNetworkAccessManager & mgr,
|
||||||
|
string wikidictID );
|
||||||
|
|
||||||
virtual void cancel();
|
virtual void cancel();
|
||||||
|
|
||||||
|
@ -190,6 +192,7 @@ private:
|
||||||
void addQuery( QNetworkAccessManager & mgr, wstring const & word );
|
void addQuery( QNetworkAccessManager & mgr, wstring const & word );
|
||||||
|
|
||||||
virtual void requestFinished( QNetworkReply * );
|
virtual void requestFinished( QNetworkReply * );
|
||||||
|
string dictID;
|
||||||
};
|
};
|
||||||
|
|
||||||
void MediaWikiArticleRequest::cancel()
|
void MediaWikiArticleRequest::cancel()
|
||||||
|
@ -200,8 +203,9 @@ void MediaWikiArticleRequest::cancel()
|
||||||
MediaWikiArticleRequest::MediaWikiArticleRequest( wstring const & str,
|
MediaWikiArticleRequest::MediaWikiArticleRequest( wstring const & str,
|
||||||
vector< wstring > const & alts,
|
vector< wstring > const & alts,
|
||||||
QString const & url_,
|
QString const & url_,
|
||||||
QNetworkAccessManager & mgr ):
|
QNetworkAccessManager & mgr,
|
||||||
url( url_ )
|
string wikidictID ):
|
||||||
|
url( url_ ),dictID(wikidictID)
|
||||||
{
|
{
|
||||||
connect( &mgr, SIGNAL( finished( QNetworkReply * ) ),
|
connect( &mgr, SIGNAL( finished( QNetworkReply * ) ),
|
||||||
this, SLOT( requestFinished( QNetworkReply * ) ),
|
this, SLOT( requestFinished( QNetworkReply * ) ),
|
||||||
|
@ -295,7 +299,10 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r )
|
||||||
|
|
||||||
// Add "http:" to image source urls
|
// Add "http:" to image source urls
|
||||||
articleString.replace( " src=\"//", " src=\"http://" );
|
articleString.replace( " src=\"//", " src=\"http://" );
|
||||||
|
//fix audio
|
||||||
|
articleString.replace( QRegExp("<button\\s+[^>]*(upload\\.wikimedia\\.org/wikipedia/commons/[^\"'&]*\\.ogg)[^>]*>\\s*<[^<]*</button>"),
|
||||||
|
QString::fromStdString(addAudioLink("\"http://\\1\"",this->dictID)+
|
||||||
|
"<a href=\"http://\\1\"><img src=\"qrcx://localhost/icons/playsound.png\" border=\"0\" alt=\"Play\"></a>"));
|
||||||
// In those strings, change any underscores to spaces
|
// In those strings, change any underscores to spaces
|
||||||
for( ; ; )
|
for( ; ; )
|
||||||
{
|
{
|
||||||
|
@ -366,7 +373,7 @@ sptr< DataRequest > MediaWikiDictionary::getArticle( wstring const & word,
|
||||||
return new DataRequestInstant( false );
|
return new DataRequestInstant( false );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return new MediaWikiArticleRequest( word, alts, url, netMgr );
|
return new MediaWikiArticleRequest( word, alts, url, netMgr,this->getId() );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue