opt: tab icon change logic rewrite

fix #1554
This commit is contained in:
YiFang Xiao 2024-06-13 00:09:36 +08:00 committed by xiaoyifang
parent 1580220aa3
commit 70d31a8f4b
3 changed files with 4 additions and 25 deletions

View file

@ -177,8 +177,6 @@ ArticleView::ArticleView( QWidget * parent,
connect( webview->page(), &QWebEnginePage::titleChanged, this, &ArticleView::handleTitleChanged );
connect( webview->page(), &QWebEnginePage::urlChanged, this, &ArticleView::handleUrlChanged );
connect( webview, &QWidget::customContextMenuRequested, this, &ArticleView::contextMenuRequested );
connect( webview->page(), &QWebEnginePage::linkHovered, this, &ArticleView::linkHovered );
@ -486,24 +484,6 @@ void ArticleView::handleTitleChanged( QString const & title )
emit titleChanged( this, title );
}
void ArticleView::handleUrlChanged( QUrl const & url )
{
QIcon icon;
if ( unsigned group = getGroup( url ) ) {
// Find the group's instance corresponding to the fragment value
for ( auto const & g : groups ) {
if ( g.id == group ) {
// Found it
icon = g.makeIcon();
break;
}
}
}
emit iconChanged( this, icon );
}
unsigned ArticleView::getGroup( QUrl const & url )
{
if ( url.scheme() == "gdlookup" && Utils::Url::hasQueryItem( url, "group" ) )

View file

@ -261,8 +261,6 @@ public:
signals:
void iconChanged( ArticleView *, QIcon const & icon );
void titleChanged( ArticleView *, QString const & title );
void pageLoaded( ArticleView * );
@ -338,7 +336,6 @@ private slots:
void inspectElement();
void loadFinished( bool ok );
void handleTitleChanged( QString const & title );
void handleUrlChanged( QUrl const & url );
void attachWebChannelToHtml();
void linkHovered( const QString & link );

View file

@ -1760,8 +1760,6 @@ ArticleView * MainWindow::createNewTab( bool switchToIt, QString const & name )
connect( view, &ArticleView::titleChanged, this, &MainWindow::titleChanged );
connect( view, &ArticleView::iconChanged, this, &MainWindow::iconChanged );
connect( view, &ArticleView::pageLoaded, this, &MainWindow::pageLoaded );
connect( view, &ArticleView::updateFoundInDictsList, this, &MainWindow::updateFoundInDictsList );
@ -2297,6 +2295,10 @@ void MainWindow::currentGroupChanged( int )
if ( igrp ) {
GlobalBroadcaster::instance()->currentGroupId = grg_id;
ui.tabWidget->setTabIcon( ui.tabWidget->currentIndex(), igrp->makeIcon() );
}
else {
ui.tabWidget->setTabIcon( ui.tabWidget->currentIndex(), QIcon() );
}
updateDictionaryBar();