##// END OF EJS Templates
minor. typo
Michal Klocek -
r754:5e0869857880
parent child
Show More
@@ -1,331 +1,331
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE:BSD$
9 ** $QT_BEGIN_LICENSE:BSD$
10 ** You may use this file under the terms of the BSD license as follows:
10 ** You may use this file under the terms of the BSD license as follows:
11 **
11 **
12 ** "Redistribution and use in source and binary forms, with or without
12 ** "Redistribution and use in source and binary forms, with or without
13 ** modification, are permitted provided that the following conditions are
13 ** modification, are permitted provided that the following conditions are
14 ** met:
14 ** met:
15 ** * Redistributions of source code must retain the above copyright
15 ** * Redistributions of source code must retain the above copyright
16 ** notice, this list of conditions and the following disclaimer.
16 ** notice, this list of conditions and the following disclaimer.
17 ** * Redistributions in binary form must reproduce the above copyright
17 ** * Redistributions in binary form must reproduce the above copyright
18 ** notice, this list of conditions and the following disclaimer in
18 ** notice, this list of conditions and the following disclaimer in
19 ** the documentation and/or other materials provided with the
19 ** the documentation and/or other materials provided with the
20 ** distribution.
20 ** distribution.
21 ** * Neither the name of Digia nor the names of its contributors
21 ** * Neither the name of Digia nor the names of its contributors
22 ** may be used to endorse or promote products derived from this
22 ** may be used to endorse or promote products derived from this
23 ** software without specific prior written permission.
23 ** software without specific prior written permission.
24 **
24 **
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36 ** $QT_END_LICENSE$
36 ** $QT_END_LICENSE$
37 **
37 **
38 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
38 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
39 **
39 **
40 ****************************************************************************/
40 ****************************************************************************/
41
41
42 #include "themewidget.h"
42 #include "themewidget.h"
43
43
44 #include <QChartView>
44 #include <QChartView>
45 #include <QPieSeries>
45 #include <QPieSeries>
46 #include <QPieSlice>
46 #include <QPieSlice>
47 #include <QBarSeries>
47 #include <QBarSeries>
48 #include <QPercentBarSeries>
48 #include <QPercentBarSeries>
49 #include <QStackedBarSeries>
49 #include <QStackedBarSeries>
50 #include <QBarSet>
50 #include <QBarSet>
51 #include <QLineSeries>
51 #include <QLineSeries>
52 #include <QSplineSeries>
52 #include <QSplineSeries>
53 #include <QScatterSeries>
53 #include <QScatterSeries>
54 #include <QAreaSeries>
54 #include <QAreaSeries>
55 #include <QGridLayout>
55 #include <QGridLayout>
56 #include <QFormLayout>
56 #include <QFormLayout>
57 #include <QComboBox>
57 #include <QComboBox>
58 #include <QSpinBox>
58 #include <QSpinBox>
59 #include <QCheckBox>
59 #include <QCheckBox>
60 #include <QGroupBox>
60 #include <QGroupBox>
61 #include <QLabel>
61 #include <QLabel>
62 #include <QTime>
62 #include <QTime>
63
63
64 ThemeWidget::ThemeWidget(QWidget* parent) :
64 ThemeWidget::ThemeWidget(QWidget* parent) :
65 QWidget(parent),
65 QWidget(parent),
66 m_listCount(3),
66 m_listCount(3),
67 m_valueMax(100),
67 m_valueMax(100),
68 m_valueCount(11),
68 m_valueCount(11),
69 m_dataTable(generateRandomData(m_listCount,m_valueMax,m_valueCount)),
69 m_dataTable(generateRandomData(m_listCount,m_valueMax,m_valueCount)),
70 m_themeComboBox(createThemeBox()),
70 m_themeComboBox(createThemeBox()),
71 m_antialiasCheckBox(new QCheckBox("Anti aliasing")),
71 m_antialiasCheckBox(new QCheckBox("Anti aliasing")),
72 m_animatedComboBox(createAnimationBox())
72 m_animatedComboBox(createAnimationBox())
73 {
73 {
74
74
75 connectSignals();
75 connectSignals();
76 // create layout
76 // create layout
77 QGridLayout* baseLayout = new QGridLayout();
77 QGridLayout* baseLayout = new QGridLayout();
78 QHBoxLayout *settingsLayout = new QHBoxLayout();
78 QHBoxLayout *settingsLayout = new QHBoxLayout();
79 settingsLayout->addWidget(new QLabel("Theme:"));
79 settingsLayout->addWidget(new QLabel("Theme:"));
80 settingsLayout->addWidget(m_themeComboBox);
80 settingsLayout->addWidget(m_themeComboBox);
81 settingsLayout->addWidget(new QLabel("Animation:"));
81 settingsLayout->addWidget(new QLabel("Animation:"));
82 settingsLayout->addWidget(m_animatedComboBox);
82 settingsLayout->addWidget(m_animatedComboBox);
83 settingsLayout->addWidget(m_antialiasCheckBox);
83 settingsLayout->addWidget(m_antialiasCheckBox);
84 settingsLayout->addStretch();
84 settingsLayout->addStretch();
85 baseLayout->addLayout(settingsLayout, 0, 0, 1, 3);
85 baseLayout->addLayout(settingsLayout, 0, 0, 1, 3);
86
86
87 //create charts
87 //create charts
88
88
89 QChartView *chartView;
89 QChartView *chartView;
90
90
91 chartView = new QChartView(createAreaChart());
91 chartView = new QChartView(createAreaChart());
92 baseLayout->addWidget(chartView, 1, 0);
92 baseLayout->addWidget(chartView, 1, 0);
93 m_charts << chartView;
93 m_charts << chartView;
94
94
95 chartView = new QChartView(createBarChart(m_valueCount));
95 chartView = new QChartView(createBarChart(m_valueCount));
96 baseLayout->addWidget(chartView, 1, 1);
96 baseLayout->addWidget(chartView, 1, 1);
97 m_charts << chartView;
97 m_charts << chartView;
98
98
99 chartView = new QChartView(createLineChart());
99 chartView = new QChartView(createLineChart());
100 baseLayout->addWidget(chartView, 1, 2);
100 baseLayout->addWidget(chartView, 1, 2);
101 m_charts << chartView;
101 m_charts << chartView;
102
102
103 chartView = new QChartView(createPieChart());
103 chartView = new QChartView(createPieChart());
104 chartView->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); // funny things happen if the pie slice labels no not fit the screen...
104 chartView->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); // funny things happen if the pie slice labels no not fit the screen...
105 baseLayout->addWidget(chartView, 2, 0);
105 baseLayout->addWidget(chartView, 2, 0);
106 m_charts << chartView;
106 m_charts << chartView;
107
107
108 chartView = new QChartView(createSplineChart());
108 chartView = new QChartView(createSplineChart());
109 baseLayout->addWidget(chartView, 2, 1);
109 baseLayout->addWidget(chartView, 2, 1);
110 m_charts << chartView;
110 m_charts << chartView;
111
111
112 chartView = new QChartView(createSplineChart());
112 chartView = new QChartView(createScatterChart());
113 baseLayout->addWidget(chartView, 2, 2);
113 baseLayout->addWidget(chartView, 2, 2);
114 m_charts << chartView;
114 m_charts << chartView;
115
115
116 setLayout(baseLayout);
116 setLayout(baseLayout);
117 }
117 }
118
118
119 ThemeWidget::~ThemeWidget()
119 ThemeWidget::~ThemeWidget()
120 {
120 {
121 }
121 }
122
122
123 void ThemeWidget::connectSignals()
123 void ThemeWidget::connectSignals()
124 {
124 {
125 connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
125 connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
126 connect(m_antialiasCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI()));
126 connect(m_antialiasCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI()));
127 connect(m_animatedComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
127 connect(m_animatedComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
128 }
128 }
129
129
130 DataTable ThemeWidget::generateRandomData(int listCount,int valueMax,int valueCount) const
130 DataTable ThemeWidget::generateRandomData(int listCount,int valueMax,int valueCount) const
131 {
131 {
132 DataTable dataTable;
132 DataTable dataTable;
133
133
134 // set seed for random stuff
134 // set seed for random stuff
135 qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
135 qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
136
136
137 // generate random data
137 // generate random data
138 for (int i(0); i < listCount; i++) {
138 for (int i(0); i < listCount; i++) {
139 DataList dataList;
139 DataList dataList;
140 for (int j(0); j < valueCount; j++) {
140 for (int j(0); j < valueCount; j++) {
141 QPointF value(j + (qreal) rand() / (qreal) RAND_MAX, qrand() % valueMax);
141 QPointF value(j + (qreal) rand() / (qreal) RAND_MAX, qrand() % valueMax);
142 QString label = "Item " + QString::number(i) + ":" + QString::number(j);
142 QString label = "Item " + QString::number(i) + ":" + QString::number(j);
143 dataList << Data(value, label);
143 dataList << Data(value, label);
144 }
144 }
145 dataTable << dataList;
145 dataTable << dataList;
146 }
146 }
147
147
148 return dataTable;
148 return dataTable;
149 }
149 }
150
150
151 QComboBox* ThemeWidget::createThemeBox() const
151 QComboBox* ThemeWidget::createThemeBox() const
152 {
152 {
153 // settings layout
153 // settings layout
154 QComboBox* themeComboBox = new QComboBox();
154 QComboBox* themeComboBox = new QComboBox();
155 themeComboBox->addItem("Default", QChart::ChartThemeDefault);
155 themeComboBox->addItem("Default", QChart::ChartThemeDefault);
156 themeComboBox->addItem("Light", QChart::ChartThemeLight);
156 themeComboBox->addItem("Light", QChart::ChartThemeLight);
157 themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean);
157 themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean);
158 themeComboBox->addItem("Dark", QChart::ChartThemeDark);
158 themeComboBox->addItem("Dark", QChart::ChartThemeDark);
159 themeComboBox->addItem("Brown Sand", QChart::ChartThemeBrownSand);
159 themeComboBox->addItem("Brown Sand", QChart::ChartThemeBrownSand);
160 themeComboBox->addItem("Blue NCS", QChart::ChartThemeBlueNcs);
160 themeComboBox->addItem("Blue NCS", QChart::ChartThemeBlueNcs);
161 themeComboBox->addItem("Icy", QChart::ChartThemeIcy);
161 themeComboBox->addItem("Icy", QChart::ChartThemeIcy);
162 themeComboBox->addItem("Scientific", QChart::ChartThemeScientific);
162 themeComboBox->addItem("Scientific", QChart::ChartThemeScientific);
163 return themeComboBox;
163 return themeComboBox;
164 }
164 }
165
165
166 QComboBox* ThemeWidget::createAnimationBox() const
166 QComboBox* ThemeWidget::createAnimationBox() const
167 {
167 {
168 // settings layout
168 // settings layout
169 QComboBox* animationComboBox = new QComboBox();
169 QComboBox* animationComboBox = new QComboBox();
170 animationComboBox->addItem("No Animations", QChart::NoAnimation);
170 animationComboBox->addItem("No Animations", QChart::NoAnimation);
171 animationComboBox->addItem("GridAxis Animations", QChart::GridAxisAnimations);
171 animationComboBox->addItem("GridAxis Animations", QChart::GridAxisAnimations);
172 animationComboBox->addItem("Series Animations", QChart::SeriesAnimations);
172 animationComboBox->addItem("Series Animations", QChart::SeriesAnimations);
173 animationComboBox->addItem("All Animations", QChart::AllAnimations);
173 animationComboBox->addItem("All Animations", QChart::AllAnimations);
174 return animationComboBox;
174 return animationComboBox;
175 }
175 }
176
176
177 QChart* ThemeWidget::createAreaChart() const
177 QChart* ThemeWidget::createAreaChart() const
178 {
178 {
179 // area chart
179 // area chart
180 QChart *chart = new QChart();
180 QChart *chart = new QChart();
181 chart->setTitle("Area chart");
181 chart->setTitle("Area chart");
182 {
182 {
183 for (int i(0); i < m_dataTable.count(); i++) {
183 for (int i(0); i < m_dataTable.count(); i++) {
184 QLineSeries *series1 = new QLineSeries(chart);
184 QLineSeries *series1 = new QLineSeries(chart);
185 QLineSeries *series2 = new QLineSeries(chart);
185 QLineSeries *series2 = new QLineSeries(chart);
186 foreach (Data data, m_dataTable[i]) {
186 foreach (Data data, m_dataTable[i]) {
187 series1->add(data.first);
187 series1->add(data.first);
188 series2->add(QPointF(data.first.x(), 0.0));
188 series2->add(QPointF(data.first.x(), 0.0));
189 }
189 }
190 QAreaSeries *area = new QAreaSeries(series1, series2);
190 QAreaSeries *area = new QAreaSeries(series1, series2);
191 chart->addSeries(area);
191 chart->addSeries(area);
192 }
192 }
193 }
193 }
194 return chart;
194 return chart;
195 }
195 }
196
196
197 QChart* ThemeWidget::createBarChart(int valueCount) const
197 QChart* ThemeWidget::createBarChart(int valueCount) const
198 {
198 {
199 // bar chart
199 // bar chart
200 QChart* chart = new QChart();
200 QChart* chart = new QChart();
201 chart->setTitle("Bar chart");
201 chart->setTitle("Bar chart");
202 {
202 {
203 QBarCategories categories;
203 QBarCategories categories;
204 // TODO: categories
204 // TODO: categories
205 for (int i(0); i < valueCount; i++)
205 for (int i(0); i < valueCount; i++)
206 categories << QString::number(i);
206 categories << QString::number(i);
207 // QBarSeries* series = new QBarSeries(categories, chart);
207 // QBarSeries* series = new QBarSeries(categories, chart);
208 // QPercentBarSeries* series = new QPercentBarSeries(categories, chart);
208 // QPercentBarSeries* series = new QPercentBarSeries(categories, chart);
209 QStackedBarSeries* series = new QStackedBarSeries(categories, chart);
209 QStackedBarSeries* series = new QStackedBarSeries(categories, chart);
210 for (int i(0); i < m_dataTable.count(); i++) {
210 for (int i(0); i < m_dataTable.count(); i++) {
211 QBarSet *set = new QBarSet("Set" + QString::number(i));
211 QBarSet *set = new QBarSet("Set" + QString::number(i));
212 foreach (Data data, m_dataTable[i])
212 foreach (Data data, m_dataTable[i])
213 *set << data.first.y();
213 *set << data.first.y();
214 series->addBarSet(set);
214 series->addBarSet(set);
215 }
215 }
216 chart->addSeries(series);
216 chart->addSeries(series);
217 }
217 }
218 return chart;
218 return chart;
219 }
219 }
220
220
221 QChart* ThemeWidget::createLineChart() const
221 QChart* ThemeWidget::createLineChart() const
222 {
222 {
223 // line chart
223 // line chart
224 QChart* chart = new QChart();
224 QChart* chart = new QChart();
225 chart->setTitle("Line chart");
225 chart->setTitle("Line chart");
226 foreach (DataList list, m_dataTable) {
226 foreach (DataList list, m_dataTable) {
227 QLineSeries *series = new QLineSeries(chart);
227 QLineSeries *series = new QLineSeries(chart);
228 foreach (Data data, list)
228 foreach (Data data, list)
229 series->add(data.first);
229 series->add(data.first);
230 chart->addSeries(series);
230 chart->addSeries(series);
231 }
231 }
232 return chart;
232 return chart;
233 }
233 }
234
234
235 QChart* ThemeWidget::createPieChart() const
235 QChart* ThemeWidget::createPieChart() const
236 {
236 {
237 // pie chart
237 // pie chart
238 QChart* chart = new QChart();
238 QChart* chart = new QChart();
239 chart->setTitle("Pie chart");
239 chart->setTitle("Pie chart");
240 qreal pieSize = 1.0 / m_dataTable.count();
240 qreal pieSize = 1.0 / m_dataTable.count();
241 for (int i = 0; i < m_dataTable.count(); i++) {
241 for (int i = 0; i < m_dataTable.count(); i++) {
242 QPieSeries *series = new QPieSeries(chart);
242 QPieSeries *series = new QPieSeries(chart);
243 foreach (Data data, m_dataTable[i]) {
243 foreach (Data data, m_dataTable[i]) {
244 QPieSlice *slice = series->add(data.first.y(), data.second);
244 QPieSlice *slice = series->add(data.first.y(), data.second);
245 if (data == m_dataTable[i].first()) {
245 if (data == m_dataTable[i].first()) {
246 slice->setLabelVisible();
246 slice->setLabelVisible();
247 slice->setExploded();
247 slice->setExploded();
248 }
248 }
249 }
249 }
250 qreal hPos = (pieSize / 2) + (i / (qreal) m_dataTable.count());
250 qreal hPos = (pieSize / 2) + (i / (qreal) m_dataTable.count());
251 series->setPieSize(pieSize);
251 series->setPieSize(pieSize);
252 series->setPiePosition(hPos, 0.5);
252 series->setPiePosition(hPos, 0.5);
253 chart->addSeries(series);
253 chart->addSeries(series);
254 }
254 }
255
255
256 return chart;
256 return chart;
257 }
257 }
258
258
259 QChart* ThemeWidget::createSplineChart() const
259 QChart* ThemeWidget::createSplineChart() const
260 { // spine chart
260 { // spine chart
261 QChart* chart = new QChart();
261 QChart* chart = new QChart();
262 chart->setTitle("Spline chart");
262 chart->setTitle("Spline chart");
263 foreach (DataList list, m_dataTable) {
263 foreach (DataList list, m_dataTable) {
264 QSplineSeries *series = new QSplineSeries(chart);
264 QSplineSeries *series = new QSplineSeries(chart);
265 foreach (Data data, list)
265 foreach (Data data, list)
266 series->add(data.first);
266 series->add(data.first);
267 chart->addSeries(series);
267 chart->addSeries(series);
268 }
268 }
269 return chart;
269 return chart;
270 }
270 }
271
271
272 QChart* ThemeWidget::createScatterChart() const
272 QChart* ThemeWidget::createScatterChart() const
273 { // scatter chart
273 { // scatter chart
274 QChart* chart = new QChart();
274 QChart* chart = new QChart();
275 chart->setTitle("Scatter chart");
275 chart->setTitle("Scatter chart");
276 foreach (DataList list, m_dataTable) {
276 foreach (DataList list, m_dataTable) {
277 QScatterSeries *series = new QScatterSeries(chart);
277 QScatterSeries *series = new QScatterSeries(chart);
278 foreach (Data data, list)
278 foreach (Data data, list)
279 series->add(data.first);
279 series->add(data.first);
280 chart->addSeries(series);
280 chart->addSeries(series);
281 }
281 }
282 return chart;
282 return chart;
283 }
283 }
284
284
285 void ThemeWidget::updateUI()
285 void ThemeWidget::updateUI()
286 {
286 {
287 QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData(m_themeComboBox->currentIndex()).toInt();
287 QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData(m_themeComboBox->currentIndex()).toInt();
288
288
289 if (m_charts.at(0)->chart()->theme() != theme) {
289 if (m_charts.at(0)->chart()->theme() != theme) {
290 foreach (QChartView *chartView, m_charts)
290 foreach (QChartView *chartView, m_charts)
291 chartView->chart()->setTheme(theme);
291 chartView->chart()->setTheme(theme);
292
292
293 QPalette pal = window()->palette();
293 QPalette pal = window()->palette();
294 if (theme == QChart::ChartThemeLight) {
294 if (theme == QChart::ChartThemeLight) {
295 pal.setColor(QPalette::Window, QRgb(0xf0f0f0));
295 pal.setColor(QPalette::Window, QRgb(0xf0f0f0));
296 pal.setColor(QPalette::WindowText, QRgb(0x404044));
296 pal.setColor(QPalette::WindowText, QRgb(0x404044));
297 }
297 }
298 else if (theme == QChart::ChartThemeDark) {
298 else if (theme == QChart::ChartThemeDark) {
299 pal.setColor(QPalette::Window, QRgb(0x121218));
299 pal.setColor(QPalette::Window, QRgb(0x121218));
300 pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6));
300 pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6));
301 }
301 }
302 else if (theme == QChart::ChartThemeBlueCerulean) {
302 else if (theme == QChart::ChartThemeBlueCerulean) {
303 pal.setColor(QPalette::Window, QRgb(0x40434a));
303 pal.setColor(QPalette::Window, QRgb(0x40434a));
304 pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6));
304 pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6));
305 }
305 }
306 else if (theme == QChart::ChartThemeBrownSand) {
306 else if (theme == QChart::ChartThemeBrownSand) {
307 pal.setColor(QPalette::Window, QRgb(0x9e8965));
307 pal.setColor(QPalette::Window, QRgb(0x9e8965));
308 pal.setColor(QPalette::WindowText, QRgb(0x404044));
308 pal.setColor(QPalette::WindowText, QRgb(0x404044));
309 }
309 }
310 else if (theme == QChart::ChartThemeBlueNcs) {
310 else if (theme == QChart::ChartThemeBlueNcs) {
311 pal.setColor(QPalette::Window, QRgb(0x018bba));
311 pal.setColor(QPalette::Window, QRgb(0x018bba));
312 pal.setColor(QPalette::WindowText, QRgb(0x404044));
312 pal.setColor(QPalette::WindowText, QRgb(0x404044));
313 }
313 }
314 else {
314 else {
315 pal.setColor(QPalette::Window, QRgb(0xf0f0f0));
315 pal.setColor(QPalette::Window, QRgb(0xf0f0f0));
316 pal.setColor(QPalette::WindowText, QRgb(0x404044));
316 pal.setColor(QPalette::WindowText, QRgb(0x404044));
317 }
317 }
318 window()->setPalette(pal);
318 window()->setPalette(pal);
319 }
319 }
320
320
321 bool checked = m_antialiasCheckBox->isChecked();
321 bool checked = m_antialiasCheckBox->isChecked();
322 foreach (QChartView *chart, m_charts)
322 foreach (QChartView *chart, m_charts)
323 chart->setRenderHint(QPainter::Antialiasing, checked);
323 chart->setRenderHint(QPainter::Antialiasing, checked);
324
324
325 QChart::AnimationOptions options(m_animatedComboBox->itemData(m_animatedComboBox->currentIndex()).toInt());
325 QChart::AnimationOptions options(m_animatedComboBox->itemData(m_animatedComboBox->currentIndex()).toInt());
326 if (m_charts.at(0)->chart()->animationOptions() != options) {
326 if (m_charts.at(0)->chart()->animationOptions() != options) {
327 foreach (QChartView *chartView, m_charts)
327 foreach (QChartView *chartView, m_charts)
328 chartView->chart()->setAnimationOptions(options);
328 chartView->chart()->setAnimationOptions(options);
329 }
329 }
330 }
330 }
331
331
General Comments 0
You need to be logged in to leave comments. Login now