@@ -65,9 +65,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
65 | 65 | ChartTheme::ChartTheme(QChart::ChartTheme id) : |
|
66 | 66 | m_masterFont(QFont("arial", 14)), |
|
67 | 67 | m_labelFont(QFont("arial", 10)), |
|
68 |
m_ |
|
|
68 | m_labelBrush(QColor(QRgb(0x000000))), | |
|
69 | 69 | m_axisLinePen(QPen(QRgb(0x000000))), |
|
70 | m_axisLabelBrush(QColor(QRgb(0x000000))), | |
|
71 | 70 | m_backgroundShadesPen(Qt::NoPen), |
|
72 | 71 | m_backgroundShadesBrush(Qt::NoBrush), |
|
73 | 72 | m_backgroundShades(BackgroundShadesNone), |
@@ -109,7 +108,7 void ChartTheme::decorate(QChart *chart) | |||
|
109 | 108 | if(brush == chart->backgroundBrush() || m_force) |
|
110 | 109 | chart->setBackgroundBrush(m_chartBackgroundGradient); |
|
111 | 110 | chart->setTitleFont(m_masterFont); |
|
112 |
chart->setTitleBrush(m_ |
|
|
111 | chart->setTitleBrush(m_labelBrush); | |
|
113 | 112 | chart->setDropShadowEnabled(m_backgroundDropShadowEnabled); |
|
114 | 113 | } |
|
115 | 114 | |
@@ -125,12 +124,11 void ChartTheme::decorate(QLegend *legend) | |||
|
125 | 124 | if (brush == legend->brush() || m_force) |
|
126 | 125 | legend->setBrush(m_chartBackgroundGradient); |
|
127 | 126 | |
|
128 | // TODO: should legend have own brush & font defined by theme? | |
|
129 | 127 | if (font == legend->font() || m_force) |
|
130 | 128 | legend->setFont(m_labelFont); |
|
131 | 129 | |
|
132 | 130 | if (brush == legend->labelBrush() || m_force) |
|
133 |
legend->setLabelBrush(m_ |
|
|
131 | legend->setLabelBrush(m_labelBrush); | |
|
134 | 132 | } |
|
135 | 133 | |
|
136 | 134 | void ChartTheme::decorate(QAreaSeries *series, int index) |
@@ -241,7 +239,7 void ChartTheme::decorate(QPieSeries *series, int index) | |||
|
241 | 239 | d->setBrush(brushColor, true); |
|
242 | 240 | |
|
243 | 241 | if (d->m_data.m_labelBrush.isThemed() || m_force) |
|
244 |
d->setLabelBrush( |
|
|
242 | d->setLabelBrush(m_labelBrush.color(), true); | |
|
245 | 243 | |
|
246 | 244 | if (d->m_data.m_labelFont.isThemed() || m_force) |
|
247 | 245 | d->setLabelFont(m_labelFont, true); |
@@ -267,7 +265,7 void ChartTheme::decorate(QAxis *axis,bool axisX) | |||
|
267 | 265 | if (axis->isAxisVisible()) { |
|
268 | 266 | |
|
269 | 267 | if(brush == axis->labelsBrush() || m_force){ |
|
270 |
axis->setLabelsBrush(m_ |
|
|
268 | axis->setLabelsBrush(m_labelBrush); | |
|
271 | 269 | } |
|
272 | 270 | if(pen == axis->labelsPen() || m_force){ |
|
273 | 271 | axis->setLabelsPen(Qt::NoPen); // NoPen for performance reasons |
@@ -95,9 +95,8 protected: | |||
|
95 | 95 | |
|
96 | 96 | QFont m_masterFont; |
|
97 | 97 | QFont m_labelFont; |
|
98 |
QBrush m_ |
|
|
98 | QBrush m_labelBrush; | |
|
99 | 99 | QPen m_axisLinePen; |
|
100 | QBrush m_axisLabelBrush; | |
|
101 | 100 | QPen m_backgroundShadesPen; |
|
102 | 101 | QBrush m_backgroundShadesBrush; |
|
103 | 102 | BackgroundShadesMode m_backgroundShades; |
@@ -52,13 +52,13 LegendMarker::LegendMarker(QAbstractSeries *series, QLegend *legend) : | |||
|
52 | 52 | |
|
53 | 53 | void LegendMarker::setPen(const QPen &pen) |
|
54 | 54 | { |
|
55 |
m_ |
|
|
55 | m_rectItem->setPen(pen); | |
|
56 | 56 | updateLayout(); |
|
57 | 57 | } |
|
58 | 58 | |
|
59 | 59 | QPen LegendMarker::pen() const |
|
60 | 60 | { |
|
61 |
return m_ |
|
|
61 | return m_rectItem->pen(); | |
|
62 | 62 | } |
|
63 | 63 | |
|
64 | 64 | void LegendMarker::setBrush(const QBrush &brush) |
@@ -109,17 +109,6 QBrush LegendMarker::labelBrush() const | |||
|
109 | 109 | return m_textItem->brush(); |
|
110 | 110 | } |
|
111 | 111 | |
|
112 | void LegendMarker::setLabelPen(const QPen &pen) | |
|
113 | { | |
|
114 | m_textItem->setPen(pen); | |
|
115 | updateLayout(); | |
|
116 | } | |
|
117 | ||
|
118 | QPen LegendMarker::labelPen() const | |
|
119 | { | |
|
120 | return m_textItem->pen(); | |
|
121 | } | |
|
122 | ||
|
123 | 112 | void LegendMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
124 | 113 | { |
|
125 | 114 | Q_UNUSED(option) |
@@ -68,8 +68,6 public: | |||
|
68 | 68 | QString label() const; |
|
69 | 69 | void setLabelBrush(const QBrush &brush); |
|
70 | 70 | QBrush labelBrush() const; |
|
71 | void setLabelPen(const QPen &pen); | |
|
72 | QPen labelPen() const; | |
|
73 | 71 | |
|
74 | 72 | QAbstractSeries *series() const { return m_series;} |
|
75 | 73 |
@@ -286,26 +286,11 QFont QLegend::font() const | |||
|
286 | 286 | return d_ptr->m_font; |
|
287 | 287 | } |
|
288 | 288 | |
|
289 | void QLegend::setLabelPen(const QPen &pen) | |
|
290 | { | |
|
291 | if (d_ptr->m_labelPen != pen) { | |
|
292 | d_ptr->setLabelPen(pen); | |
|
293 | emit labelPenChanged(pen); | |
|
294 | } | |
|
295 | } | |
|
296 | ||
|
297 | QPen QLegend::labelPen() const | |
|
298 | { | |
|
299 | return d_ptr->m_labelPen; | |
|
300 | } | |
|
301 | ||
|
302 | 289 | void QLegend::setLabelBrush(const QBrush &brush) |
|
303 | 290 | { |
|
304 | qDebug() << "setting legend brush 1"; | |
|
305 | 291 | if (d_ptr->m_labelBrush != brush) { |
|
306 | 292 | d_ptr->setLabelBrush(brush); |
|
307 | 293 | emit labelBrushChanged(brush); |
|
308 | qDebug() << "setting legend brush 2"; | |
|
309 | 294 | } |
|
310 | 295 | } |
|
311 | 296 | |
@@ -440,7 +425,6 QLegendPrivate::QLegendPrivate(ChartPresenter* presenter, QChart *chart, QLegend | |||
|
440 | 425 | m_alignment(Qt::AlignTop), |
|
441 | 426 | m_brush(QBrush()), |
|
442 | 427 | m_pen(QPen()), |
|
443 | m_labelPen(QPen(Qt::NoPen)), | |
|
444 | 428 | m_labelBrush(QBrush()), |
|
445 | 429 | m_offsetX(0), |
|
446 | 430 | m_offsetY(0), |
@@ -765,18 +749,6 void QLegendPrivate::setFont(const QFont &font) | |||
|
765 | 749 | updateLayout(); |
|
766 | 750 | } |
|
767 | 751 | |
|
768 | void QLegendPrivate::setLabelPen(const QPen &pen) | |
|
769 | { | |
|
770 | m_labelPen = pen; | |
|
771 | QList<QGraphicsItem *> items = m_markers->childItems(); | |
|
772 | ||
|
773 | foreach (QGraphicsItem *markers, items) { | |
|
774 | LegendMarker *marker = static_cast<LegendMarker*>(markers); | |
|
775 | marker->setPen(m_labelPen); | |
|
776 | } | |
|
777 | updateLayout(); | |
|
778 | } | |
|
779 | ||
|
780 | 752 | void QLegendPrivate::setLabelBrush(const QBrush &brush) |
|
781 | 753 | { |
|
782 | 754 | m_labelBrush = brush; |
@@ -796,7 +768,6 void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain) | |||
|
796 | 768 | QList<LegendMarker*> markers = series->d_ptr->createLegendMarker(q_ptr); |
|
797 | 769 | foreach(LegendMarker* marker, markers) { |
|
798 | 770 | marker->setFont(m_font); |
|
799 | marker->setLabelPen(m_labelPen); | |
|
800 | 771 | marker->setLabelBrush(m_labelBrush); |
|
801 | 772 | m_markers->addToGroup(marker); |
|
802 | 773 | } |
@@ -49,8 +49,6 class QTCOMMERCIALCHART_EXPORT QLegend : public QGraphicsWidget | |||
|
49 | 49 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) |
|
50 | 50 | Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) |
|
51 | 51 | Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged) |
|
52 | // TODO? | |
|
53 | // Q_PROPERTY(QColor labelBorderColor READ labelBorderColor WRITE setLabelBorderColor NOTIFY labelBorderColorChanged) | |
|
54 | 52 | |
|
55 | 53 | private: |
|
56 | 54 | explicit QLegend(QChart *chart); |
@@ -73,8 +71,6 public: | |||
|
73 | 71 | |
|
74 | 72 | void setFont(const QFont &font); |
|
75 | 73 | QFont font() const; |
|
76 | void setLabelPen(const QPen &pen); | |
|
77 | QPen labelPen() const; | |
|
78 | 74 | void setLabelBrush(const QBrush &brush); |
|
79 | 75 | QBrush labelBrush() const; |
|
80 | 76 | |
@@ -104,11 +100,8 Q_SIGNALS: | |||
|
104 | 100 | void colorChanged(QColor color); |
|
105 | 101 | void borderColorChanged(QColor color); |
|
106 | 102 | void fontChanged(QFont font); |
|
107 | void labelPenChanged(QPen pen); | |
|
108 | 103 | void labelBrushChanged(QBrush brush); |
|
109 | 104 | void labelColorChanged(QColor color); |
|
110 | // TODO? | |
|
111 | // void labelBorderColorChanged(QColor color); | |
|
112 | 105 | |
|
113 | 106 | private: |
|
114 | 107 | QScopedPointer<QLegendPrivate> d_ptr; |
@@ -52,7 +52,6 public: | |||
|
52 | 52 | void attachToChart(); |
|
53 | 53 | int roundness(qreal size); |
|
54 | 54 | void setFont(const QFont &font); |
|
55 | void setLabelPen(const QPen &pen); | |
|
56 | 55 | void setLabelBrush(const QBrush &brush); |
|
57 | 56 | |
|
58 | 57 | public Q_SLOTS: |
@@ -71,7 +70,6 private: | |||
|
71 | 70 | QBrush m_brush; |
|
72 | 71 | QPen m_pen; |
|
73 | 72 | QFont m_font; |
|
74 | QPen m_labelPen; | |
|
75 | 73 | QBrush m_labelBrush; |
|
76 | 74 | QRectF m_rect; |
|
77 | 75 | qreal m_offsetX; |
@@ -55,10 +55,9 public: | |||
|
55 | 55 | m_chartBackgroundGradient = backgroundGradient; |
|
56 | 56 | |
|
57 | 57 | // Axes and other |
|
58 |
m_ |
|
|
58 | m_labelBrush = QBrush(QRgb(0xffffff)); | |
|
59 | 59 | m_axisLinePen = QPen(QRgb(0xd6d6d6)); |
|
60 | 60 | m_axisLinePen.setWidth(2); |
|
61 | m_axisLabelBrush = QBrush(QRgb(0xffffff)); | |
|
62 | 61 | m_gridLinePen = QPen(QRgb(0x84a2b0)); |
|
63 | 62 | m_gridLinePen.setWidth(1); |
|
64 | 63 | m_backgroundShades = BackgroundShadesNone; |
@@ -56,10 +56,9 public: | |||
|
56 | 56 | m_backgroundDropShadowEnabled = true; |
|
57 | 57 | |
|
58 | 58 | // Axes and other |
|
59 |
m_ |
|
|
59 | m_labelBrush = QBrush(QRgb(0x404044)); | |
|
60 | 60 | m_axisLinePen = QPen(QRgb(0xd6d6d6)); |
|
61 | 61 | m_axisLinePen.setWidth(2); |
|
62 | m_axisLabelBrush = QBrush(QRgb(0x404044)); | |
|
63 | 62 | m_gridLinePen = QPen(QRgb(0xe2e2e2)); |
|
64 | 63 | m_gridLinePen.setWidth(1); |
|
65 | 64 | m_backgroundShades = BackgroundShadesNone; |
@@ -55,10 +55,9 public: | |||
|
55 | 55 | m_chartBackgroundGradient = backgroundGradient; |
|
56 | 56 | |
|
57 | 57 | // Axes and other |
|
58 |
m_ |
|
|
58 | m_labelBrush = QBrush(QRgb(0x404044)); | |
|
59 | 59 | m_axisLinePen = QPen(QRgb(0xd6d6d6)); |
|
60 | 60 | m_axisLinePen.setWidth(2); |
|
61 | m_axisLabelBrush = QBrush(QRgb(0x404044)); | |
|
62 | 61 | m_gridLinePen = QPen(QRgb(0xe2e2e2)); |
|
63 | 62 | m_gridLinePen.setWidth(1); |
|
64 | 63 | m_backgroundShades = BackgroundShadesNone; |
@@ -55,10 +55,9 public: | |||
|
55 | 55 | m_chartBackgroundGradient = backgroundGradient; |
|
56 | 56 | |
|
57 | 57 | // Axes and other |
|
58 |
m_ |
|
|
58 | m_labelBrush = QBrush(QRgb(0x404044)); | |
|
59 | 59 | m_axisLinePen = QPen(QRgb(0xb5b0a7)); |
|
60 | 60 | m_axisLinePen.setWidth(2); |
|
61 | m_axisLabelBrush = QBrush(QRgb(0x404044)); | |
|
62 | 61 | m_gridLinePen = QPen(QRgb(0xd4cec3)); |
|
63 | 62 | m_gridLinePen.setWidth(1); |
|
64 | 63 | m_backgroundShades = BackgroundShadesNone; |
@@ -55,10 +55,9 public: | |||
|
55 | 55 | m_chartBackgroundGradient = backgroundGradient; |
|
56 | 56 | |
|
57 | 57 | // Axes and other |
|
58 |
m_ |
|
|
58 | m_labelBrush = QBrush(QRgb(0xffffff)); | |
|
59 | 59 | m_axisLinePen = QPen(QRgb(0x86878c)); |
|
60 | 60 | m_axisLinePen.setWidth(2); |
|
61 | m_axisLabelBrush = QBrush(QRgb(0xffffff)); | |
|
62 | 61 | m_gridLinePen = QPen(QRgb(0x86878c)); |
|
63 | 62 | m_gridLinePen.setWidth(1); |
|
64 | 63 | m_backgroundShades = BackgroundShadesNone; |
@@ -56,10 +56,9 public: | |||
|
56 | 56 | m_backgroundDropShadowEnabled = true; |
|
57 | 57 | |
|
58 | 58 | // Axes and other |
|
59 |
m_ |
|
|
59 | m_labelBrush = QBrush(QRgb(0x181818)); | |
|
60 | 60 | m_axisLinePen = QPen(QRgb(0x8c8c8c)); |
|
61 | 61 | m_axisLinePen.setWidth(2); |
|
62 | m_axisLabelBrush = QBrush(QRgb(0x181818)); | |
|
63 | 62 | m_gridLinePen = QPen(QRgb(0x8c8c8c)); |
|
64 | 63 | m_gridLinePen.setWidth(1); |
|
65 | 64 | m_backgroundShadesBrush = QBrush(QRgb(0xffeecd)); |
@@ -59,7 +59,7 public: | |||
|
59 | 59 | // Axes and other |
|
60 | 60 | m_axisLinePen = QPen(0xd6d6d6); |
|
61 | 61 | m_axisLinePen.setWidth(1); |
|
62 |
m_ |
|
|
62 | m_labelBrush = QBrush(QRgb(0x404044)); | |
|
63 | 63 | m_gridLinePen = QPen(QRgb(0xe2e2e2)); |
|
64 | 64 | m_gridLinePen.setWidth(1); |
|
65 | 65 | m_backgroundShades = BackgroundShadesNone; |
@@ -98,7 +98,7 public: | |||
|
98 | 98 | // Axes and other |
|
99 | 99 | m_axisLinePen = QPen(0xd6d6d6); |
|
100 | 100 | m_axisLinePen.setWidth(1); |
|
101 |
m_ |
|
|
101 | m_labelBrush = QBrush(QRgb(0x404044)); | |
|
102 | 102 | m_gridLinePen = QPen(QRgb(0xe2e2e2)); |
|
103 | 103 | m_gridLinePen.setWidth(1); |
|
104 | 104 | m_backgroundShades = BackgroundShadesNone; |
@@ -121,7 +121,7 public: | |||
|
121 | 121 | // Axes and other |
|
122 | 122 | m_axisLinePen = QPen(0xd6d6d6); |
|
123 | 123 | m_axisLinePen.setWidth(1); |
|
124 |
m_ |
|
|
124 | m_labelBrush = QBrush(QRgb(0x404044)); | |
|
125 | 125 | m_gridLinePen = QPen(QRgb(0xe2e2e2)); |
|
126 | 126 | m_gridLinePen.setWidth(1); |
|
127 | 127 | m_backgroundShades = BackgroundShadesNone; |
@@ -144,7 +144,7 public: | |||
|
144 | 144 | // Axes and other |
|
145 | 145 | m_axisLinePen = QPen(0xd6d6d6); |
|
146 | 146 | m_axisLinePen.setWidth(1); |
|
147 |
m_ |
|
|
147 | m_labelBrush = QBrush(QRgb(0x404044)); | |
|
148 | 148 | m_gridLinePen = QPen(QRgb(0xe2e2e2)); |
|
149 | 149 | m_gridLinePen.setWidth(1); |
|
150 | 150 | m_backgroundShades = BackgroundShadesNone; |
@@ -167,7 +167,7 public: | |||
|
167 | 167 | // Axes and other |
|
168 | 168 | m_axisLinePen = QPen(0xd6d6d6); |
|
169 | 169 | m_axisLinePen.setWidth(1); |
|
170 |
m_ |
|
|
170 | m_labelBrush = QBrush(QRgb(0x404044)); | |
|
171 | 171 | m_gridLinePen = QPen(QRgb(0xe2e2e2)); |
|
172 | 172 | m_gridLinePen.setWidth(1); |
|
173 | 173 | m_backgroundShades = BackgroundShadesNone; |
@@ -63,6 +63,8 ChartView { | |||
|
63 | 63 | legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible); |
|
64 | 64 | legend.onColorChanged: console.log("legend.onColorChanged: " + color); |
|
65 | 65 | legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color); |
|
66 | legend.onLabelColorChanged: console.log("legend.onLabelColorChanged: " + color); | |
|
67 | legend.onLabelBrushChanged: console.log("legend.onLabelBrushChanged: " + brush); | |
|
66 | 68 | |
|
67 | 69 | axisX.onColorChanged: console.log("axisX.onColorChanged: " + color); |
|
68 | 70 | axisX.onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible); |
General Comments 0
You need to be logged in to leave comments.
Login now