Skip to content

Commit f816bce

Browse files
committedMay 6, 2014
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
1 parent 1af7581 commit f816bce

File tree

12 files changed

+175
-150
lines changed

12 files changed

+175
-150
lines changed
 

‎python/core/symbology-ng/qgsstylev2.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class QgsStyleV2
1+
class QgsStyleV2 : QObject
22
{
33
%TypeHeaderCode
44
#include <qgsstylev2.h>

‎python/gui/symbology-ng/qgssymbolslistwidget.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class QgsSymbolsListWidget : QWidget
1212
void setMarkerAngle( double angle );
1313
void setMarkerSize( double size );
1414
void setLineWidth( double width );
15-
void addSymbolToStyle();
15+
void symbolAddedToStyle( QString name, QgsSymbolV2* symbol );
1616
void on_mSymbolUnitComboBox_currentIndexChanged( const QString & text );
1717
void on_mTransparencySlider_valueChanged( int value );
1818

‎src/core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ SET(QGIS_CORE_MOC_HDRS
370370

371371
symbology-ng/qgscptcityarchive.h
372372
symbology-ng/qgssvgcache.h
373+
symbology-ng/qgsstylev2.h
373374
)
374375

375376
IF (WITH_INTERNAL_QEXTSERIALPORT)

‎src/core/symbology-ng/qgsstylev2.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
QgsStyleV2 *QgsStyleV2::mDefaultStyle = 0;
3939

4040

41-
QgsStyleV2::QgsStyleV2()
41+
QgsStyleV2::QgsStyleV2() : QObject()
4242
{
4343
mCurrentDB = 0;
4444
}
@@ -130,6 +130,8 @@ bool QgsStyleV2::saveSymbol( QString name, QgsSymbolV2* symbol, int groupid, QSt
130130
return false;
131131
}
132132

133+
emit symbolSaved( name, symbol );
134+
133135
return true;
134136
}
135137

‎src/core/symbology-ng/qgsstylev2.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ enum TagmapTable { TagmapTagId, TagmapSymbolId };
6363
enum ColorrampTable { ColorrampId, ColorrampName, ColorrampXML, ColorrampGroupId };
6464
enum SmartgroupTable { SmartgroupId, SmartgroupName, SmartgroupXML };
6565

66-
class CORE_EXPORT QgsStyleV2
66+
class CORE_EXPORT QgsStyleV2 : public QObject
6767
{
68+
Q_OBJECT
69+
6870
public:
6971
QgsStyleV2();
7072
~QgsStyleV2();
@@ -315,6 +317,10 @@ class CORE_EXPORT QgsStyleV2
315317
//! Imports the symbols and colorramps into the default style database from the given XML file
316318
bool importXML( QString filename );
317319

320+
signals:
321+
322+
void symbolSaved( QString name, QgsSymbolV2* symbol );
323+
318324
protected:
319325

320326
QgsSymbolV2Map mSymbols;
@@ -350,6 +356,9 @@ class CORE_EXPORT QgsStyleV2
350356
* \return Success state of the update operation
351357
*/
352358
bool updateSymbol( StyleEntity type, QString name );
359+
360+
private:
361+
Q_DISABLE_COPY( QgsStyleV2 )
353362
};
354363

355364

‎src/gui/symbology-ng/qgssymbolslistwidget.cpp

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,8 @@ QgsSymbolsListWidget::QgsSymbolsListWidget( QgsSymbolV2* symbol, QgsStyleV2* sty
6262
viewSymbols->setModel( model );
6363
connect( viewSymbols->selectionModel(), SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ), this, SLOT( setSymbolFromStyle( const QModelIndex & ) ) );
6464

