Skip to content

Commit c882f88

Browse files
committed
Remove "relative path" checkbox from svg selector widget
It is decided on different level whether files are saved with relative paths and internally now QGIS always uses absolute paths to SVG files.
1 parent 5bdae75 commit c882f88

File tree

5 files changed

+27
-76
lines changed

5 files changed

+27
-76
lines changed

doc/api_break.dox

+13
Original file line numberDiff line numberDiff line change
@@ -1983,6 +1983,19 @@ QgsSvgMarkerSymbolLayer {#qgis_api_break_3_0_QgsSvgMarkerSymbolLayer}
19831983

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

1986+
QgsSvgSelectorWidget {#qgis_api_break_3_0_QgsSvgSelectorWidget}
1987+
--------------------
1988+
1989+
- create() has been removed - use ordinary constructor instead.
1990+
- currentSvgPathToName() has been removed - absolute paths are always used.
1991+
- groupsTreeView(), imagesListView(), filePathLineEdit(), filePathButton(), relativePathCheckbox(), selectorLayout() have been removed as they were leaking implementation details.
1992+
1993+
QgsSvgSelectorDialog {#qgis_api_break_3_0_QgsSvgSelectorDialog}
1994+
--------------------
1995+
1996+
- layout(), buttonBox() has been removed as they were leaking implementation details.
1997+
1998+
19861999
QgsStyle (renamed from QgsStyleV2) {#qgis_api_break_3_0_QgsStyle}
19872000
----------------------------------
19882001
- All group functions have been removed: group(), addGroup(), groupId(), groupName(), groupNames(), groupIds(), symbolsOfGroup(), getGroupRemoveQuery()

python/gui/symbology-ng/qgssvgselectorwidget.sip

-17
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,9 @@ class QgsSvgSelectorWidget : QWidget
3333
QgsSvgSelectorWidget( QWidget *parent /TransferThis/ = 0 );
3434
~QgsSvgSelectorWidget();
3535

36-
static QgsSvgSelectorWidget *create( QWidget *parent = 0 ) /Factory/;
37-
3836
QString currentSvgPath() const;
39-
QString currentSvgPathToName() const;
40-
41-
QTreeView *groupsTreeView();
42-
QListView *imagesListView();
43-
QLineEdit *filePathLineEdit();
44-
QPushButton *filePathButton();
45-
QCheckBox *relativePathCheckbox();
46-
QLayout *selectorLayout();
4737

4838
public slots:
49-
/** Accepts absolute and relative paths */
5039
void setSvgPath( const QString &svgPath );
5140

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

70-
//! Returns the central layout. Widgets added to it must have this dialog as parent
71-
QVBoxLayout *layout();
72-
73-
//! Returns the button box
74-
QDialogButtonBox *buttonBox();
75-
7659
//! Returns pointer to the embedded SVG selector widget
7760
QgsSvgSelectorWidget *svgSelector();
7861

src/gui/symbology-ng/qgssvgselectorwidget.cpp

+2-29
Original file line numberDiff line numberDiff line change
@@ -382,37 +382,18 @@ QgsSvgSelectorWidget::QgsSvgSelectorWidget( QWidget *parent )
382382
this, &QgsSvgSelectorWidget::svgSelectionChanged );
383383
connect( mGroupsTreeView->selectionModel(), &QItemSelectionModel::currentChanged,
384384
this, &QgsSvgSelectorWidget::populateIcons );
385-
386-
QgsSettings settings;
387-
bool useRelativePath = ( QgsProject::instance()->readBoolEntry( QStringLiteral( "Paths" ), QStringLiteral( "/Absolute" ), false )
388-
|| settings.value( QStringLiteral( "Windows/SvgSelectorWidget/RelativePath" ) ).toBool() );
389-
mRelativePathChkBx->setChecked( useRelativePath );
390385
}
391386

392387
QgsSvgSelectorWidget::~QgsSvgSelectorWidget()
393388
{
394-
QgsSettings settings;
395-
settings.setValue( QStringLiteral( "Windows/SvgSelectorWidget/RelativePath" ), mRelativePathChkBx->isChecked() );
396389
}
397390

398391
void QgsSvgSelectorWidget::setSvgPath( const QString &svgPath )
399392
{
400-
QString updatedPath( QLatin1String( "" ) );
401-
402-
// skip possible urls, excepting those that may locally resolve
403-
if ( !svgPath.contains( QLatin1String( "://" ) ) || ( svgPath.contains( QLatin1String( "file://" ), Qt::CaseInsensitive ) ) )
404-
{
405-
QString resolvedPath = QgsSymbolLayerUtils::svgSymbolNameToPath( svgPath.trimmed(), QgsProject::instance()->pathResolver() );
406-
if ( !resolvedPath.isNull() )
407-
{
408-
updatedPath = resolvedPath;
409-
}
410-
}
411-
412-
mCurrentSvgPath = updatedPath;
393+
mCurrentSvgPath = svgPath;
413394

414395
mFileLineEdit->blockSignals( true );
415-
mFileLineEdit->setText( updatedPath );
396+
mFileLineEdit->setText( svgPath );
416397
mFileLineEdit->blockSignals( false );
417398

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

435416
QString QgsSvgSelectorWidget::currentSvgPath() const
436417
{
437-
if ( mRelativePathChkBx->isChecked() )
438-
return currentSvgPathToName();
439-
440418
return mCurrentSvgPath;
441419
}
442420

443-
QString QgsSvgSelectorWidget::currentSvgPathToName() const
444-
{
445-
return QgsSymbolLayerUtils::svgSymbolPathToName( mCurrentSvgPath, QgsProject::instance()->pathResolver() );
446-
}
447-
448421
void QgsSvgSelectorWidget::updateCurrentSvgPath( const QString &svgPath )
449422
{
450423
mCurrentSvgPath = svgPath;

src/gui/symbology-ng/qgssvgselectorwidget.h

+2-18
Original file line numberDiff line numberDiff line change
@@ -235,20 +235,10 @@ class GUI_EXPORT QgsSvgSelectorWidget : public QWidget, private Ui::WidgetSvgSel
235235
QgsSvgSelectorWidget( QWidget *parent SIP_TRANSFERTHIS = 0 );
236236
~QgsSvgSelectorWidget();
237237

238-
static QgsSvgSelectorWidget *create( QWidget *parent = nullptr ) { return new QgsSvgSelectorWidget( parent ); }
239-
240238
QString currentSvgPath() const;
241-
QString currentSvgPathToName() const;
242-
243-
QTreeView *groupsTreeView() { return mGroupsTreeView; }
244-
QListView *imagesListView() { return mImagesListView; }
245-
QLineEdit *filePathLineEdit() { return mFileLineEdit; }
246-
QPushButton *filePathButton() { return mFilePushButton; }
247-
QCheckBox *relativePathCheckbox() { return mRelativePathChkBx; }
248-
QLayout *selectorLayout() { return this->layout(); }
249239

250240
public slots:
251-
//! Accepts absolute and relative paths
241+
//! Accepts absolute paths
252242
void setSvgPath( const QString &svgPath );
253243

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

269259
private:
270-
QString mCurrentSvgPath; // always stored as absolute path
260+
QString mCurrentSvgPath; //!< Always stored as absolute path
271261

272262
};
273263

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

290-
//! Returns the central layout. Widgets added to it must have this dialog as parent
291-
QVBoxLayout *layout() { return mLayout; }
292-
293-
//! Returns the button box
294-
QDialogButtonBox *buttonBox() { return mButtonBox; }
295-
296280
//! Returns pointer to the embedded SVG selector widget
297281
QgsSvgSelectorWidget *svgSelector() { return mSvgSelector; }
298282

src/ui/symbollayer/widget_svgselector.ui

+10-12
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@
1414
<string>Form</string>
1515
</property>
1616
<layout class="QGridLayout" name="gridLayout">
17-
<property name="margin">
17+
<property name="leftMargin">
18+
<number>0</number>
19+
</property>
20+
<property name="topMargin">
21+
<number>0</number>
22+
</property>
23+
<property name="rightMargin">
24+
<number>0</number>
25+
</property>
26+
<property name="bottomMargin">
1827
<number>0</number>
1928
</property>
2029
<item row="1" column="1">
@@ -111,16 +120,6 @@
111120
</property>
112121
</widget>
113122
</item>
114-
<item>
115-
<widget class="QCheckBox" name="mRelativePathChkBx">
116-
<property name="toolTip">
117-
<string>Generated path will be relative to current SVG search directories or to Project file</string>
118-
</property>
119-
<property name="text">
120-
<string>Relative path</string>
121-
</property>
122-
</widget>
123-
</item>
124123
</layout>
125124
</item>
126125
</layout>
@@ -130,7 +129,6 @@
130129
<tabstop>mImagesListView</tabstop>
131130
<tabstop>mFileLineEdit</tabstop>
132131
<tabstop>mFilePushButton</tabstop>
133-
<tabstop>mRelativePathChkBx</tabstop>
134132
</tabstops>
135133
<resources/>
136134
<connections/>

0 commit comments

Comments
 (0)