article inspector debug info

This commit is contained in:
Xiao YiFang 2022-08-08 20:48:46 +08:00
parent e7f60a9335
commit c41068d608
5 changed files with 8 additions and 10 deletions

View file

@ -16,9 +16,8 @@ ArticleInspector::ArticleInspector( QWidget * parent ) : QWidget( parent, Qt::Wi
resize(800,600); resize(800,600);
} }
void ArticleInspector::setInspectPage( QWebEngineView * view ) void ArticleInspector::setInspectPage( QWebEnginePage * page )
{ {
auto page = view->page();
viewContainer->page()->setInspectedPage( page ); viewContainer->page()->setInspectedPage( page );
#if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) #if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
page->triggerAction( QWebEnginePage::InspectElement ); page->triggerAction( QWebEnginePage::InspectElement );
@ -28,10 +27,12 @@ void ArticleInspector::setInspectPage( QWebEngineView * view )
static bool first{ true }; static bool first{ true };
if( first ) if( first )
{ {
qDebug()<<"inspector,phase first time";
first = false; first = false;
} }
else else
{ {
qDebug()<<"inspector,phase not first time";
page->triggerAction( QWebEnginePage::InspectElement ); page->triggerAction( QWebEnginePage::InspectElement );
} }
#endif #endif

View file

@ -13,7 +13,7 @@ class ArticleInspector : public QWidget
public: public:
ArticleInspector( QWidget * parent = nullptr ); ArticleInspector( QWidget * parent = nullptr );
void setInspectPage( QWebEngineView * view); void setInspectPage( QWebEnginePage * page);
private: private:
virtual void closeEvent( QCloseEvent * ); virtual void closeEvent( QCloseEvent * );

View file

@ -528,7 +528,7 @@ void ArticleView::showAnticipation()
void ArticleView::inspectElement() void ArticleView::inspectElement()
{ {
emit inspectSignal( ui.definition ); emit inspectSignal( ui.definition->page() );
} }
void ArticleView::loadFinished( bool result ) void ArticleView::loadFinished( bool result )

View file

@ -290,7 +290,7 @@ signals:
/// signal finished javascript; /// signal finished javascript;
void notifyJavascriptFinished(); void notifyJavascriptFinished();
void inspectSignal(QWebEngineView * view); void inspectSignal(QWebEnginePage * page);
void saveBookmarkSignal( const QString & bookmark ); void saveBookmarkSignal( const QString & bookmark );

View file

@ -1655,11 +1655,8 @@ ArticleView * MainWindow::createNewTab( bool switchToIt,
dictionaryBar.toggleViewAction(), dictionaryBar.toggleViewAction(),
groupList ); groupList );
connect( view, &ArticleView::inspectSignal,this,[this](QWebEngineView * view){ connect( view, &ArticleView::inspectSignal,this,[this](QWebEnginePage * page){
if( !inspector ){ inspector->setInspectPage( page );
inspector = new ArticleInspector( this );
}
inspector->setInspectPage( view );
}); });
connect( view, SIGNAL( titleChanged( ArticleView *, QString const & ) ), connect( view, SIGNAL( titleChanged( ArticleView *, QString const & ) ),