65-
if ( parent )
66-
{
67-
if ( dynamic_cast<QgsStyleV2ManagerDialog*>( parent->parentWidget() ) )
68-
{
69-
btnStyle->setVisible( false );
70-
}
71-
}
72-
// Set the Style Menu under btnStyle
73-
QMenu *styleMenu = new QMenu( btnStyle );
74-
QAction *styleMgrAction = new QAction( tr( "Style Manager" ), styleMenu );
75-
styleMenu->addAction( styleMgrAction );
76-
QAction *saveStyle = new QAction( tr( "Save in symbol library..." ), styleMenu );
77-
styleMenu->addAction( saveStyle );
78-
connect( styleMgrAction, SIGNAL( triggered() ), this, SLOT( openStyleManager() ) );
79-
connect( saveStyle, SIGNAL( triggered() ), this, SLOT( addSymbolToStyle() ) );
80-
btnStyle->setMenu( styleMenu );
65+
connect( mStyle, SIGNAL( symbolSaved( QString, QgsSymbolV2* ) ), this, SLOT( symbolAddedToStyle( QString, QgsSymbolV2* ) ) );
66+
connect( openStyleManagerButton, SIGNAL( pressed() ), this, SLOT( openStyleManager() ) );
8167

8268
lblSymbolName->setText( "" );
8369
populateSymbolView();
@@ -217,33 +203,8 @@ void QgsSymbolsListWidget::setLineWidth( double width )
217203
emit changed();
218204
}
219205

220-
void QgsSymbolsListWidget::addSymbolToStyle()
206+
void QgsSymbolsListWidget::symbolAddedToStyle( QString name, QgsSymbolV2* symbol)
221207
{
222-
bool ok;
223-
QString name = QInputDialog::getText( this, tr( "Symbol name" ),
224-
tr( "Please enter name for the symbol:" ) , QLineEdit::Normal, tr( "New symbol" ), &ok );
225-
if ( !ok || name.isEmpty() )
226-
return;
227-
228-
// check if there is no symbol with same name
229-
if ( mStyle->symbolNames().contains( name ) )
230-
{
231-
int res = QMessageBox::warning( this, tr( "Save symbol" ),
232-
tr( "Symbol with name '%1' already exists. Overwrite?" )
233-
.arg( name ),
234-
QMessageBox::Yes | QMessageBox::No );
235-
if ( res != QMessageBox::Yes )
236-
{
237-
return;
238-
}
239-
}
240-
241-
// add new symbol to style and re-populate the list
242-
mStyle->addSymbol( name, mSymbol->clone() );
243-
244-
// make sure the symbol is stored
245-
mStyle->saveSymbol( name, mSymbol->clone(), 0, QStringList() );
246-
247208
populateSymbolView();
248209
}
249210

‎src/gui/symbology-ng/qgssymbolslistwidget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class GUI_EXPORT QgsSymbolsListWidget : public QWidget, private Ui::SymbolsListW
3838
void setMarkerAngle( double angle );
3939
void setMarkerSize( double size );
4040
void setLineWidth( double width );
41-
void addSymbolToStyle();
41+
void symbolAddedToStyle( QString name, QgsSymbolV2* symbol );
4242
void on_mSymbolUnitComboBox_currentIndexChanged( const QString & text );
4343
void on_mTransparencySlider_valueChanged( int value );
4444

‎src/gui/symbology-ng/qgssymbolv2selectordialog.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ QgsSymbolV2SelectorDialog::QgsSymbolV2SelectorDialog( QgsSymbolV2* symbol, QgsSt
182182
connect( btnAddLayer, SIGNAL( clicked() ), this, SLOT( addLayer() ) );
183183
connect( btnRemoveLayer, SIGNAL( clicked() ), this, SLOT( removeLayer() ) );
184184
connect( btnLock, SIGNAL( clicked() ), this, SLOT( lockLayer() ) );
185+
connect( btnSaveSymbol, SIGNAL( clicked() ), this, SLOT( saveSymbol() ) );
185186

186187
updateUi();
187188

@@ -485,6 +486,34 @@ void QgsSymbolV2SelectorDialog::lockLayer()
485486
layer->setLocked( btnLock->isChecked() );
486487
}
487488

