From 17afc214787a6557a4dac9f39d57e3aca4b80722 Mon Sep 17 00:00:00 2001 From: xiaoyifang Date: Wed, 22 Sep 2021 11:20:42 +0800 Subject: [PATCH] 1.js undefined error 2,disable chrome auto play feature --- article_maker.cc | 9 +-------- articleview.cc | 2 +- mainwindow.cc | 1 + 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/article_maker.cc b/article_maker.cc index aa6075bc..3b63b7a3 100644 --- a/article_maker.cc +++ b/article_maker.cc @@ -185,7 +185,7 @@ std::string ArticleMaker::makeHtmlHeader( QString const & word, "el=document.getElementById( gdCurrentArticle ); el.className = el.className.replace(' gdactivearticle','');" "el=document.getElementById( 'gdfrom-' + newId ); el.className = el.className + ' gdactivearticle';" "gdCurrentArticle = 'gdfrom-' + newId; gdAudioLinks.current = newId;" - "articleview.onJsActiveArticleChanged(gdCurrentArticle); } }" + " } }" "var overIframeId = null;" "function gdSelectArticle( id ) {" "var selection = window.getSelection(); var range = document.createRange();" @@ -630,13 +630,6 @@ void ArticleRequest::bodyFinished() { head += "
"; } - else - { - // This is the first article - head += ""; - } bool collapse = false; if( articleSizeLimit >= 0 ) diff --git a/articleview.cc b/articleview.cc index 8ac3b459..28f57ea4 100644 --- a/articleview.cc +++ b/articleview.cc @@ -272,7 +272,6 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm, connect( ui.definition, SIGNAL( loadFinished( bool ) ), this, SLOT( loadFinished( bool ) ) ); - attachToJavaScript(); // connect( ui.definition->page(), SIGNAL( javaScriptWindowObjectCleared() ), // this, SLOT( attachToJavaScript() ) ); @@ -753,6 +752,7 @@ void ArticleView::setCurrentArticle( QString const & id, bool moveToIt ) "}").arg(articleId).arg(moveToIt).arg(id); ui.definition->page()->runJavaScript(script); + onJsActiveArticleChanged(id); // if ( getArticlesList().contains( id.mid( 7 ) ) ) // { diff --git a/mainwindow.cc b/mainwindow.cc index 58537061..16424cbd 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -1301,6 +1301,7 @@ void MainWindow::applyWebSettings() { QWebEngineSettings *defaultSettings = QWebEngineSettings::globalSettings(); defaultSettings->setAttribute(QWebEngineSettings::PluginsEnabled, cfg.preferences.enableWebPlugins); + defaultSettings->setAttribute(QWebEngineSettings::PlaybackRequiresUserGesture, false); //defaultSettings->setAttribute( QWebEngineSettings::DeveloperExtrasEnabled, true ); }