From e5122ae0e7148672b1893104c7777d404665f1ce 2013-04-11 10:00:52 From: Mika Salmela Date: 2013-04-11 10:00:52 Subject: [PATCH] Theme modifications. Change-Id: If089f741da6ddc1ff0f3bb2de0d5f17e87d00330 Reviewed-by: Mika Salmela --- diff --git a/src/boxplotchart/qboxplotseries.cpp b/src/boxplotchart/qboxplotseries.cpp index 0de3a82..8c338c9 100644 --- a/src/boxplotchart/qboxplotseries.cpp +++ b/src/boxplotchart/qboxplotseries.cpp @@ -188,19 +188,24 @@ void QBoxPlotSeriesPrivate::initializeGraphics(QGraphicsItem* parent) void QBoxPlotSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forced) { Q_Q(QBoxPlotSeries); + qDebug() << "QBoxPlotSeriesPrivate::initializeTheme"; const QList gradients = theme->seriesGradients(); if (forced || m_brush == QBrush(Qt::NoBrush)) { - QColor brushColor = ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 0.1); + QColor brushColor = ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 0.5); q->setBrush(brushColor); } if (forced || m_pen == QPen(Qt::NoPen)) { - QPen pen; - pen.setColor(ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 1.0)); - pen.setWidthF(1.0); + QPen pen = theme->outlinePen(); pen.setCosmetic(true); + +// QPen pen; +// pen.setColor(ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 1.0)); +// pen.setWidthF(2.0); +// pen.setCosmetic(true); + q->setPen(pen); } } diff --git a/src/boxplotchart/qboxplotseries.h b/src/boxplotchart/qboxplotseries.h index b273a51..74ad187 100644 --- a/src/boxplotchart/qboxplotseries.h +++ b/src/boxplotchart/qboxplotseries.h @@ -38,8 +38,6 @@ public: QAbstractSeries::SeriesType type() const; - void mika(); - void setBrush(const QBrush &brush); QBrush brush() const; void setPen(const QPen &pen); diff --git a/src/themes/charttheme_p.h b/src/themes/charttheme_p.h index 71b8208..b697a67 100644 --- a/src/themes/charttheme_p.h +++ b/src/themes/charttheme_p.h @@ -61,6 +61,7 @@ public: QBrush labelBrush() const { return m_labelBrush; } QPen axisLinePen() const { return m_axisLinePen; } QPen backgroundShadesPen() const { return m_backgroundShadesPen; } + QPen outlinePen() const { return m_outlinePen; } QBrush backgroundShadesBrush() const { return m_backgroundShadesBrush; } BackgroundShadesMode backgroundShades() const { return m_backgroundShades; } bool isBackgroundDropShadowEnabled() const { return m_backgroundDropShadowEnabled; } @@ -77,6 +78,7 @@ protected: QBrush m_labelBrush; QPen m_axisLinePen; QPen m_backgroundShadesPen; + QPen m_outlinePen; QBrush m_backgroundShadesBrush; BackgroundShadesMode m_backgroundShades; bool m_backgroundDropShadowEnabled; diff --git a/src/themes/chartthemebluecerulean_p.h b/src/themes/chartthemebluecerulean_p.h index 3c9096f..3ebaeba 100644 --- a/src/themes/chartthemebluecerulean_p.h +++ b/src/themes/chartthemebluecerulean_p.h @@ -60,6 +60,8 @@ public: m_gridLinePen = QPen(QRgb(0x84a2b0)); m_gridLinePen.setWidth(1); m_backgroundShades = BackgroundShadesNone; + m_outlinePen = QPen(QRgb(0xd6d6d6)); + m_outlinePen.setWidthF(2.0); } }; diff --git a/src/themes/chartthemeblueicy_p.h b/src/themes/chartthemeblueicy_p.h index 86277d0..243bf8f 100644 --- a/src/themes/chartthemeblueicy_p.h +++ b/src/themes/chartthemeblueicy_p.h @@ -62,6 +62,8 @@ public: m_gridLinePen = QPen(QRgb(0xe2e2e2)); m_gridLinePen.setWidth(1); m_backgroundShades = BackgroundShadesNone; + m_outlinePen = QPen(QColor(Qt::black)); + m_outlinePen.setWidthF(2.0); } }; diff --git a/src/themes/chartthemebluencs_p.h b/src/themes/chartthemebluencs_p.h index ac5cafb..753348b 100644 --- a/src/themes/chartthemebluencs_p.h +++ b/src/themes/chartthemebluencs_p.h @@ -61,6 +61,8 @@ public: m_gridLinePen = QPen(QRgb(0xe2e2e2)); m_gridLinePen.setWidth(1); m_backgroundShades = BackgroundShadesNone; + m_outlinePen = QPen(QColor(Qt::black)); + m_outlinePen.setWidthF(2.0); } }; diff --git a/src/themes/chartthemebrownsand_p.h b/src/themes/chartthemebrownsand_p.h index ab24169..d05bf0f 100644 --- a/src/themes/chartthemebrownsand_p.h +++ b/src/themes/chartthemebrownsand_p.h @@ -61,6 +61,8 @@ public: m_gridLinePen = QPen(QRgb(0xd4cec3)); m_gridLinePen.setWidth(1); m_backgroundShades = BackgroundShadesNone; + m_outlinePen = QPen(QColor(Qt::black)); + m_outlinePen.setWidthF(2.0); } }; diff --git a/src/themes/chartthemedark_p.h b/src/themes/chartthemedark_p.h index 53a30ac..7341ed1 100644 --- a/src/themes/chartthemedark_p.h +++ b/src/themes/chartthemedark_p.h @@ -61,6 +61,8 @@ public: m_gridLinePen = QPen(QRgb(0x86878c)); m_gridLinePen.setWidth(1); m_backgroundShades = BackgroundShadesNone; + m_outlinePen = QPen(QRgb(0xd6d6d6)); + m_outlinePen.setWidthF(1.0); } }; diff --git a/src/themes/chartthemehighcontrast_p.h b/src/themes/chartthemehighcontrast_p.h index 972f1fb..dcd39a7 100644 --- a/src/themes/chartthemehighcontrast_p.h +++ b/src/themes/chartthemehighcontrast_p.h @@ -63,6 +63,8 @@ public: m_gridLinePen.setWidth(1); m_backgroundShadesBrush = QBrush(QRgb(0xffeecd)); m_backgroundShades = BackgroundShadesHorizontal; + m_outlinePen = QPen(QColor(Qt::black)); + m_outlinePen.setWidthF(1.0); } }; diff --git a/src/themes/chartthemelight_p.h b/src/themes/chartthemelight_p.h index 251422e..5543f71 100644 --- a/src/themes/chartthemelight_p.h +++ b/src/themes/chartthemelight_p.h @@ -63,6 +63,8 @@ public: m_gridLinePen = QPen(QRgb(0xe2e2e2)); m_gridLinePen.setWidth(1); m_backgroundShades = BackgroundShadesNone; + m_outlinePen = QPen(QColor(Qt::black)); + m_outlinePen.setWidthF(2.0); } }; diff --git a/tests/boxplottester/mainwidget.cpp b/tests/boxplottester/mainwidget.cpp index 0f1e578..fe5303d 100644 --- a/tests/boxplottester/mainwidget.cpp +++ b/tests/boxplottester/mainwidget.cpp @@ -43,11 +43,14 @@ QTCOMMERCIALCHART_USE_NAMESPACE +QString addCategories[] = {"Jul", "Aug", "Sep", "Nov", "Dec"}; + MainWidget::MainWidget(QWidget *parent) : QWidget(parent), m_chart(0), rowPos(0), - nSeries(0) + nSeries(0), + nNewBoxes(0) { m_chart = new QChart(); @@ -164,12 +167,14 @@ void MainWidget::addSeries() m_chart->addSeries(m_series[nSeries]); - QStringList categories; - categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; - QBarCategoryAxis *axis = new QBarCategoryAxis(); - axis->append(categories); - m_chart->createDefaultAxes(); - m_chart->setAxisX(axis, m_series[nSeries]); + if (nSeries == 0) { + QStringList categories; + categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; + m_axis = new QBarCategoryAxis(); + m_axis->append(categories); + m_chart->createDefaultAxes(); + m_chart->setAxisX(m_axis, m_series[nSeries]); + } nSeries++; } @@ -191,6 +196,10 @@ void MainWidget::addBox() *newSet << 5 << 6 << 6.8 << 7 << 8; m_series[0]->append(newSet); + + m_axis->append(addCategories[nNewBoxes]); + + nNewBoxes++; } void MainWidget::animationToggled(bool enabled) @@ -223,5 +232,8 @@ void MainWidget::titleToggled(bool enabled) void MainWidget::changeChartTheme(int themeIndex) { qDebug() << "BoxPlotTester::changeChartTheme: " << themeIndex; - m_chart->setTheme((QChart::ChartTheme) themeIndex); + if (themeIndex == 0) + m_chart->setTheme(QChart::ChartThemeLight); + else + m_chart->setTheme((QChart::ChartTheme) (themeIndex - 1)); } diff --git a/tests/boxplottester/mainwidget.h b/tests/boxplottester/mainwidget.h index a0670bb..5e20c83 100644 --- a/tests/boxplottester/mainwidget.h +++ b/tests/boxplottester/mainwidget.h @@ -26,6 +26,7 @@ #include "qchartview.h" #include #include +#include class QGridLayout; @@ -56,8 +57,10 @@ private: QChart *m_chart; QChartView *m_chartView; QGridLayout *m_scatterLayout; + QBarCategoryAxis *m_axis; int rowPos; int nSeries; + int nNewBoxes; QBoxPlotSeries *m_series[10]; };