mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
1
This commit is contained in:
parent
c6387df392
commit
2c91b78e13
|
@ -42,6 +42,8 @@ class ArticleView: public QWidget
|
|||
QWebChannel * channel;
|
||||
ArticleViewAgent * agent;
|
||||
|
||||
ArticleView * parentView;
|
||||
|
||||
AnkiConnector * ankiConnector;
|
||||
|
||||
QAction pasteAction, articleUpAction, articleDownAction, goBackAction, goForwardAction, selectCurrentArticleAction,
|
||||
|
@ -101,6 +103,15 @@ public:
|
|||
AudioPlayerPtr const & audioPlayer_,
|
||||
Config::Class const & cfg_ );
|
||||
|
||||
void setParentView( ArticleView * parentView_ )
|
||||
{
|
||||
parentView = parentView_;
|
||||
}
|
||||
|
||||
ArticleView * getParentView()
|
||||
{
|
||||
return parentView;
|
||||
}
|
||||
void setCurrentGroupId( unsigned currengGrgId );
|
||||
unsigned getCurrentGroupId();
|
||||
|
||||
|
|
|
@ -2173,7 +2173,7 @@ void MainWindow::updateBackForwardButtons()
|
|||
{
|
||||
ArticleView * view = getCurrentArticleView();
|
||||
|
||||
if ( view ) {
|
||||
if ( view != nullptr ) {
|
||||
navBack->setEnabled( view->canGoBack() );
|
||||
navForward->setEnabled( view->canGoForward() );
|
||||
}
|
||||
|
@ -3714,7 +3714,13 @@ void MainWindow::messageFromAnotherInstanceReceived( QString const & message )
|
|||
ArticleView * MainWindow::getCurrentArticleView()
|
||||
{
|
||||
if ( QWidget * cw = ui.tabWidget->currentWidget() ) {
|
||||
return dynamic_cast< ArticleView * >( cw );
|
||||
auto * pView = dynamic_cast< ArticleView * >( cw );
|
||||
if ( pView != nullptr ) {
|
||||
if ( pView->getParentView() != nullptr ) {
|
||||
return pView->getParentView();
|
||||
}
|
||||
}
|
||||
return pView;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -4375,7 +4381,7 @@ void MainWindow::openWebsiteInNewTab( QString name, QString url )
|
|||
QString escaped = Utils::escapeAmps( name );
|
||||
|
||||
auto * view = new ArticleView( this, articleNetMgr, audioPlayerFactory.player(), cfg );
|
||||
|
||||
view->setParentView( getCurrentArticleView() );
|
||||
connect( view, &ArticleView::inspectSignal, this, &MainWindow::inspectElement );
|
||||
view->load( url );
|
||||
int index = cfg.preferences.newTabsOpenAfterCurrentOne ? ui.tabWidget->currentIndex() + 1 : ui.tabWidget->count();
|
||||
|
|
Loading…
Reference in a new issue