fix: set shortcut context (#1644)

* fix: work around to fix ctrl+F in macos popup
This commit is contained in:
xiaoyifang 2024-07-06 21:57:18 +08:00 committed by GitHub
parent 456f7f1aaf
commit c4fa9b44e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 2 deletions

View file

@ -1774,7 +1774,16 @@ 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 );
connect( ui.searchInPageAction, &QAction::triggered, this, [ this, view ]() {
#ifdef Q_OS_MACOS
//workaround to fix macos popup page search Ctrl + F
if ( scanPopup && scanPopup->isActiveWindow() ) {
scanPopup->openSearch();
return;
}
#endif
view->openSearch();
} );
view->setSelectionBySingleClick( cfg.preferences.selectWordBySingleClick );

View file

@ -113,6 +113,7 @@ ScanPopup::ScanPopup( QWidget * parent,
connect( definition, &ArticleView::typingEvent, this, &ScanPopup::typingEvent );
openSearchAction.setShortcut( QKeySequence( "Ctrl+F" ) );
openSearchAction.setShortcutContext( Qt::WidgetWithChildrenShortcut );
addAction( &openSearchAction );
connect( &openSearchAction, &QAction::triggered, definition, &ArticleView::openSearch );
@ -1126,6 +1127,11 @@ void ScanPopup::setGroupByName( QString const & name ) const
gdWarning( "Group \"%s\" for popup window is not found\n", name.toUtf8().data() );
}
void ScanPopup::openSearch()
{
definition->openSearch();
}
void ScanPopup::alwaysOnTopClicked( bool checked )
{
bool wasVisible = isVisible();

View file

@ -81,7 +81,6 @@ signals:
/// Put translated word into Favorites
void sendWordToFavorites( QString const & word, unsigned groupId, bool );
#ifdef Q_OS_WIN32
/// Ask for source window is current translate tab
bool isGoldenDictWindow( HWND hwnd );
@ -102,6 +101,8 @@ public slots:
#ifdef HAVE_X11
void showEngagePopup();
#endif
void openSearch();
private: