Skip to content

Commit b6682c5

Browse files
author
wonder
committed
"Add symbol to style" functionality in symbol selector.
git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@11169 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 92d7e23 commit b6682c5

File tree

3 files changed

+37
-13
lines changed

3 files changed

+37
-13
lines changed

src/gui/symbology-ng/qgssymbolv2selectordialog.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
#include "qgssymbollayerv2utils.h"
88
#include "qgsstylev2.h"
99

10+
#include "qgsapplication.h"
11+
1012
#include <QColorDialog>
1113
#include <QPainter>
1214
#include <QStandardItemModel>
15+
#include <QInputDialog>
1316

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

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

5055
void QgsSymbolV2SelectorDialog::populateSymbolView()
@@ -183,3 +188,17 @@ void QgsSymbolV2SelectorDialog::setLineWidth(double width)
183188
updateSymbolPreview();
184189
emit symbolModified();
185190
}
191+
192+
void QgsSymbolV2SelectorDialog::addSymbolToStyle()
193+
{
194+
bool ok;
195+
QString name = QInputDialog::getText(this, "Symbol name",
196+
"Please enter name for the symbol:", QLineEdit::Normal, "New symbol", &ok);
197+
if (!ok || name.isEmpty())
198+
return;
199+
200+
// add new symbol to style and re-populate the list
201+
mStyle->addSymbol(name, mSymbol->clone());
202+
203+
populateSymbolView();
204+
}

src/gui/symbology-ng/qgssymbolv2selectordialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public slots:
3030
void setMarkerAngle(double angle);
3131
void setMarkerSize(double size);
3232
void setLineWidth(double width);
33+
void addSymbolToStyle();
3334

3435
signals:
3536
void symbolModified();

src/ui/qgssymbolv2selectordialogbase.ui

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>477</width>
9+
<width>452</width>
1010
<height>397</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
1414
<string>Symbol selector</string>
1515
</property>
16-
<layout class="QVBoxLayout">
16+
<layout class="QVBoxLayout" name="verticalLayout">
1717
<item>
18-
<layout class="QGridLayout">
19-
<item row="0" column="0" rowspan="2">
18+
<layout class="QGridLayout" name="gridLayout">
19+
<item row="0" column="0" rowspan="3">
2020
<widget class="QLabel" name="lblPreview">
2121
<property name="sizePolicy">
2222
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
@@ -45,7 +45,7 @@
4545
</property>
4646
</widget>
4747
</item>
48-
<item row="0" column="2" rowspan="2">
48+
<item row="0" column="2" rowspan="3">
4949
<widget class="QStackedWidget" name="stackedWidget">
5050
<property name="currentIndex">
5151
<number>1</number>
@@ -116,28 +116,32 @@
116116
</widget>
117117
</item>
118118
<item row="0" column="3" rowspan="2">
119-
<spacer>
119+
<spacer name="verticalSpacer">
120120
<property name="orientation">
121-
<enum>Qt::Horizontal</enum>
122-
</property>
123-
<property name="sizeType">
124-
<enum>QSizePolicy::Preferred</enum>
121+
<enum>Qt::Vertical</enum>
125122
</property>
126123
<property name="sizeHint" stdset="0">
127124
<size>
128-
<width>50</width>
129-
<height>81</height>
125+
<width>20</width>
126+
<height>40</height>
130127
</size>
131128
</property>
132129
</spacer>
133130
</item>
134-
<item row="1" column="1">
131+
<item row="1" column="1" rowspan="2">
135132
<widget class="QPushButton" name="btnSetColor">
136133
<property name="text">
137134
<string>Set color</string>
138135
</property>
139136
</widget>
140137
</item>
138+
<item row="2" column="3">
139+
<widget class="QPushButton" name="btnAddToStyle">
140+
<property name="text">
141+
<string>Add to style</string>
142+
</property>
143+
</widget>
144+
</item>
141145
</layout>
142146
</item>
143147
<item>

0 commit comments

Comments
 (0)