Merge pull request #1064 from xiaoyifang/fix/completer-signal

fix: qcompleter lost signal when qlineedit lost focus
This commit is contained in:
xiaoyifang 2023-08-12 12:55:56 +08:00 committed by GitHub
commit 64b1863208
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View file

@ -2396,10 +2396,7 @@ void MainWindow::respondToTranslationRequest( QString const & word, bool checkMo
activateWindow();
}
auto view = getCurrentArticleView();
view->activateWindow();
view->focus();
focusArticleView();
}
}
@ -2586,7 +2583,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
activateWindow();
}
getCurrentArticleView()->focus();
focusArticleView();
return cfg.preferences.searchInDock;
}

View file

@ -79,9 +79,17 @@ void TranslateBox::setSizePolicy( QSizePolicy policy )
void TranslateBox::setModel( QStringList & _words )
{
disconnect( completer, 0, translate_line, 0 );
auto model = (QStringListModel *)( completer->model() );
model->setStringList( _words );
connect( completer,
QOverload< const QString & >::of( &QCompleter::activated ),
translate_line,
[ & ]( const QString & ) {
emit translate_line->returnPressed();
} );
}
void TranslateBox::showPopup()