mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 23:34:06 +00:00
1. Don't show "failed to download" error message while saving resources like "gdau://search/..."
2. Stop search if resource is found
This commit is contained in:
parent
9beaf862e8
commit
2085314eb9
|
@ -1324,7 +1324,7 @@ vector< ResourceToSaveHandler * > ArticleView::saveResource( const QUrl & url, c
|
||||||
vector< ResourceToSaveHandler * > handlers;
|
vector< ResourceToSaveHandler * > handlers;
|
||||||
sptr< Dictionary::DataRequest > req;
|
sptr< Dictionary::DataRequest > req;
|
||||||
|
|
||||||
if( url.scheme() == "bres" || url.scheme() == "gico" || url.scheme() == "gdau")
|
if( url.scheme() == "bres" || url.scheme() == "gico" || url.scheme() == "gdau" )
|
||||||
{
|
{
|
||||||
if ( url.host() == "search" )
|
if ( url.host() == "search" )
|
||||||
{
|
{
|
||||||
|
@ -1357,8 +1357,14 @@ vector< ResourceToSaveHandler * > ArticleView::saveResource( const QUrl & url, c
|
||||||
req = (*activeDicts)[ x ]->getResource(
|
req = (*activeDicts)[ x ]->getResource(
|
||||||
Qt4x5::Url::path( url ).mid( 1 ).toUtf8().data() );
|
Qt4x5::Url::path( url ).mid( 1 ).toUtf8().data() );
|
||||||
|
|
||||||
ResourceToSaveHandler * handler = new ResourceToSaveHandler( this, req, fileName );
|
ResourceToSaveHandler * handler = new ResourceToSaveHandler( this, req, fileName, true );
|
||||||
handlers.push_back( handler );
|
handlers.push_back( handler );
|
||||||
|
|
||||||
|
if( req.get()->isFinished() && req.get()->dataSize() > 0 )
|
||||||
|
{
|
||||||
|
// A request was instantly finished with success. Stop search.
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch( std::exception & e )
|
catch( std::exception & e )
|
||||||
{
|
{
|
||||||
|
@ -2743,10 +2749,11 @@ QString ArticleView::wordAtPoint( int x, int y )
|
||||||
|
|
||||||
ResourceToSaveHandler::ResourceToSaveHandler(
|
ResourceToSaveHandler::ResourceToSaveHandler(
|
||||||
ArticleView * view, sptr< Dictionary::DataRequest > req,
|
ArticleView * view, sptr< Dictionary::DataRequest > req,
|
||||||
QString const & fileName ) :
|
QString const & fileName, bool search ) :
|
||||||
QObject( view ),
|
QObject( view ),
|
||||||
req( req ),
|
req( req ),
|
||||||
fileName( fileName )
|
fileName( fileName ),
|
||||||
|
search_req( search )
|
||||||
{
|
{
|
||||||
connect( this, SIGNAL( statusBarMessage( QString, int, QPixmap ) ),
|
connect( this, SIGNAL( statusBarMessage( QString, int, QPixmap ) ),
|
||||||
view, SIGNAL( statusBarMessage( QString, int, QPixmap ) ) );
|
view, SIGNAL( statusBarMessage( QString, int, QPixmap ) ) );
|
||||||
|
@ -2797,9 +2804,12 @@ void ResourceToSaveHandler::downloadFinished()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
emit statusBarMessage(
|
if( !search_req )
|
||||||
tr( "ERROR: %1" ).arg( tr( "The referenced resource failed to download." ) ),
|
{
|
||||||
10000, QPixmap( ":/icons/error.png" ) );
|
emit statusBarMessage(
|
||||||
|
tr( "ERROR: %1" ).arg( tr( "The referenced resource failed to download." ) ),
|
||||||
|
10000, QPixmap( ":/icons/error.png" ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit done();
|
emit done();
|
||||||
|
|
|
@ -366,7 +366,7 @@ class ResourceToSaveHandler: public QObject
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ResourceToSaveHandler( ArticleView * view, sptr< Dictionary::DataRequest > req,
|
explicit ResourceToSaveHandler( ArticleView * view, sptr< Dictionary::DataRequest > req,
|
||||||
QString const & fileName );
|
QString const & fileName, bool search = false );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void done();
|
void done();
|
||||||
|
@ -378,6 +378,7 @@ private slots:
|
||||||
private:
|
private:
|
||||||
sptr< Dictionary::DataRequest > req;
|
sptr< Dictionary::DataRequest > req;
|
||||||
QString fileName;
|
QString fileName;
|
||||||
|
bool search_req;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue