Skip to content

Commit

Permalink
Tweak UI for symbol builder and selector.
Browse files Browse the repository at this point in the history
- Move blend options to below symbol builder
- Move Save symbol to under symbol stack
- Move open Symbol manager to next to group dropdown
  • Loading branch information
NathanW2 committed May 6, 2014
1 parent 1af7581 commit f816bce
Show file tree
Hide file tree
Showing 12 changed files with 175 additions and 150 deletions.
2 changes: 1 addition & 1 deletion python/core/symbology-ng/qgsstylev2.sip
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
class QgsStyleV2 class QgsStyleV2 : QObject
{ {
%TypeHeaderCode %TypeHeaderCode
#include <qgsstylev2.h> #include <qgsstylev2.h>
Expand Down
2 changes: 1 addition & 1 deletion python/gui/symbology-ng/qgssymbolslistwidget.sip
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class QgsSymbolsListWidget : QWidget
void setMarkerAngle( double angle ); void setMarkerAngle( double angle );
void setMarkerSize( double size ); void setMarkerSize( double size );
void setLineWidth( double width ); void setLineWidth( double width );
void addSymbolToStyle(); void symbolAddedToStyle( QString name, QgsSymbolV2* symbol );
void on_mSymbolUnitComboBox_currentIndexChanged( const QString & text ); void on_mSymbolUnitComboBox_currentIndexChanged( const QString & text );
void on_mTransparencySlider_valueChanged( int value ); void on_mTransparencySlider_valueChanged( int value );


Expand Down
1 change: 1 addition & 0 deletions src/core/CMakeLists.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ SET(QGIS_CORE_MOC_HDRS


symbology-ng/qgscptcityarchive.h symbology-ng/qgscptcityarchive.h
symbology-ng/qgssvgcache.h symbology-ng/qgssvgcache.h
symbology-ng/qgsstylev2.h
) )


IF (WITH_INTERNAL_QEXTSERIALPORT) IF (WITH_INTERNAL_QEXTSERIALPORT)
Expand Down
4 changes: 3 additions & 1 deletion src/core/symbology-ng/qgsstylev2.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
QgsStyleV2 *QgsStyleV2::mDefaultStyle = 0; QgsStyleV2 *QgsStyleV2::mDefaultStyle = 0;




QgsStyleV2::QgsStyleV2() QgsStyleV2::QgsStyleV2() : QObject()
{ {
mCurrentDB = 0; mCurrentDB = 0;
} }
Expand Down Expand Up @@ -130,6 +130,8 @@ bool QgsStyleV2::saveSymbol( QString name, QgsSymbolV2* symbol, int groupid, QSt
return false; return false;
} }


emit symbolSaved( name, symbol );

return true; return true;
} }


Expand Down
11 changes: 10 additions & 1 deletion src/core/symbology-ng/qgsstylev2.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ enum TagmapTable { TagmapTagId, TagmapSymbolId };
enum ColorrampTable { ColorrampId, ColorrampName, ColorrampXML, ColorrampGroupId }; enum ColorrampTable { ColorrampId, ColorrampName, ColorrampXML, ColorrampGroupId };
enum SmartgroupTable { SmartgroupId, SmartgroupName, SmartgroupXML }; enum SmartgroupTable { SmartgroupId, SmartgroupName, SmartgroupXML };


class CORE_EXPORT QgsStyleV2 class CORE_EXPORT QgsStyleV2 : public QObject
{ {
Q_OBJECT

public: public:
QgsStyleV2(); QgsStyleV2();
~QgsStyleV2(); ~QgsStyleV2();
Expand Down Expand Up @@ -315,6 +317,10 @@ class CORE_EXPORT QgsStyleV2
//! Imports the symbols and colorramps into the default style database from the given XML file //! Imports the symbols and colorramps into the default style database from the given XML file
bool importXML( QString filename ); bool importXML( QString filename );


signals:

void symbolSaved( QString name, QgsSymbolV2* symbol );

protected: protected:


QgsSymbolV2Map mSymbols; QgsSymbolV2Map mSymbols;
Expand Down Expand Up @@ -350,6 +356,9 @@ class CORE_EXPORT QgsStyleV2
* \return Success state of the update operation * \return Success state of the update operation
*/ */
bool updateSymbol( StyleEntity type, QString name ); bool updateSymbol( StyleEntity type, QString name );

private:
Q_DISABLE_COPY( QgsStyleV2 )
}; };




Expand Down
45 changes: 3 additions & 42 deletions src/gui/symbology-ng/qgssymbolslistwidget.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -62,22 +62,8 @@ QgsSymbolsListWidget::QgsSymbolsListWidget( QgsSymbolV2* symbol, QgsStyleV2* sty
viewSymbols->setModel( model ); viewSymbols->setModel( model );
connect( viewSymbols->selectionModel(), SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ), this, SLOT( setSymbolFromStyle( const QModelIndex & ) ) ); connect( viewSymbols->selectionModel(), SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ), this, SLOT( setSymbolFromStyle( const QModelIndex & ) ) );


if ( parent ) connect( mStyle, SIGNAL( symbolSaved( QString, QgsSymbolV2* ) ), this, SLOT( symbolAddedToStyle( QString, QgsSymbolV2* ) ) );
{ connect( openStyleManagerButton, SIGNAL( pressed() ), this, SLOT( openStyleManager() ) );
if ( dynamic_cast<QgsStyleV2ManagerDialog*>( parent->parentWidget() ) )
{
btnStyle->setVisible( false );
}
}
// Set the Style Menu under btnStyle
QMenu *styleMenu = new QMenu( btnStyle );
QAction *styleMgrAction = new QAction( tr( "Style Manager" ), styleMenu );
styleMenu->addAction( styleMgrAction );
QAction *saveStyle = new QAction( tr( "Save in symbol library..." ), styleMenu );
styleMenu->addAction( saveStyle );
connect( styleMgrAction, SIGNAL( triggered() ), this, SLOT( openStyleManager() ) );
connect( saveStyle, SIGNAL( triggered() ), this, SLOT( addSymbolToStyle() ) );
btnStyle->setMenu( styleMenu );


lblSymbolName->setText( "" ); lblSymbolName->setText( "" );
populateSymbolView(); populateSymbolView();
Expand Down Expand Up @@ -217,33 +203,8 @@ void QgsSymbolsListWidget::setLineWidth( double width )
emit changed(); emit changed();
} }


void QgsSymbolsListWidget::addSymbolToStyle() void QgsSymbolsListWidget::symbolAddedToStyle( QString name, QgsSymbolV2* symbol)
{ {
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() );

populateSymbolView(); populateSymbolView();
} }


Expand Down
2 changes: 1 addition & 1 deletion src/gui/symbology-ng/qgssymbolslistwidget.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class GUI_EXPORT QgsSymbolsListWidget : public QWidget, private Ui::SymbolsListW
void setMarkerAngle( double angle ); void setMarkerAngle( double angle );
void setMarkerSize( double size ); void setMarkerSize( double size );
void setLineWidth( double width ); void setLineWidth( double width );
void addSymbolToStyle(); void symbolAddedToStyle( QString name, QgsSymbolV2* symbol );
void on_mSymbolUnitComboBox_currentIndexChanged( const QString & text ); void on_mSymbolUnitComboBox_currentIndexChanged( const QString & text );
void on_mTransparencySlider_valueChanged( int value ); void on_mTransparencySlider_valueChanged( int value );


Expand Down
29 changes: 29 additions & 0 deletions src/gui/symbology-ng/qgssymbolv2selectordialog.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ QgsSymbolV2SelectorDialog::QgsSymbolV2SelectorDialog( QgsSymbolV2* symbol, QgsSt
connect( btnAddLayer, SIGNAL( clicked() ), this, SLOT( addLayer() ) ); connect( btnAddLayer, SIGNAL( clicked() ), this, SLOT( addLayer() ) );
connect( btnRemoveLayer, SIGNAL( clicked() ), this, SLOT( removeLayer() ) ); connect( btnRemoveLayer, SIGNAL( clicked() ), this, SLOT( removeLayer() ) );
connect( btnLock, SIGNAL( clicked() ), this, SLOT( lockLayer() ) ); connect( btnLock, SIGNAL( clicked() ), this, SLOT( lockLayer() ) );
connect( btnSaveSymbol, SIGNAL( clicked() ), this, SLOT( saveSymbol() ) );


updateUi(); updateUi();


Expand Down Expand Up @@ -485,6 +486,34 @@ void QgsSymbolV2SelectorDialog::lockLayer()
layer->setLocked( btnLock->isChecked() ); layer->setLocked( btnLock->isChecked() );
} }


void QgsSymbolV2SelectorDialog::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 QgsSymbolV2SelectorDialog::changeLayer( QgsSymbolLayerV2* newLayer ) void QgsSymbolV2SelectorDialog::changeLayer( QgsSymbolLayerV2* newLayer )
{ {
SymbolLayerItem *item = currentLayerItem(); SymbolLayerItem *item = currentLayerItem();
Expand Down
1 change: 1 addition & 0 deletions src/gui/symbology-ng/qgssymbolv2selectordialog.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class GUI_EXPORT QgsSymbolV2SelectorDialog : public QDialog, private Ui::QgsSymb
void addLayer(); void addLayer();
void removeLayer(); void removeLayer();


void saveSymbol();
void lockLayer(); void lockLayer();


void layerChanged(); void layerChanged();
Expand Down
136 changes: 68 additions & 68 deletions src/ui/qgsrendererv2propsdialogbase.ui
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,69 +14,6 @@
<string>Renderer settings</string> <string>Renderer settings</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QgsCollapsibleGroupBox" name="groupBox">
<property name="title">
<string>Layer rendering</string>
</property>
<property name="collapsed" stdset="0">
<bool>false</bool>
</property>
<property name="saveCollapsedState" stdset="0">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QSlider" name="mLayerTransparencySlider">
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="mLayerTransparencySpnBx">
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblTransparency">
<property name="text">
<string>Layer transparency</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QgsBlendModeComboBox" name="mFeatureBlendComboBox"/>
</item>
<item row="1" column="2">
<widget class="QLabel" name="lblFeatureBlend">
<property name="text">
<string>Feature blending mode</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblLayerBlend">
<property name="text">
<string>Layer blending mode</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QgsBlendModeComboBox" name="mBlendModeComboBox"/>
</item>
</layout>
</widget>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
Expand Down Expand Up @@ -127,6 +64,69 @@
</widget> </widget>
</widget> </widget>
</item> </item>
<item>
<widget class="QgsCollapsibleGroupBox" name="groupBox">
<property name="title">
<string>Layer rendering</string>
</property>
<property name="collapsed" stdset="0">
<bool>false</bool>
</property>
<property name="saveCollapsedState" stdset="0">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QSlider" name="mLayerTransparencySlider">
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="mLayerTransparencySpnBx">
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblTransparency">
<property name="text">
<string>Layer transparency</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QgsBlendModeComboBox" name="mFeatureBlendComboBox"/>
</item>
<item row="1" column="2">
<widget class="QLabel" name="lblFeatureBlend">
<property name="text">
<string>Feature blending mode</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblLayerBlend">
<property name="text">
<string>Layer blending mode</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QgsBlendModeComboBox" name="mBlendModeComboBox"/>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons"> <property name="standardButtons">
Expand All @@ -137,17 +137,17 @@
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget>
<class>QgsBlendModeComboBox</class>
<extends>QComboBox</extends>
<header>qgsblendmodecombobox.h</header>
</customwidget>
<customwidget> <customwidget>
<class>QgsCollapsibleGroupBox</class> <class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends> <extends>QGroupBox</extends>
<header>qgscollapsiblegroupbox.h</header> <header>qgscollapsiblegroupbox.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>QgsBlendModeComboBox</class>
<extends>QComboBox</extends>
<header>qgsblendmodecombobox.h</header>
</customwidget>
</customwidgets> </customwidgets>
<tabstops> <tabstops>
<tabstop>cboRenderers</tabstop> <tabstop>cboRenderers</tabstop>
Expand Down
Loading

0 comments on commit f816bce

Please sign in to comment.