Skip to content

Commit

Permalink
Update the QgsRatioLockButton use for fixedAspectRatio in SVG marker
Browse files Browse the repository at this point in the history
  • Loading branch information
rldhont committed Sep 28, 2017
1 parent aee93b0 commit f8152c1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
27 changes: 20 additions & 7 deletions src/gui/symbology/qgssymbollayerwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1756,7 +1756,7 @@ QgsSvgMarkerSymbolLayerWidget::QgsSvgMarkerSymbolLayerWidget( const QgsVectorLay
connect( viewGroups->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsSvgMarkerSymbolLayerWidget::populateIcons );
connect( spinWidth, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setWidth );
connect( spinHeight, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setHeight );
connect( mLockAspectRatio, static_cast < void ( QgsRatioLockButton::* )( bool ) > ( &QgsRatioLockButton::lockChanged ), this, &QgsSvgMarkerSymbolLayerWidget::stateChangedAspectRatio );
connect( mLockAspectRatio, static_cast < void ( QgsRatioLockButton::* )( bool ) > ( &QgsRatioLockButton::lockChanged ), this, &QgsSvgMarkerSymbolLayerWidget::lockAspectRatioChanged );
connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setAngle );
connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setOffset );
connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setOffset );
Expand Down Expand Up @@ -1876,9 +1876,9 @@ void QgsSvgMarkerSymbolLayerWidget::setGuiForSvg( const QgsSvgMarkerSymbolLayer
{
spinHeight->setValue( layer->size() * layer->fixedAspectRatio() );
}
spinHeight->setEnabled( layer->defaultAspectRatio() > 0.0 );
spinHeight->blockSignals( false );
spinHeight->setEnabled( !preservedAspectRatio );
mLockAspectRatio->setLocked( preservedAspectRatio );
whileBlocking( mLockAspectRatio )->setLocked( preservedAspectRatio );
}

void QgsSvgMarkerSymbolLayerWidget::updateAssistantSymbol()
Expand Down Expand Up @@ -2036,11 +2036,24 @@ void QgsSvgMarkerSymbolLayerWidget::setHeight()
emit changed();
}

void QgsSvgMarkerSymbolLayerWidget::stateChangedAspectRatio()
void QgsSvgMarkerSymbolLayerWidget::lockAspectRatioChanged( const bool locked )
{
spinHeight->setEnabled( !mLockAspectRatio->locked() );
setWidth();
emit changed();
//spinHeight->setEnabled( !locked );
double defaultAspectRatio = mLayer->defaultAspectRatio();
if ( defaultAspectRatio <= 0.0 )
{
whileBlocking( mLockAspectRatio )->setLocked( true );
}
else if ( locked )
{
mLayer->setFixedAspectRatio( 0.0 );
setWidth();
}
else
{
mLayer->setFixedAspectRatio( spinHeight->value() / spinWidth->value() );
}
//emit changed();
}

void QgsSvgMarkerSymbolLayerWidget::setAngle()
Expand Down
2 changes: 1 addition & 1 deletion src/gui/symbology/qgssymbollayerwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ class GUI_EXPORT QgsSvgMarkerSymbolLayerWidget : public QgsSymbolLayerWidget, pr
private slots:
void setWidth();
void setHeight();
void stateChangedAspectRatio();
void lockAspectRatioChanged( const bool locked );
void setAngle();
void setOffset();
void updateAssistantSymbol();
Expand Down
2 changes: 1 addition & 1 deletion src/ui/symbollayer/widget_svgmarker.ui
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
</sizepolicy>
</property>
<property name="toolTip">
<string>Lock aspect ratio (including while drawing extent onto canvas)</string>
<string>Lock aspect ratio</string>
</property>
<property name="leftMargin" stdset="0">
<number>13</number>
Expand Down

0 comments on commit f8152c1

Please sign in to comment.