Skip to content

Commit

Permalink
Add chartbar background color config
Browse files Browse the repository at this point in the history
.. so users can configure the color of the chartbar, but more
   likely to just setup via themes.
  • Loading branch information
liversedge committed Nov 24, 2021
1 parent 680f7b9 commit a8de13b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/Charts/ChartBar.cpp
Expand Up @@ -149,7 +149,7 @@ ChartBar::configChanged(qint32)
scrollArea->setFixedHeight(height);
buttonBar->setFixedHeight(height);

QColor col=GColor(CTOOLBAR);
QColor col=GColor(CCHARTBAR);
scrollArea->setStyleSheet(QString("QScrollArea { background: rgb(%1,%2,%3); }").arg(col.red()).arg(col.green()).arg(col.blue()));

foreach(ChartBarItem *b, buttons) {
Expand All @@ -165,7 +165,7 @@ ChartBar::configChanged(qint32)
"padding-top: 0px; padding-bottom: 0px; }"
"QPushButton:hover { background-color: %3; }"
"QPushButton:hover:pressed { background-color: %3; }"
).arg(GColor(CTOOLBAR).name()).arg(3 * dpiXFactor).arg(GColor(CHOVER).name());
).arg(GColor(CCHARTBAR).name()).arg(3 * dpiXFactor).arg(GColor(CHOVER).name());
menuButton->setStyleSheet(buttonstyle);
left->setStyleSheet(buttonstyle);
right->setStyleSheet(buttonstyle);
Expand Down Expand Up @@ -393,7 +393,7 @@ ChartBar::paintBackground(QPaintEvent *)
painter.save();
QRect all(0,0,width(),height());

painter.fillRect(all, GColor(CTOOLBAR));
painter.fillRect(all, GColor(CCHARTBAR));

painter.restore();
}
Expand All @@ -419,7 +419,7 @@ ButtonBar::paintBackground(QPaintEvent *)
// fill with a linear gradient
painter.setPen(Qt::NoPen);
painter.fillRect(all, QColor(Qt::white));
painter.fillRect(all, GColor(CTOOLBAR));
painter.fillRect(all, GColor(CCHARTBAR));

if (!GCColor::isFlat()) {
QPen black(QColor(100,100,100,200));
Expand Down Expand Up @@ -460,7 +460,7 @@ ChartBarItem::paintEvent(QPaintEvent *)
painter.setPen(Qt::NoPen);

// background - chrome or slected colour
QBrush brush(GColor(CTOOLBAR));
QBrush brush(GColor(CCHARTBAR));
if (underMouse() && !checked) brush = GColor(CHOVER);
if (checked) brush = color;
painter.fillRect(body, brush);
Expand Down
7 changes: 6 additions & 1 deletion src/Gui/Colors.cpp
Expand Up @@ -238,6 +238,7 @@ void GCColor::setupColors()
{ tr("Respiratory Frequency"), "CRESPFREQUENCY", Qt::yellow },
{ tr("FeO2"), "CFEO2", Qt::yellow },
{ tr("Toolbar Hover"), "CHOVER", Qt::lightGray },
{ tr("Chartbar background"), "CCHARTBAR", Qt::lightGray },
{ "", "", QColor(0,0,0) },
};

Expand Down Expand Up @@ -457,11 +458,14 @@ GCColor::readConfig()
rgb[2].toInt());
} else {

// set sensible defaults for any not set...
// set sensible defaults for any not set (as new colors are added)
if (ColorList[i].name == "CTOOLBAR") {
QPalette def;
ColorList[i].color = def.color(QPalette::Window);
}
if (ColorList[i].name == "CCHARTBAR") {
ColorList[i].color = ColorList[CTOOLBAR].color;
}
if (ColorList[i].name == "CCALCURRENT") {
QPalette def;
ColorList[i].color = def.color(QPalette::Highlight);
Expand Down Expand Up @@ -934,6 +938,7 @@ GCColor::applyTheme(int index)
break;

case CCHROME:
case CCHARTBAR:
case CTOOLBAR: // we always keep them the same, but user can make different
color = theme.colors[1];
break;
Expand Down
3 changes: 2 additions & 1 deletion src/Gui/Colors.h
Expand Up @@ -184,7 +184,7 @@ class ColorEngine : public QObject
#define GColor(x) GCColor::getColor(x)

// Define how many cconfigurable metric colors are available
#define CNUMOFCFGCOLORS 105
#define CNUMOFCFGCOLORS 106

#define CPLOTBACKGROUND 0
#define CRIDEPLOTBACKGROUND 1
Expand Down Expand Up @@ -291,4 +291,5 @@ class ColorEngine : public QObject
#define CRESPFREQUENCY 102
#define CFEO2 103
#define CHOVER 104
#define CCHARTBAR 105
#endif
1 change: 1 addition & 0 deletions src/Gui/Pages.cpp
Expand Up @@ -1443,6 +1443,7 @@ ColorsPage::applyThemeClicked()
break;

case CCHROME:
case CCHARTBAR:
case CTOOLBAR: // we always keep them the same, but user can make different
// set to black for dark themese and grey for light themes
color = theme.colors[1];
Expand Down

0 comments on commit a8de13b

Please sign in to comment.