From c41068d6080571252a3f1a9e95d2546e8da1724c Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Mon, 8 Aug 2022 20:48:46 +0800 Subject: [PATCH] article inspector debug info --- article_inspect.cpp | 5 +++-- article_inspect.h | 2 +- articleview.cc | 2 +- articleview.hh | 2 +- mainwindow.cc | 7 ++----- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/article_inspect.cpp b/article_inspect.cpp index 69bd1b13..1cdf821b 100644 --- a/article_inspect.cpp +++ b/article_inspect.cpp @@ -16,9 +16,8 @@ ArticleInspector::ArticleInspector( QWidget * parent ) : QWidget( parent, Qt::Wi resize(800,600); } -void ArticleInspector::setInspectPage( QWebEngineView * view ) +void ArticleInspector::setInspectPage( QWebEnginePage * page ) { - auto page = view->page(); viewContainer->page()->setInspectedPage( page ); #if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) page->triggerAction( QWebEnginePage::InspectElement ); @@ -28,10 +27,12 @@ void ArticleInspector::setInspectPage( QWebEngineView * view ) static bool first{ true }; if( first ) { + qDebug()<<"inspector,phase first time"; first = false; } else { + qDebug()<<"inspector,phase not first time"; page->triggerAction( QWebEnginePage::InspectElement ); } #endif diff --git a/article_inspect.h b/article_inspect.h index 8c7b50c5..ba4826e0 100644 --- a/article_inspect.h +++ b/article_inspect.h @@ -13,7 +13,7 @@ class ArticleInspector : public QWidget public: ArticleInspector( QWidget * parent = nullptr ); - void setInspectPage( QWebEngineView * view); + void setInspectPage( QWebEnginePage * page); private: virtual void closeEvent( QCloseEvent * ); diff --git a/articleview.cc b/articleview.cc index ada189cf..302ebbbc 100644 --- a/articleview.cc +++ b/articleview.cc @@ -528,7 +528,7 @@ void ArticleView::showAnticipation() void ArticleView::inspectElement() { - emit inspectSignal( ui.definition ); + emit inspectSignal( ui.definition->page() ); } void ArticleView::loadFinished( bool result ) diff --git a/articleview.hh b/articleview.hh index 8a09d71e..c4131053 100644 --- a/articleview.hh +++ b/articleview.hh @@ -290,7 +290,7 @@ signals: /// signal finished javascript; void notifyJavascriptFinished(); - void inspectSignal(QWebEngineView * view); + void inspectSignal(QWebEnginePage * page); void saveBookmarkSignal( const QString & bookmark ); diff --git a/mainwindow.cc b/mainwindow.cc index 91271300..fac44c72 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -1655,11 +1655,8 @@ ArticleView * MainWindow::createNewTab( bool switchToIt, dictionaryBar.toggleViewAction(), groupList ); - connect( view, &ArticleView::inspectSignal,this,[this](QWebEngineView * view){ - if( !inspector ){ - inspector = new ArticleInspector( this ); - } - inspector->setInspectPage( view ); + connect( view, &ArticleView::inspectSignal,this,[this](QWebEnginePage * page){ + inspector->setInspectPage( page ); }); connect( view, SIGNAL( titleChanged( ArticleView *, QString const & ) ),