Skip to content

Commit

Permalink
Remove "relative path" checkbox from svg selector widget
Browse files Browse the repository at this point in the history
It is decided on different level whether files are saved with relative paths
and internally now QGIS always uses absolute paths to SVG files.
wonder-sk committed May 13, 2017
1 parent 5bdae75 commit c882f88
Showing 5 changed files with 27 additions and 76 deletions.
13 changes: 13 additions & 0 deletions doc/api_break.dox
Original file line number Diff line number Diff line change
@@ -1983,6 +1983,19 @@ QgsSvgMarkerSymbolLayer {#qgis_api_break_3_0_QgsSvgMarkerSymbolLayer}

- The first argument of the constructor (path) does not have a default value anymore.

QgsSvgSelectorWidget {#qgis_api_break_3_0_QgsSvgSelectorWidget}
--------------------

- create() has been removed - use ordinary constructor instead.
- currentSvgPathToName() has been removed - absolute paths are always used.
- groupsTreeView(), imagesListView(), filePathLineEdit(), filePathButton(), relativePathCheckbox(), selectorLayout() have been removed as they were leaking implementation details.

QgsSvgSelectorDialog {#qgis_api_break_3_0_QgsSvgSelectorDialog}
--------------------

- layout(), buttonBox() has been removed as they were leaking implementation details.


QgsStyle (renamed from QgsStyleV2) {#qgis_api_break_3_0_QgsStyle}
----------------------------------
- All group functions have been removed: group(), addGroup(), groupId(), groupName(), groupNames(), groupIds(), symbolsOfGroup(), getGroupRemoveQuery()
17 changes: 0 additions & 17 deletions python/gui/symbology-ng/qgssvgselectorwidget.sip
Original file line number Diff line number Diff line change
@@ -33,20 +33,9 @@ class QgsSvgSelectorWidget : QWidget
QgsSvgSelectorWidget( QWidget *parent /TransferThis/ = 0 );
~QgsSvgSelectorWidget();

static QgsSvgSelectorWidget *create( QWidget *parent = 0 ) /Factory/;

QString currentSvgPath() const;
QString currentSvgPathToName() const;

QTreeView *groupsTreeView();
QListView *imagesListView();
QLineEdit *filePathLineEdit();
QPushButton *filePathButton();
QCheckBox *relativePathCheckbox();
QLayout *selectorLayout();

public slots:
/** Accepts absolute and relative paths */
void setSvgPath( const QString &svgPath );

signals:
@@ -67,12 +56,6 @@ class QgsSvgSelectorDialog : QDialog
Qt::Orientation orientation = Qt::Horizontal );
~QgsSvgSelectorDialog();

//! Returns the central layout. Widgets added to it must have this dialog as parent
QVBoxLayout *layout();

//! Returns the button box
QDialogButtonBox *buttonBox();

//! Returns pointer to the embedded SVG selector widget
QgsSvgSelectorWidget *svgSelector();

31 changes: 2 additions & 29 deletions src/gui/symbology-ng/qgssvgselectorwidget.cpp
Original file line number Diff line number Diff line change
@@ -382,37 +382,18 @@ QgsSvgSelectorWidget::QgsSvgSelectorWidget( QWidget *parent )
this, &QgsSvgSelectorWidget::svgSelectionChanged );
connect( mGroupsTreeView->selectionModel(), &QItemSelectionModel::currentChanged,
this, &QgsSvgSelectorWidget::populateIcons );

QgsSettings settings;
bool useRelativePath = ( QgsProject::instance()->readBoolEntry( QStringLiteral( "Paths" ), QStringLiteral( "/Absolute" ), false )
|| settings.value( QStringLiteral( "Windows/SvgSelectorWidget/RelativePath" ) ).toBool() );
mRelativePathChkBx->setChecked( useRelativePath );
}

QgsSvgSelectorWidget::~QgsSvgSelectorWidget()
{
QgsSettings settings;
settings.setValue( QStringLiteral( "Windows/SvgSelectorWidget/RelativePath" ), mRelativePathChkBx->isChecked() );
}

void QgsSvgSelectorWidget::setSvgPath( const QString &svgPath )
{
QString updatedPath( QLatin1String( "" ) );

// skip possible urls, excepting those that may locally resolve
if ( !svgPath.contains( QLatin1String( "://" ) ) || ( svgPath.contains( QLatin1String( "file://" ), Qt::CaseInsensitive ) ) )
{
QString resolvedPath = QgsSymbolLayerUtils::svgSymbolNameToPath( svgPath.trimmed(), QgsProject::instance()->pathResolver() );
if ( !resolvedPath.isNull() )
{
updatedPath = resolvedPath;
}
}

mCurrentSvgPath = updatedPath;
mCurrentSvgPath = svgPath;

mFileLineEdit->blockSignals( true );
mFileLineEdit->setText( updatedPath );
mFileLineEdit->setText( svgPath );
mFileLineEdit->blockSignals( false );

mImagesListView->selectionModel()->blockSignals( true );
@@ -434,17 +415,9 @@ void QgsSvgSelectorWidget::setSvgPath( const QString &svgPath )

QString QgsSvgSelectorWidget::currentSvgPath() const
{
if ( mRelativePathChkBx->isChecked() )
return currentSvgPathToName();

return mCurrentSvgPath;
}

QString QgsSvgSelectorWidget::currentSvgPathToName() const
{
return QgsSymbolLayerUtils::svgSymbolPathToName( mCurrentSvgPath, QgsProject::instance()->pathResolver() );
}

void QgsSvgSelectorWidget::updateCurrentSvgPath( const QString &svgPath )
{
mCurrentSvgPath = svgPath;
20 changes: 2 additions & 18 deletions src/gui/symbology-ng/qgssvgselectorwidget.h
Original file line number Diff line number Diff line change
@@ -235,20 +235,10 @@ class GUI_EXPORT QgsSvgSelectorWidget : public QWidget, private Ui::WidgetSvgSel
QgsSvgSelectorWidget( QWidget *parent SIP_TRANSFERTHIS = 0 );
~QgsSvgSelectorWidget();

static QgsSvgSelectorWidget *create( QWidget *parent = nullptr ) { return new QgsSvgSelectorWidget( parent ); }

QString currentSvgPath() const;
QString currentSvgPathToName() const;

QTreeView *groupsTreeView() { return mGroupsTreeView; }
QListView *imagesListView() { return mImagesListView; }
QLineEdit *filePathLineEdit() { return mFileLineEdit; }
QPushButton *filePathButton() { return mFilePushButton; }
QCheckBox *relativePathCheckbox() { return mRelativePathChkBx; }
QLayout *selectorLayout() { return this->layout(); }

public slots:
//! Accepts absolute and relative paths
//! Accepts absolute paths
void setSvgPath( const QString &svgPath );

signals:
@@ -267,7 +257,7 @@ class GUI_EXPORT QgsSvgSelectorWidget : public QWidget, private Ui::WidgetSvgSel
void on_mFileLineEdit_textChanged( const QString &text );

private:
QString mCurrentSvgPath; // always stored as absolute path
QString mCurrentSvgPath; //!< Always stored as absolute path

};

@@ -287,12 +277,6 @@ class GUI_EXPORT QgsSvgSelectorDialog : public QDialog
Qt::Orientation orientation = Qt::Horizontal );
~QgsSvgSelectorDialog();

//! Returns the central layout. Widgets added to it must have this dialog as parent
QVBoxLayout *layout() { return mLayout; }

//! Returns the button box
QDialogButtonBox *buttonBox() { return mButtonBox; }

//! Returns pointer to the embedded SVG selector widget
QgsSvgSelectorWidget *svgSelector() { return mSvgSelector; }

22 changes: 10 additions & 12 deletions src/ui/symbollayer/widget_svgselector.ui
Original file line number Diff line number Diff line change
@@ -14,7 +14,16 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="1">
@@ -111,16 +120,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mRelativePathChkBx">
<property name="toolTip">
<string>Generated path will be relative to current SVG search directories or to Project file</string>
</property>
<property name="text">
<string>Relative path</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@@ -130,7 +129,6 @@
<tabstop>mImagesListView</tabstop>
<tabstop>mFileLineEdit</tabstop>
<tabstop>mFilePushButton</tabstop>
<tabstop>mRelativePathChkBx</tabstop>
</tabstops>
<resources/>
<connections/>

0 comments on commit c882f88

Please sign in to comment.