Merge remote-tracking branch 'origin/feature/optimize-F12' into staged

This commit is contained in:
xiaoyifang 2022-02-19 18:23:12 +08:00
commit 69f7627668
2 changed files with 25 additions and 10 deletions

View file

@ -321,15 +321,8 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm, Au
inspectAction.setText( tr( "Inspect" ) );
ui.definition->addAction( &inspectAction );
QWebEnginePage *page = ui.definition->page();
connect(&inspectAction, &QAction::triggered, this, [page, this]() {
if (inspectView == nullptr || !inspectView->isVisible()) {
inspectView = new QWebEngineView();
page->setDevToolsPage(inspectView->page());
page->triggerAction(QWebEnginePage::InspectElement);
inspectView->show();
}
});
connect(&inspectAction, &QAction::triggered, this, &ArticleView::inspectElement);
ui.definition->installEventFilter( this );
ui.searchFrame->installEventFilter( this );
@ -512,6 +505,27 @@ void ArticleView::showAnticipation()
ui.definition->setCursor( Qt::WaitCursor );
}
void ArticleView::inspectElement(){
QWebEnginePage *page = ui.definition->page();
if (inspectView == nullptr) {
inspectView = new QWebEngineView();
page->setDevToolsPage( inspectView->page() );
devDialog = new QDialog( this );
devDialog->setWindowTitle( tr( "Inspect" ) );
devDialog->setWindowFlags( Qt::Window );
devDialog->setContentsMargins( 0, 0, 0, 0 );
devDialog->setAttribute( Qt::WidgetAttribute::WA_DeleteOnClose, false );
QVBoxLayout * v=new QVBoxLayout( devDialog );
// devDialog->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
// inspectView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding);
// inspectView->setContentsMargins(0,0,0,0);
v->addWidget( inspectView );
}
page->triggerAction( QWebEnginePage::InspectElement );
devDialog->raise();
devDialog->show();
}
void ArticleView::loadFinished( bool result )
{
setZoomFactor(cfg.preferences.zoomFactor);

View file

@ -46,6 +46,7 @@ class ArticleView: public QFrame
//used to hold the F12 inspect source view.
QWebEngineView *inspectView = nullptr;
QDialog * devDialog = nullptr;
/// Any resource we've decided to download off the dictionary gets stored here.
/// Full vector capacity is used for search requests, where we have to make
@ -303,7 +304,7 @@ public slots:
//aim to receive signal from html. the fragment url click to navigation through page wil not be intecepted by weburlinteceptor
Q_INVOKABLE void linkClickedInHtml( QUrl const & );
private slots:
void inspectElement();
void loadFinished( bool ok );
void loadProgress(int);
void handleTitleChanged( QString const & title );