diff --git a/article_netmgr.cc b/article_netmgr.cc index cc8b8f40..061bc57a 100644 --- a/article_netmgr.cc +++ b/article_netmgr.cc @@ -438,8 +438,6 @@ ArticleResourceReply::ArticleResourceReply( QObject * parent, { connect( this, SIGNAL( readyReadSignal() ), this, SLOT( readyReadSlot() ), Qt::QueuedConnection ); - connect( this, SIGNAL( finishedSignal() ), - this, SLOT( finishedSlot() ), Qt::QueuedConnection ); emit readyReadSignal(); @@ -448,6 +446,10 @@ ArticleResourceReply::ArticleResourceReply( QObject * parent, emit finishedSignal(); GD_DPRINTF( "In-place finish.\n" ); } + else{ + connect( this, SIGNAL( finishedSignal() ), + this, SLOT( finishedSlot() ), Qt::QueuedConnection ); + } } } diff --git a/gico_schemahandler.h b/gico_schemahandler.h deleted file mode 100644 index a5bd15b4..00000000 --- a/gico_schemahandler.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef GICO_SCHEMAHANDLER_H -#define GICO_SCHEMAHANDLER_H - -#include"article_netmgr.hh" - -class GicoSchemeHandler : public QWebEngineUrlSchemeHandler -{ - Q_OBJECT -public: - GicoSchemeHandler(ArticleNetworkAccessManager& articleNetMgr); - void requestStarted(QWebEngineUrlRequestJob *requestJob); - -protected: - -private: - ArticleNetworkAccessManager& mManager; - QMimeDatabase db; -}; - -#endif // GICO_SCHEMAHANDLER_H diff --git a/goldendict.pro b/goldendict.pro index 0d57d5b2..9f88f32b 100644 --- a/goldendict.pro +++ b/goldendict.pro @@ -247,11 +247,11 @@ DEFINES += PROGRAM_VERSION=\\\"$$VERSION\\\" # Input HEADERS += folding.hh \ - gico_schemahandler.h \ globalbroadcaster.h \ inc_case_folding.hh \ inc_diacritic_folding.hh \ mainwindow.hh \ + resourceschemehandler.h \ sptr.hh \ dictionary.hh \ ex.hh \ @@ -388,11 +388,11 @@ FORMS += groups.ui \ fulltextsearch.ui SOURCES += folding.cc \ - gico_schemahandler.cpp \ globalbroadcaster.cpp \ main.cc \ dictionary.cc \ config.cc \ + resourceschemehandler.cpp \ sources.cc \ mainwindow.cc \ utf8.cc \ diff --git a/mainwindow.cc b/mainwindow.cc index 31a41cf7..0e1ecb1a 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -48,7 +48,7 @@ #include "utils.hh" #include #include "ui_authentication.h" -#include "gico_schemahandler.h" +#include "resourceschemehandler.h" #ifdef Q_OS_MAC #include "lionsupport.h" @@ -146,14 +146,14 @@ MainWindow::MainWindow( Config::Class & cfg_ ): #endif - LocalSchemeHandler *handler = new LocalSchemeHandler(articleNetMgr); - QWebEngineProfile::defaultProfile()->installUrlSchemeHandler("gdlookup", handler); - QWebEngineProfile::defaultProfile()->installUrlSchemeHandler("bword", handler); + localSchemeHandler = new LocalSchemeHandler(articleNetMgr); + QWebEngineProfile::defaultProfile()->installUrlSchemeHandler("gdlookup", localSchemeHandler); + QWebEngineProfile::defaultProfile()->installUrlSchemeHandler("bword", localSchemeHandler); QStringList localSchemes={"gdau","gico","qrcx","bres","gdprg","gdvideo","gdpicture","gdtts"}; - GicoSchemeHandler *h=new GicoSchemeHandler(articleNetMgr); + resourceSchemeHandler = new ResourceSchemeHandler(articleNetMgr); for(int i=0;iinstallUrlSchemeHandler(localSchemes.at(i).toLatin1(), h); + QWebEngineProfile::defaultProfile()->installUrlSchemeHandler(localSchemes.at(i).toLatin1(), resourceSchemeHandler); } wuri = new WebUrlRequestInterceptor(); diff --git a/mainwindow.hh b/mainwindow.hh index 36392790..0e8584e4 100644 --- a/mainwindow.hh +++ b/mainwindow.hh @@ -33,6 +33,7 @@ #include "hotkeywrapper.hh" #include "weburlrequestinterceptor.h" +#include "resourceschemehandler.h" #ifdef HAVE_X11 #include #endif @@ -194,6 +195,9 @@ private: QIcon starIcon, blueStarIcon; + LocalSchemeHandler *localSchemeHandler; + ResourceSchemeHandler *resourceSchemeHandler; + /// Applies the qt's stylesheet, given the style's name. void applyQtStyleSheet( QString const & displayStyle, QString const & addonStyle ); diff --git a/gico_schemahandler.cpp b/resourceschemehandler.cpp similarity index 65% rename from gico_schemahandler.cpp rename to resourceschemehandler.cpp index 2cc97a4c..40cdcb3f 100644 --- a/gico_schemahandler.cpp +++ b/resourceschemehandler.cpp @@ -1,9 +1,9 @@ -#include "gico_schemahandler.h" +#include "resourceschemehandler.h" -GicoSchemeHandler::GicoSchemeHandler(ArticleNetworkAccessManager& articleNetMgr):mManager(articleNetMgr){ +ResourceSchemeHandler::ResourceSchemeHandler(ArticleNetworkAccessManager& articleNetMgr):mManager(articleNetMgr){ } -void GicoSchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob) +void ResourceSchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob) { QUrl url = requestJob->requestUrl(); @@ -17,7 +17,7 @@ void GicoSchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob) requestJob->fail(QWebEngineUrlRequestJob::UrlNotFound); return; } - + qDebug() << "resource scheme handler receive finished signal:" << reply->request().url(); QMimeType mineType = db.mimeTypeForUrl(url); QString contentType = mineType.name(); // Reply segment diff --git a/resourceschemehandler.h b/resourceschemehandler.h new file mode 100644 index 00000000..5e6642ae --- /dev/null +++ b/resourceschemehandler.h @@ -0,0 +1,20 @@ +#ifndef RESOURCESCHEMEHANDLER_H +#define RESOURCESCHEMEHANDLER_H + +#include"article_netmgr.hh" + +class ResourceSchemeHandler : public QWebEngineUrlSchemeHandler +{ + Q_OBJECT +public: + ResourceSchemeHandler(ArticleNetworkAccessManager& articleNetMgr); + void requestStarted(QWebEngineUrlRequestJob *requestJob); + +protected: + +private: + ArticleNetworkAccessManager& mManager; + QMimeDatabase db; +}; + +#endif // RESOURCESCHEMEHANDLER_H