Skip to content

Commit 703fbde

Browse files
committed
Do not activate auxiliary data button everywhere
1 parent 429b1ec commit 703fbde

File tree

7 files changed

+36
-22
lines changed

7 files changed

+36
-22
lines changed

python/gui/qgspropertyoverridebutton.sip

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,29 @@ class QgsPropertyOverrideButton: QToolButton
4242
void init( int propertyKey,
4343
const QgsProperty &property,
4444
const QgsPropertiesDefinition &definitions,
45-
const QgsVectorLayer *layer = 0 );
45+
const QgsVectorLayer *layer = 0,
46+
bool auxiliaryStorageEnabled = false );
4647
%Docstring
4748
Initialize a newly constructed property button (useful if button was included in a UI layout).
4849
\param propertyKey key for corresponding property
4950
\param property initial value of associated property to show in widget
5051
\param definitions properties definitions for corresponding collection
5152
\param layer associated vector layer
53+
\param auxiliaryStorageEnabled If true, activate the button to store data defined in auxiliary storage
5254
%End
5355

5456
void init( int propertyKey,
5557
const QgsAbstractPropertyCollection &collection,
5658
const QgsPropertiesDefinition &definitions,
57-
const QgsVectorLayer *layer = 0 );
59+
const QgsVectorLayer *layer = 0,
60+
bool auxiliaryStorageEnabled = false );
5861
%Docstring
5962
Initialize a newly constructed property button (useful if button was included in a UI layout).
6063
\param propertyKey key for corresponding property
6164
\param collection associated property collection
6265
\param definitions properties definitions for collection
6366
\param layer associated vector layer
67+
\param auxiliaryStorageEnabled If true, activate the button to store data defined in auxiliary storage
6468
%End
6569

6670
QgsProperty toProperty() const;

src/app/qgsdiagramproperties.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ QgsDiagramProperties::~QgsDiagramProperties()
486486

