Skip to content

Commit 194b0f2

Browse files
committed
Transparency test...
1 parent 3ab9580 commit 194b0f2

File tree

5 files changed

+81
-38
lines changed

5 files changed

+81
-38
lines changed

src/app/qgsdiagramproperties.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare
165165
mDiagramFont = settingList.at( 0 ).font;
166166
QSizeF size = settingList.at( 0 ).size;
167167
mBackgroundColorButton->setColor( settingList.at( 0 ).backgroundColor );
168+
mTransparencySlider->setValue( settingList.at( 0 ).transparency * 100 / 256 );
168169
mDiagramPenColorButton->setColor( settingList.at( 0 ).penColor );
169170
mPenWidthSpinBox->setValue( settingList.at( 0 ).penWidth );
170171
mDiagramSizeSpinBox->setValue(( size.width() + size.height() ) / 2.0 );
@@ -281,7 +282,7 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare
281282
else
282283
{
283284
QMessageBox::warning( this, tr( "Unknown diagram type." ),
284-
tr( "The diagram type '%s' is unknown. A default type is selected for you." ).arg( diagramName ), QMessageBox::Ok );
285+
tr( "The diagram type '%1' is unknown. A default type is selected for you." ).arg( diagramName ), QMessageBox::Ok );
285286
mDiagramTypeComboBox->setCurrentIndex( mDiagramTypeComboBox->findText( tr( "Pie chart" ) ) );
286287
}
287288
}
@@ -337,7 +338,6 @@ void QgsDiagramProperties::on_mDiagramTypeComboBox_currentIndexChanged( const QS
337338
}
338339
}
339340

340-
341341
void QgsDiagramProperties::on_mIncreaseSmallDiagramsCheckBox_stateChanged( int state )
342342
{
343343
if ( Qt::Checked == state )
@@ -352,6 +352,10 @@ void QgsDiagramProperties::on_mIncreaseSmallDiagramsCheckBox_stateChanged( int s
352352
}
353353
}
354354

355+
void QgsDiagramProperties::on_mTransparencySlider_valueChanged( int value )
356+
{
357+
mTransparencyLabel->setText( tr( "Transparency: %1%" ).arg( value ) );
358+
}
355359

356360
void QgsDiagramProperties::on_mAddCategoryPushButton_clicked()
357361
{
@@ -527,7 +531,13 @@ void QgsDiagramProperties::apply()
527531
}
528532

