Skip to content

Commit 653a1e6

Browse files
committed
[ui] move the save symbol button
1 parent f6ed453 commit 653a1e6

File tree

8 files changed

+53
-19
lines changed

8 files changed

+53
-19
lines changed

python/gui/symbology-ng/qgssymbolslistwidget.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class QgsSymbolsListWidget : QWidget
5151
void setMarkerSize( double size );
5252
void setLineWidth( double width );
5353
void addSymbolToStyle();
54+
void saveSymbol();
5455
void symbolAddedToStyle( const QString& name, QgsSymbolV2* symbol );
5556
void on_mSymbolUnitWidget_changed();
5657
void on_mTransparencySlider_valueChanged( int value );

python/gui/symbology-ng/qgssymbolv2selectordialog.sip

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ class QgsSymbolV2SelectorDialog : QDialog
6464
void addLayer();
6565
void removeLayer();
6666

67-
void saveSymbol();
6867
void lockLayer();
6968

69+
void saveSymbol() /Deprecated/;
70+
7071
//! Duplicates the current symbol layer and places the duplicated layer above the current symbol layer
7172
//! @note added in QGIS 2.14
7273
void duplicateLayer();

src/gui/symbology-ng/qgssymbolslistwidget.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ QgsSymbolsListWidget::QgsSymbolsListWidget( QgsSymbolV2* symbol, QgsStyleV2* sty
118118
btnColor->setAllowAlpha( true );
119119
btnColor->setColorDialogTitle( tr( "Select color" ) );
120120
btnColor->setContext( "symbology" );
121+
122+
connect( btnSaveSymbol, SIGNAL( clicked() ), this, SLOT( saveSymbol() ) );
121123
}
122124

123125
QgsSymbolsListWidget::~QgsSymbolsListWidget()
@@ -360,6 +362,34 @@ void QgsSymbolsListWidget::addSymbolToStyle()
360362
populateSymbolView();
361363
}
362364

365+
void QgsSymbolsListWidget::saveSymbol()
366+
{
367+
bool ok;
368+
QString name = QInputDialog::getText( this, tr( "Symbol name" ),
369+
tr( "Please enter name for the symbol:" ), QLineEdit::Normal, tr( "New symbol" ), &ok );
370+
if ( !ok || name.isEmpty() )
371+
return;
372+
373+
// check if there is no symbol with same name
374+
if ( mStyle->symbolNames().contains( name ) )
375+
{
376+
int res = QMessageBox::warning( this, tr( "Save symbol" ),
377+
tr( "Symbol with name '%1' already exists. Overwrite?" )
378+
.arg( name ),
379+
QMessageBox::Yes | QMessageBox::No );
380+
if ( res != QMessageBox::Yes )
381+
{
382+
return;
383+
}
384+
}
385+
386+
// add new symbol to style and re-populate the list
387+
mStyle->addSymbol( name, mSymbol->clone() );
388+
389+
// make sure the symbol is stored
390+
mStyle->saveSymbol( name, mSymbol->clone(), 0, QStringList() );
391+
}
392+
363393
void QgsSymbolsListWidget::on_mSymbolUnitWidget_changed()
364394
{
365395
if ( mSymbol )

src/gui/symbology-ng/qgssymbolslistwidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class GUI_EXPORT QgsSymbolsListWidget : public QWidget, private Ui::SymbolsListW
8181
void setMarkerSize( double size );
8282
void setLineWidth( double width );
8383
void addSymbolToStyle();
84+
void saveSymbol();
8485
void symbolAddedToStyle( const QString& name, QgsSymbolV2* symbol );
8586
void on_mSymbolUnitWidget_changed();
8687
void on_mTransparencySlider_valueChanged( int value );

src/gui/symbology-ng/qgssymbolv2selectordialog.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ QgsSymbolV2SelectorDialog::QgsSymbolV2SelectorDialog( QgsSymbolV2* symbol, QgsSt
261261
connect( btnRemoveLayer, SIGNAL( clicked() ), this, SLOT( removeLayer() ) );
262262
connect( btnLock, SIGNAL( clicked() ), this, SLOT( lockLayer() ) );
263263
connect( btnDuplicate, SIGNAL( clicked() ), this, SLOT( duplicateLayer() ) );
264-
connect( btnSaveSymbol, SIGNAL( clicked() ), this, SLOT( saveSymbol() ) );
265264

266265
updateUi();
267266

src/gui/symbology-ng/qgssymbolv2selectordialog.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,10 @@ class GUI_EXPORT QgsSymbolV2SelectorDialog : public QDialog, private Ui::QgsSymb
136136
void addLayer();
137137
void removeLayer();
138138

139-
void saveSymbol();
140139
void lockLayer();
141140

141+
Q_DECL_DEPRECATED void saveSymbol();
142+
142143
//! Duplicates the current symbol layer and places the duplicated layer above the current symbol layer
143144
//! @note added in QGIS 2.14
144145
void duplicateLayer();

src/ui/qgssymbolv2selectordialogbase.ui

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -159,22 +159,6 @@
159159
</property>
160160
</spacer>
161161
</item>
162-
<item>
163-
<widget class="QPushButton" name="btnSaveSymbol">
164-
<property name="maximumSize">
165-
<size>
166-
<width>70</width>
167-
<height>16777215</height>
168-
</size>
169-
</property>
170-
<property name="toolTip">
171-
<string>Save symbol</string>
172-
</property>
173-
<property name="text">
174-
<string>Save</string>
175-
</property>
176-
</widget>
177-
</item>
178162
</layout>
179163
</item>
180164
</layout>

src/ui/symbollayer/widget_symbolslist.ui

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,22 @@
337337
</property>
338338
</spacer>
339339
</item>
340+
<item>
341+
<widget class="QPushButton" name="btnSaveSymbol">
342+
<property name="maximumSize">
343+
<size>
344+
<width>70</width>
345+
<height>16777215</height>
346+
</size>
347+
</property>
348+
<property name="toolTip">
349+
<string>Save symbol</string>
350+
</property>
351+
<property name="text">
352+
<string>Save</string>
353+
</property>
354+
</widget>
355+
</item>
340356
<item>
341357
<widget class="QPushButton" name="btnAdvanced">
342358
<property name="text">
@@ -391,6 +407,7 @@
391407
<tabstop>groupsCombo</tabstop>
392408
<tabstop>openStyleManagerButton</tabstop>
393409
<tabstop>viewSymbols</tabstop>
410+
<tabstop>btnSaveSymbol</tabstop>
394411
<tabstop>btnAdvanced</tabstop>
395412
</tabstops>
396413
<resources/>

0 commit comments

Comments
 (0)