mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
fix regression: select translation line text when got focused (#841)
* fix: select translation line text when got focused
* 🎨 apply clang-format changes
* fix: code smells
---------
Co-authored-by: xiaoyifang <xiaoyifang@users.noreply.github.com>
This commit is contained in:
parent
fe1c609b49
commit
9c1a77a3f8
|
@ -2507,6 +2507,15 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
|
|||
}
|
||||
}
|
||||
|
||||
if ( ev->type() == QEvent::FocusIn ) {
|
||||
|
||||
// select all on mouse click
|
||||
if ( const auto focusEvent = dynamic_cast< QFocusEvent * >( ev ); focusEvent->reason() == Qt::MouseFocusReason ) {
|
||||
QTimer::singleShot( 0, this, SLOT( focusTranslateLine() ) );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ev->type() == QEvent::Resize ) {
|
||||
QResizeEvent * resizeEvent = static_cast< QResizeEvent * >( ev );
|
||||
groupList->setFixedHeight( resizeEvent->size().height() );
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <QScrollBar>
|
||||
#include <QStyle>
|
||||
#include <QStringListModel>
|
||||
#include <QTimer>
|
||||
|
||||
TranslateBox::TranslateBox( QWidget * parent ):
|
||||
QWidget( parent ),
|
||||
|
@ -49,9 +50,12 @@ TranslateBox::TranslateBox( QWidget * parent ):
|
|||
completer->setCompletionMode( QCompleter::UnfilteredPopupCompletion );
|
||||
completer->setMaxVisibleItems( 16 );
|
||||
|
||||
connect( completer, QOverload< const QString & >::of( &QCompleter::activated ), this, [ = ]( const QString & text ) {
|
||||
emit translate_line->returnPressed();
|
||||
} );
|
||||
connect( completer,
|
||||
QOverload< const QString & >::of( &QCompleter::activated ),
|
||||
translate_line,
|
||||
[ & ]( const QString & ) {
|
||||
emit translate_line->returnPressed();
|
||||
} );
|
||||
}
|
||||
|
||||
void TranslateBox::setText( const QString & text, bool showPopup )
|
||||
|
|
Loading…
Reference in a new issue