487487
void QgsDiagramProperties::registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsDiagramLayerSettings::Property key )
488488
{
489-
button->init( key, mDataDefinedProperties, QgsDiagramLayerSettings::propertyDefinitions(), mLayer );
489+
button->init( key, mDataDefinedProperties, QgsDiagramLayerSettings::propertyDefinitions(), mLayer, true );
490490
connect( button, &QgsPropertyOverrideButton::changed, this, &QgsDiagramProperties::updateProperty );
491491
connect( button, &QgsPropertyOverrideButton::createAuxiliaryField, this, &QgsDiagramProperties::createAuxiliaryField );
492492
button->registerExpressionContextGenerator( this );

src/app/qgslabelinggui.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ QgsExpressionContext QgsLabelingGui::createExpressionContext() const
4646

4747
void QgsLabelingGui::registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsPalLayerSettings::Property key )
4848
{
49-
button->init( key, mDataDefinedProperties, QgsPalLayerSettings::propertyDefinitions(), mLayer );
49+
button->init( key, mDataDefinedProperties, QgsPalLayerSettings::propertyDefinitions(), mLayer, true );
5050
connect( button, &QgsPropertyOverrideButton::changed, this, &QgsLabelingGui::updateProperty );
5151
connect( button, &QgsPropertyOverrideButton::createAuxiliaryField, this, &QgsLabelingGui::createAuxiliaryField );
5252
button->registerExpressionContextGenerator( this );

src/gui/qgspropertyoverridebutton.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,10 @@ QgsPropertyOverrideButton::QgsPropertyOverrideButton( QWidget *parent,
8383
}
8484

8585

86-
void QgsPropertyOverrideButton::init( int propertyKey, const QgsProperty &property, const QgsPropertiesDefinition &definitions, const QgsVectorLayer *layer )
86+
void QgsPropertyOverrideButton::init( int propertyKey, const QgsProperty &property, const QgsPropertiesDefinition &definitions, const QgsVectorLayer *layer, bool auxiliaryStorageEnabled )
8787
{
8888
mVectorLayer = layer;
89+
mAuxiliaryStorageEnabled = auxiliaryStorageEnabled;
8990
setToProperty( property );
9091
mPropertyKey = propertyKey;
9192

@@ -126,9 +127,9 @@ void QgsPropertyOverrideButton::init( int propertyKey, const QgsProperty &proper
126127
updateGui();
127128
}
128129

129-
void QgsPropertyOverrideButton::init( int propertyKey, const QgsAbstractPropertyCollection &collection, const QgsPropertiesDefinition &definitions, const QgsVectorLayer *layer )
130+
void QgsPropertyOverrideButton::init( int propertyKey, const QgsAbstractPropertyCollection &collection, const QgsPropertiesDefinition &definitions, const QgsVectorLayer *layer, bool auxiliaryStorageEnabled )
130131
{
131-
init( propertyKey, collection.property( propertyKey ), definitions, layer );
132+
init( propertyKey, collection.property( propertyKey ), definitions, layer, auxiliaryStorageEnabled );
132133
}
133134

134135

@@ -334,18 +335,21 @@ void QgsPropertyOverrideButton::aboutToShowMenu()
334335
mDefineMenu->addSeparator();
335336

336337
// deactivate button if field already exists
337-
mDefineMenu->addAction( mActionCreateAuxiliaryField );
338+
if ( mAuxiliaryStorageEnabled )
339+
{
340+
mDefineMenu->addAction( mActionCreateAuxiliaryField );
338341

339-
const QgsAuxiliaryLayer *alayer = mVectorLayer->auxiliaryLayer();
342+
const QgsAuxiliaryLayer *alayer = mVectorLayer->auxiliaryLayer();
340343

341-
mActionCreateAuxiliaryField->setEnabled( true );
342-
mActionCreateAuxiliaryField->setChecked( false );
343-
if ( alayer && alayer->exists( mDefinition ) )
344-
{
345-
if ( mProperty.field() == QgsAuxiliaryField::nameFromProperty( mDefinition, true ) )
344+
mActionCreateAuxiliaryField->setEnabled( true );
345+
mActionCreateAuxiliaryField->setChecked( false );
346+
if ( alayer && alayer->exists( mDefinition ) )
346347
{
347-
mActionCreateAuxiliaryField->setEnabled( false );
348-
mActionCreateAuxiliaryField->setChecked( true );
348+
if ( mProperty.field() == QgsAuxiliaryField::nameFromProperty( mDefinition, true ) )
349+
{
350+
mActionCreateAuxiliaryField->setEnabled( false );
351+
mActionCreateAuxiliaryField->setChecked( true );
352+
}
349353
}
350354
}
351355

src/gui/qgspropertyoverridebutton.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,27 @@ class GUI_EXPORT QgsPropertyOverrideButton: public QToolButton
6969
* \param property initial value of associated property to show in widget
7070
* \param definitions properties definitions for corresponding collection
7171
* \param layer associated vector layer
72+
* \param auxiliaryStorageEnabled If true, activate the button to store data defined in auxiliary storage
7273
*/
7374
void init( int propertyKey,
7475
const QgsProperty &property,
7576
const QgsPropertiesDefinition &definitions,
76-
const QgsVectorLayer *layer = nullptr );
77+
const QgsVectorLayer *layer = nullptr,
78+
bool auxiliaryStorageEnabled = false );
7779

7880
/**
7981
* Initialize a newly constructed property button (useful if button was included in a UI layout).
8082
* \param propertyKey key for corresponding property
8183
* \param collection associated property collection
8284
* \param definitions properties definitions for collection
8385
* \param layer associated vector layer
86+
* \param auxiliaryStorageEnabled If true, activate the button to store data defined in auxiliary storage
8487
*/
8588
void init( int propertyKey,
8689
const QgsAbstractPropertyCollection &collection,
8790
const QgsPropertiesDefinition &definitions,
88-
const QgsVectorLayer *layer = nullptr );
91+
const QgsVectorLayer *layer = nullptr,
92+
bool auxiliaryStorageEnabled = false );
8993

9094
/**
9195
* Returns a QgsProperty object encapsulating the current state of the
@@ -295,6 +299,8 @@ class GUI_EXPORT QgsPropertyOverrideButton: public QToolButton
295299
//! Internal property used for storing state of widget
296300
QgsProperty mProperty;
297301

302+
bool mAuxiliaryStorageEnabled = false;
303+
298304
std::shared_ptr< QgsSymbol > mSymbol;
299305

300306
private slots:

src/gui/symbology/qgssymbollayerwidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ QgsSymbolWidgetContext QgsSymbolLayerWidget::context() const
111111

112112
void QgsSymbolLayerWidget::registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsSymbolLayer::Property key )
113113
{
114-
button->init( key, symbolLayer()->dataDefinedProperties(), QgsSymbolLayer::propertyDefinitions(), mVectorLayer );
114+
button->init( key, symbolLayer()->dataDefinedProperties(), QgsSymbolLayer::propertyDefinitions(), mVectorLayer, true );
115115
connect( button, &QgsPropertyOverrideButton::changed, this, &QgsSymbolLayerWidget::updateDataDefinedProperty );
116116
connect( button, &QgsPropertyOverrideButton::createAuxiliaryField, this, &QgsSymbolLayerWidget::createAuxiliaryField );
117117

src/gui/symbology/qgssymbolslistwidget.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,10 @@ void QgsSymbolsListWidget::updateSymbolInfo()
559559
if ( mLayer )
560560
{
561561
QgsProperty ddSize( markerSymbol->dataDefinedSize() );
562-
mSizeDDBtn->init( QgsSymbolLayer::PropertySize, ddSize, QgsSymbolLayer::propertyDefinitions(), mLayer );
562+
mSizeDDBtn->init( QgsSymbolLayer::PropertySize, ddSize, QgsSymbolLayer::propertyDefinitions(), mLayer, true );
563563
spinSize->setEnabled( !mSizeDDBtn->isActive() );
564564
QgsProperty ddAngle( markerSymbol->dataDefinedAngle() );
565-
mRotationDDBtn->init( QgsSymbolLayer::PropertyAngle, ddAngle, QgsSymbolLayer::propertyDefinitions(), mLayer );
565+
mRotationDDBtn->init( QgsSymbolLayer::PropertyAngle, ddAngle, QgsSymbolLayer::propertyDefinitions(), mLayer, true );
566566
spinAngle->setEnabled( !mRotationDDBtn->isActive() );
567567
}
568568
else
@@ -579,7 +579,7 @@ void QgsSymbolsListWidget::updateSymbolInfo()
579579
if ( mLayer )
580580
{
581581
QgsProperty dd( lineSymbol->dataDefinedWidth() );
582-
mWidthDDBtn->init( QgsSymbolLayer::PropertyStrokeWidth, dd, QgsSymbolLayer::propertyDefinitions(), mLayer );
582+
mWidthDDBtn->init( QgsSymbolLayer::PropertyStrokeWidth, dd, QgsSymbolLayer::propertyDefinitions(), mLayer, true );
583583
spinWidth->setEnabled( !mWidthDDBtn->isActive() );
584584
}
585585
else

0 commit comments

Comments
 (0)