mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 23:34:06 +00:00
imp. : wrap articleview in webchannel for security reason
This commit is contained in:
parent
f93745cc69
commit
cf10810fe2
|
@ -41,6 +41,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "globalbroadcaster.h"
|
#include "globalbroadcaster.h"
|
||||||
|
#include "articleviewagent.hh"
|
||||||
using std::map;
|
using std::map;
|
||||||
using std::list;
|
using std::list;
|
||||||
|
|
||||||
|
@ -1077,7 +1078,7 @@ void ArticleView::attachToJavaScript() {
|
||||||
ui.definition->page()->setWebChannel(channel, QWebEngineScript::MainWorld);
|
ui.definition->page()->setWebChannel(channel, QWebEngineScript::MainWorld);
|
||||||
|
|
||||||
// register QObjects to be exposed to JavaScript
|
// register QObjects to be exposed to JavaScript
|
||||||
channel->registerObject(QStringLiteral("articleview"), this);
|
channel->registerObject(QStringLiteral("articleview"), new ArticleViewAgent(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArticleView::linkClicked( QUrl const & url_ )
|
void ArticleView::linkClicked( QUrl const & url_ )
|
||||||
|
|
20
articleviewagent.cc
Normal file
20
articleviewagent.cc
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#include "articleviewagent.hh"
|
||||||
|
|
||||||
|
ArticleViewAgent::ArticleViewAgent(QObject *parent)
|
||||||
|
: QObject{parent}
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
ArticleViewAgent::ArticleViewAgent(ArticleView *articleView)
|
||||||
|
: articleView(articleView)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArticleViewAgent::onJsActiveArticleChanged(QString const & id){
|
||||||
|
articleView->onJsActiveArticleChanged(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArticleViewAgent::linkClickedInHtml(QUrl const & url){
|
||||||
|
articleView->linkClickedInHtml(url);
|
||||||
|
}
|
23
articleviewagent.hh
Normal file
23
articleviewagent.hh
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#ifndef ARTICLEVIEWAGENT_HH
|
||||||
|
#define ARTICLEVIEWAGENT_HH
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include "articleview.hh"
|
||||||
|
|
||||||
|
class ArticleViewAgent : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
ArticleView* articleView;
|
||||||
|
public:
|
||||||
|
explicit ArticleViewAgent(QObject *parent = nullptr);
|
||||||
|
ArticleViewAgent(ArticleView* articleView);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
Q_INVOKABLE void onJsActiveArticleChanged(QString const & id);
|
||||||
|
Q_INVOKABLE void linkClickedInHtml( QUrl const & );
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ARTICLEVIEWAGENT_HH
|
|
@ -239,6 +239,7 @@ DEFINES += PROGRAM_VERSION=\\\"$$VERSION\\\"
|
||||||
|
|
||||||
# Input
|
# Input
|
||||||
HEADERS += folding.hh \
|
HEADERS += folding.hh \
|
||||||
|
articleviewagent.hh \
|
||||||
globalbroadcaster.h \
|
globalbroadcaster.h \
|
||||||
inc_case_folding.hh \
|
inc_case_folding.hh \
|
||||||
inc_diacritic_folding.hh \
|
inc_diacritic_folding.hh \
|
||||||
|
@ -380,6 +381,7 @@ FORMS += groups.ui \
|
||||||
fulltextsearch.ui
|
fulltextsearch.ui
|
||||||
|
|
||||||
SOURCES += folding.cc \
|
SOURCES += folding.cc \
|
||||||
|
articleviewagent.cc \
|
||||||
globalbroadcaster.cpp \
|
globalbroadcaster.cpp \
|
||||||
main.cc \
|
main.cc \
|
||||||
dictionary.cc \
|
dictionary.cc \
|
||||||
|
|
Loading…
Reference in a new issue