From ac346143dd389413ce8b0c5f8347aac73b45a6a1 2012-03-15 14:14:29 From: Tero Ahola Date: 2012-03-15 14:14:29 Subject: [PATCH] Fonts and background of the themes The theme demo app window color now matches the theme --- diff --git a/demos/chartthemes/main.cpp b/demos/chartthemes/main.cpp index d0dbd5a..8e92f96 100644 --- a/demos/chartthemes/main.cpp +++ b/demos/chartthemes/main.cpp @@ -174,6 +174,16 @@ public Q_SLOTS: QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData(m_themeComboBox->currentIndex()).toInt(); foreach (QChartView *chart, m_charts) chart->setChartTheme(theme); + + QPalette pal = window()->palette(); + if (theme == QChart::ChartThemeBlueCerulean) { + pal.setColor(QPalette::Window, QRgb(0x121218)); + pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); + } else { + pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); + pal.setColor(QPalette::WindowText, QRgb(0x404044)); + } + window()->setPalette(pal); } private: diff --git a/src/charttheme.cpp b/src/charttheme.cpp index 7444b33..892fb75 100644 --- a/src/charttheme.cpp +++ b/src/charttheme.cpp @@ -40,7 +40,15 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE -ChartTheme::ChartTheme(QChart::ChartTheme id) +ChartTheme::ChartTheme(QChart::ChartTheme id) : + m_masterFont(QFont()), + m_titleBrush(QColor(QRgb(0x000000))), + m_axisLinePen(QPen(QRgb(0x000000))), + m_axisLabelBrush(QColor(QRgb(0x000000))), + m_backgroundShadesPen(Qt::NoPen), + m_backgroundShadesBrush(Qt::NoBrush), + m_backgroundShades(BackgroundShadesNone), + m_gridLinePen(QPen(QRgb(0x000000))) { m_id = id; qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); @@ -75,6 +83,7 @@ void ChartTheme::decorate(QChart* chart) chart->setChartBackgroundBrush(Qt::NoBrush); } chart->setChartTitleFont(m_masterFont); + chart->setChartTitleBrush(m_titleBrush); } void ChartTheme::decorate(QLegend* legend) @@ -214,7 +223,7 @@ void ChartTheme::decorate(QChartAxis* axis,bool axisX) { if (axis->isAxisVisible()) { axis->setLabelsBrush(m_axisLabelBrush); - axis->setLabelsPen(m_axisLabelPen); + axis->setLabelsPen(Qt::NoPen); // NoPen for performance reasons if (m_backgroundShades == BackgroundShadesBoth || (m_backgroundShades == BackgroundShadesVertical && axisX) || (m_backgroundShades == BackgroundShadesHorizontal && !axisX)) { diff --git a/src/charttheme_p.h b/src/charttheme_p.h index 3e416ce..e5f454a 100644 --- a/src/charttheme_p.h +++ b/src/charttheme_p.h @@ -67,9 +67,9 @@ protected: QLinearGradient m_chartBackgroundGradient; QFont m_masterFont; + QBrush m_titleBrush; QPen m_axisLinePen; QBrush m_axisLabelBrush; - QPen m_axisLabelPen; QPen m_backgroundShadesPen; QBrush m_backgroundShadesBrush; BackgroundShadesMode m_backgroundShades; diff --git a/src/themes/chartthemebluecerulean_p.h b/src/themes/chartthemebluecerulean_p.h index 86a8f1a..ea240f3 100644 --- a/src/themes/chartthemebluecerulean_p.h +++ b/src/themes/chartthemebluecerulean_p.h @@ -17,19 +17,17 @@ public: // Background QLinearGradient backgroundGradient; - backgroundGradient.setColorAt(0.0, QRgb(0xd6d6d6)); + 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(); + m_masterFont = QFont("arial"); + m_titleBrush = QBrush(QRgb(0xffffff)); m_axisLinePen = QPen(QRgb(0x86878c)); m_axisLinePen.setWidth(2); - m_axisLabelBrush = QBrush(QRgb(0x86878c)); - m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons - m_backgroundShadesPen = Qt::NoPen; - m_backgroundShades = BackgroundShadesNone; + m_axisLabelBrush = QBrush(QRgb(0xffffff)); m_gridLinePen = QPen(QRgb(0x86878c)); m_gridLinePen.setWidth(1); } diff --git a/src/themes/chartthemedefault_p.h b/src/themes/chartthemedefault_p.h index c25c93d..329b30a 100644 --- a/src/themes/chartthemedefault_p.h +++ b/src/themes/chartthemedefault_p.h @@ -9,7 +9,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE class ChartThemeDefault: public ChartTheme { public: - ChartThemeDefault():ChartTheme(QChart::ChartThemeDefault) + ChartThemeDefault() : ChartTheme(QChart::ChartThemeDefault) { #ifdef Q_OS_WIN // TODO: use theme specific window frame color as a series base color (it would give more @@ -63,13 +63,6 @@ public: GetGValue(colorWindow), GetBValue(colorWindow))); // Axes and other - m_masterFont = QFont(); - m_masterFont.setPointSizeF(10.0); - m_axisLinePen = QPen(Qt::black); - m_axisLinePen.setWidth(2); - m_axisLabelBrush = QBrush(Qt::black); - m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons - m_backgroundShadesPen = Qt::NoPen; m_backgroundShadesBrush = QBrush(QColor(0xaf, 0xaf, 0xaf, 0x50)); m_backgroundShades = BackgroundShadesVertical; @@ -88,13 +81,6 @@ public: m_chartBackgroundGradient = backgroundGradient; // Axes and other - m_masterFont = QFont(); - m_masterFont.setPointSizeF(10.0); - m_axisLinePen = QPen(Qt::black); - m_axisLinePen.setWidth(2); - m_axisLabelBrush = QBrush(Qt::black); - m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons - m_backgroundShadesPen = Qt::NoPen; m_backgroundShadesBrush = QBrush(QColor(0xaf, 0xaf, 0xaf, 0x50)); m_backgroundShades = BackgroundShadesVertical; @@ -113,13 +99,6 @@ public: m_chartBackgroundGradient = backgroundGradient; // Axes and other - m_masterFont = QFont(); - m_masterFont.setPointSizeF(10.0); - m_axisLinePen = QPen(Qt::black); - m_axisLinePen.setWidth(2); - m_axisLabelBrush = QBrush(Qt::black); - m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons - m_backgroundShadesPen = Qt::NoPen; m_backgroundShadesBrush = QBrush(QColor(0xaf, 0xaf, 0xaf, 0x50)); m_backgroundShades = BackgroundShadesVertical; @@ -138,13 +117,6 @@ public: m_backgroundGradient = backgroundGradient; // Axes and other - m_masterFont = QFont(); - m_masterFont.setPointSizeF(10.0); - m_axisLinePen = QPen(Qt::black); - m_axisLinePen.setWidth(2); - m_axisLabelBrush = QBrush(Qt::black); - m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons - m_backgroundShadesPen = Qt::NoPen; m_backgroundShadesBrush = QBrush(QColor(0xaf, 0xaf, 0xaf, 0x50)); m_backgroundShades = BackgroundShadesVertical; #endif diff --git a/src/themes/chartthemegrayscale_p.h b/src/themes/chartthemegrayscale_p.h index 6ae2c7f..09148a7 100644 --- a/src/themes/chartthemegrayscale_p.h +++ b/src/themes/chartthemegrayscale_p.h @@ -5,7 +5,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE class ChartThemeGrayscale: public ChartTheme { public: - ChartThemeGrayscale():ChartTheme(QChart::ChartThemeGrayscale) + ChartThemeGrayscale() : ChartTheme(QChart::ChartThemeGrayscale) { // Series colors m_seriesColors << QRgb(0x869299); @@ -22,13 +22,9 @@ public: m_chartBackgroundGradient = backgroundGradient; // Axes and other - m_masterFont = QFont(); m_axisLinePen = QPen(QRgb(0x0f0f0f)); m_axisLinePen.setWidth(2); m_axisLabelBrush = QBrush(QRgb(0x3f3f3f)); - m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons - m_backgroundShadesPen = Qt::NoPen; - m_backgroundShades = BackgroundShadesNone; m_gridLinePen = QPen(QRgb(0x0f0f0f)); m_gridLinePen.setWidth(2); } diff --git a/src/themes/chartthemeicy_p.h b/src/themes/chartthemeicy_p.h index 78b873f..1e39fc3 100644 --- a/src/themes/chartthemeicy_p.h +++ b/src/themes/chartthemeicy_p.h @@ -5,7 +5,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE class ChartThemeIcy: public ChartTheme { public: - ChartThemeIcy():ChartTheme(QChart::ChartThemeIcy) + ChartThemeIcy() : ChartTheme(QChart::ChartThemeIcy) { // Series m_seriesColors << QRgb(0x0d2673); @@ -22,13 +22,9 @@ public: m_chartBackgroundGradient = backgroundGradient; // Axes and other - m_masterFont = QFont(); m_axisLinePen = QPen(QRgb(0x0f0f0f)); m_axisLinePen.setWidth(2); m_axisLabelBrush = QBrush(QRgb(0x3f3f3f)); - m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons - m_backgroundShadesPen = Qt::NoPen; - m_backgroundShades = BackgroundShadesNone; m_gridLinePen = QPen(QRgb(0x0f0f0f)); m_gridLinePen.setWidth(2); } diff --git a/src/themes/chartthemelight_p.h b/src/themes/chartthemelight_p.h index 7172400..7d949f4 100644 --- a/src/themes/chartthemelight_p.h +++ b/src/themes/chartthemelight_p.h @@ -23,13 +23,10 @@ public: m_chartBackgroundGradient = backgroundGradient; // Axes and other - m_masterFont = QFont(); - m_axisLinePen = QPen(QRgb(0xe2e2e2)); + m_masterFont = QFont("arial"); + m_axisLinePen = QPen(0xd6d6d6); m_axisLinePen.setWidth(1); - m_axisLabelBrush = QBrush(QRgb(0x838383)); - m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons - m_backgroundShadesPen = Qt::NoPen; - m_backgroundShades = BackgroundShadesNone; + m_axisLabelBrush = QBrush(QRgb(0x404044)); m_gridLinePen = QPen(QRgb(0xe2e2e2)); m_gridLinePen.setWidth(1); } diff --git a/src/themes/chartthemescientific_p.h b/src/themes/chartthemescientific_p.h index 67b9c99..1b0e5bf 100644 --- a/src/themes/chartthemescientific_p.h +++ b/src/themes/chartthemescientific_p.h @@ -5,7 +5,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE class ChartThemeScientific: public ChartTheme { public: - ChartThemeScientific():ChartTheme(QChart::ChartThemeScientific) + ChartThemeScientific() : ChartTheme(QChart::ChartThemeScientific) { // Series m_seriesColors << QRgb(0xFFAD00); @@ -22,13 +22,9 @@ public: m_chartBackgroundGradient = backgroundGradient; // Axes and other - m_masterFont = QFont(); m_axisLinePen = QPen(QRgb(0x0f0f0f)); m_axisLinePen.setWidth(2); m_axisLabelBrush = QBrush(QRgb(0x3f3f3f)); - m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons - m_backgroundShadesPen = Qt::NoPen; -// m_backgroundShadesBrush = QBrush(QColor(0x0f, 0x0f, 0x0f, 0x80)); m_backgroundShadesBrush = QBrush(QColor(0xff, 0xad, 0x00, 0x50)); m_backgroundShades = BackgroundShadesHorizontal; m_gridLinePen = QPen(QRgb(0x0f0f0f)); diff --git a/src/themes/chartthemevanilla_p.h b/src/themes/chartthemevanilla_p.h index ecd149b..7c79091 100644 --- a/src/themes/chartthemevanilla_p.h +++ b/src/themes/chartthemevanilla_p.h @@ -5,7 +5,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE class ChartThemeVanilla: public ChartTheme { public: - ChartThemeVanilla():ChartTheme(QChart::ChartThemeVanilla) + ChartThemeVanilla() : ChartTheme(QChart::ChartThemeVanilla) { // Series m_seriesColors << QRgb(0xd9c574); @@ -23,13 +23,9 @@ public: m_chartBackgroundGradient = backgroundGradient; // Axes and other - m_masterFont = QFont(); m_axisLinePen = QPen(QRgb(0x0f0f0f)); m_axisLinePen.setWidth(2); m_axisLabelBrush = QBrush(QRgb(0xa0a071)); - m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons - m_backgroundShadesPen = Qt::NoPen; - m_backgroundShades = BackgroundShadesNone; m_gridLinePen = QPen(QRgb(0x0f0f0f)); m_gridLinePen.setWidth(2); }