From 57a5c526208d04b63381e5ff8d4319c2bb179a1f Mon Sep 17 00:00:00 2001 From: shenleban tongying Date: Thu, 21 Mar 2024 19:09:05 -0400 Subject: [PATCH] clean: remove unnecessary passing of openSearchAction to ArticleView's ctor --- src/ui/articleview.cc | 5 ----- src/ui/articleview.hh | 8 +++----- src/ui/mainwindow.cc | 3 ++- src/ui/scanpopup.cc | 6 +++--- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/ui/articleview.cc b/src/ui/articleview.cc index fce90d76..ed6940b5 100644 --- a/src/ui/articleview.cc +++ b/src/ui/articleview.cc @@ -94,7 +94,6 @@ ArticleView::ArticleView( QWidget * parent, Instances::Groups const & groups_, bool popupView_, Config::Class const & cfg_, - QAction & openSearchAction_, QLineEdit const * translateLine_, QAction * dictionaryBarToggled_, GroupComboBox const * groupComboBox_ ): @@ -113,7 +112,6 @@ ArticleView::ArticleView( QWidget * parent, selectCurrentArticleAction( this ), copyAsTextAction( this ), inspectAction( this ), - openSearchAction( openSearchAction_ ), searchIsOpened( false ), dictionaryBarToggled( dictionaryBarToggled_ ), groupComboBox( groupComboBox_ ), @@ -201,9 +199,6 @@ ArticleView::ArticleView( QWidget * parent, webview->addAction( &articleDownAction ); connect( &articleDownAction, &QAction::triggered, this, &ArticleView::moveOneArticleDown ); - webview->addAction( &openSearchAction ); - connect( &openSearchAction, &QAction::triggered, this, &ArticleView::openSearch ); - selectCurrentArticleAction.setShortcut( QKeySequence( "Ctrl+Shift+A" ) ); selectCurrentArticleAction.setText( tr( "Select Current Article" ) ); webview->addAction( &selectCurrentArticleAction ); diff --git a/src/ui/articleview.hh b/src/ui/articleview.hh index 7544be7e..a29d05df 100644 --- a/src/ui/articleview.hh +++ b/src/ui/articleview.hh @@ -49,7 +49,6 @@ class ArticleView: public QWidget QAction pasteAction, articleUpAction, articleDownAction, goBackAction, goForwardAction, selectCurrentArticleAction, copyAsTextAction, inspectAction; - QAction & openSearchAction; bool searchIsOpened; bool expandOptionalParts; QString rangeVarName; @@ -105,7 +104,6 @@ public: Instances::Groups const &, bool popupView, Config::Class const & cfg, - QAction & openSearchAction_, QLineEdit const * translateLine, QAction * dictionaryBarToggled = nullptr, GroupComboBox const * groupComboBox = nullptr ); @@ -319,6 +317,9 @@ signals: public slots: + /// Opens the search (Ctrl+F) + void openSearch(); + void on_searchPrevious_clicked(); void on_searchNext_clicked(); @@ -361,9 +362,6 @@ private slots: /// Nagivates to the next article relative to the active one. void moveOneArticleDown(); - /// Opens the search area - void openSearch(); - void on_searchText_textEdited(); void on_searchText_returnPressed(); void on_searchCloseButton_clicked(); diff --git a/src/ui/mainwindow.cc b/src/ui/mainwindow.cc index 2cd1cdc3..c77092f0 100644 --- a/src/ui/mainwindow.cc +++ b/src/ui/mainwindow.cc @@ -1783,7 +1783,6 @@ ArticleView * MainWindow::createNewTab( bool switchToIt, QString const & name ) groupInstances, false, cfg, - *ui.searchInPageAction, translateLine, dictionaryBar.toggleViewAction(), groupList ); @@ -1823,6 +1822,8 @@ ArticleView * MainWindow::createNewTab( bool switchToIt, QString const & name ) connect( view, &ArticleView::zoomOut, this, &MainWindow::zoomout ); connect( view, &ArticleView::saveBookmarkSignal, this, &MainWindow::addBookmarkToFavorite ); + connect( ui.searchInPageAction, &QAction::triggered, view, &ArticleView::openSearch ); + view->setSelectionBySingleClick( cfg.preferences.selectWordBySingleClick ); int index = cfg.preferences.newTabsOpenAfterCurrentOne ? ui.tabWidget->currentIndex() + 1 : ui.tabWidget->count(); diff --git a/src/ui/scanpopup.cc b/src/ui/scanpopup.cc index 5b4aa34d..c52eae24 100644 --- a/src/ui/scanpopup.cc +++ b/src/ui/scanpopup.cc @@ -85,8 +85,6 @@ ScanPopup::ScanPopup( QWidget * parent, { ui.setupUi( this ); - openSearchAction.setShortcut( QKeySequence( "Ctrl+F" ) ); - if ( layoutDirection() == Qt::RightToLeft ) { // Adjust button icons for Right-To-Left layout ui.goBackButton->setIcon( QIcon( ":/icons/next.svg" ) ); @@ -104,7 +102,6 @@ ScanPopup::ScanPopup( QWidget * parent, groups, true, cfg, - openSearchAction, ui.translateBox->translateLine(), dictionaryBar.toggleViewAction() ); @@ -114,6 +111,9 @@ ScanPopup::ScanPopup( QWidget * parent, connect( definition, &ArticleView::sendWordToHistory, this, &ScanPopup::sendWordToHistory ); connect( definition, &ArticleView::typingEvent, this, &ScanPopup::typingEvent ); + openSearchAction.setShortcut( QKeySequence( "Ctrl+F" ) ); + connect( &openSearchAction, &QAction::triggered, definition, &ArticleView::openSearch ); + wordListDefaultFont = ui.translateBox->completerWidget()->font(); translateLineDefaultFont = ui.translateBox->font(); groupListDefaultFont = ui.groupList->font();