diff --git a/src/charts/axis/cartesianchartaxis.cpp b/src/charts/axis/cartesianchartaxis.cpp index 374d846..9386522 100644 --- a/src/charts/axis/cartesianchartaxis.cpp +++ b/src/charts/axis/cartesianchartaxis.cpp @@ -225,6 +225,26 @@ void CartesianChartAxis::handleMinorGridPenChanged(const QPen &pen) static_cast(item)->setPen(pen); } +void CartesianChartAxis::handleGridLineColorChanged(const QColor &color) +{ + foreach (QGraphicsItem *item, gridItems()) { + QGraphicsLineItem *lineItem = static_cast(item); + QPen pen = lineItem->pen(); + pen.setColor(color); + lineItem->setPen(pen); + } +} + +void CartesianChartAxis::handleMinorGridLineColorChanged(const QColor &color) +{ + foreach (QGraphicsItem *item, minorGridItems()) { + QGraphicsLineItem *lineItem = static_cast(item); + QPen pen = lineItem->pen(); + pen.setColor(color); + lineItem->setPen(pen); + } +} + void CartesianChartAxis::handleShadesBrushChanged(const QBrush &brush) { foreach (QGraphicsItem *item, shadeItems()) diff --git a/src/charts/axis/cartesianchartaxis_p.h b/src/charts/axis/cartesianchartaxis_p.h index d26d0b3..f8779b0 100644 --- a/src/charts/axis/cartesianchartaxis_p.h +++ b/src/charts/axis/cartesianchartaxis_p.h @@ -62,6 +62,8 @@ public Q_SLOTS: virtual void handleShadesPenChanged(const QPen &pen); virtual void handleMinorArrowPenChanged(const QPen &pen); virtual void handleMinorGridPenChanged(const QPen &pen); + virtual void handleGridLineColorChanged(const QColor &color); + virtual void handleMinorGridLineColorChanged(const QColor &color); private: void createItems(int count); diff --git a/src/charts/axis/chartaxiselement.cpp b/src/charts/axis/chartaxiselement.cpp index 34d7e84..d8dcaad 100644 --- a/src/charts/axis/chartaxiselement.cpp +++ b/src/charts/axis/chartaxiselement.cpp @@ -106,6 +106,10 @@ void ChartAxisElement::connectSlots() this, SLOT(handleMinorGridVisibleChanged(bool))); QObject::connect(axis(), SIGNAL(minorGridLinePenChanged(const QPen&)), this, SLOT(handleMinorGridPenChanged(const QPen&))); + QObject::connect(axis(), SIGNAL(gridLineColorChanged(const QColor&)), + this, SLOT(handleGridLineColorChanged(const QColor&))); + QObject::connect(axis(), SIGNAL(minorGridLineColorChanged(const QColor&)), + this, SLOT(handleMinorGridLineColorChanged(const QColor&))); if (axis()->type() == QAbstractAxis::AxisTypeCategory) { QCategoryAxis *categoryAxis = static_cast(axis()); diff --git a/src/charts/axis/chartaxiselement_p.h b/src/charts/axis/chartaxiselement_p.h index 8edbd4d..85ae2ed 100644 --- a/src/charts/axis/chartaxiselement_p.h +++ b/src/charts/axis/chartaxiselement_p.h @@ -122,6 +122,8 @@ public Q_SLOTS: virtual void handleGridPenChanged(const QPen &pen) = 0; virtual void handleMinorArrowPenChanged(const QPen &pen) = 0; virtual void handleMinorGridPenChanged(const QPen &pen) = 0; + virtual void handleMinorGridLineColorChanged(const QColor &color) = 0; + virtual void handleGridLineColorChanged(const QColor &color) = 0; void handleLabelsBrushChanged(const QBrush &brush); void handleLabelsFontChanged(const QFont &font); void handleTitleBrushChanged(const QBrush &brush); diff --git a/src/charts/axis/polarchartaxisangular.cpp b/src/charts/axis/polarchartaxisangular.cpp index d1e6547..1a8cb1f 100644 --- a/src/charts/axis/polarchartaxisangular.cpp +++ b/src/charts/axis/polarchartaxisangular.cpp @@ -356,6 +356,26 @@ void PolarChartAxisAngular::handleMinorGridPenChanged(const QPen &pen) static_cast(item)->setPen(pen); } +void PolarChartAxisAngular::handleGridLineColorChanged(const QColor &color) +{ + foreach (QGraphicsItem *item, gridItems()) { + QGraphicsLineItem *lineItem = static_cast(item); + QPen pen = lineItem->pen(); + pen.setColor(color); + lineItem->setPen(pen); + } +} + +void PolarChartAxisAngular::handleMinorGridLineColorChanged(const QColor &color) +{ + foreach (QGraphicsItem *item, minorGridItems()) { + QGraphicsLineItem *lineItem = static_cast(item); + QPen pen = lineItem->pen(); + pen.setColor(color); + lineItem->setPen(pen); + } +} + QSizeF PolarChartAxisAngular::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const { Q_UNUSED(which); diff --git a/src/charts/axis/polarchartaxisangular_p.h b/src/charts/axis/polarchartaxisangular_p.h index c8ac965..4cbb930 100644 --- a/src/charts/axis/polarchartaxisangular_p.h +++ b/src/charts/axis/polarchartaxisangular_p.h @@ -54,6 +54,8 @@ public Q_SLOTS: virtual void handleGridPenChanged(const QPen &pen); virtual void handleMinorArrowPenChanged(const QPen &pen); virtual void handleMinorGridPenChanged(const QPen &pen); + virtual void handleGridLineColorChanged(const QColor &color); + virtual void handleMinorGridLineColorChanged(const QColor &color); private: QRectF moveLabelToPosition(qreal angularCoordinate, QPointF labelPoint, QRectF labelRect) const; diff --git a/src/charts/axis/polarchartaxisradial.cpp b/src/charts/axis/polarchartaxisradial.cpp index 8cff0c2..3f9cacb 100644 --- a/src/charts/axis/polarchartaxisradial.cpp +++ b/src/charts/axis/polarchartaxisradial.cpp @@ -332,6 +332,26 @@ void PolarChartAxisRadial::handleMinorGridPenChanged(const QPen &pen) static_cast(item)->setPen(pen); } +void PolarChartAxisRadial::handleGridLineColorChanged(const QColor &color) +{ + foreach (QGraphicsItem *item, gridItems()) { + QGraphicsEllipseItem *ellipseItem = static_cast(item); + QPen pen = ellipseItem->pen(); + pen.setColor(color); + ellipseItem->setPen(pen); + } +} + +void PolarChartAxisRadial::handleMinorGridLineColorChanged(const QColor &color) +{ + foreach (QGraphicsItem *item, minorGridItems()) { + QGraphicsEllipseItem *ellipseItem = static_cast(item); + QPen pen = ellipseItem->pen(); + pen.setColor(color); + ellipseItem->setPen(pen); + } +} + QSizeF PolarChartAxisRadial::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const { Q_UNUSED(which); diff --git a/src/charts/axis/polarchartaxisradial_p.h b/src/charts/axis/polarchartaxisradial_p.h index 21a32a5..34a7955 100644 --- a/src/charts/axis/polarchartaxisradial_p.h +++ b/src/charts/axis/polarchartaxisradial_p.h @@ -54,6 +54,8 @@ public Q_SLOTS: virtual void handleGridPenChanged(const QPen &pen); virtual void handleMinorArrowPenChanged(const QPen &pen); virtual void handleMinorGridPenChanged(const QPen &pen); + virtual void handleGridLineColorChanged(const QColor &color); + virtual void handleMinorGridLineColorChanged(const QColor &color); }; QT_CHARTS_END_NAMESPACE diff --git a/src/charts/axis/qabstractaxis.cpp b/src/charts/axis/qabstractaxis.cpp index eab95cd..e286ba5 100644 --- a/src/charts/axis/qabstractaxis.cpp +++ b/src/charts/axis/qabstractaxis.cpp @@ -142,6 +142,16 @@ QT_CHARTS_BEGIN_NAMESPACE */ /*! + \property QAbstractAxis::gridLineColor + The color of the grid line. +*/ + +/*! + \property QAbstractAxis::minorGridLineColor + The color of the minor grid line. Applies only to QValueAxis. +*/ + +/*! \property QAbstractAxis::labelsFont The font of the axis labels. */ @@ -359,6 +369,16 @@ QT_CHARTS_BEGIN_NAMESPACE */ /*! + \fn void QAbstractAxis::gridLineColorChanged(const QColor &color) + The color of the pen of the grid line has changed to \a color. +*/ + +/*! + \fn void QAbstractAxis::minorGridLineColorChanged(const QColor &color) + The color of the pen of the minor grid line has changed to \a color. +*/ + +/*! \fn void QAbstractAxis::colorChanged(QColor color) Emitted if the \a color of the axis is changed. */ @@ -584,6 +604,36 @@ QPen QAbstractAxis::minorGridLinePen() const return d_ptr->m_minorGridLinePen; } +void QAbstractAxis::setGridLineColor(const QColor &color) +{ + QPen pen = d_ptr->m_gridLinePen; + if (color != pen.color()) { + pen.setColor(color); + d_ptr->m_gridLinePen = pen; + emit gridLineColorChanged(color); + } +} + +QColor QAbstractAxis::gridLineColor() +{ + return d_ptr->m_gridLinePen.color(); +} + +void QAbstractAxis::setMinorGridLineColor(const QColor &color) +{ + QPen pen = d_ptr->m_minorGridLinePen; + if (color != pen.color()) { + pen.setColor(color); + d_ptr->m_minorGridLinePen = pen; + emit minorGridLineColorChanged(color); + } +} + +QColor QAbstractAxis::minorGridLineColor() +{ + return d_ptr->m_minorGridLinePen.color(); +} + void QAbstractAxis::setLabelsVisible(bool visible) { if (d_ptr->m_labelsVisible != visible) { diff --git a/src/charts/axis/qabstractaxis.h b/src/charts/axis/qabstractaxis.h index 48a16a7..dba1023 100644 --- a/src/charts/axis/qabstractaxis.h +++ b/src/charts/axis/qabstractaxis.h @@ -48,6 +48,8 @@ class QT_CHARTS_EXPORT QAbstractAxis : public QObject Q_PROPERTY(QPen gridLinePen READ gridLinePen WRITE setGridLinePen NOTIFY gridLinePenChanged) Q_PROPERTY(bool minorGridVisible READ isMinorGridLineVisible WRITE setMinorGridLineVisible NOTIFY minorGridVisibleChanged) Q_PROPERTY(QPen minorGridLinePen READ minorGridLinePen WRITE setMinorGridLinePen NOTIFY minorGridLinePenChanged) + Q_PROPERTY(QColor gridLineColor READ gridLineColor WRITE setGridLineColor NOTIFY gridLineColorChanged) + Q_PROPERTY(QColor minorGridLineColor READ minorGridLineColor WRITE setMinorGridLineColor NOTIFY minorGridLineColorChanged) //shades Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged) Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged) @@ -109,6 +111,10 @@ public: void setMinorGridLineVisible(bool visible = true); void setMinorGridLinePen(const QPen &pen); QPen minorGridLinePen() const; + void setGridLineColor(const QColor &color); + QColor gridLineColor(); + void setMinorGridLineColor(const QColor &color); + QColor minorGridLineColor(); //labels handling bool labelsVisible() const; @@ -168,6 +174,8 @@ Q_SIGNALS: void gridVisibleChanged(bool visible); void minorGridVisibleChanged(bool visible); void minorGridLinePenChanged(const QPen &pen); + void gridLineColorChanged(const QColor &color); + void minorGridLineColorChanged(const QColor &color); void colorChanged(QColor color); void labelsColorChanged(QColor color); void titleTextChanged(const QString &title); diff --git a/src/chartsqml2/plugins.qmltypes b/src/chartsqml2/plugins.qmltypes index 9195306..af019e2 100644 --- a/src/chartsqml2/plugins.qmltypes +++ b/src/chartsqml2/plugins.qmltypes @@ -2027,6 +2027,8 @@ Module { Property { name: "gridLinePen"; type: "QPen" } Property { name: "minorGridVisible"; type: "bool" } Property { name: "minorGridLinePen"; type: "QPen" } + Property { name: "gridLineColor"; type: "QColor" } + Property { name: "minorGridLineColor"; type: "QColor" } Property { name: "shadesVisible"; type: "bool" } Property { name: "shadesColor"; type: "QColor" } Property { name: "shadesBorderColor"; type: "QColor" } @@ -2084,6 +2086,14 @@ Module { Parameter { name: "pen"; type: "QPen" } } Signal { + name: "gridLineColorChanged" + Parameter { name: "color"; type: "QColor" } + } + Signal { + name: "minorGridLineColorChanged" + Parameter { name: "color"; type: "QColor" } + } + Signal { name: "colorChanged" Parameter { name: "color"; type: "QColor" } } diff --git a/tests/auto/qabstractaxis/tst_qabstractaxis.cpp b/tests/auto/qabstractaxis/tst_qabstractaxis.cpp index ad240e1..ed92722 100644 --- a/tests/auto/qabstractaxis/tst_qabstractaxis.cpp +++ b/tests/auto/qabstractaxis/tst_qabstractaxis.cpp @@ -65,6 +65,8 @@ void tst_QAbstractAxis::qabstractaxis() m_axis->setLinePenColor(QColor()); m_axis->setGridLinePen(QPen()); m_axis->setGridLineVisible(false); + m_axis->setGridLineColor(QColor()); + m_axis->setMinorGridLineColor(QColor()); m_axis->setLabelsAngle(-1); m_axis->setLabelsBrush(QBrush()); m_axis->setLabelsColor(QColor()); @@ -111,6 +113,8 @@ void tst_QAbstractAxis::axisPen() QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool))); + QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor))); + QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor))); m_axis->setLinePen(axisPen); QCOMPARE(m_axis->linePen(), axisPen); @@ -125,6 +129,8 @@ void tst_QAbstractAxis::axisPen() QCOMPARE(spy7.count(), 0); QCOMPARE(spy8.count(), 0); QCOMPARE(spy9.count(), 0); + QCOMPARE(spy10.count(), 0); + QCOMPARE(spy11.count(), 0); m_chart->setAxisX(m_axis, m_series); m_view->show(); @@ -165,6 +171,9 @@ void tst_QAbstractAxis::gridLinePen() QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); + QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool))); + QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor))); + QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor))); m_axis->setGridLinePen(gridLinePen); QCOMPARE(m_axis->gridLinePen(), gridLinePen); @@ -178,6 +187,9 @@ void tst_QAbstractAxis::gridLinePen() QCOMPARE(spy6.count(), 0); QCOMPARE(spy7.count(), 0); QCOMPARE(spy8.count(), 0); + QCOMPARE(spy9.count(), 0); + QCOMPARE(spy10.count(), 0); + QCOMPARE(spy11.count(), 0); m_chart->setAxisX(m_axis, m_series); m_view->show(); @@ -210,6 +222,8 @@ void tst_QAbstractAxis::minorGridLinePen() QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool))); + QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor))); + QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor))); m_axis->setMinorGridLinePen(minorGridLinePen); QCOMPARE(m_axis->minorGridLinePen(), minorGridLinePen); @@ -224,6 +238,8 @@ void tst_QAbstractAxis::minorGridLinePen() QCOMPARE(spy7.count(), 0); QCOMPARE(spy8.count(), 0); QCOMPARE(spy9.count(), 0); + QCOMPARE(spy10.count(), 0); + QCOMPARE(spy11.count(), 0); m_chart->setAxisX(m_axis, m_series); m_view->show(); @@ -254,6 +270,8 @@ void tst_QAbstractAxis::lineVisible() QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool))); + QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor))); + QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor))); m_axis->setLineVisible(lineVisible); QCOMPARE(m_axis->isLineVisible(), lineVisible); @@ -268,6 +286,8 @@ void tst_QAbstractAxis::lineVisible() QCOMPARE(spy7.count(), 0); QCOMPARE(spy8.count(), 0); QCOMPARE(spy9.count(), 0); + QCOMPARE(spy10.count(), 0); + QCOMPARE(spy11.count(), 0); m_chart->setAxisX(m_axis, m_series); m_view->show(); @@ -297,6 +317,7 @@ void tst_QAbstractAxis::gridLineVisible() QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); + QSignalSpy spy9(m_axis, SIGNAL(gridLineColorChanged(QColor))); m_axis->setGridLineVisible(gridLineVisible); QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible); @@ -310,6 +331,7 @@ void tst_QAbstractAxis::gridLineVisible() QCOMPARE(spy6.count(), 0); QCOMPARE(spy7.count(), 0); QCOMPARE(spy8.count(), 0); + QCOMPARE(spy9.count(), 0); m_chart->setAxisX(m_axis, m_series); m_view->show(); @@ -341,6 +363,8 @@ void tst_QAbstractAxis::minorGridLineVisible() QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool))); + QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor))); + QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor))); m_axis->setMinorGridLineVisible(minorGridLineVisible); QCOMPARE(m_axis->isMinorGridLineVisible(), minorGridLineVisible); @@ -355,6 +379,8 @@ void tst_QAbstractAxis::minorGridLineVisible() QCOMPARE(spy7.count(), 0); QCOMPARE(spy8.count(), 0); QCOMPARE(spy9.count(), 1); + QCOMPARE(spy10.count(), 0); + QCOMPARE(spy11.count(), 0); m_chart->setAxisX(m_axis, m_series); m_view->show(); @@ -363,6 +389,100 @@ void tst_QAbstractAxis::minorGridLineVisible() } +void tst_QAbstractAxis::gridLineColor_data() +{ + QTest::addColumn("gridLineColor"); + QTest::newRow("blue") << QColor(Qt::blue); + QTest::newRow("red") << QColor(Qt::red); + QTest::newRow("yellow") << QColor(Qt::yellow); +} + +void tst_QAbstractAxis::gridLineColor() +{ + QFETCH(QColor, gridLineColor); + + QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); + QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); + QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); + QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); + QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); + QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); + QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); + QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); + QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); + QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool))); + QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor))); + QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor))); + + m_axis->setGridLineColor(gridLineColor); + QCOMPARE(m_axis->gridLineColor(), gridLineColor); + + QCOMPARE(spy0.count(), 0); + QCOMPARE(spy1.count(), 0); + QCOMPARE(spy2.count(), 0); + QCOMPARE(spy3.count(), 0); + QCOMPARE(spy4.count(), 0); + QCOMPARE(spy5.count(), 0); + QCOMPARE(spy6.count(), 0); + QCOMPARE(spy7.count(), 0); + QCOMPARE(spy8.count(), 0); + QCOMPARE(spy9.count(), 0); + QCOMPARE(spy10.count(), 1); + QCOMPARE(spy11.count(), 0); + + m_chart->setAxisX(m_axis, m_series); + m_view->show(); + QTest::qWaitForWindowShown(m_view); + +} + +void tst_QAbstractAxis::minorGridLineColor_data() +{ + QTest::addColumn("minorGridLineColor"); + QTest::newRow("blue") << QColor(Qt::blue); + QTest::newRow("red") << QColor(Qt::red); + QTest::newRow("yellow") << QColor(Qt::yellow); +} + +void tst_QAbstractAxis::minorGridLineColor() +{ + QFETCH(QColor, minorGridLineColor); + + QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); + QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); + QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); + QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); + QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); + QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); + QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); + QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); + QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); + QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool))); + QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor))); + QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor))); + + m_axis->setMinorGridLineColor(minorGridLineColor); + QCOMPARE(m_axis->minorGridLineColor(), minorGridLineColor); + + QCOMPARE(spy0.count(), 0); + QCOMPARE(spy1.count(), 0); + QCOMPARE(spy2.count(), 0); + QCOMPARE(spy3.count(), 0); + QCOMPARE(spy4.count(), 0); + QCOMPARE(spy5.count(), 0); + QCOMPARE(spy6.count(), 0); + QCOMPARE(spy7.count(), 0); + QCOMPARE(spy8.count(), 0); + QCOMPARE(spy9.count(), 0); + QCOMPARE(spy10.count(), 0); + QCOMPARE(spy11.count(), 1); + + m_chart->setAxisX(m_axis, m_series); + m_view->show(); + QTest::qWaitForWindowShown(m_view); + +} + void tst_QAbstractAxis::visible_data() { QTest::addColumn("visible"); @@ -386,6 +506,8 @@ void tst_QAbstractAxis::visible() QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool))); + QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor))); + QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor))); m_axis->setVisible(visible); QCOMPARE(m_axis->isVisible(), visible); @@ -400,6 +522,8 @@ void tst_QAbstractAxis::visible() QCOMPARE(spy7.count(), 0); QCOMPARE(spy8.count(), 1); QCOMPARE(spy9.count(), 0); + QCOMPARE(spy10.count(), 0); + QCOMPARE(spy11.count(), 0); m_chart->setAxisX(m_axis, m_series); m_view->show(); @@ -429,6 +553,8 @@ void tst_QAbstractAxis::labelsAngle() QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool))); + QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor))); + QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor))); m_axis->setLabelsAngle(labelsAngle); QCOMPARE(m_axis->labelsAngle(), labelsAngle); @@ -443,6 +569,8 @@ void tst_QAbstractAxis::labelsAngle() QCOMPARE(spy7.count(), 0); QCOMPARE(spy8.count(), 0); QCOMPARE(spy9.count(), 0); + QCOMPARE(spy10.count(), 0); + QCOMPARE(spy11.count(), 0); m_chart->setAxisX(m_axis, m_series); m_view->show(); @@ -474,6 +602,8 @@ void tst_QAbstractAxis::labelsBrush() QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool))); + QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor))); + QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor))); m_axis->setLabelsBrush(labelsBrush); QCOMPARE(m_axis->labelsBrush(), labelsBrush); @@ -488,6 +618,8 @@ void tst_QAbstractAxis::labelsBrush() QCOMPARE(spy7.count(), 0); QCOMPARE(spy8.count(), 0); QCOMPARE(spy9.count(), 0); + QCOMPARE(spy10.count(), 0); + QCOMPARE(spy11.count(), 0); m_view->show(); QTest::qWaitForWindowShown(m_view); @@ -527,6 +659,8 @@ void tst_QAbstractAxis::labelsFont() QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool))); + QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor))); + QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor))); m_axis->setLabelsFont(labelsFont); QCOMPARE(m_axis->labelsFont(), labelsFont); @@ -541,6 +675,8 @@ void tst_QAbstractAxis::labelsFont() QCOMPARE(spy7.count(), 0); QCOMPARE(spy8.count(), 0); QCOMPARE(spy9.count(), 0); + QCOMPARE(spy10.count(), 0); + QCOMPARE(spy11.count(), 0); m_view->show(); QTest::qWaitForWindowShown(m_view); @@ -571,6 +707,8 @@ void tst_QAbstractAxis::labelsVisible() QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool))); + QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor))); + QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor))); m_axis->setLabelsVisible(labelsVisible); QCOMPARE(m_axis->labelsVisible(), labelsVisible); @@ -585,6 +723,8 @@ void tst_QAbstractAxis::labelsVisible() QCOMPARE(spy7.count(), 0); QCOMPARE(spy8.count(), 0); QCOMPARE(spy9.count(), 0); + QCOMPARE(spy10.count(), 0); + QCOMPARE(spy11.count(), 0); m_chart->setAxisX(m_axis, m_series); m_view->show(); @@ -613,6 +753,8 @@ void tst_QAbstractAxis::orientation() QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool))); + QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor))); + QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor))); if(orientation==Qt::Vertical){ m_chart->setAxisY(m_axis,m_series); @@ -631,6 +773,8 @@ void tst_QAbstractAxis::orientation() QCOMPARE(spy7.count(), 0); QCOMPARE(spy8.count(), 0); QCOMPARE(spy9.count(), 0); + QCOMPARE(spy10.count(), 0); + QCOMPARE(spy11.count(), 0); m_view->show(); QTest::qWaitForWindowShown(m_view); @@ -716,6 +860,8 @@ void tst_QAbstractAxis::shadesBrush() QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool))); + QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor))); + QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor))); m_axis->setShadesBrush(shadesBrush); QCOMPARE(m_axis->shadesBrush(), shadesBrush); @@ -730,6 +876,8 @@ void tst_QAbstractAxis::shadesBrush() QCOMPARE(spy7.count(), 0); QCOMPARE(spy8.count(), 0); QCOMPARE(spy9.count(), 0); + QCOMPARE(spy10.count(), 0); + QCOMPARE(spy11.count(), 0); m_view->show(); QTest::qWaitForWindowShown(m_view); @@ -769,6 +917,8 @@ void tst_QAbstractAxis::shadesPen() QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool))); + QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor))); + QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor))); m_axis->setShadesPen(shadesPen); QCOMPARE(m_axis->shadesPen(), shadesPen); @@ -783,6 +933,8 @@ void tst_QAbstractAxis::shadesPen() QCOMPARE(spy7.count(), 0); QCOMPARE(spy8.count(), 0); QCOMPARE(spy9.count(), 0); + QCOMPARE(spy10.count(), 0); + QCOMPARE(spy11.count(), 0); m_chart->setAxisX(m_axis, m_series); m_view->show(); @@ -813,6 +965,8 @@ void tst_QAbstractAxis::shadesVisible() QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool))); + QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor))); + QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor))); m_axis->setShadesVisible(shadesVisible); QCOMPARE(m_axis->shadesVisible(), shadesVisible); @@ -827,6 +981,8 @@ void tst_QAbstractAxis::shadesVisible() QCOMPARE(spy7.count(), 1); QCOMPARE(spy8.count(), 0); QCOMPARE(spy9.count(), 0); + QCOMPARE(spy10.count(), 0); + QCOMPARE(spy11.count(), 0); m_chart->setAxisX(m_axis, m_series); m_view->show(); @@ -854,6 +1010,8 @@ void tst_QAbstractAxis::show() QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool))); + QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor))); + QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor))); m_axis->show(); @@ -867,6 +1025,8 @@ void tst_QAbstractAxis::show() QCOMPARE(spy7.count(), 0); QCOMPARE(spy8.count(), 1); QCOMPARE(spy9.count(), 0); + QCOMPARE(spy10.count(), 0); + QCOMPARE(spy11.count(), 0); QCOMPARE(m_axis->isVisible(), true); } @@ -890,6 +1050,8 @@ void tst_QAbstractAxis::hide() QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool))); + QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor))); + QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor))); m_axis->hide(); @@ -903,6 +1065,8 @@ void tst_QAbstractAxis::hide() QCOMPARE(spy7.count(), 0); QCOMPARE(spy8.count(), 1); QCOMPARE(spy9.count(), 0); + QCOMPARE(spy10.count(), 0); + QCOMPARE(spy11.count(), 0); QCOMPARE(m_axis->isVisible(),false); } diff --git a/tests/auto/qabstractaxis/tst_qabstractaxis.h b/tests/auto/qabstractaxis/tst_qabstractaxis.h index 6be7a23..141bec2 100644 --- a/tests/auto/qabstractaxis/tst_qabstractaxis.h +++ b/tests/auto/qabstractaxis/tst_qabstractaxis.h @@ -51,6 +51,10 @@ private slots: void gridLineVisible(); void minorGridLineVisible_data(); void minorGridLineVisible(); + void gridLineColor_data(); + void gridLineColor(); + void minorGridLineColor_data(); + void minorGridLineColor(); void visible_data(); void visible(); void labelsAngle_data(); diff --git a/tests/manual/polarcharttest/mainwindow.cpp b/tests/manual/polarcharttest/mainwindow.cpp index e2fff3b..78d5c98 100644 --- a/tests/manual/polarcharttest/mainwindow.cpp +++ b/tests/manual/polarcharttest/mainwindow.cpp @@ -169,6 +169,8 @@ MainWindow::MainWindow(QWidget *parent) : this, SLOT(gridIndexChanged(int))); connect(ui->minorGridComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(minorGridIndexChanged(int))); + connect(ui->gridLineColorComboBox, SIGNAL(currentIndexChanged(int)), + this, SLOT(gridLineColorIndexChanged(int))); connect(ui->arrowComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(arrowIndexChanged(int))); connect(ui->logBaseSpin, SIGNAL(valueChanged(double)), @@ -956,6 +958,29 @@ void MainWindow::minorGridIndexChanged(int index) m_radialAxis->setMinorGridLineVisible(m_minorGridVisible); } +void MainWindow::gridLineColorIndexChanged(int index) +{ + QColor color; + switch (index) { + case 0: + color = Qt::black; + break; + case 1: + color = Qt::green; + break; + case 2: + color = Qt::red; + break; + default: + break; + } + + m_angularAxis->setGridLineColor(color); + m_radialAxis->setGridLineColor(color); + m_angularAxis->setMinorGridLineColor(color); + m_radialAxis->setMinorGridLineColor(color); +} + void MainWindow::arrowIndexChanged(int index) { delete m_arrowPen; diff --git a/tests/manual/polarcharttest/mainwindow.h b/tests/manual/polarcharttest/mainwindow.h index ec5b2e7..9de0145 100644 --- a/tests/manual/polarcharttest/mainwindow.h +++ b/tests/manual/polarcharttest/mainwindow.h @@ -70,6 +70,7 @@ public slots: void titleFontSizeChanged(int value); void gridIndexChanged(int index); void minorGridIndexChanged(int index); + void gridLineColorIndexChanged(int index); void arrowIndexChanged(int index); void angularRangeChanged(qreal min, qreal max); void radialRangeChanged(qreal min, qreal max); diff --git a/tests/manual/polarcharttest/mainwindow.ui b/tests/manual/polarcharttest/mainwindow.ui index e438b5a..99f781f 100644 --- a/tests/manual/polarcharttest/mainwindow.ui +++ b/tests/manual/polarcharttest/mainwindow.ui @@ -335,7 +335,7 @@ 10 - 814 + 810 131 20 @@ -394,7 +394,7 @@ 10 - 840 + 830 117 16 @@ -689,7 +689,7 @@ 10 680 - 191 + 198 31 @@ -714,7 +714,7 @@ 10 - 740 + 730 221 22 @@ -736,7 +736,7 @@ 10 - 766 + 760 136 42 @@ -912,6 +912,40 @@ Category Label On Tick + + + + 10 + 850 + 133 + 20 + + + + + 0 + 0 + + + + 0 + + + + Black grid line + + + + + Green grid line + + + + + Red grid line + + + diff --git a/tests/manual/qmlchartproperties/qml/qmlchartproperties/Chart.qml b/tests/manual/qmlchartproperties/qml/qmlchartproperties/Chart.qml index 5d10346..973401f 100644 --- a/tests/manual/qmlchartproperties/qml/qmlchartproperties/Chart.qml +++ b/tests/manual/qmlchartproperties/qml/qmlchartproperties/Chart.qml @@ -72,11 +72,16 @@ ChartView { ValueAxis{ id: axisX + minorGridVisible: false + minorTickCount: 2 onColorChanged: console.log("axisX.onColorChanged: " + color); onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible); onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color); onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible); onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible); + onMinorGridVisibleChanged: console.log("axisX.onMinorGridVisibleChanged: " + visible); + onGridLineColorChanged: console.log("axisX.onGridLineColorChanged: " + color); + onMinorGridLineColorChanged: console.log("axisX.onMinorGridLineColorChanged: " + color); onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible); onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color); onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color); @@ -87,11 +92,16 @@ ChartView { ValueAxis{ id: axisY + minorGridVisible: false + minorTickCount: 2 onColorChanged: console.log("axisY.onColorChanged: " + color); onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible); onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color); onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible); onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible); + onMinorGridVisibleChanged: console.log("axisX.onMinorGridVisibleChanged: " + visible); + onGridLineColorChanged: console.log("axisX.onGridLineColorChanged: " + color); + onMinorGridLineColorChanged: console.log("axisX.onMinorGridLineColorChanged: " + color); onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible); onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color); onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color); diff --git a/tests/manual/qmlchartproperties/qml/qmlchartproperties/ChartEditorAxis.qml b/tests/manual/qmlchartproperties/qml/qmlchartproperties/ChartEditorAxis.qml index 67f7de2..ffe0c0f 100644 --- a/tests/manual/qmlchartproperties/qml/qmlchartproperties/ChartEditorAxis.qml +++ b/tests/manual/qmlchartproperties/qml/qmlchartproperties/ChartEditorAxis.qml @@ -65,6 +65,14 @@ Row { onClicked: axis.minorGridVisible = !axis.minorGridVisible; } Button { + text: "axis grid color" + onClicked: axis.gridLineColor = main.nextColor(); + } + Button { + text: "axis minor grid color" + onClicked: axis.minorGridLineColor = main.nextColor(); + } + Button { text: "axis shades visible" onClicked: axis.shadesVisible = !axis.shadesVisible; }