@@ -749,25 +749,31 @@ void QgsPropertyOverrideButton::updateGui()
749
749
750
750
QIcon icon = QgsApplication::getThemeIcon ( QStringLiteral ( " /mIconDataDefine.svg" ) );
751
751
QString deftip = tr ( " undefined" );
752
+ QString deftype;
752
753
if ( mProperty .propertyType () == QgsProperty::ExpressionBasedProperty && hasExp )
753
754
{
754
755
icon = mProperty .isActive () ? QgsApplication::getThemeIcon ( QStringLiteral ( " /mIconDataDefineExpressionOn.svg" ) ) : QgsApplication::getThemeIcon ( QStringLiteral ( " /mIconDataDefineExpression.svg" ) );
755
756
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 () )
758
760
{
759
761
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" );
767
764
}
768
765
else
769
766
{
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
+ }
771
777
}
772
778
}
773
779
else if ( mProperty .propertyType () != QgsProperty::ExpressionBasedProperty && hasField )
@@ -807,10 +813,9 @@ void QgsPropertyOverrideButton::updateGui()
807
813
mFullDescription += tr ( " <b>Valid input types:</b><br>%1<br>" ).arg ( mDataTypesString );
808
814
}
809
815
810
- QString deftype;
811
- if ( deftip != tr ( " undefined" ) )
816
+ if ( deftype.isEmpty () && deftip != tr ( " undefined" ) )
812
817
{
813
- deftype = QStringLiteral ( " (%1) " ). arg ( mProperty .propertyType () == QgsProperty::ExpressionBasedProperty ? tr ( " expression" ) : tr ( " field" ) );
818
+ deftype = mProperty .propertyType () == QgsProperty::ExpressionBasedProperty ? tr ( " expression" ) : tr ( " field" );
814
819
}
815
820
816
821
// truncate long expressions, or tool tip may be too wide for screen
@@ -820,7 +825,7 @@ void QgsPropertyOverrideButton::updateGui()
820
825
deftip.append ( QChar ( 0x2026 ) );
821
826
}
822
827
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 );
824
829
825
830
setToolTip ( mFullDescription );
826
831
0 commit comments