Skip to content

Commit

Permalink
"Add symbol to style" functionality in symbol selector.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@11169 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Jul 24, 2009
1 parent 92d7e23 commit b6682c5
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 13 deletions.
19 changes: 19 additions & 0 deletions src/gui/symbology-ng/qgssymbolv2selectordialog.cpp
Expand Up @@ -7,9 +7,12 @@
#include "qgssymbollayerv2utils.h"
#include "qgsstylev2.h"

#include "qgsapplication.h"

#include <QColorDialog>
#include <QPainter>
#include <QStandardItemModel>
#include <QInputDialog>

QgsSymbolV2SelectorDialog::QgsSymbolV2SelectorDialog(QgsSymbolV2* symbol, QgsStyleV2* style, QWidget* parent, bool embedded)
: QDialog(parent)
Expand Down Expand Up @@ -45,6 +48,8 @@ QgsSymbolV2SelectorDialog::QgsSymbolV2SelectorDialog(QgsSymbolV2* symbol, QgsSty
connect(spinSize, SIGNAL(valueChanged(double)), this, SLOT(setMarkerSize(double)));
connect(spinWidth, SIGNAL(valueChanged(double)), this, SLOT(setLineWidth(double)));

connect(btnAddToStyle, SIGNAL(clicked()), this, SLOT(addSymbolToStyle()));
btnAddToStyle->setIcon( QIcon( QgsApplication::defaultThemePath() + "symbologyAdd.png" ) );
}

void QgsSymbolV2SelectorDialog::populateSymbolView()
Expand Down Expand Up @@ -183,3 +188,17 @@ void QgsSymbolV2SelectorDialog::setLineWidth(double width)
updateSymbolPreview();
emit symbolModified();
}

void QgsSymbolV2SelectorDialog::addSymbolToStyle()
{
bool ok;
QString name = QInputDialog::getText(this, "Symbol name",
"Please enter name for the symbol:", QLineEdit::Normal, "New symbol", &ok);
if (!ok || name.isEmpty())
return;

// add new symbol to style and re-populate the list
mStyle->addSymbol(name, mSymbol->clone());

populateSymbolView();
}
1 change: 1 addition & 0 deletions src/gui/symbology-ng/qgssymbolv2selectordialog.h
Expand Up @@ -30,6 +30,7 @@ public slots:
void setMarkerAngle(double angle);
void setMarkerSize(double size);
void setLineWidth(double width);
void addSymbolToStyle();

signals:
void symbolModified();
Expand Down
30 changes: 17 additions & 13 deletions src/ui/qgssymbolv2selectordialogbase.ui
Expand Up @@ -6,17 +6,17 @@
<rect>
<x>0</x>
<y>0</y>
<width>477</width>
<width>452</width>
<height>397</height>
</rect>
</property>
<property name="windowTitle">
<string>Symbol selector</string>
</property>
<layout class="QVBoxLayout">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout">
<item row="0" column="0" rowspan="2">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" rowspan="3">
<widget class="QLabel" name="lblPreview">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
Expand Down Expand Up @@ -45,7 +45,7 @@
</property>
</widget>
</item>
<item row="0" column="2" rowspan="2">
<item row="0" column="2" rowspan="3">
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>1</number>
Expand Down Expand Up @@ -116,28 +116,32 @@
</widget>
</item>
<item row="0" column="3" rowspan="2">
<spacer>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>50</width>
<height>81</height>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<item row="1" column="1" rowspan="2">
<widget class="QPushButton" name="btnSetColor">
<property name="text">
<string>Set color</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QPushButton" name="btnAddToStyle">
<property name="text">
<string>Add to style</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down

0 comments on commit b6682c5

Please sign in to comment.