Skip to content

Commit

Permalink
Add line edit to select svg marker
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jun 20, 2011
1 parent 3fcdc4c commit a21e1db
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 6 deletions.
32 changes: 30 additions & 2 deletions src/gui/symbology-ng/qgssymbollayerv2widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
#include <QAbstractButton>
#include <QColorDialog>
#include <QDir>
#include <QFileDialog>
#include <QPainter>
#include <QSettings>
#include <QStandardItemModel>
#include <QSvgRenderer>

Expand Down Expand Up @@ -618,8 +620,9 @@ QgsSymbolLayerV2* QgsSvgMarkerSymbolLayerV2Widget::symbolLayer()

void QgsSvgMarkerSymbolLayerV2Widget::setName( const QModelIndex& idx )
{
mLayer->setPath( idx.data( Qt::UserRole ).toString() );

QString name = idx.data( Qt::UserRole ).toString();
mLayer->setPath( name );
mFileLineEdit->setText( name );
emit changed();
}

Expand All @@ -641,6 +644,31 @@ void QgsSvgMarkerSymbolLayerV2Widget::setOffset()
emit changed();
}

void QgsSvgMarkerSymbolLayerV2Widget::on_mFileToolButton_clicked()
{
QSettings s;
QString file = QFileDialog::getOpenFileName( 0, tr( "Select SVG file" ), s.value( "/UI/lastSVGMarkerDir" ).toString(), "SVG files (*.svg)" );
QFileInfo fi( file );
if ( file.isEmpty() || !fi.exists() )
{
return;
}
mFileLineEdit->setText( file );
mLayer->setPath( file );
s.setValue( "/UI/lastSVGMarkerDir", fi.absolutePath() );
emit changed();
}

void QgsSvgMarkerSymbolLayerV2Widget::on_mFileLineEdit_textEdited( const QString& text )
{
if ( !QFileInfo( text ).exists() )
{
return;
}
mLayer->setPath( text );
emit changed();
}

///////////////

QgsLineDecorationSymbolLayerV2Widget::QgsLineDecorationSymbolLayerV2Widget( QWidget* parent )
Expand Down
2 changes: 2 additions & 0 deletions src/gui/symbology-ng/qgssymbollayerv2widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ class GUI_EXPORT QgsSvgMarkerSymbolLayerV2Widget : public QgsSymbolLayerV2Widget
void setSize();
void setAngle();
void setOffset();
void on_mFileToolButton_clicked();
void on_mFileLineEdit_textEdited( const QString& text );

protected:

Expand Down
22 changes: 18 additions & 4 deletions src/ui/symbollayer/widget_svgmarker.ui
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
Expand Down Expand Up @@ -120,14 +120,14 @@
</item>
</layout>
</item>
<item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>SVG Image</string>
</property>
</widget>
</item>
<item>
<item row="2" column="0">
<widget class="QListView" name="viewImages">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
Expand Down Expand Up @@ -167,6 +167,20 @@
</property>
</widget>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="mFileLineEdit"/>
</item>
<item>
<widget class="QToolButton" name="mFileToolButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
Expand Down

0 comments on commit a21e1db

Please sign in to comment.