Allow shrinking scan popup's toolbar height

Before this commit, when group combobox was visible, the Alt+- shortcut
reduced the heights of group combobox and translate line in the main
window, but not in scan popup. These UI elements in scan popup did not
become lower than at the time scan popup was constructed.

Applying the solution from the main window fixes this bug (#1108).
This commit is contained in:
Igor Kushnir 2019-01-29 13:01:30 +02:00
parent c88774151c
commit ec96d6ac5a
2 changed files with 21 additions and 7 deletions

View file

@ -847,15 +847,29 @@ void ScanPopup::typingEvent( QString const & t )
bool ScanPopup::eventFilter( QObject * watched, QEvent * event ) bool ScanPopup::eventFilter( QObject * watched, QEvent * event )
{ {
if ( event->type() == QEvent::FocusIn && watched == ui.translateBox->translateLine() ) if ( watched == ui.translateBox->translateLine() )
{ {
QFocusEvent * focusEvent = static_cast< QFocusEvent * >( event ); if ( event->type() == QEvent::FocusIn )
{
QFocusEvent * focusEvent = static_cast< QFocusEvent * >( event );
// select all on mouse click // select all on mouse click
if ( focusEvent->reason() == Qt::MouseFocusReason ) { if ( focusEvent->reason() == Qt::MouseFocusReason ) {
QTimer::singleShot(0, this, SLOT(focusTranslateLine())); QTimer::singleShot(0, this, SLOT(focusTranslateLine()));
}
return false;
}
if ( event->type() == QEvent::Resize )
{
// The UI looks ugly when group combobox is higher than translate line.
// Make the height of the combobox the same as the line edit's height.
// The fonts of these UI items should be kept in sync by applyWordsZoomLevel()
// so that text in the combobox is not clipped.
const QResizeEvent * const resizeEvent = static_cast< const QResizeEvent * >( event );
ui.groupList->setFixedHeight( resizeEvent->size().height() );
return false;
} }
return false;
} }
if ( mouseIntercepted ) if ( mouseIntercepted )

View file

@ -83,7 +83,7 @@
<item> <item>
<widget class="TranslateBox" name="translateBox"> <widget class="TranslateBox" name="translateBox">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>