From ec96d6ac5a46c8bb5caf67052e5c260a86cab198 Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Tue, 29 Jan 2019 13:01:30 +0200 Subject: [PATCH] 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). --- scanpopup.cc | 26 ++++++++++++++++++++------ scanpopup.ui | 2 +- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/scanpopup.cc b/scanpopup.cc index be5f6441..ba0f614b 100644 --- a/scanpopup.cc +++ b/scanpopup.cc @@ -847,15 +847,29 @@ void ScanPopup::typingEvent( QString const & t ) 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 - if ( focusEvent->reason() == Qt::MouseFocusReason ) { - QTimer::singleShot(0, this, SLOT(focusTranslateLine())); + // select all on mouse click + if ( focusEvent->reason() == Qt::MouseFocusReason ) { + 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 ) diff --git a/scanpopup.ui b/scanpopup.ui index 4d48b12a..a9dd1c58 100644 --- a/scanpopup.ui +++ b/scanpopup.ui @@ -83,7 +83,7 @@ - + 0 0