opt: use italic to indicate the no results (#1232)

* opt: use italic to indicate the no results

* [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-10-15 22:36:39 +08:00 committed by GitHub
parent 7767d42d2a
commit 0fbcdda72f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 18 deletions

View file

@ -38,17 +38,16 @@ QString Utils::Url::getSchemeAndHost( QUrl const & url )
void Utils::Widget::setNoResultColor( QWidget * widget, bool noResult )
{
if ( noResult ) {
QPalette pal( widget->palette() );
// #febb7d
QRgb rgb = 0xfebb7d;
pal.setColor( QPalette::Base, QColor( rgb ) );
widget->setAutoFillBackground( true );
widget->setPalette( pal );
auto font = widget->font();
font.setItalic( true );
widget->setFont( font );
}
else {
QPalette pal( widget->style()->standardPalette() );
widget->setAutoFillBackground( true );
widget->setPalette( pal );
auto font = widget->font();
font.setItalic( false );
widget->setFont( font );
}
}

View file

@ -275,9 +275,6 @@ ScanPopup::ScanPopup( QWidget * parent,
void ScanPopup::refresh()
{
// TODO: GroupCombox's update should be moved inside GroupCombox
// currentIndexChanged() signal is very trigger-happy. To avoid triggering
// it, we disconnect it while we're clearing and filling back groups.
disconnect( ui.groupList, &GroupComboBox::currentIndexChanged, this, &ScanPopup::currentGroupChanged );
@ -627,13 +624,7 @@ void ScanPopup::updateSuggestionList( QString const & text )
// An empty request always results in an empty result
wordFinder.cancel();
// Reset the noResults mark if it's on right now
if ( ui.translateBox->translateLine()->property( "noResults" ).toBool() ) {
auto translateLine = ui.translateBox->translateLine();
translateLine->setProperty( "noResults", false );
Utils::Widget::setNoResultColor( translateLine, false );
}
return;
}
@ -899,6 +890,10 @@ void ScanPopup::prefixMatchFinished()
_results << fst;
}
// Reset the noResults mark if it's on right now
auto translateLine = ui.translateBox->translateLine();
Utils::Widget::setNoResultColor( translateLine, _results.isEmpty() );
ui.translateBox->setModel( _results );
}
}