529533
ds.backgroundColor = mBackgroundColorButton->color();
534+
ds.transparency = mTransparencySlider->value() * 255 / 100;
535+
foreach( QColor col, ds.categoryColors )
536+
{
537+
col.setAlpha( 255 - ds.transparency );
538+
}
530539
ds.penColor = mDiagramPenColorButton->color();
540+
ds.penColor.setAlpha( 255 - ds.transparency );
531541
ds.penWidth = mPenWidthSpinBox->value();
532542
if ( mVisibilityGroupBox->isChecked() )
533543
{

src/app/qgsdiagramproperties.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class QgsDiagramProperties : public QWidget, private Ui::QgsDiagramPropertiesBas
3636
void apply();
3737
void on_mDiagramTypeComboBox_currentIndexChanged( const QString& itemtext );
3838
void on_mIncreaseSmallDiagramsCheckBox_stateChanged( int state );
39+
void on_mTransparencySlider_valueChanged( int value );
3940
void on_mAddCategoryPushButton_clicked();
4041
void on_mBackgroundColorButton_clicked();
4142
void on_mFindMaximumValueButton_clicked();

src/core/diagram/qgspiediagram.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ void QgsPieDiagram::renderDiagram( const QgsAttributeMap& att, QgsRenderContext&
119119
for ( ; valIt != values.constEnd(); ++valIt, ++colIt )
120120
{
121121
currentAngle = *valIt / valSum * 360 * 16;
122-
mCategoryBrush.setColor( *colIt );
122+
QColor col = *colIt;
123+
col.setAlpha( 255 - s.transparency );
124+
mCategoryBrush.setColor( col );
123125
p->setBrush( mCategoryBrush );
124126
p->drawPie( baseX, baseY, w, h, totalAngle, currentAngle );
125127
totalAngle += currentAngle;

src/core/qgsdiagramrendererv2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ struct CORE_EXPORT QgsDiagramSettings
124124
LabelPlacementMethod labelPlacementMethod;
125125
DiagramOrientation diagramOrientation;
126126
double barWidth;
127+
int transparency; // 0 - 100
127128
bool scaleByArea;
128129

129130
//scale range (-1 if no lower / upper bound )

src/ui/qgsdiagrampropertiesbase.ui

Lines changed: 64 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
<item>
118118
<widget class="QTabWidget" name="mDiagramPropertiesTabWidget">
119119
<property name="currentIndex">
120-
<number>2</number>
120+
<number>0</number>
121121
</property>
122122
<widget class="QWidget" name="tab">
123123
<attribute name="title">
@@ -126,40 +126,77 @@
126126
<layout class="QGridLayout" name="gridLayout_8">
127127
<item row="0" column="0" rowspan="2">
128128
<layout class="QGridLayout" name="gridLayout">
129-
<item row="2" column="1">
129+
<item row="3" column="1">
130130
<widget class="QLabel" name="mBackgroundColorLabel">
131131
<property name="text">
132132
<string>Background color</string>
133133
</property>
134134
</widget>
135135
</item>
136-
<item row="3" column="1">
136+
<item row="4" column="1">
137137
<widget class="QLabel" name="mPenColorLabel">
138138
<property name="text">
139139
<string>Line color</string>
140140
</property>
141141
</widget>
142142
</item>
143-
<item row="3" column="2">
144-
<widget class="QgsColorButton" name="mDiagramPenColorButton">
143+
<item row="5" column="1">
144+
<widget class="QLabel" name="mPenWidthLabel">
145+
<property name="text">
146+
<string>Line width</string>
147+
</property>
148+
</widget>
149+
</item>
150+
<item row="6" column="1">
151+
<widget class="QPushButton" name="mDiagramFontButton">
145152
<property name="sizePolicy">
146-
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
153+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
147154
<horstretch>0</horstretch>
148155
<verstretch>0</verstretch>
149156
</sizepolicy>
150157
</property>
158+
<property name="text">
159+
<string>Font...</string>
160+
</property>
161+
</widget>
162+
</item>
163+
<item row="1" column="1">
164+
<widget class="QLabel" name="mBarWidthLabel">
165+
<property name="text">
166+
<string>Bar width</string>
167+
</property>
168+
</widget>
169+
</item>
170+
<item row="2" column="1">
171+
<widget class="QLabel" name="mTransparencyLabel">
151172
<property name="minimumSize">
152173
<size>
153-
<width>25</width>
174+
<width>130</width>
154175
<height>0</height>
155176
</size>
156177
</property>
157178
<property name="text">
158-
<string/>
179+
<string>Transparency 0%</string>
159180
</property>
160181
</widget>
161182
</item>
162-
<item row="2" column="2">
183+
<item row="2" column="2" colspan="2">
184+
<widget class="QSlider" name="mTransparencySlider">
185+
<property name="minimumSize">
186+
<size>
187+
<width>300</width>
188+
<height>0</height>
189+
</size>
190+
</property>
191+
<property name="maximum">
192+
<number>100</number>
193+
</property>
194+
<property name="orientation">
195+
<enum>Qt::Horizontal</enum>
196+
</property>
197+
</widget>
198+
</item>
199+
<item row="3" column="2">
163200
<widget class="QgsColorButton" name="mBackgroundColorButton">
164201
<property name="sizePolicy">
165202
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
@@ -178,43 +215,35 @@
178215
</property>
179216
</widget>
180217
</item>
181-
<item row="4" column="1">
182-
<widget class="QLabel" name="mPenWidthLabel">
183-
<property name="text">
184-
<string>Line width</string>
185-
</property>
186-
</widget>
218+
<item row="1" column="2">
219+
<widget class="QDoubleSpinBox" name="mBarWidthSpinBox"/>
187220
</item>
188221
<item row="4" column="2">
189-
<widget class="QDoubleSpinBox" name="mPenWidthSpinBox">
190-
<property name="decimals">
191-
<number>5</number>
192-
</property>
193-
<property name="maximum">
194-
<double>99999.990000000005239</double>
195-
</property>
196-
</widget>
197-
</item>
198-
<item row="5" column="1">
199-
<widget class="QPushButton" name="mDiagramFontButton">
222+
<widget class="QgsColorButton" name="mDiagramPenColorButton">
200223
<property name="sizePolicy">
201-
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
224+
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
202225
<horstretch>0</horstretch>
203226
<verstretch>0</verstretch>
204227
</sizepolicy>
205228
</property>
229+
<property name="minimumSize">
230+
<size>
231+
<width>25</width>
232+
<height>0</height>
233+
</size>
234+
</property>
206235
<property name="text">
207-
<string>Font...</string>
236+
<string/>
208237
</property>
209238
</widget>
210239
</item>
211-
<item row="1" column="2">
212-
<widget class="QDoubleSpinBox" name="mBarWidthSpinBox"/>
213-
</item>
214-
<item row="1" column="1">
215-
<widget class="QLabel" name="mBarWidthLabel">
216-
<property name="text">
217-
<string>Bar width</string>
240+
<item row="5" column="2">
241+
<widget class="QDoubleSpinBox" name="mPenWidthSpinBox">
242+
<property name="decimals">
243+
<number>5</number>
244+
</property>
245+
<property name="maximum">
246+
<double>99999.990000000005239</double>
218247
</property>
219248
</widget>
220249
</item>

0 commit comments

Comments
 (0)