diff --git a/src/ui/mainwindow.cc b/src/ui/mainwindow.cc index 1911de5b..a0579e70 100644 --- a/src/ui/mainwindow.cc +++ b/src/ui/mainwindow.cc @@ -670,7 +670,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ): connect( ui.translateLine, &QLineEdit::returnPressed, [ this ]() { translateInputFinished( true ); } ); - connect( translateBox->translateLine(), &QLineEdit::returnPressed, [ this ]() { + connect( translateBox, &TranslateBox::returnPressed, [ this ]() { translateInputFinished( true ); } ); diff --git a/src/ui/translatebox.cc b/src/ui/translatebox.cc index 34a2aa5e..53848923 100644 --- a/src/ui/translatebox.cc +++ b/src/ui/translatebox.cc @@ -53,8 +53,9 @@ TranslateBox::TranslateBox( QWidget * parent ): connect( completer, QOverload< const QString & >::of( &QCompleter::activated ), translate_line, - [ & ]( const QString & ) { - emit translate_line->returnPressed(); + [ & ]( const QString & text ) { + translate_line->setText( text ); + emit returnPressed(); } ); } @@ -89,7 +90,7 @@ void TranslateBox::setModel( QStringList & _words ) translate_line, [ & ]( const QString & text) { translate_line->setText(text); - emit translate_line->returnPressed(); + emit returnPressed(); } ); } diff --git a/src/ui/translatebox.hh b/src/ui/translatebox.hh index 00cdf8c3..e6a3b2b8 100644 --- a/src/ui/translatebox.hh +++ b/src/ui/translatebox.hh @@ -27,6 +27,9 @@ public: public slots: void setPopupEnabled( bool enable ); +signals: + void returnPressed(); + private slots: void showPopup(); void rightButtonClicked();