Skip to content

Commit

Permalink
opt: use italic to indicate the no results (#1232)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
xiaoyifang and autofix-ci[bot] authored Oct 15, 2023
1 parent 7767d42 commit 0fbcdda
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
17 changes: 8 additions & 9 deletions src/common/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}

Expand Down
13 changes: 4 additions & 9 deletions src/ui/scanpopup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 );
}
}
Expand Down

0 comments on commit 0fbcdda

Please sign in to comment.