@@ -225,6 +225,7 void QLegend::setBrush(const QBrush &brush) | |||||
225 | if (d_ptr->m_brush != brush) { |
|
225 | if (d_ptr->m_brush != brush) { | |
226 | d_ptr->m_brush = brush; |
|
226 | d_ptr->m_brush = brush; | |
227 | update(); |
|
227 | update(); | |
|
228 | emit colorChanged(brush.color()); | |||
228 | } |
|
229 | } | |
229 | } |
|
230 | } | |
230 |
|
231 | |||
@@ -243,7 +244,6 void QLegend::setColor(QColor color) | |||||
243 | b.setStyle(Qt::SolidPattern); |
|
244 | b.setStyle(Qt::SolidPattern); | |
244 | b.setColor(color); |
|
245 | b.setColor(color); | |
245 | setBrush(b); |
|
246 | setBrush(b); | |
246 | emit colorChanged(color); |
|
|||
247 | } |
|
247 | } | |
248 | } |
|
248 | } | |
249 |
|
249 | |||
@@ -260,6 +260,7 void QLegend::setPen(const QPen &pen) | |||||
260 | if (d_ptr->m_pen != pen) { |
|
260 | if (d_ptr->m_pen != pen) { | |
261 | d_ptr->m_pen = pen; |
|
261 | d_ptr->m_pen = pen; | |
262 | update(); |
|
262 | update(); | |
|
263 | emit borderColorChanged(pen.color()); | |||
263 | } |
|
264 | } | |
264 | } |
|
265 | } | |
265 |
|
266 | |||
@@ -296,7 +297,6 void QLegend::setBorderColor(QColor color) | |||||
296 | if (p.color() != color) { |
|
297 | if (p.color() != color) { | |
297 | p.setColor(color); |
|
298 | p.setColor(color); | |
298 | setPen(p); |
|
299 | setPen(p); | |
299 | emit borderColorChanged(color); |
|
|||
300 | } |
|
300 | } | |
301 | } |
|
301 | } | |
302 |
|
302 | |||
@@ -311,13 +311,11 QColor QLegend::borderColor() | |||||
311 | void QLegend::setLabelBrush(const QBrush &brush) |
|
311 | void QLegend::setLabelBrush(const QBrush &brush) | |
312 | { |
|
312 | { | |
313 | if (d_ptr->m_labelBrush != brush) { |
|
313 | if (d_ptr->m_labelBrush != brush) { | |
314 |
|
||||
315 | d_ptr->m_labelBrush = brush; |
|
314 | d_ptr->m_labelBrush = brush; | |
316 |
|
||||
317 | foreach (LegendMarker *marker, d_ptr->markers()) { |
|
315 | foreach (LegendMarker *marker, d_ptr->markers()) { | |
318 | marker->setLabelBrush(d_ptr->m_labelBrush); |
|
316 | marker->setLabelBrush(d_ptr->m_labelBrush); | |
319 | } |
|
317 | } | |
320 |
emit label |
|
318 | emit labelColorChanged(brush.color()); | |
321 | } |
|
319 | } | |
322 | } |
|
320 | } | |
323 |
|
321 | |||
@@ -336,7 +334,6 void QLegend::setLabelColor(QColor color) | |||||
336 | b.setStyle(Qt::SolidPattern); |
|
334 | b.setStyle(Qt::SolidPattern); | |
337 | b.setColor(color); |
|
335 | b.setColor(color); | |
338 | setLabelBrush(b); |
|
336 | setLabelBrush(b); | |
339 | emit labelColorChanged(color); |
|
|||
340 | } |
|
337 | } | |
341 | } |
|
338 | } | |
342 |
|
339 |
@@ -96,7 +96,6 Q_SIGNALS: | |||||
96 | void colorChanged(QColor color); |
|
96 | void colorChanged(QColor color); | |
97 | void borderColorChanged(QColor color); |
|
97 | void borderColorChanged(QColor color); | |
98 | void fontChanged(QFont font); |
|
98 | void fontChanged(QFont font); | |
99 | void labelBrushChanged(QBrush brush); |
|
|||
100 | void labelColorChanged(QColor color); |
|
99 | void labelColorChanged(QColor color); | |
101 |
|
100 | |||
102 | private: |
|
101 | private: |
@@ -360,7 +360,44 void tst_QChart::legend_data() | |||||
360 |
|
360 | |||
361 | void tst_QChart::legend() |
|
361 | void tst_QChart::legend() | |
362 | { |
|
362 | { | |
363 |
Q |
|
363 | QLegend *legend = m_chart->legend(); | |
|
364 | QVERIFY(legend); | |||
|
365 | ||||
|
366 | // Colors related signals | |||
|
367 | QSignalSpy colorSpy(legend, SIGNAL(colorChanged(QColor))); | |||
|
368 | QSignalSpy borderColorSpy(legend, SIGNAL(borderColorChanged(QColor))); | |||
|
369 | QSignalSpy labelColorSpy(legend, SIGNAL(labelColorChanged(QColor))); | |||
|
370 | ||||
|
371 | // colorChanged | |||
|
372 | legend->setColor(QColor("aliceblue")); | |||
|
373 | QCOMPARE(colorSpy.count(), 1); | |||
|
374 | QBrush b = legend->brush(); | |||
|
375 | b.setColor(QColor("aqua")); | |||
|
376 | legend->setBrush(b); | |||
|
377 | QCOMPARE(colorSpy.count(), 2); | |||
|
378 | ||||
|
379 | // borderColorChanged | |||
|
380 | legend->setBorderColor(QColor("aliceblue")); | |||
|
381 | QCOMPARE(borderColorSpy.count(), 1); | |||
|
382 | QPen p = legend->pen(); | |||
|
383 | p.setColor(QColor("aqua")); | |||
|
384 | legend->setPen(p); | |||
|
385 | QCOMPARE(borderColorSpy.count(), 2); | |||
|
386 | ||||
|
387 | // labelColorChanged | |||
|
388 | legend->setLabelColor(QColor("lightsalmon")); | |||
|
389 | QCOMPARE(labelColorSpy.count(), 1); | |||
|
390 | b = legend->labelBrush(); | |||
|
391 | b.setColor(QColor("lightseagreen")); | |||
|
392 | legend->setLabelBrush(b); | |||
|
393 | QCOMPARE(labelColorSpy.count(), 2); | |||
|
394 | ||||
|
395 | // fontChanged | |||
|
396 | QSignalSpy fontSpy(legend, SIGNAL(fontChanged(QFont))); | |||
|
397 | QFont f = legend->font(); | |||
|
398 | f.setBold(!f.bold()); | |||
|
399 | legend->setFont(f); | |||
|
400 | QCOMPARE(fontSpy.count(), 1); | |||
364 | } |
|
401 | } | |
365 |
|
402 | |||
366 | void tst_QChart::margins_data() |
|
403 | void tst_QChart::margins_data() |
@@ -64,7 +64,6 ChartView { | |||||
64 | legend.onColorChanged: console.log("legend.onColorChanged: " + color); |
|
64 | legend.onColorChanged: console.log("legend.onColorChanged: " + color); | |
65 | legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color); |
|
65 | legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color); | |
66 | legend.onLabelColorChanged: console.log("legend.onLabelColorChanged: " + color); |
|
66 | legend.onLabelColorChanged: console.log("legend.onLabelColorChanged: " + color); | |
67 | legend.onLabelBrushChanged: console.log("legend.onLabelBrushChanged: " + brush); |
|
|||
68 |
|
67 | |||
69 | axisX.onColorChanged: console.log("axisX.onColorChanged: " + color); |
|
68 | axisX.onColorChanged: console.log("axisX.onColorChanged: " + color); | |
70 | axisX.onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible); |
|
69 | axisX.onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible); |
General Comments 0
You need to be logged in to leave comments.
Login now