Tweak UI for symbol builder and selector.

- Move blend options to below symbol builder
- Move Save symbol to under symbol stack
- Move open Symbol manager to next to group dropdown
This commit is contained in:
Nathan Woodrow 2014-03-30 15:47:08 +10:00
parent 1af7581bf0
commit f816bce9f1
12 changed files with 175 additions and 150 deletions

View File

@ -1,4 +1,4 @@
class QgsStyleV2
class QgsStyleV2 : QObject
{
%TypeHeaderCode
#include <qgsstylev2.h>

View File

@ -12,7 +12,7 @@ class QgsSymbolsListWidget : QWidget
void setMarkerAngle( double angle );
void setMarkerSize( double size );
void setLineWidth( double width );
void addSymbolToStyle();
void symbolAddedToStyle( QString name, QgsSymbolV2* symbol );
void on_mSymbolUnitComboBox_currentIndexChanged( const QString & text );
void on_mTransparencySlider_valueChanged( int value );

View File

@ -370,6 +370,7 @@ SET(QGIS_CORE_MOC_HDRS
symbology-ng/qgscptcityarchive.h
symbology-ng/qgssvgcache.h
symbology-ng/qgsstylev2.h
)
IF (WITH_INTERNAL_QEXTSERIALPORT)

View File

@ -38,7 +38,7 @@
QgsStyleV2 *QgsStyleV2::mDefaultStyle = 0;
QgsStyleV2::QgsStyleV2()
QgsStyleV2::QgsStyleV2() : QObject()
{
mCurrentDB = 0;
}
@ -130,6 +130,8 @@ bool QgsStyleV2::saveSymbol( QString name, QgsSymbolV2* symbol, int groupid, QSt
return false;
}
emit symbolSaved( name, symbol );
return true;
}

View File

@ -63,8 +63,10 @@ enum TagmapTable { TagmapTagId, TagmapSymbolId };
enum ColorrampTable { ColorrampId, ColorrampName, ColorrampXML, ColorrampGroupId };
enum SmartgroupTable { SmartgroupId, SmartgroupName, SmartgroupXML };
class CORE_EXPORT QgsStyleV2
class CORE_EXPORT QgsStyleV2 : public QObject
{
Q_OBJECT
public:
QgsStyleV2();
~QgsStyleV2();
@ -315,6 +317,10 @@ class CORE_EXPORT QgsStyleV2
//! Imports the symbols and colorramps into the default style database from the given XML file
bool importXML( QString filename );
signals:
void symbolSaved( QString name, QgsSymbolV2* symbol );
protected:
QgsSymbolV2Map mSymbols;
@ -350,6 +356,9 @@ class CORE_EXPORT QgsStyleV2
* \return Success state of the update operation
*/
bool updateSymbol( StyleEntity type, QString name );
private:
Q_DISABLE_COPY( QgsStyleV2 )
};

View File

@ -62,22 +62,8 @@ QgsSymbolsListWidget::QgsSymbolsListWidget( QgsSymbolV2* symbol, QgsStyleV2* sty
viewSymbols->setModel( model );
connect( viewSymbols->selectionModel(), SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ), this, SLOT( setSymbolFromStyle( const QModelIndex & ) ) );
if ( parent )
{
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 );
connect( mStyle, SIGNAL( symbolSaved( QString, QgsSymbolV2* ) ), this, SLOT( symbolAddedToStyle( QString, QgsSymbolV2* ) ) );
connect( openStyleManagerButton, SIGNAL( pressed() ), this, SLOT( openStyleManager() ) );
lblSymbolName->setText( "" );
populateSymbolView();
@ -217,33 +203,8 @@ void QgsSymbolsListWidget::setLineWidth( double width )
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();
}

View File

@ -38,7 +38,7 @@ class GUI_EXPORT QgsSymbolsListWidget : public QWidget, private Ui::SymbolsListW
void setMarkerAngle( double angle );
void setMarkerSize( double size );
void setLineWidth( double width );
void addSymbolToStyle();
void symbolAddedToStyle( QString name, QgsSymbolV2* symbol );
void on_mSymbolUnitComboBox_currentIndexChanged( const QString & text );
void on_mTransparencySlider_valueChanged( int value );

View File

@ -182,6 +182,7 @@ QgsSymbolV2SelectorDialog::QgsSymbolV2SelectorDialog( QgsSymbolV2* symbol, QgsSt
connect( btnAddLayer, SIGNAL( clicked() ), this, SLOT( addLayer() ) );
connect( btnRemoveLayer, SIGNAL( clicked() ), this, SLOT( removeLayer() ) );
connect( btnLock, SIGNAL( clicked() ), this, SLOT( lockLayer() ) );
connect( btnSaveSymbol, SIGNAL( clicked() ), this, SLOT( saveSymbol() ) );
updateUi();
@ -485,6 +486,34 @@ void QgsSymbolV2SelectorDialog::lockLayer()
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 )
{
SymbolLayerItem *item = currentLayerItem();

View File

@ -72,6 +72,7 @@ class GUI_EXPORT QgsSymbolV2SelectorDialog : public QDialog, private Ui::QgsSymb
void addLayer();
void removeLayer();
void saveSymbol();
void lockLayer();
void layerChanged();

View File

@ -14,69 +14,6 @@
<string>Renderer settings</string>
</property>
<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>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@ -127,6 +64,69 @@
</widget>
</widget>
</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>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
@ -137,17 +137,17 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsBlendModeComboBox</class>
<extends>QComboBox</extends>
<header>qgsblendmodecombobox.h</header>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
<header>qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsBlendModeComboBox</class>
<extends>QComboBox</extends>
<header>qgsblendmodecombobox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>cboRenderers</tabstop>

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>444</width>
<height>383</height>
<width>436</width>
<height>359</height>
</rect>
</property>
<property name="windowTitle">
@ -44,13 +44,6 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Symbol layers</string>
</property>
</widget>
</item>
<item>
<widget class="QTreeView" name="layersTree">
<property name="sizePolicy">
@ -137,6 +130,35 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnSaveSymbol">
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Move down</string>
</property>
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@ -160,12 +182,18 @@
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="sizePolicy">

View File

@ -114,7 +114,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="pageMarker">
<layout class="QGridLayout" name="gridLayout">
@ -204,7 +204,7 @@
</item>
</layout>
</item>
<item row="1" column="0">
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>3</number>
@ -212,23 +212,10 @@
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Saved styles</string>
<string>Symbols in library</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="groupsCombo">
<property name="sizePolicy">
@ -248,9 +235,16 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="openStyleManagerButton">
<property name="text">
<string>Open Library</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QListView" name="viewSymbols">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@ -287,7 +281,7 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="topMargin">
<number>2</number>
@ -312,13 +306,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnStyle">
<property name="text">
<string>Symbol</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnAdvanced">
<property name="text">
@ -328,6 +315,13 @@
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>