Skip to content
Permalink
Browse files

Show tooltip in locator actions results if different to action title

  • Loading branch information
nyalldawson committed May 11, 2018
1 parent 0c24e29 commit b87a92b26cb734ad7769995f2d2dab364be17035
Showing with 19 additions and 0 deletions.
  1. +19 −0 src/app/locator/qgsinbuiltlocatorfilters.cpp
@@ -144,6 +144,9 @@ void QgsActionLocatorFilter::searchActions( const QString &string, QWidget *pare
{
searchActions( string, widget, found );
}

QRegularExpression extractFromTooltip( QStringLiteral( "<b>(.*)</b>" ) );

Q_FOREACH ( QAction *action, parent->actions() )
{
if ( action->menu() )
@@ -159,6 +162,22 @@ void QgsActionLocatorFilter::searchActions( const QString &string, QWidget *pare

QString searchText = action->text();
searchText.replace( '&', QString() );

QString tooltip = action->toolTip();
QRegularExpressionMatch match = extractFromTooltip.match( tooltip );
if ( match.hasMatch() )
{
tooltip = match.captured( 1 );
}
tooltip.replace( QStringLiteral( "..." ), QString() );
tooltip.replace( QStringLiteral( "" ), QString() );
searchText.replace( QStringLiteral( "..." ), QString() );
searchText.replace( QStringLiteral( "" ), QString() );
if ( searchText.trimmed().compare( tooltip.trimmed(), Qt::CaseInsensitive ) != 0 )
{
searchText += QStringLiteral( " (%1)" ).arg( tooltip.trimmed() );
}

if ( stringMatches( searchText, string ) )
{
QgsLocatorResult result;

0 comments on commit b87a92b

Please sign in to comment.
You can’t perform that action at this time.