fix: translatebox press Enter does not translate the selected item (#1134)

* fix: translatebox press Enter does not translate the selected item

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
xiaoyifang 2023-09-10 17:52:18 +08:00 committed by GitHub
parent 283b406a8a
commit 8dd9119aec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View file

@ -670,7 +670,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
connect( ui.translateLine, &QLineEdit::returnPressed, [ this ]() { connect( ui.translateLine, &QLineEdit::returnPressed, [ this ]() {
translateInputFinished( true ); translateInputFinished( true );
} ); } );
connect( translateBox->translateLine(), &QLineEdit::returnPressed, [ this ]() { connect( translateBox, &TranslateBox::returnPressed, [ this ]() {
translateInputFinished( true ); translateInputFinished( true );
} ); } );

View file

@ -53,8 +53,9 @@ TranslateBox::TranslateBox( QWidget * parent ):
connect( completer, connect( completer,
QOverload< const QString & >::of( &QCompleter::activated ), QOverload< const QString & >::of( &QCompleter::activated ),
translate_line, translate_line,
[ & ]( const QString & ) { [ & ]( const QString & text ) {
emit translate_line->returnPressed(); translate_line->setText( text );
emit returnPressed();
} ); } );
} }
@ -89,7 +90,7 @@ void TranslateBox::setModel( QStringList & _words )
translate_line, translate_line,
[ & ]( const QString & text) { [ & ]( const QString & text) {
translate_line->setText(text); translate_line->setText(text);
emit translate_line->returnPressed(); emit returnPressed();
} ); } );
} }

View file

@ -27,6 +27,9 @@ public:
public slots: public slots:
void setPopupEnabled( bool enable ); void setPopupEnabled( bool enable );
signals:
void returnPressed();
private slots: private slots:
void showPopup(); void showPopup();
void rightButtonClicked(); void rightButtonClicked();