statistics: collect colors in a StatsTheme class

To enable rudimentary theming, collect all colors in a new
theme class. The class has to be passed down to the various
items.

In general the items save a reference to the them in the
constructor. Alternatively, they might also just query
the StatsView everytime they need to access a color.
For now, it's hard the say what is preferred: a reference
per item or a function call per invokation?

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-02-16 17:05:39 +01:00 committed by Dirk Hohndel
parent 56e02dbcc0
commit b5aac29cea
25 changed files with 272 additions and 166 deletions

View file

@ -11,8 +11,9 @@ static const int distanceFromPointer = 10; // Distance to place box from mouse p
InformationBox::InformationBox(StatsView &v) :
ChartRectItem(v, ChartZValue::InformationBox,
QPen(informationBorderColor, informationBorder),
QBrush(informationColor), informationBorderRadius),
QPen(v.getCurrentTheme().informationBorderColor, informationBorder),
QBrush(v.getCurrentTheme().informationColor), informationBorderRadius),
theme(v.getCurrentTheme()),
width(0.0),
height(0.0)
{
@ -36,7 +37,7 @@ void InformationBox::setText(const std::vector<QString> &text, QPointF pos)
ChartRectItem::resize(QSizeF(width, height));
painter->setPen(QPen(darkLabelColor)); // QPainter uses QPen to set text color!
painter->setPen(QPen(theme.darkLabelColor)); // QPainter uses QPen to set text color!
double y = 2.0 * informationBorder;
for (size_t i = 0; i < widths.size(); ++i) {
QRectF rect(2.0 * informationBorder, y, widths[i], fontHeight);