Commit 1b89af74 authored by Laurent Montel's avatar Laurent Montel 😁

Load jquery

parent 4e214c45
......@@ -31,6 +31,8 @@ set(libwebengineviewer_SRCS
${libwebengineviewer_webengine_SRCS}
)
qt5_add_resources(libwebengineviewer_webengine_SRCS jquery.qrc)
ecm_qt_declare_logging_category(libwebengineviewer_webengine_SRCS HEADER webengineviewer_debug.h IDENTIFIER WEBENGINEVIEWER_LOG CATEGORY_NAME log_webengineviewer)
......
<RCC>
<qresource prefix="/" >
<file>data/jquery.min.js</file>
</qresource>
</RCC>
......@@ -31,6 +31,7 @@ public:
{
}
QString mJquery;
QWidget *mCurrentWidget;
};
......@@ -38,6 +39,13 @@ WebEngineView::WebEngineView(QWidget *parent)
: QWebEngineView(parent),
d(new WebEngineViewer::WebEngineViewPrivate)
{
QFile file;
file.setFileName(QStringLiteral(":/data/jquery.min.js"));
file.open(QIODevice::ReadOnly);
d->mJquery = QString::fromUtf8(file.readAll());
d->mJquery.append(QStringLiteral("\nvar qt = { 'jQuery': jQuery.noConflict(true) };"));
file.close();
installEventFilter(this);
connect(this, &WebEngineView::loadFinished, this, &WebEngineView::slotLoadFinished);
}
......@@ -145,5 +153,6 @@ bool WebEngineView::eventFilter(QObject *obj, QEvent *event)
void WebEngineView::slotLoadFinished()
{
//TODO load jquery
page()->runJavaScript(d->mJquery);
//qDebug() << " d->mJquery" << d->mJquery;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment