This commit is contained in:
YiFang Xiao 2024-11-03 17:42:20 +08:00
parent c6387df392
commit 2c91b78e13
2 changed files with 20 additions and 3 deletions

View file

@ -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();

View file

@ -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();