From 17e2918b5f02101a3d3ccd244dcbce0b06c84116 2012-03-19 12:44:14 From: Tero Ahola Date: 2012-03-19 12:44:14 Subject: [PATCH] Three more themes --- diff --git a/demos/chartthemes/main.cpp b/demos/chartthemes/main.cpp index 23ceb65..645b884 100644 --- a/demos/chartthemes/main.cpp +++ b/demos/chartthemes/main.cpp @@ -57,12 +57,15 @@ public: // settings layout m_themeComboBox = new QComboBox(); m_themeComboBox->addItem("Default", QChart::ChartThemeDefault); + m_themeComboBox->addItem("Light", QChart::ChartThemeLight); + m_themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean); + m_themeComboBox->addItem("Dark", QChart::ChartThemeDark); + m_themeComboBox->addItem("Brown Sand", QChart::ChartThemeBrownSand); + m_themeComboBox->addItem("Blue NCS", QChart::ChartThemeBlueNcs); m_themeComboBox->addItem("Vanilla", QChart::ChartThemeVanilla); m_themeComboBox->addItem("Icy", QChart::ChartThemeIcy); m_themeComboBox->addItem("Grayscale", QChart::ChartThemeGrayscale); m_themeComboBox->addItem("Scientific", QChart::ChartThemeScientific); - m_themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean); - m_themeComboBox->addItem("Light", QChart::ChartThemeLight); connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this ,SLOT(updateTheme())); QCheckBox *antialiasCheckBox = new QCheckBox("Anti aliasing"); connect(antialiasCheckBox, SIGNAL(toggled(bool)), this ,SLOT(updateAntialiasing(bool))); @@ -178,9 +181,21 @@ public Q_SLOTS: chart->setChartTheme(theme); QPalette pal = window()->palette(); - if (theme == QChart::ChartThemeBlueCerulean) { + if (theme == QChart::ChartThemeLight) { + pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); + pal.setColor(QPalette::WindowText, QRgb(0x404044)); + } else if (theme == QChart::ChartThemeDark) { pal.setColor(QPalette::Window, QRgb(0x121218)); pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); + } else if (theme == QChart::ChartThemeBlueCerulean) { + pal.setColor(QPalette::Window, QRgb(0x40434a)); + pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); + } else if (theme == QChart::ChartThemeBrownSand) { + pal.setColor(QPalette::Window, QRgb(0x9e8965)); + pal.setColor(QPalette::WindowText, QRgb(0x404044)); + } else if (theme == QChart::ChartThemeBlueNcs) { + pal.setColor(QPalette::Window, QRgb(0x018bba)); + pal.setColor(QPalette::WindowText, QRgb(0x404044)); } else { pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); pal.setColor(QPalette::WindowText, QRgb(0x404044)); diff --git a/qmlplugin/declarativechart.h b/qmlplugin/declarativechart.h index c882289..e4b19f1 100644 --- a/qmlplugin/declarativechart.h +++ b/qmlplugin/declarativechart.h @@ -18,12 +18,15 @@ class DeclarativeChart : public QDeclarativeItem public: enum ChartTheme { ThemeDefault, + ThemeLight, + ThemeBlueCerulean, + ThemeDark, + ThemeBrownSand, + ThemeBlueNcs, ThemeVanilla, ThemeIcy, ThemeGrayscale, - ThemeScientific, - ThemeBlueCerulean, - ThemeLight + ThemeScientific }; DeclarativeChart(QDeclarativeItem *parent = 0); diff --git a/src/charttheme.cpp b/src/charttheme.cpp index 19511be..d61fd04 100644 --- a/src/charttheme.cpp +++ b/src/charttheme.cpp @@ -30,13 +30,15 @@ //themes #include "chartthemedefault_p.h" +#include "chartthemelight_p.h" +#include "chartthemebluecerulean_p.h" +#include "chartthemedark_p.h" +#include "chartthemebrownsand_p.h" +#include "chartthemebluencs_p.h" #include "chartthemevanilla_p.h" #include "chartthemeicy_p.h" #include "chartthemegrayscale_p.h" #include "chartthemescientific_p.h" -#include "chartthemebluecerulean_p.h" -#include "chartthemelight_p.h" - QTCOMMERCIALCHART_BEGIN_NAMESPACE @@ -58,6 +60,16 @@ ChartTheme::ChartTheme(QChart::ChartTheme id) : ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme) { switch(theme) { + case QChart::ChartThemeLight: + return new ChartThemeLight(); + case QChart::ChartThemeBlueCerulean: + return new ChartThemeBlueCerulean(); + case QChart::ChartThemeDark: + return new ChartThemeDark(); + case QChart::ChartThemeBrownSand: + return new ChartThemeBrownSand(); + case QChart::ChartThemeBlueNcs: + return new ChartThemeBlueNcs(); case QChart::ChartThemeVanilla: return new ChartThemeVanilla(); case QChart::ChartThemeIcy: @@ -66,10 +78,6 @@ ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme) return new ChartThemeGrayscale(); case QChart::ChartThemeScientific: return new ChartThemeScientific(); - case QChart::ChartThemeBlueCerulean: - return new ChartThemeBlueCerulean(); - case QChart::ChartThemeLight: - return new ChartThemeLight(); default: return new ChartThemeDefault(); } diff --git a/src/qchart.h b/src/qchart.h index ced697c..f081c73 100644 --- a/src/qchart.h +++ b/src/qchart.h @@ -30,12 +30,15 @@ class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget public: enum ChartTheme { ChartThemeDefault, + ChartThemeLight, + ChartThemeBlueCerulean, + ChartThemeDark, + ChartThemeBrownSand, + ChartThemeBlueNcs, ChartThemeVanilla, ChartThemeIcy, ChartThemeGrayscale, ChartThemeScientific, - ChartThemeBlueCerulean, - ChartThemeLight, ChartThemeCount }; diff --git a/src/src.pro b/src/src.pro index edcb983..e89c305 100644 --- a/src/src.pro +++ b/src/src.pro @@ -44,12 +44,15 @@ include(scatterseries/scatter.pri) include(splinechart/splinechart.pri) THEMES += themes/chartthemedefault_p.h \ + themes/chartthemelight_p.h \ + themes/chartthemebluecerulean_p.h \ + themes/chartthemedark_p.h \ + themes/chartthemebrownsand_p.h \ + themes/chartthemebluencs_p.h \ themes/chartthemeicy_p.h \ themes/chartthemegrayscale_p.h \ themes/chartthemescientific_p.h \ - themes/chartthemevanilla_p.h \ - themes/chartthemebluecerulean_p.h \ - themes/chartthemelight_p.h + themes/chartthemevanilla_p.h HEADERS += $$PUBLIC_HEADERS HEADERS += $$PRIVATE_HEADERS diff --git a/src/themes/chartthemebluecerulean_p.h b/src/themes/chartthemebluecerulean_p.h index ea240f3..d74706d 100644 --- a/src/themes/chartthemebluecerulean_p.h +++ b/src/themes/chartthemebluecerulean_p.h @@ -8,27 +8,27 @@ public: ChartThemeBlueCerulean() : ChartTheme(QChart::ChartThemeBlueCerulean) { // Series colors - m_seriesColors << QRgb(0x38ad6b); - m_seriesColors << QRgb(0x3c84a7); - m_seriesColors << QRgb(0xeb8817); - m_seriesColors << QRgb(0x7b7f8c); - m_seriesColors << QRgb(0xbf593e); + m_seriesColors << QRgb(0xc7e85b); + m_seriesColors << QRgb(0x1cb54f); + m_seriesColors << QRgb(0x5cbf9b); + m_seriesColors << QRgb(0x009fbf); + m_seriesColors << QRgb(0xee7392); generateSeriesGradients(); // Background QLinearGradient backgroundGradient; - backgroundGradient.setColorAt(0.0, QRgb(0x2e303a)); - backgroundGradient.setColorAt(1.0, QRgb(0x121218)); + backgroundGradient.setColorAt(0.0, QRgb(0x056189)); + backgroundGradient.setColorAt(1.0, QRgb(0x101a31)); backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); m_chartBackgroundGradient = backgroundGradient; // Axes and other m_masterFont = QFont("arial"); m_titleBrush = QBrush(QRgb(0xffffff)); - m_axisLinePen = QPen(QRgb(0x86878c)); + m_axisLinePen = QPen(QRgb(0xd6d6d6)); m_axisLinePen.setWidth(2); m_axisLabelBrush = QBrush(QRgb(0xffffff)); - m_gridLinePen = QPen(QRgb(0x86878c)); + m_gridLinePen = QPen(QRgb(0x84a2b0)); m_gridLinePen.setWidth(1); } }; diff --git a/src/themes/chartthemebluencs_p.h b/src/themes/chartthemebluencs_p.h new file mode 100644 index 0000000..76c0132 --- /dev/null +++ b/src/themes/chartthemebluencs_p.h @@ -0,0 +1,36 @@ +#include "charttheme_p.h" + +QTCOMMERCIALCHART_BEGIN_NAMESPACE + +class ChartThemeBlueNcs: public ChartTheme +{ +public: + ChartThemeBlueNcs() : ChartTheme(QChart::ChartThemeBlueNcs) + { + // Series colors + m_seriesColors << QRgb(0x1db0da); + m_seriesColors << QRgb(0x1341a6); + m_seriesColors << QRgb(0x88d41e); + m_seriesColors << QRgb(0xff8e1a); + m_seriesColors << QRgb(0x398ca3); + generateSeriesGradients(); + + // Background + QLinearGradient backgroundGradient; + backgroundGradient.setColorAt(0.0, QRgb(0xffffff)); + backgroundGradient.setColorAt(1.0, QRgb(0xffffff)); + backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); + m_chartBackgroundGradient = backgroundGradient; + + // Axes and other + m_masterFont = QFont("arial"); + m_titleBrush = QBrush(QRgb(0x404044)); + m_axisLinePen = QPen(QRgb(0xd6d6d6)); + m_axisLinePen.setWidth(2); + m_axisLabelBrush = QBrush(QRgb(0x404044)); + m_gridLinePen = QPen(QRgb(0xe2e2e2)); + m_gridLinePen.setWidth(1); + } +}; + +QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/themes/chartthemebrownsand_p.h b/src/themes/chartthemebrownsand_p.h new file mode 100644 index 0000000..91e1f16 --- /dev/null +++ b/src/themes/chartthemebrownsand_p.h @@ -0,0 +1,36 @@ +#include "charttheme_p.h" + +QTCOMMERCIALCHART_BEGIN_NAMESPACE + +class ChartThemeBrownSand: public ChartTheme +{ +public: + ChartThemeBrownSand() : ChartTheme(QChart::ChartThemeBrownSand) + { + // Series colors + m_seriesColors << QRgb(0xb39b72); + m_seriesColors << QRgb(0xb3b376); + m_seriesColors << QRgb(0xc35660); + m_seriesColors << QRgb(0x536780); + m_seriesColors << QRgb(0x494345); + generateSeriesGradients(); + + // Background + QLinearGradient backgroundGradient; + backgroundGradient.setColorAt(0.0, QRgb(0xf3ece0)); + backgroundGradient.setColorAt(1.0, QRgb(0xf3ece0)); + backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); + m_chartBackgroundGradient = backgroundGradient; + + // Axes and other + m_masterFont = QFont("arial"); + m_titleBrush = QBrush(QRgb(0x404044)); + m_axisLinePen = QPen(QRgb(0xb5b0a7)); + m_axisLinePen.setWidth(2); + m_axisLabelBrush = QBrush(QRgb(0x404044)); + m_gridLinePen = QPen(QRgb(0xd4cec3)); + m_gridLinePen.setWidth(1); + } +}; + +QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/themes/chartthemedark_p.h b/src/themes/chartthemedark_p.h new file mode 100644 index 0000000..829be2a --- /dev/null +++ b/src/themes/chartthemedark_p.h @@ -0,0 +1,36 @@ +#include "charttheme_p.h" + +QTCOMMERCIALCHART_BEGIN_NAMESPACE + +class ChartThemeDark : public ChartTheme +{ +public: + ChartThemeDark() : ChartTheme(QChart::ChartThemeDark) + { + // Series colors + m_seriesColors << QRgb(0x38ad6b); + m_seriesColors << QRgb(0x3c84a7); + m_seriesColors << QRgb(0xeb8817); + m_seriesColors << QRgb(0x7b7f8c); + m_seriesColors << QRgb(0xbf593e); + generateSeriesGradients(); + + // Background + QLinearGradient backgroundGradient; + backgroundGradient.setColorAt(0.0, QRgb(0x2e303a)); + backgroundGradient.setColorAt(1.0, QRgb(0x121218)); + backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); + m_chartBackgroundGradient = backgroundGradient; + + // Axes and other + m_masterFont = QFont("arial"); + m_titleBrush = QBrush(QRgb(0xffffff)); + m_axisLinePen = QPen(QRgb(0x86878c)); + m_axisLinePen.setWidth(2); + m_axisLabelBrush = QBrush(QRgb(0xffffff)); + m_gridLinePen = QPen(QRgb(0x86878c)); + m_gridLinePen.setWidth(1); + } +}; + +QTCOMMERCIALCHART_END_NAMESPACE