Skip to content

Commit fc5c065

Browse files
committedJan 11, 2019
Update tooltip to reflect color setting
1 parent 56b363e commit fc5c065

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed
 

‎src/gui/qgspropertyoverridebutton.cpp

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -749,25 +749,31 @@ void QgsPropertyOverrideButton::updateGui()
749749

750750
QIcon icon = QgsApplication::getThemeIcon( QStringLiteral( "/mIconDataDefine.svg" ) );
751751
QString deftip = tr( "undefined" );
752+
QString deftype;
752753
if ( mProperty.propertyType() == QgsProperty::ExpressionBasedProperty && hasExp )
753754
{
754755
icon = mProperty.isActive() ? QgsApplication::getThemeIcon( QStringLiteral( "/mIconDataDefineExpressionOn.svg" ) ) : QgsApplication::getThemeIcon( QStringLiteral( "/mIconDataDefineExpression.svg" ) );
755756

756-
QRegularExpression rx( QStringLiteral( "^project_color\\('.*'\\)$" ) );
757-
if ( rx.match( mExpressionString ).hasMatch() )
757+
QRegularExpression rx( QStringLiteral( "^project_color\\('(.*)'\\)$" ) );
758+
QRegularExpressionMatch match = rx.match( mExpressionString );
759+
if ( match.hasMatch() )
758760
{
759761
icon = mProperty.isActive() ? QgsApplication::getThemeIcon( QStringLiteral( "/mIconDataDefineColorOn.svg" ) ) : QgsApplication::getThemeIcon( QStringLiteral( "/mIconDataDefineColor.svg" ) );
760-
}
761-
762-
QgsExpression exp( mExpressionString );
763-
if ( exp.hasParserError() )
764-
{
765-
icon = QgsApplication::getThemeIcon( QStringLiteral( "/mIconDataDefineExpressionError.svg" ) );
766-
deftip = tr( "Parse error: %1" ).arg( exp.parserErrorString() );
762+
deftip = match.captured( 1 );
763+
deftype = tr( "project color" );
767764
}
768765
else
769766
{
770-
deftip = mExpressionString;
767+
QgsExpression exp( mExpressionString );
768+
if ( exp.hasParserError() )
769+
{
770+
icon = QgsApplication::getThemeIcon( QStringLiteral( "/mIconDataDefineExpressionError.svg" ) );
771+
deftip = tr( "Parse error: %1" ).arg( exp.parserErrorString() );
772+
}
773+
else
774+
{
775+
deftip = mExpressionString;
776+
}
771777
}
772778
}
773779
else if ( mProperty.propertyType() != QgsProperty::ExpressionBasedProperty && hasField )
@@ -807,10 +813,9 @@ void QgsPropertyOverrideButton::updateGui()
807813
mFullDescription += tr( "<b>Valid input types:</b><br>%1<br>" ).arg( mDataTypesString );
808814
}
809815

810-
QString deftype;
811-
if ( deftip != tr( "undefined" ) )
816+
if ( deftype.isEmpty() && deftip != tr( "undefined" ) )
812817
{
813-
deftype = QStringLiteral( " (%1)" ).arg( mProperty.propertyType() == QgsProperty::ExpressionBasedProperty ? tr( "expression" ) : tr( "field" ) );
818+
deftype = mProperty.propertyType() == QgsProperty::ExpressionBasedProperty ? tr( "expression" ) : tr( "field" );
814819
}
815820

816821
// truncate long expressions, or tool tip may be too wide for screen
@@ -820,7 +825,7 @@ void QgsPropertyOverrideButton::updateGui()
820825
deftip.append( QChar( 0x2026 ) );
821826
}
822827

823-
mFullDescription += tr( "<b>Current definition %1:</b><br>%2" ).arg( deftype, deftip );
828+
mFullDescription += tr( "<b>Current definition (%1):</b><br>%2" ).arg( deftype, deftip );
824829

825830
setToolTip( mFullDescription );
826831

0 commit comments

Comments
 (0)
Please sign in to comment.