Skip to content

Commit f8152c1

Browse files
committed
Update the QgsRatioLockButton use for fixedAspectRatio in SVG marker
1 parent aee93b0 commit f8152c1

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

src/gui/symbology/qgssymbollayerwidget.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,7 @@ QgsSvgMarkerSymbolLayerWidget::QgsSvgMarkerSymbolLayerWidget( const QgsVectorLay
17561756
connect( viewGroups->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsSvgMarkerSymbolLayerWidget::populateIcons );
17571757
connect( spinWidth, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setWidth );
17581758
connect( spinHeight, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setHeight );
1759-
connect( mLockAspectRatio, static_cast < void ( QgsRatioLockButton::* )( bool ) > ( &QgsRatioLockButton::lockChanged ), this, &QgsSvgMarkerSymbolLayerWidget::stateChangedAspectRatio );
1759+
connect( mLockAspectRatio, static_cast < void ( QgsRatioLockButton::* )( bool ) > ( &QgsRatioLockButton::lockChanged ), this, &QgsSvgMarkerSymbolLayerWidget::lockAspectRatioChanged );
17601760
connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setAngle );
17611761
connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setOffset );
17621762
connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setOffset );
@@ -1876,9 +1876,9 @@ void QgsSvgMarkerSymbolLayerWidget::setGuiForSvg( const QgsSvgMarkerSymbolLayer
18761876
{
18771877
spinHeight->setValue( layer->size() * layer->fixedAspectRatio() );
18781878
}
1879+
spinHeight->setEnabled( layer->defaultAspectRatio() > 0.0 );
18791880
spinHeight->blockSignals( false );
1880-
spinHeight->setEnabled( !preservedAspectRatio );
1881-
mLockAspectRatio->setLocked( preservedAspectRatio );
1881+
whileBlocking( mLockAspectRatio )->setLocked( preservedAspectRatio );
18821882
}
18831883

18841884
void QgsSvgMarkerSymbolLayerWidget::updateAssistantSymbol()
@@ -2036,11 +2036,24 @@ void QgsSvgMarkerSymbolLayerWidget::setHeight()
20362036
emit changed();
20372037
}
20382038

2039-
void QgsSvgMarkerSymbolLayerWidget::stateChangedAspectRatio()
2039+
void QgsSvgMarkerSymbolLayerWidget::lockAspectRatioChanged( const bool locked )
20402040
{
2041-
spinHeight->setEnabled( !mLockAspectRatio->locked() );
2042-
setWidth();
2043-
emit changed();
2041+
//spinHeight->setEnabled( !locked );
2042+
double defaultAspectRatio = mLayer->defaultAspectRatio();
2043+
if ( defaultAspectRatio <= 0.0 )
2044+
{
2045+
whileBlocking( mLockAspectRatio )->setLocked( true );
2046+
}
2047+
else if ( locked )
2048+
{
2049+
mLayer->setFixedAspectRatio( 0.0 );
2050+
setWidth();
2051+
}
2052+
else
2053+
{
2054+
mLayer->setFixedAspectRatio( spinHeight->value() / spinWidth->value() );
2055+
}
2056+
//emit changed();
20442057
}
20452058

20462059
void QgsSvgMarkerSymbolLayerWidget::setAngle()

src/gui/symbology/qgssymbollayerwidget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ class GUI_EXPORT QgsSvgMarkerSymbolLayerWidget : public QgsSymbolLayerWidget, pr
459459
private slots:
460460
void setWidth();
461461
void setHeight();
462-
void stateChangedAspectRatio();
462+
void lockAspectRatioChanged( const bool locked );
463463
void setAngle();
464464
void setOffset();
465465
void updateAssistantSymbol();

src/ui/symbollayer/widget_svgmarker.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
</sizepolicy>
164164
</property>
165165
<property name="toolTip">
166-
<string>Lock aspect ratio (including while drawing extent onto canvas)</string>
166+
<string>Lock aspect ratio</string>
167167
</property>
168168
<property name="leftMargin" stdset="0">
169169
<number>13</number>

0 commit comments

Comments
 (0)