mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Realtime honours color settings
Updated the realtime plots and dials to use the colour settings from the ride plot. So if you prefer plots of light colours on dark backgrounds you can do this now. The use of colour on the telemetry values makes it easier to distinguish which value related to power et al .. especially when you're pushing out that last max power interval.
This commit is contained in:
@@ -38,6 +38,7 @@ DialWindow::DialWindow(MainWindow *mainWindow) :
|
||||
|
||||
// data series selection
|
||||
QLabel *seriesLabel = new QLabel(tr("Data Series"), this);
|
||||
seriesLabel->setAutoFillBackground(true);
|
||||
seriesSelector = new QComboBox(this);
|
||||
foreach (RealtimeData::DataSeries x, RealtimeData::listDataSeries()) {
|
||||
seriesSelector->addItem(RealtimeData::seriesName(x), static_cast<int>(x));
|
||||
@@ -52,6 +53,11 @@ DialWindow::DialWindow(MainWindow *mainWindow) :
|
||||
|
||||
// get updates..
|
||||
connect(mainWindow, SIGNAL(telemetryUpdate(RealtimeData)), this, SLOT(telemetryUpdate(RealtimeData)));
|
||||
connect(seriesSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(seriesChanged()));
|
||||
connect(mainWindow, SIGNAL(configChanged()), this, SLOT(seriesChanged()));
|
||||
|
||||
// setup colors
|
||||
seriesChanged();
|
||||
|
||||
// setup fontsize etc
|
||||
resizeEvent(NULL);
|
||||
@@ -123,3 +129,50 @@ void DialWindow::resizeEvent(QResizeEvent * )
|
||||
font.setWeight(QFont::Bold);
|
||||
valueLabel->setFont(font);
|
||||
}
|
||||
|
||||
void DialWindow::seriesChanged()
|
||||
{
|
||||
// we got some!
|
||||
RealtimeData::DataSeries series = static_cast<RealtimeData::DataSeries>
|
||||
(seriesSelector->itemData(seriesSelector->currentIndex()).toInt());
|
||||
|
||||
// the series selector changed so update the colors
|
||||
switch(series) {
|
||||
|
||||
case RealtimeData::Time:
|
||||
case RealtimeData::LapTime:
|
||||
case RealtimeData::Distance:
|
||||
case RealtimeData::Lap:
|
||||
case RealtimeData::Load:
|
||||
case RealtimeData::None:
|
||||
foreground = GColor(CPLOTMARKER);
|
||||
break;
|
||||
|
||||
case RealtimeData::XPower:
|
||||
case RealtimeData::Joules:
|
||||
case RealtimeData::BikeScore:
|
||||
case RealtimeData::Watts:
|
||||
foreground = GColor(CPOWER);
|
||||
break;
|
||||
|
||||
case RealtimeData::Speed:
|
||||
foreground = GColor(CSPEED);
|
||||
break;
|
||||
|
||||
case RealtimeData::Cadence:
|
||||
foreground = GColor(CCADENCE);
|
||||
break;
|
||||
|
||||
case RealtimeData::HeartRate:
|
||||
foreground = GColor(CHEARTRATE);
|
||||
break;
|
||||
}
|
||||
|
||||
// ugh. we use style sheets becuase palettes don't work on labels
|
||||
background = GColor(CRIDEPLOTBACKGROUND);
|
||||
setProperty("color", background);
|
||||
QString sh = QString("QLabel { background: %1; color: %2; }")
|
||||
.arg(background.name())
|
||||
.arg(foreground.name());
|
||||
valueLabel->setStyleSheet(sh);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
#include "RideFile.h" // for data series types
|
||||
#include "RealtimeData.h" // for realtimedata structure
|
||||
|
||||
#include "Settings.h" // for realtimedata structure
|
||||
#include "Colors.h" // for realtimedata structure
|
||||
|
||||
class DialWindow : public GcWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -68,6 +71,7 @@ class DialWindow : public GcWindow
|
||||
public slots:
|
||||
|
||||
// trap signals
|
||||
void seriesChanged();
|
||||
void telemetryUpdate(const RealtimeData &rtData); // got new data
|
||||
void lap(int lapnumber);
|
||||
void start();
|
||||
@@ -102,6 +106,8 @@ class DialWindow : public GcWindow
|
||||
|
||||
// display
|
||||
QLabel *valueLabel;
|
||||
|
||||
QColor foreground, background;
|
||||
};
|
||||
|
||||
#endif // _GC_DialWindow_h
|
||||
|
||||
@@ -137,18 +137,21 @@ GcWindow::GcWindow()
|
||||
qRegisterMetaType<QWidget*>("controls");
|
||||
qRegisterMetaType<RideItem*>("ride");
|
||||
qRegisterMetaType<GcWinID>("type");
|
||||
qRegisterMetaType<QColor>("color");
|
||||
setControls(NULL);
|
||||
setRideItem(NULL);
|
||||
setTitle("");
|
||||
setContentsMargins(0,0,0,0);
|
||||
setResizable(false);
|
||||
setMouseTracking(true);
|
||||
setProperty("color", Qt::white);
|
||||
}
|
||||
|
||||
GcWindow::GcWindow(QWidget *parent) : QFrame(parent), dragState(None) {
|
||||
qRegisterMetaType<QWidget*>("controls");
|
||||
qRegisterMetaType<RideItem*>("ride");
|
||||
qRegisterMetaType<GcWinID>("type");
|
||||
qRegisterMetaType<QColor>("color");
|
||||
setParent(parent);
|
||||
setControls(NULL);
|
||||
setRideItem(NULL);
|
||||
@@ -156,6 +159,7 @@ GcWindow::GcWindow(QWidget *parent) : QFrame(parent), dragState(None) {
|
||||
setContentsMargins(0,0,0,0);
|
||||
setResizable(false);
|
||||
setMouseTracking(true);
|
||||
setProperty("color", Qt::white);
|
||||
}
|
||||
|
||||
GcWindow::~GcWindow()
|
||||
@@ -188,7 +192,7 @@ GcWindow::paintEvent(QPaintEvent * /*event*/)
|
||||
QPainter painter(this);
|
||||
// background light gray for now?
|
||||
QRect all(0,0,width(),height());
|
||||
painter.fillRect(all, Qt::white);
|
||||
painter.fillRect(all, property("color").value<QColor>());
|
||||
|
||||
if (contentsMargins().top() > 0) {
|
||||
|
||||
|
||||
@@ -94,13 +94,34 @@ RealtimePlot::RealtimePlot() : pwrCurve(NULL)
|
||||
setAxisTitle(yRight2, "Speed");
|
||||
setAxisTitle(xBottom, "Seconds Ago");
|
||||
|
||||
QPalette pal;
|
||||
setAxisScale(yLeft, 0, 500); // watts
|
||||
pal.setColor(QPalette::WindowText, GColor(CPOWER));
|
||||
pal.setColor(QPalette::Text, GColor(CPOWER));
|
||||
axisWidget(QwtPlot::yLeft)->setPalette(pal);
|
||||
axisWidget(QwtPlot::yLeft)->scaleDraw()->setTickLength(QwtScaleDiv::MajorTick, 3);
|
||||
|
||||
setAxisScale(yRight, 0, 230); // cadence / hr
|
||||
pal.setColor(QPalette::WindowText, GColor(CHEARTRATE));
|
||||
pal.setColor(QPalette::Text, GColor(CHEARTRATE));
|
||||
axisWidget(QwtPlot::yRight)->setPalette(pal);
|
||||
axisWidget(QwtPlot::yRight)->scaleDraw()->setTickLength(QwtScaleDiv::MajorTick, 3);
|
||||
|
||||
setAxisScale(xBottom, 50, 0, 15); // time ago
|
||||
pal.setColor(QPalette::WindowText, GColor(CPLOTMARKER));
|
||||
pal.setColor(QPalette::Text, GColor(CPLOTMARKER));
|
||||
axisWidget(QwtPlot::xBottom)->setPalette(pal);
|
||||
axisWidget(QwtPlot::xBottom)->scaleDraw()->setTickLength(QwtScaleDiv::MajorTick, 3);
|
||||
|
||||
setAxisScale(yRight2, 0, 60); // speed km/h - 60kmh on a turbo is good going!
|
||||
pal.setColor(QPalette::WindowText, GColor(CSPEED));
|
||||
pal.setColor(QPalette::Text, GColor(CSPEED));
|
||||
axisWidget(QwtPlot::yRight2)->setPalette(pal);
|
||||
axisWidget(QwtPlot::yRight2)->scaleDraw()->setTickLength(QwtScaleDiv::MajorTick, 3);
|
||||
|
||||
setAxisLabelRotation(yRight2,90);
|
||||
setAxisLabelAlignment(yRight2,Qt::AlignVCenter);
|
||||
|
||||
enableAxis(xBottom, false); // very little value and some cpu overhead
|
||||
enableAxis(yLeft, true);
|
||||
enableAxis(yRight, true);
|
||||
@@ -173,7 +194,7 @@ RealtimePlot::setAxisTitle(int axis, QString label)
|
||||
void
|
||||
RealtimePlot::configChanged()
|
||||
{
|
||||
setCanvasBackground(GColor(CPLOTBACKGROUND));
|
||||
setCanvasBackground(GColor(CRIDEPLOTBACKGROUND));
|
||||
QPen pwr30pen = QPen(GColor(CPOWER), 2.0, Qt::DashLine);
|
||||
pwr30Curve->setPen(pwr30pen);
|
||||
pwr30Curve->setData(pwr30Data);
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include <qwt_plot_curve.h>
|
||||
#include <qwt_plot_grid.h>
|
||||
#include <qwt_scale_draw.h>
|
||||
#include <qwt_scale_div.h>
|
||||
#include <qwt_scale_widget.h>
|
||||
#include <qwt_data.h>
|
||||
#include "Settings.h"
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ RealtimePlotWindow::RealtimePlotWindow(MainWindow *mainWindow) :
|
||||
setContentsMargins(0,0,0,0);
|
||||
setInstanceName("RT Plot");
|
||||
setControls(NULL);
|
||||
setProperty("color", GColor(CRIDEPLOTBACKGROUND));
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
rtPlot = new RealtimePlot();
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
#include "RealtimePlot.h"
|
||||
#include "RealtimeData.h" // for realtimedata structure
|
||||
|
||||
#include "Settings.h"
|
||||
#include "Colors.h"
|
||||
|
||||
class RealtimePlotWindow : public GcWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -23,6 +23,7 @@ GcWindow(parent), home(home), main(parent)
|
||||
{
|
||||
setControls(NULL);
|
||||
setInstanceName("Video Window");
|
||||
setProperty("color", Qt::black);
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout();
|
||||
setLayout(layout);
|
||||
|
||||
Reference in New Issue
Block a user