Skip to content
Permalink
Browse files
Merge pull request #42745 from gacarrillor/default_custom_expression_…
…tweaks

Minor tweaks to expression dialog and default expression function
  • Loading branch information
rouault committed Apr 10, 2021
2 parents 497cd1b + df9a6ae commit c8b891b8a19d5be55088d92d329ddd7458a63051
Showing with 5 additions and 5 deletions.
  1. +1 −1 python/user.py
  2. +2 −2 src/gui/qgsexpressionbuilderwidget.cpp
  3. +2 −2 src/gui/qgsexpressionpreviewwidget.cpp
@@ -66,7 +66,7 @@ def load_user_expressions(path):
template = """from qgis.core import *
from qgis.gui import *
@qgsfunction(args='auto', group='Custom')
@qgsfunction(args='auto', group='Custom', referenced_columns=[])
def my_sum(value1, value2, feature, parent):
\"\"\"
Calculates the sum of the two parameters value1 and value2.
@@ -399,8 +399,8 @@ void QgsExpressionBuilderWidget::updateFunctionFileList( const QString &path )
{
// Create default sample entry.
newFunctionFile( "default" );
txtPython->setText( QStringLiteral( "'''\n#Sample custom function file\n "
"(uncomment to use and customize or Add button to create a new file) \n%1 \n '''" ).arg( txtPython->text() ) );
txtPython->setText( QStringLiteral( "'''\n#Sample custom function file\n"
"#(uncomment to use and customize or Add button to create a new file) \n%1 \n '''" ).arg( txtPython->text() ) );
saveFunctionFile( "default" );
}
}
@@ -85,7 +85,7 @@ void QgsExpressionPreviewWidget::refreshPreview()
if ( !mExpression.referencedColumns().isEmpty() || mExpression.needsGeometry() )
{
mPreviewLabel->setText( tr( "No feature was found on this layer to evaluate the expression." ) );
mPreviewLabel->setStyleSheet( QStringLiteral( "color: rgba(255, 6, 10, 255);" ) );
mPreviewLabel->setStyleSheet( QStringLiteral( "color: rgba(220, 125, 0, 255);" ) );
return;
}
}
@@ -116,7 +116,7 @@ void QgsExpressionPreviewWidget::refreshPreview()
tooltip += QStringLiteral( "<b>%1:</b> %2" ).arg( tr( "Eval Error" ), mExpression.evalErrorString() );

mPreviewLabel->setText( tr( "Expression is invalid <a href=""more"">(more info)</a>" ) );
mPreviewLabel->setStyleSheet( QStringLiteral( "color: rgba(255, 6, 10, 255);" ) );
mPreviewLabel->setStyleSheet( QStringLiteral( "color: rgba(255, 6, 10, 255);" ) );
setExpressionToolTip( tooltip );
emit expressionParsed( false );
setParserError( mExpression.hasParserError() );

0 comments on commit c8b891b

Please sign in to comment.