Skip to content

Commit

Permalink
avoid adding unclear API
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed May 11, 2021
1 parent f29fbd9 commit c8c534d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 47 deletions.
18 changes: 1 addition & 17 deletions python/gui/auto_generated/symbology/qgssvgselectorwidget.sip.in
Expand Up @@ -119,7 +119,7 @@ Initialize the parameters model so the context and the layer are referenced.

QString currentSvgPath() const;

QgsAbstractFileContentSourceLineEdit *sourceLineEdit() const;
QgsPictureSourceLineEditBase *sourceLineEdit() const;
%Docstring
Returns the source line edit

Expand Down Expand Up @@ -151,22 +151,6 @@ Defines if the SVG browser should be visible
%Docstring
Returns if the SVG browser should be visible

.. versionadded:: 3.20
%End

void setAllowAnyImage( bool allowAnyImage );
%Docstring
Defines if the widget should allow any raster or SVG image
or if the file chooser will be limited to open SVG files

.. versionadded:: 3.20
%End

bool allowAnyImage() const;
%Docstring
Returns if the widget should allow any raster or SVG image
or if the file chooser will be limited to open SVG files

.. versionadded:: 3.20
%End

Expand Down
6 changes: 5 additions & 1 deletion src/gui/layout/qgslayoutpicturewidget.cpp
Expand Up @@ -450,7 +450,11 @@ void QgsLayoutPictureWidget::modeChanged( bool checked )
bool svg = mRadioSVG->isChecked();
const QgsLayoutItemPicture::Format newFormat = svg ? QgsLayoutItemPicture::FormatSVG : QgsLayoutItemPicture::FormatRaster;

mSvgSelectorWidget->setAllowAnyImage( !svg );
if ( svg )
mSvgSelectorWidget->sourceLineEdit()->setMode( QgsPictureSourceLineEditBase::Svg );
else
mSvgSelectorWidget->sourceLineEdit()->setMode( QgsPictureSourceLineEditBase::Image );

mSvgSelectorWidget->setBrowserVisible( svg );
mSvgSelectorWidget->setAllowParameters( svg );
mSVGParamsGroupBox->setVisible( svg );
Expand Down
12 changes: 0 additions & 12 deletions src/gui/symbology/qgssvgselectorwidget.cpp
Expand Up @@ -393,8 +393,6 @@ QgsSvgSelectorWidget::QgsSvgSelectorWidget( QWidget *parent )
// TODO: in-code gui setup with option to vertically or horizontally stack SVG groups/images widgets
setupUi( this );

setAllowAnyImage( mAllowAnyImage );

mIconSize = std::max( 30, static_cast< int >( std::round( Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 3 ) ) );
mImagesListView->setGridSize( QSize( mIconSize * 1.2, mIconSize * 1.2 ) );
mImagesListView->setUniformItemSizes( false );
Expand Down Expand Up @@ -494,16 +492,6 @@ void QgsSvgSelectorWidget::setBrowserVisible( bool visible )
mSvgBrowserGroupBox->setVisible( visible );
}

void QgsSvgSelectorWidget::setAllowAnyImage( bool allowAnyImage )
{
mAllowAnyImage = allowAnyImage;

if ( allowAnyImage )
mSourceLineEdit->setMode( QgsPictureSourceLineEditBase::Image );
else
mSourceLineEdit->setMode( QgsPictureSourceLineEditBase::Svg );
}

QgsPropertyOverrideButton *QgsSvgSelectorWidget::propertyOverrideToolButton() const
{
return mSourceLineEdit->propertyOverrideToolButton();
Expand Down
18 changes: 1 addition & 17 deletions src/gui/symbology/qgssvgselectorwidget.h
Expand Up @@ -44,7 +44,6 @@ class QTreeView;

class QgsExpressionContextGenerator;
class QgsSvgSelectorListModel;
class QgsAbstractFileContentSourceLineEdit;
class QgsPropertyOverrideButton;


Expand Down Expand Up @@ -398,7 +397,7 @@ class GUI_EXPORT QgsSvgSelectorWidget : public QWidget, private Ui::WidgetSvgSel
* Returns the source line edit
* \since QGIS 3.16
*/
QgsAbstractFileContentSourceLineEdit *sourceLineEdit() const {return mSourceLineEdit;}
QgsPictureSourceLineEditBase *sourceLineEdit() const {return mSourceLineEdit;}

/**
* Defines if the group box to fill parameters is visible
Expand All @@ -424,20 +423,6 @@ class GUI_EXPORT QgsSvgSelectorWidget : public QWidget, private Ui::WidgetSvgSel
*/
bool browserVisible() const {return mBrowserVisible;}

/**
* Defines if the widget should allow any raster or SVG image
* or if the file chooser will be limited to open SVG files
* \since QGIS 3.20
*/
void setAllowAnyImage( bool allowAnyImage );

/**
* Returns if the widget should allow any raster or SVG image
* or if the file chooser will be limited to open SVG files
* \since QGIS 3.20
*/
bool allowAnyImage() const {return mAllowAnyImage;}

/**
* Returns the property override tool button of the file line edit
* \since QGIS 3.20
Expand Down Expand Up @@ -474,7 +459,6 @@ class GUI_EXPORT QgsSvgSelectorWidget : public QWidget, private Ui::WidgetSvgSel

private:
int mIconSize = 30;
bool mAllowAnyImage = false;
QString mCurrentSvgPath; //!< Always stored as absolute path
bool mAllowParameters = false;
bool mBrowserVisible = true;
Expand Down

0 comments on commit c8c534d

Please sign in to comment.