mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 23:34:06 +00:00
optimize: F12 improve
when close inspected windows,the inspect is still working .
This commit is contained in:
parent
e1730ab5f8
commit
ae8c2df4a8
25
article_inspect.cpp
Normal file
25
article_inspect.cpp
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#include "article_inspect.h"
|
||||||
|
#include <QCloseEvent>
|
||||||
|
article_inspect::article_inspect( QWidget * parent ) : QDialog( parent, Qt::WindowType::Window )
|
||||||
|
{
|
||||||
|
setAttribute( Qt::WidgetAttribute::WA_DeleteOnClose, false );
|
||||||
|
QVBoxLayout * v = new QVBoxLayout( this );
|
||||||
|
v->setSpacing( 0 );
|
||||||
|
v->setContentsMargins( 0, 0, 0, 0 );
|
||||||
|
inspectView = new QWebEngineView();
|
||||||
|
v->addWidget( inspectView );
|
||||||
|
}
|
||||||
|
|
||||||
|
void article_inspect::setInspectPage( QWebEnginePage * page )
|
||||||
|
{
|
||||||
|
this->inspectedPage = page;
|
||||||
|
page->setDevToolsPage( inspectView->page() );
|
||||||
|
page->triggerAction( QWebEnginePage::InspectElement );
|
||||||
|
raise();
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void article_inspect::closeEvent( QCloseEvent * ev )
|
||||||
|
{
|
||||||
|
inspectedPage->setDevToolsPage( nullptr );
|
||||||
|
}
|
24
article_inspect.h
Normal file
24
article_inspect.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef ARTICLE_INSPECT_H
|
||||||
|
#define ARTICLE_INSPECT_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QWebEngineView>
|
||||||
|
#include <QWebEnginePage>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
class article_inspect : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
QWebEngineView * inspectView = nullptr;
|
||||||
|
QWebEnginePage * inspectedPage = nullptr;
|
||||||
|
public:
|
||||||
|
article_inspect( QWidget * parent = nullptr );
|
||||||
|
|
||||||
|
void setInspectPage( QWebEnginePage * page );
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
virtual void closeEvent( QCloseEvent * );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ARTICLE_INSPECT_H
|
|
@ -507,21 +507,12 @@ void ArticleView::showAnticipation()
|
||||||
|
|
||||||
void ArticleView::inspectElement(){
|
void ArticleView::inspectElement(){
|
||||||
QWebEnginePage *page = ui.definition->page();
|
QWebEnginePage *page = ui.definition->page();
|
||||||
if (inspectView == nullptr) {
|
if( inspector == nullptr )
|
||||||
inspectView = new QWebEngineView();
|
{
|
||||||
page->setDevToolsPage( inspectView->page() );
|
inspector = new article_inspect( this );
|
||||||
devDialog = new QDialog( this );
|
inspector->setWindowTitle( tr( "Inspect" ) );
|
||||||
devDialog->setWindowTitle( tr( "Inspect" ) );
|
|
||||||
devDialog->setWindowFlags( Qt::Window );
|
|
||||||
devDialog->setAttribute( Qt::WidgetAttribute::WA_DeleteOnClose, false );
|
|
||||||
QVBoxLayout * v = new QVBoxLayout( devDialog );
|
|
||||||
v->setSpacing( 0 );
|
|
||||||
v->setContentsMargins( 0, 0, 0, 0 );
|
|
||||||
v->addWidget( inspectView );
|
|
||||||
}
|
}
|
||||||
page->triggerAction( QWebEnginePage::InspectElement );
|
inspector->setInspectPage( page );
|
||||||
devDialog->raise();
|
|
||||||
devDialog->show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArticleView::loadFinished( bool result )
|
void ArticleView::loadFinished( bool result )
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "groupcombobox.hh"
|
#include "groupcombobox.hh"
|
||||||
#include "ui_articleview.h"
|
#include "ui_articleview.h"
|
||||||
#include "globalbroadcaster.h"
|
#include "globalbroadcaster.h"
|
||||||
|
#include "article_inspect.h"
|
||||||
|
|
||||||
class ResourceToSaveHandler;
|
class ResourceToSaveHandler;
|
||||||
class ArticleViewAgent ;
|
class ArticleViewAgent ;
|
||||||
|
@ -45,8 +46,7 @@ class ArticleView: public QFrame
|
||||||
QString rangeVarName;
|
QString rangeVarName;
|
||||||
|
|
||||||
//used to hold the F12 inspect source view.
|
//used to hold the F12 inspect source view.
|
||||||
QWebEngineView *inspectView = nullptr;
|
article_inspect * inspector = nullptr;
|
||||||
QDialog * devDialog = nullptr;
|
|
||||||
|
|
||||||
/// Any resource we've decided to download off the dictionary gets stored here.
|
/// 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
|
/// Full vector capacity is used for search requests, where we have to make
|
||||||
|
|
|
@ -217,6 +217,7 @@ DEFINES += PROGRAM_VERSION=\\\"$$VERSION\\\"
|
||||||
|
|
||||||
# Input
|
# Input
|
||||||
HEADERS += folding.hh \
|
HEADERS += folding.hh \
|
||||||
|
article_inspect.h \
|
||||||
globalbroadcaster.h \
|
globalbroadcaster.h \
|
||||||
inc_case_folding.hh \
|
inc_case_folding.hh \
|
||||||
inc_diacritic_folding.hh \
|
inc_diacritic_folding.hh \
|
||||||
|
@ -356,6 +357,7 @@ FORMS += groups.ui \
|
||||||
fulltextsearch.ui
|
fulltextsearch.ui
|
||||||
|
|
||||||
SOURCES += folding.cc \
|
SOURCES += folding.cc \
|
||||||
|
article_inspect.cpp \
|
||||||
globalbroadcaster.cpp \
|
globalbroadcaster.cpp \
|
||||||
main.cc \
|
main.cc \
|
||||||
dictionary.cc \
|
dictionary.cc \
|
||||||
|
|
Loading…
Reference in a new issue