From a1d539ff1fe07cd660b0a7c298103cf98389b0cf Mon Sep 17 00:00:00 2001 From: Abs62 Date: Fri, 27 Sep 2013 17:04:25 +0400 Subject: [PATCH] Qt5-specific: Fix pictures loading for Bgl and some Stardict dictionaries --- article_netmgr.cc | 2 +- articleview.cc | 4 ++-- mainwindow.cc | 2 +- qt4x5.hh | 9 +++++++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/article_netmgr.cc b/article_netmgr.cc index 243007e6..e058334a 100644 --- a/article_netmgr.cc +++ b/article_netmgr.cc @@ -203,7 +203,7 @@ sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource( } try { - return dictionaries[ x ]->getResource( url.path().mid( 1 ).toUtf8().data() ); + return dictionaries[ x ]->getResource( Qt4x5::Url::path( url ).mid( 1 ).toUtf8().data() ); } catch( std::exception & e ) { diff --git a/articleview.cc b/articleview.cc index b917b3d2..f48bdf66 100644 --- a/articleview.cc +++ b/articleview.cc @@ -1042,7 +1042,7 @@ vector< ResourceToSaveHandler * > ArticleView::saveResource( const QUrl & url, c for( unsigned x = 0; x < activeDicts->size(); ++x ) { req = (*activeDicts)[ x ]->getResource( - url.path().mid( 1 ).toUtf8().data() ); + Qt4x5::Url::path( url ).mid( 1 ).toUtf8().data() ); ResourceToSaveHandler * handler = new ResourceToSaveHandler( this, req, fileName ); handlers.push_back( handler ); @@ -1453,7 +1453,7 @@ void ArticleView::contextMenuRequested( QPoint const & pos ) savePath = QDir::homePath(); } - QString name = url.path().section( '/', -1 ); + QString name = Qt4x5::Url::path( url ).section( '/', -1 ); if ( result == saveSoundAction ) { diff --git a/mainwindow.cc b/mainwindow.cc index d337d7c9..5a04b0a3 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -2964,7 +2964,7 @@ static void filterAndCollectResources( QString & html, QRegExp & rx, const QStri { QUrl url( rx.cap( 1 ) ); QString host = url.host(); - QString resourcePath = QString::fromLatin1( QUrl::toPercentEncoding( url.path(), "/" ) ); + QString resourcePath = QString::fromLatin1( QUrl::toPercentEncoding( Qt4x5::Url::path( url ), "/" ) ); if ( !host.startsWith( '/' ) ) host.insert( 0, '/' ); diff --git a/qt4x5.hh b/qt4x5.hh index 1cbfa395..b88a0587 100644 --- a/qt4x5.hh +++ b/qt4x5.hh @@ -110,6 +110,15 @@ inline void setQueryItems( QUrl & url, QList< QPair< QString, QString > > const #endif } +inline QString path( QUrl const & url ) +{ +#if IS_QT_5 + return url.path( QUrl::FullyDecoded ); +#else + return url.path(); +#endif +} + } namespace Dom