##// END OF EJS Templates
Chenged the order of conditions checking in chartstheme decorate functions
Marek Rosa -
r1776:49bea5f62bed
parent child
Show More
@@ -521,10 +521,9 QColor QBarSet::labelColor()
521 521 Sets the color of labels for this barset
522 522 */
523 523 void QBarSet::setLabelColor(QColor color)
524 {
525 QBrush defaultBrush;
524 {
526 525 QBrush b = labelBrush();
527 if (b == defaultBrush)
526 if (b == QBrush())
528 527 b.setStyle(Qt::SolidPattern);
529 528
530 529 if (b.color() != color) {
@@ -105,7 +105,7 void ChartTheme::decorate(QChart *chart)
105 105 {
106 106 QBrush brush;
107 107
108 if(brush == chart->backgroundBrush() || m_force)
108 if(m_force || brush == chart->backgroundBrush())
109 109 chart->setBackgroundBrush(m_chartBackgroundGradient);
110 110 chart->setTitleFont(m_masterFont);
111 111 chart->setTitleBrush(m_labelBrush);
@@ -118,16 +118,16 void ChartTheme::decorate(QLegend *legend)
118 118 QBrush brush;
119 119 QFont font;
120 120
121 if (pen == legend->pen() || m_force)
121 if (m_force || pen == legend->pen())
122 122 legend->setPen(m_axisLinePen);
123 123
124 if (brush == legend->brush() || m_force)
124 if (m_force || brush == legend->brush())
125 125 legend->setBrush(m_chartBackgroundGradient);
126 126
127 if (font == legend->font() || m_force)
127 if (m_force || font == legend->font())
128 128 legend->setFont(m_labelFont);
129 129
130 if (brush == legend->labelBrush() || m_force)
130 if (m_force || brush == legend->labelBrush())
131 131 legend->setLabelBrush(m_labelBrush);
132 132 }
133 133
@@ -136,13 +136,13 void ChartTheme::decorate(QAreaSeries *series, int index)
136 136 QPen pen;
137 137 QBrush brush;
138 138
139 if (pen == series->pen() || m_force){
139 if (m_force || pen == series->pen()){
140 140 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0));
141 141 pen.setWidthF(2);
142 142 series->setPen(pen);
143 143 }
144 144
145 if (brush == series->brush() || m_force) {
145 if (m_force || brush == series->brush()) {
146 146 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
147 147 series->setBrush(brush);
148 148 }
@@ -152,7 +152,7 void ChartTheme::decorate(QAreaSeries *series, int index)
152 152 void ChartTheme::decorate(QLineSeries *series,int index)
153 153 {
154 154 QPen pen;
155 if(pen == series->pen() || m_force ){
155 if(m_force || pen == series->pen()){
156 156 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
157 157 pen.setWidthF(2);
158 158 series->setPen(pen);
@@ -184,19 +184,19 void ChartTheme::decorate(QAbstractBarSeries *series, int index)
184 184 takeAtPos += step;
185 185 takeAtPos -= (int) takeAtPos;
186 186 }
187 if (brush == sets.at(i)->brush() || m_force )
187 if (m_force || brush == sets.at(i)->brush())
188 188 sets.at(i)->setBrush(colorAt(m_seriesGradients.at(colorIndex), takeAtPos));
189 189
190 190 // Pick label color from the opposite end of the gradient.
191 191 // 0.3 as a boundary seems to work well.
192 if (brush == sets.at(i)->labelBrush() || m_force) {
192 if (m_force || brush == sets.at(i)->labelBrush()) {
193 193 if (takeAtPos < 0.3)
194 194 sets.at(i)->setLabelBrush(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1));
195 195 else
196 196 sets.at(i)->setLabelBrush(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0));
197 197 }
198 198
199 if (pen == sets.at(i)->pen() || m_force) {
199 if (m_force || pen == sets.at(i)->pen()) {
200 200 QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0);
201 201 sets.at(i)->setPen(c);
202 202 }
@@ -208,13 +208,13 void ChartTheme::decorate(QScatterSeries *series, int index)
208 208 QPen pen;
209 209 QBrush brush;
210 210
211 if (pen == series->pen() || m_force) {
211 if (m_force || pen == series->pen()) {
212 212 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0));
213 213 pen.setWidthF(2);
214 214 series->setPen(pen);
215 215 }
216 216
217 if (brush == series->brush() || m_force) {
217 if (m_force || brush == series->brush()) {
218 218 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
219 219 series->setBrush(brush);
220 220 }
@@ -234,16 +234,16 void ChartTheme::decorate(QPieSeries *series, int index)
234 234 QPieSlice *s = series->slices().at(i);
235 235 QPieSlicePrivate *d = QPieSlicePrivate::fromSlice(s);
236 236
237 if (d->m_data.m_slicePen.isThemed() || m_force)
237 if (m_force || d->m_data.m_slicePen.isThemed())
238 238 d->setPen(penColor, true);
239 239
240 if (d->m_data.m_sliceBrush.isThemed() || m_force)
240 if (m_force || d->m_data.m_sliceBrush.isThemed())
241 241 d->setBrush(brushColor, true);
242 242
243 if (d->m_data.m_labelBrush.isThemed() || m_force)
243 if (m_force || d->m_data.m_labelBrush.isThemed())
244 244 d->setLabelBrush(m_labelBrush.color(), true);
245 245
246 if (d->m_data.m_labelFont.isThemed() || m_force)
246 if (m_force || d->m_data.m_labelFont.isThemed())
247 247 d->setLabelFont(m_labelFont, true);
248 248 }
249 249 }
@@ -251,7 +251,7 void ChartTheme::decorate(QPieSeries *series, int index)
251 251 void ChartTheme::decorate(QSplineSeries *series, int index)
252 252 {
253 253 QPen pen;
254 if(pen == series->pen() || m_force){
254 if(m_force || pen == series->pen()){
255 255 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
256 256 pen.setWidthF(2);
257 257 series->setPen(pen);
@@ -268,21 +268,21 void ChartTheme::decorate(QAbstractAxis *axis)
268 268
269 269 if (axis->isArrowVisible()) {
270 270
271 if(brush == axis->labelsBrush() || m_force){
271 if(m_force || brush == axis->labelsBrush()){
272 272 axis->setLabelsBrush(m_labelBrush);
273 273 }
274 if(pen == axis->labelsPen() || m_force){
274 if(m_force || pen == axis->labelsPen()){
275 275 axis->setLabelsPen(Qt::NoPen); // NoPen for performance reasons
276 276 }
277 277
278 278
279 if (axis->shadesVisible() || m_force) {
279 if (m_force || axis->shadesVisible()) {
280 280
281 if(brush == axis->shadesBrush() || m_force){
281 if(m_force || brush == axis->shadesBrush()){
282 282 axis->setShadesBrush(m_backgroundShadesBrush);
283 283 }
284 284
285 if(pen == axis->shadesPen() || m_force){
285 if(m_force || pen == axis->shadesPen()){
286 286 axis->setShadesPen(m_backgroundShadesPen);
287 287 }
288 288
@@ -294,15 +294,15 void ChartTheme::decorate(QAbstractAxis *axis)
294 294 }
295 295 }
296 296
297 if(pen == axis->axisPen() || m_force){
297 if(m_force || pen == axis->axisPen()){
298 298 axis->setAxisPen(m_axisLinePen);
299 299 }
300 300
301 if(pen == axis->gridLinePen() || m_force){
301 if(m_force || pen == axis->gridLinePen()){
302 302 axis->setGridLinePen(m_gridLinePen);
303 303 }
304 304
305 if(font == axis->labelsFont() || m_force){
305 if(m_force || font == axis->labelsFont()){
306 306 axis->setLabelsFont(m_labelFont);
307 307 }
308 308 }
@@ -387,7 +387,7 QColor ChartTheme::colorAt(const QGradient &gradient, qreal pos)
387 387
388 388 void ChartTheme::setForced(bool enabled)
389 389 {
390 m_force=enabled;
390 m_force = enabled;
391 391 }
392 392
393 393 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now