From 70d31a8f4bb2261f90a28911f3ee84bb92d53099 Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Thu, 13 Jun 2024 00:09:36 +0800 Subject: [PATCH] =?UTF-8?q?opt=EF=BC=9A=20tab=20icon=20change=20logic=20re?= =?UTF-8?q?write?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #1554 --- src/ui/articleview.cc | 20 -------------------- src/ui/articleview.hh | 3 --- src/ui/mainwindow.cc | 6 ++++-- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/src/ui/articleview.cc b/src/ui/articleview.cc index 51e8de46..a09e8e36 100644 --- a/src/ui/articleview.cc +++ b/src/ui/articleview.cc @@ -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" ) ) diff --git a/src/ui/articleview.hh b/src/ui/articleview.hh index dc347774..1bfd7bcc 100644 --- a/src/ui/articleview.hh +++ b/src/ui/articleview.hh @@ -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 ); diff --git a/src/ui/mainwindow.cc b/src/ui/mainwindow.cc index b52e888f..f3700256 100644 --- a/src/ui/mainwindow.cc +++ b/src/ui/mainwindow.cc @@ -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();