489+
void QgsSymbolV2SelectorDialog::saveSymbol()
490+
{
491+
bool ok;
492+
QString name = QInputDialog::getText( this, tr( "Symbol name" ),
493+
tr( "Please enter name for the symbol:" ) , QLineEdit::Normal, tr( "New symbol" ), &ok );
494+
if ( !ok || name.isEmpty() )
495+
return;
496+
497+
// check if there is no symbol with same name
498+
if ( mStyle->symbolNames().contains( name ) )
499+
{
500+
int res = QMessageBox::warning( this, tr( "Save symbol" ),
501+
tr( "Symbol with name '%1' already exists. Overwrite?" )
502+
.arg( name ),
503+
QMessageBox::Yes | QMessageBox::No );
504+
if ( res != QMessageBox::Yes )
505+
{
506+
return;
507+
}
508+
}
509+
510+
// add new symbol to style and re-populate the list
511+
mStyle->addSymbol( name, mSymbol->clone() );
512+
513+
// make sure the symbol is stored
514+
mStyle->saveSymbol( name, mSymbol->clone(), 0, QStringList() );
515+
}
516+
488517
void QgsSymbolV2SelectorDialog::changeLayer( QgsSymbolLayerV2* newLayer )
489518
{
490519
SymbolLayerItem *item = currentLayerItem();

‎src/gui/symbology-ng/qgssymbolv2selectordialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class GUI_EXPORT QgsSymbolV2SelectorDialog : public QDialog, private Ui::QgsSymb
7272
void addLayer();
7373
void removeLayer();
7474

75+
void saveSymbol();
7576
void lockLayer();
7677

7778
void layerChanged();

‎src/ui/qgsrendererv2propsdialogbase.ui

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -14,69 +14,6 @@
1414
<string>Renderer settings</string>
1515
</property>
1616
<layout class="QVBoxLayout" name="verticalLayout_2">
17-
<item>
18-
<widget class="QgsCollapsibleGroupBox" name="groupBox">
19-
<property name="title">
20-
<string>Layer rendering</string>
21-
</property>
22-
<property name="collapsed" stdset="0">
23-
<bool>false</bool>
24-
</property>
25-
<property name="saveCollapsedState" stdset="0">
26-
<bool>true</bool>
27-
</property>
28-
<layout class="QGridLayout" name="gridLayout">
29-
<item row="0" column="1" colspan="3">
30-
<layout class="QHBoxLayout" name="horizontalLayout_2">
31-
<item>
32-
<widget class="QSlider" name="mLayerTransparencySlider">
33-
<property name="maximum">
34-
<number>100</number>
35-
</property>
36-
<property name="orientation">
37-
<enum>Qt::Horizontal</enum>
38-
</property>
39-
</widget>
40-
</item>
41-
<item>
42-
<widget class="QSpinBox" name="mLayerTransparencySpnBx">
43-
<property name="maximum">
44-
<number>100</number>
45-
</property>
46-
</widget>
47-
</item>
48-
</layout>
49-
</item>
50-
<item row="0" column="0">
51-
<widget class="QLabel" name="lblTransparency">
52-
<property name="text">
53-
<string>Layer transparency</string>
54-
</property>
55-
</widget>
56-
</item>
57-
<item row="1" column="3">
58-
<widget class="QgsBlendModeComboBox" name="mFeatureBlendComboBox"/>
59-
</item>
60-
<item row="1" column="2">
61-
<widget class="QLabel" name="lblFeatureBlend">
62-
<property name="text">
63-
<string>Feature blending mode</string>
64-
</property>
65-
</widget>
66-
</item>
67-
<item row="1" column="0">
68-
<widget class="QLabel" name="lblLayerBlend">
69-
<property name="text">
70-
<string>Layer blending mode</string>
71-
</property>
72-
</widget>
73-
</item>
74-
<item row="1" column="1">
75-
<widget class="QgsBlendModeComboBox" name="mBlendModeComboBox"/>
76-
</item>
77-
</layout>
78-
</widget>
79-
</item>
8017
<item>
8118
<layout class="QHBoxLayout" name="horizontalLayout">
8219
<item>
@@ -127,6 +64,69 @@
12764
</widget>
12865
</widget>
12966
</item>
67+
<item>
68+
<widget class="QgsCollapsibleGroupBox" name="groupBox">
69+
<property name="title">
70+
<string>Layer rendering</string>
71+
</property>
72+
<property name="collapsed" stdset="0">
73+
<bool>false</bool>
74+
</property>
75+
<property name="saveCollapsedState" stdset="0">
76+
<bool>true</bool>
77+
</property>
78+
<layout class="QGridLayout" name="gridLayout">
79+
<item row="0" column="1" colspan="3">
80+
<layout class="QHBoxLayout" name="horizontalLayout_2">
81+
<item>
82+
<widget class="QSlider" name="mLayerTransparencySlider">
83+
<property name="maximum">
84+
<number>100</number>
85+
</property>
86+
<property name="orientation">
87+
<enum>Qt::Horizontal</enum>
88+
</property>
89+
</widget>
90+
</item>
91+
<item>
92+
<widget class="QSpinBox" name="mLayerTransparencySpnBx">
93+
<property name="maximum">
94+
<number>100</number>
95+
</property>
96+
</widget>
97+
</item>
98+
</layout>
99+
</item>
100+
<item row="0" column="0">
101+
<widget class="QLabel" name="lblTransparency">
102+
<property name="text">
103+
<string>Layer transparency</string>
104+
</property>
105+
</widget>
106+
</item>
107+
<item row="1" column="3">
108+
<widget class="QgsBlendModeComboBox" name="mFeatureBlendComboBox"/>
109+
</item>
110+
<item row="1" column="2">
111+
<widget class="QLabel" name="lblFeatureBlend">
112+
<property name="text">
113+
<string>Feature blending mode</string>
114+
</property>
115+
</widget>
116+
</item>
117+
<item row="1" column="0">
118+
<widget class="QLabel" name="lblLayerBlend">
119+
<property name="text">
120+
<string>Layer blending mode</string>
121+
</property>
122+
</widget>
123+
</item>
124+
<item row="1" column="1">
125+
<widget class="QgsBlendModeComboBox" name="mBlendModeComboBox"/>
126+
</item>
127+
</layout>
128+
</widget>
129+
</item>
130130
<item>
131131
<widget class="QDialogButtonBox" name="buttonBox">
132132
<property name="standardButtons">
@@ -137,17 +137,17 @@
137137
</layout>
138138
</widget>
139139
<customwidgets>
140-
<customwidget>
141-
<class>QgsBlendModeComboBox</class>
142-
<extends>QComboBox</extends>
143-
<header>qgsblendmodecombobox.h</header>
144-
</customwidget>
145140
<customwidget>
146141
<class>QgsCollapsibleGroupBox</class>
147142
<extends>QGroupBox</extends>
148143
<header>qgscollapsiblegroupbox.h</header>
149144
<container>1</container>
150145
</customwidget>
146+
<customwidget>
147+
<class>QgsBlendModeComboBox</class>
148+
<extends>QComboBox</extends>
149+
<header>qgsblendmodecombobox.h</header>
150+
</customwidget>
151151
</customwidgets>
152152
<tabstops>
153153
<tabstop>cboRenderers</tabstop>

‎src/ui/qgssymbolv2selectordialogbase.ui

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>444</width>
10-
<height>383</height>
9+
<width>436</width>
10+
<height>359</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -44,13 +44,6 @@
4444
</property>
4545
</widget>
4646
</item>
47-
<item>
48-
<widget class="QLabel" name="label_3">
49-
<property name="text">
50-
<string>Symbol layers</string>
51-
</property>
52-
</widget>
53-
</item>
5447
<item>
5548
<widget class="QTreeView" name="layersTree">
5649
<property name="sizePolicy">
@@ -137,6 +130,35 @@
137130
</property>
138131
</widget>
139132
</item>
133+
<item>
134+
<spacer name="horizontalSpacer">
135+
<property name="orientation">
136+
<enum>Qt::Horizontal</enum>
137+
</property>
138+
<property name="sizeHint" stdset="0">
139+
<size>
140+
<width>40</width>
141+
<height>20</height>
142+
</size>
143+
</property>
144+
</spacer>
145+
</item>
146+
<item>
147+
<widget class="QPushButton" name="btnSaveSymbol">
148+
<property name="maximumSize">
149+
<size>
150+
<width>50</width>
151+
<height>16777215</height>
152+
</size>
153+
</property>
154+
<property name="toolTip">
155+
<string>Move down</string>
156+
</property>
157+
<property name="text">
158+
<string>Save</string>
159+
</property>
160+
</widget>
161+
</item>
140162
</layout>
141163
</item>
142164
</layout>
@@ -160,12 +182,18 @@
160182
</sizepolicy>
161183
</property>
162184
<property name="frameShape">
163-
<enum>QFrame::StyledPanel</enum>
185+
<enum>QFrame::NoFrame</enum>
164186
</property>
165187
<property name="frameShadow">
166188
<enum>QFrame::Sunken</enum>
167189
</property>
168190
<layout class="QVBoxLayout" name="verticalLayout_2">
191+
<property name="spacing">
192+
<number>0</number>
193+
</property>
194+
<property name="margin">
195+
<number>0</number>
196+
</property>
169197
<item>
170198
<widget class="QStackedWidget" name="stackedWidget">
171199
<property name="sizePolicy">

‎src/ui/symbollayer/widget_symbolslist.ui

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
</sizepolicy>
115115
</property>
116116
<property name="currentIndex">
117-
<number>2</number>
117+
<number>0</number>
118118
</property>
119119
<widget class="QWidget" name="pageMarker">
120120
<layout class="QGridLayout" name="gridLayout">
@@ -204,31 +204,18 @@
204204
</item>
205205
</layout>
206206
</item>
207-
<item row="1" column="0">
207+
<item row="2" column="0">
208208
<layout class="QHBoxLayout" name="horizontalLayout_3">
209209
<property name="spacing">
210210
<number>3</number>
211211
</property>
212212
<item>
213213
<widget class="QLabel" name="label">
214214
<property name="text">
215-
<string>Saved styles</string>
215+
<string>Symbols in library</string>
216216
</property>
217217
</widget>
218218
</item>
219-
<item>
220-
<spacer name="horizontalSpacer_2">
221-
<property name="orientation">
222-
<enum>Qt::Horizontal</enum>
223-
</property>
224-
<property name="sizeHint" stdset="0">
225-
<size>
226-
<width>0</width>
227-
<height>20</height>
228-
</size>
229-
</property>
230-
</spacer>
231-
</item>
232219
<item>
233220
<widget class="QComboBox" name="groupsCombo">
234221
<property name="sizePolicy">
@@ -248,9 +235,16 @@
248235
</property>
249236
</widget>
250237
</item>
238+
<item>
239+
<widget class="QPushButton" name="openStyleManagerButton">
240+
<property name="text">
241+
<string>Open Library</string>
242+
</property>
243+
</widget>
244+
</item>
251245
</layout>
252246
</item>
253-
<item row="2" column="0">
247+
<item row="3" column="0">
254248
<widget class="QListView" name="viewSymbols">
255249
<property name="sizePolicy">
256250
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@@ -287,7 +281,7 @@
287281
</property>
288282
</widget>
289283
</item>
290-
<item row="3" column="0">
284+
<item row="4" column="0">
291285
<layout class="QHBoxLayout" name="horizontalLayout_4">
292286
<property name="topMargin">
293287
<number>2</number>
@@ -312,13 +306,6 @@
312306
</property>
313307
</spacer>
314308
</item>
315-
<item>
316-
<widget class="QPushButton" name="btnStyle">
317-
<property name="text">
318-
<string>Symbol</string>
319-
</property>
320-
</widget>
321-
</item>
322309
<item>
323310
<widget class="QPushButton" name="btnAdvanced">
324311
<property name="text">
@@ -328,6 +315,13 @@
328315
</item>
329316
</layout>
330317
</item>
318+
<item row="1" column="0">
319+
<widget class="Line" name="line">
320+
<property name="orientation">
321+
<enum>Qt::Horizontal</enum>
322+
</property>
323+
</widget>
324+
</item>
331325
</layout>
332326
</widget>
333327
<customwidgets>

0 commit comments

Comments
 (0)
Please sign in to comment.