From 3371003402df95d35bed4d7748dce55c3de139e0 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Thu, 9 Feb 2017 17:57:17 +1000 Subject: [PATCH] Small tweaks to property override button behavior --- src/gui/qgspropertyassistantwidget.cpp | 2 +- src/gui/qgspropertyoverridebutton.cpp | 15 +++++++++------ src/gui/symbology-ng/qgssizescalewidget.h | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/gui/qgspropertyassistantwidget.cpp b/src/gui/qgspropertyassistantwidget.cpp index 29186bd1738..bdcc4cccb7b 100644 --- a/src/gui/qgspropertyassistantwidget.cpp +++ b/src/gui/qgspropertyassistantwidget.cpp @@ -82,7 +82,7 @@ void QgsPropertyAssistantWidget::registerExpressionContextGenerator( QgsExpressi void QgsPropertyAssistantWidget::updateProperty( QgsProperty& property ) { - property.setActive( true ); + property.setActive( !mExpressionWidget->currentText().isEmpty() ); if ( mExpressionWidget->isExpression() ) property.setExpressionString( mExpressionWidget->currentField() ); else diff --git a/src/gui/qgspropertyoverridebutton.cpp b/src/gui/qgspropertyoverridebutton.cpp index ff48af8646c..a6cabb1e04c 100644 --- a/src/gui/qgspropertyoverridebutton.cpp +++ b/src/gui/qgspropertyoverridebutton.cpp @@ -449,18 +449,14 @@ void QgsPropertyOverrideButton::menuActionTriggered( QAction* action ) mExpressionString = exprString; mProperty.setExpressionString( mExpressionString ); mProperty.setTransformer( nullptr ); - setActivePrivate( mProperty.isActive() ); + setActivePrivate( true ); updateGui(); emit changed(); } } else if ( action == mActionClearExpr ) { - // only deactivate if defined expression is being used - if ( mProperty.isActive() && mProperty.propertyType() == QgsProperty::ExpressionBasedProperty ) - { - setActivePrivate( false ); - } + setActivePrivate( false ); mProperty.setStaticValue( QVariant() ); mProperty.setTransformer( nullptr ); mExpressionString.clear(); @@ -528,6 +524,13 @@ void QgsPropertyOverrideButton::showExpressionDialog() void QgsPropertyOverrideButton::showAssistant() { + //first step - try to convert any existing expression to a transformer if one doesn't + //already exist + if ( !mProperty.transformer() ) + { + ( void )mProperty.convertToTransformer(); + } + QgsPanelWidget* panel = QgsPanelWidget::findParentPanel( this ); if ( panel && panel->dockMode() ) { diff --git a/src/gui/symbology-ng/qgssizescalewidget.h b/src/gui/symbology-ng/qgssizescalewidget.h index 339f31c774f..6f9cdace36e 100644 --- a/src/gui/symbology-ng/qgssizescalewidget.h +++ b/src/gui/symbology-ng/qgssizescalewidget.h @@ -22,6 +22,7 @@ #include #include #include "qgis_gui.h" +#include "qgsproperty.h" class QgsVectorLayer; class QgsSymbol;