Skip to content

Commit

Permalink
[ui] move the save symbol button
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Jan 7, 2016
1 parent f6ed453 commit 653a1e6
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 19 deletions.
1 change: 1 addition & 0 deletions python/gui/symbology-ng/qgssymbolslistwidget.sip
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class QgsSymbolsListWidget : QWidget
void setMarkerSize( double size );
void setLineWidth( double width );
void addSymbolToStyle();
void saveSymbol();
void symbolAddedToStyle( const QString& name, QgsSymbolV2* symbol );
void on_mSymbolUnitWidget_changed();
void on_mTransparencySlider_valueChanged( int value );
Expand Down
3 changes: 2 additions & 1 deletion python/gui/symbology-ng/qgssymbolv2selectordialog.sip
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ class QgsSymbolV2SelectorDialog : QDialog
void addLayer();
void removeLayer();

void saveSymbol();
void lockLayer();

void saveSymbol() /Deprecated/;

//! Duplicates the current symbol layer and places the duplicated layer above the current symbol layer
//! @note added in QGIS 2.14
void duplicateLayer();
Expand Down
30 changes: 30 additions & 0 deletions src/gui/symbology-ng/qgssymbolslistwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ QgsSymbolsListWidget::QgsSymbolsListWidget( QgsSymbolV2* symbol, QgsStyleV2* sty
btnColor->setAllowAlpha( true );
btnColor->setColorDialogTitle( tr( "Select color" ) );
btnColor->setContext( "symbology" );

connect( btnSaveSymbol, SIGNAL( clicked() ), this, SLOT( saveSymbol() ) );
}

QgsSymbolsListWidget::~QgsSymbolsListWidget()
Expand Down Expand Up @@ -360,6 +362,34 @@ void QgsSymbolsListWidget::addSymbolToStyle()
populateSymbolView();
}

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

// check if there is no symbol with same name
if ( mStyle->symbolNames().contains( name ) )
{
int res = QMessageBox::warning( this, tr( "Save symbol" ),
tr( "Symbol with name '%1' already exists. Overwrite?" )
.arg( name ),
QMessageBox::Yes | QMessageBox::No );
if ( res != QMessageBox::Yes )
{
return;
}
}

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

// make sure the symbol is stored
mStyle->saveSymbol( name, mSymbol->clone(), 0, QStringList() );
}

void QgsSymbolsListWidget::on_mSymbolUnitWidget_changed()
{
if ( mSymbol )
Expand Down
1 change: 1 addition & 0 deletions src/gui/symbology-ng/qgssymbolslistwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class GUI_EXPORT QgsSymbolsListWidget : public QWidget, private Ui::SymbolsListW
void setMarkerSize( double size );
void setLineWidth( double width );
void addSymbolToStyle();
void saveSymbol();
void symbolAddedToStyle( const QString& name, QgsSymbolV2* symbol );
void on_mSymbolUnitWidget_changed();
void on_mTransparencySlider_valueChanged( int value );
Expand Down
1 change: 0 additions & 1 deletion src/gui/symbology-ng/qgssymbolv2selectordialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ QgsSymbolV2SelectorDialog::QgsSymbolV2SelectorDialog( QgsSymbolV2* symbol, QgsSt
connect( btnRemoveLayer, SIGNAL( clicked() ), this, SLOT( removeLayer() ) );
connect( btnLock, SIGNAL( clicked() ), this, SLOT( lockLayer() ) );
connect( btnDuplicate, SIGNAL( clicked() ), this, SLOT( duplicateLayer() ) );
connect( btnSaveSymbol, SIGNAL( clicked() ), this, SLOT( saveSymbol() ) );

updateUi();

Expand Down
3 changes: 2 additions & 1 deletion src/gui/symbology-ng/qgssymbolv2selectordialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,10 @@ class GUI_EXPORT QgsSymbolV2SelectorDialog : public QDialog, private Ui::QgsSymb
void addLayer();
void removeLayer();

void saveSymbol();
void lockLayer();

Q_DECL_DEPRECATED void saveSymbol();

//! Duplicates the current symbol layer and places the duplicated layer above the current symbol layer
//! @note added in QGIS 2.14
void duplicateLayer();
Expand Down
16 changes: 0 additions & 16 deletions src/ui/qgssymbolv2selectordialogbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -159,22 +159,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnSaveSymbol">
<property name="maximumSize">
<size>
<width>70</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Save symbol</string>
</property>
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
Expand Down
17 changes: 17 additions & 0 deletions src/ui/symbollayer/widget_symbolslist.ui
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,22 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnSaveSymbol">
<property name="maximumSize">
<size>
<width>70</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Save symbol</string>
</property>
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnAdvanced">
<property name="text">
Expand Down Expand Up @@ -391,6 +407,7 @@
<tabstop>groupsCombo</tabstop>
<tabstop>openStyleManagerButton</tabstop>
<tabstop>viewSymbols</tabstop>
<tabstop>btnSaveSymbol</tabstop>
<tabstop>btnAdvanced</tabstop>
</tabstops>
<resources/>
Expand Down

0 comments on commit 653a1e6

Please sign in to comment.