Skip to content
Permalink
Browse files
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.
  • Loading branch information
wonder-sk committed May 13, 2017
1 parent 5bdae75 commit c882f88c1d4edafd5d35197a1e3a38c497ab03b8
@@ -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()
@@ -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();

@@ -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;
@@ -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; }

@@ -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.