15 changes: 11 additions & 4 deletions src/Gui/ChartSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "AbstractView.h"
#include "Athlete.h"
#include "RideCache.h"
#include "Colors.h"

#include <cmath>
#include <QGraphicsSceneMouseEvent>
Expand Down Expand Up @@ -207,6 +208,12 @@ ChartSpace::dateRangeChanged(DateRange dr)
stale=false;
}

QColor
ChartSpaceItem::color()
{
return QColor(bgcolor);
}

void
ChartSpaceItem::setData(RideItem *item)
{
Expand Down Expand Up @@ -301,7 +308,7 @@ void
ChartSpaceItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt, QWidget *widget) {

if (drag) painter->setBrush(QBrush(GColor(CPLOTMARKER)));
else painter->setBrush(GColor(CCARDBACKGROUND));
else painter->setBrush(RGBColor(color()));

QPainterPath path;
path.addRoundedRect(QRectF(0,0,geometry().width(),geometry().height()), ROWHEIGHT/5, ROWHEIGHT/5);
Expand All @@ -312,7 +319,7 @@ ChartSpaceItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt, QW
//XXXpainter->drawLine(QLineF(0,ROWHEIGHT*2,geometry().width(),ROWHEIGHT*2));
//painter->fillRect(QRectF(0,0,geometry().width()+1,geometry().height()+1), brush);
//titlefont.setWeight(QFont::Bold);
if (GCColor::luminance(GColor(CCARDBACKGROUND)) < 127) painter->setPen(QColor(200,200,200));
if (GCColor::luminance(RGBColor(color())) < 127) painter->setPen(QColor(200,200,200));
else painter->setPen(QColor(70,70,70));

painter->setFont(parent->titlefont);
Expand All @@ -335,7 +342,7 @@ ChartSpaceItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt, QW
path.addRoundedRect(QRectF(geometry().width()-40-ROWHEIGHT,0,
ROWHEIGHT+40, ROWHEIGHT+40), ROWHEIGHT/5, ROWHEIGHT/5);
painter->setPen(Qt::NoPen);
QColor darkgray(GColor(CCARDBACKGROUND).lighter(200));
QColor darkgray(RGBColor(color()).lighter(200));
painter->setBrush(darkgray);
painter->drawPath(path);
painter->fillRect(QRectF(geometry().width()-40-ROWHEIGHT, 0, ROWHEIGHT+40-(ROWHEIGHT/5), ROWHEIGHT+40), QBrush(darkgray));
Expand All @@ -358,7 +365,7 @@ ChartSpaceItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt, QW
if (!drag) {
QPainterPath path;
path.addRoundedRect(QRectF(1*dpiXFactor,1*dpiXFactor,geometry().width()-(2*dpiXFactor),geometry().height()-(2*dpiXFactor)), ROWHEIGHT/5, ROWHEIGHT/5);
QColor edge(GColor(CCARDBACKGROUND));
QColor edge(RGBColor(color()));
edge = edge.darker(105);
QPen pen(edge);
pen.setWidth(3*dpiXFactor);
Expand Down
4 changes: 4 additions & 0 deletions src/Gui/ChartSpace.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class ChartSpaceItem : public QGraphicsWidget
virtual void itemGeometryChanged() =0;
virtual void setData(RideItem *item)=0;
virtual void setDateRange(DateRange )=0;
virtual QColor color();
virtual QRectF hotspot() { return QRectF(0,0,0,0); } // don't steal events from this area of the item

virtual QWidget *config()=0; // must supply a widget to configure
Expand Down Expand Up @@ -111,6 +112,8 @@ class ChartSpaceItem : public QGraphicsWidget
this->setGraphicsEffect(effect);
#endif

bgcolor = StandardColor(CCARDBACKGROUND).name();

// watch geom changes
connect(this, SIGNAL(geometryChanged()), SLOT(geometryChanged()));
}
Expand Down Expand Up @@ -147,6 +150,7 @@ class ChartSpaceItem : public QGraphicsWidget
bool incorner;
bool invisible;
bool showconfig;
QString bgcolor;
QGraphicsDropShadowEffect *effect;

// base paint
Expand Down
12 changes: 6 additions & 6 deletions src/Gui/ColorButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <QLineEdit>
#include <QLabel>

ColorButton::ColorButton(QWidget *parent, QString name, QColor color, bool gc, bool ignore) : QPushButton("", parent), gc(gc), color(color), name(name)
ColorButton::ColorButton(QWidget *parent, QString name, QColor color, bool gc, bool ignore) : QPushButton("", parent), gc(gc), all(false), color(color), name(name)
{
#if defined(WIN32) || defined (Q_OS_LINUX)
// are we in hidpi mode? if so undo global defaults for toolbar pushbuttons
Expand Down Expand Up @@ -71,7 +71,7 @@ void
ColorButton::clicked()
{
// Color picker dialog - gc uses color palettes, otherwise not
QColor rcolor = (gc == true) ? GColorDialog::getColor(color.name())
QColor rcolor = (gc == true) ? GColorDialog::getColor(color.name(), all)
: QColorDialog::getColor(color, this, tr("Choose Color"), QColorDialog::DontUseNativeDialog);

// if we got a good color use it and notify others
Expand All @@ -82,7 +82,7 @@ ColorButton::clicked()
}


GColorDialog::GColorDialog(QColor selected, QWidget *parent) : QDialog(parent), original(selected)
GColorDialog::GColorDialog(QColor selected, QWidget *parent, bool all) : QDialog(parent), original(selected), all(all)
{
// set some flags
setWindowTitle(tr("Choose a Color"));
Expand Down Expand Up @@ -129,7 +129,7 @@ GColorDialog::GColorDialog(QColor selected, QWidget *parent) : QDialog(parent),
colorSet = GCColor::colorSet();
for (int i=0; colorSet[i].name != ""; i++) {

if (colorSet[i].group != tr("Data")) continue;
if (!all && colorSet[i].group != tr("Data")) continue;

QTreeWidgetItem *add;
ColorButton *colorButton = new ColorButton(this, colorSet[i].name, colorSet[i].color, false, true);
Expand Down Expand Up @@ -202,9 +202,9 @@ GColorDialog::searchFilter(QString text)
}
}

QColor GColorDialog::getColor(QColor color)
QColor GColorDialog::getColor(QColor color, bool all)
{
GColorDialog *dialog = new GColorDialog(color, NULL);
GColorDialog *dialog = new GColorDialog(color, NULL, all);
dialog->exec();
color = dialog->returned();
delete dialog;
Expand Down
8 changes: 6 additions & 2 deletions src/Gui/ColorButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ColorButton : public QPushButton
void setColor(QColor);
QColor getColor() { return color; }
QString getName() { return name; }
void setSelectAll(bool x) { all=x; }

public slots:
void clicked();
Expand All @@ -46,6 +47,7 @@ class ColorButton : public QPushButton

protected:
bool gc;
bool all;
QColor color;
QString name;
};
Expand All @@ -63,7 +65,7 @@ class GColorDialog : public QDialog

public:
// main constructor
GColorDialog(QColor selected, QWidget *parent);
GColorDialog(QColor selected, QWidget *parent, bool all);
QColor returned() { return returning; }

// User entry point- opens a dialog gets the answer
Expand All @@ -78,7 +80,7 @@ class GColorDialog : public QDialog
//
// or just r,g,b for normal colors (meaning that: 1,1,x is never a possible color)
//
static QColor getColor(QColor color);
static QColor getColor(QColor color, bool all=false);

public slots:

Expand Down Expand Up @@ -111,6 +113,8 @@ class GColorDialog : public QDialog
QTreeWidget *colorlist;
QPushButton *cancel, *ok;
QSignalMapper *mapper;

bool all;
};

#endif
4 changes: 4 additions & 0 deletions src/Gui/Colors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ void GCColor::setupColors()
{ tr("Data"), tr("FeO2"), "CFEO2", Qt::yellow },
{ tr("Gui"), tr("Toolbar Hover"), "CHOVER", Qt::lightGray },
{ tr("Gui"), tr("Chartbar background"), "CCHARTBAR", Qt::lightGray },
{ tr("Gui"), tr("Overview Card Background Alternate"), "CCARDBACKGROUND2", QColor(0,0,0) },
{ tr("Gui"), tr("Overview Card Background Vibrant"), "CCARDBACKGROUND3", QColor(52,52,52) },
{ "", "", "", QColor(0,0,0) },
};

Expand Down Expand Up @@ -374,6 +376,8 @@ void GCColor::setupColors()
LightDefaultColorList[101].color = QColor(101,44,45); // 101:Tidal Volume
LightDefaultColorList[102].color = QColor(134,74,255); // 102:Respiratory Frequency
LightDefaultColorList[103].color = QColor(255,46,46); // 103:FeO2
LightDefaultColorList[106].color = QColor(180,180,180); // 106:Card Alternate
LightDefaultColorList[107].color = QColor(0xee,0xf8,0xff); // 107:Card Vibrant
}

// default settings for fonts etc
Expand Down
4 changes: 3 additions & 1 deletion src/Gui/Colors.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class ColorEngine : public QObject
#define GColor(x) GCColor::getColor(x)

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

#define CPLOTBACKGROUND 0
#define CRIDEPLOTBACKGROUND 1
Expand Down Expand Up @@ -294,4 +294,6 @@ class ColorEngine : public QObject
#define CFEO2 103
#define CHOVER 104
#define CCHARTBAR 105
#define CCARDBACKGROUND2 106
#define CCARDBACKGROUND3 107
#endif
16 changes: 16 additions & 0 deletions src/Gui/Perspective.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ Perspective::configChanged(qint32)
for (int i=0; i<charts.count(); i++) {
if (currentStyle == 0) {
if (charts[i]->type() == GcWindowTypes::Overview || charts[i]->type() == GcWindowTypes::OverviewTrends) chartbar->setColor(i, GColor(COVERVIEWBACKGROUND));
else if (charts[i]->type() == GcWindowTypes::UserAnalysis || charts[i]->type() == GcWindowTypes::UserTrends) chartbar->setColor(i, RGBColor(QColor(charts[i]->property("color").toString())));
else {
if (type() == VIEW_TRAIN)chartbar->setColor(i, GColor(CTRAINPLOTBACKGROUND));
else chartbar->setColor(i, GColor(CPLOTBACKGROUND));
Expand Down Expand Up @@ -387,6 +388,21 @@ Perspective::titleChanged()
}
}

// we have a user chart and its just changed its config
void
Perspective::userChartConfigChanged(UserChartWindow *chart)
{
if (!currentStyle) {
// let chartbar know...
for(int index=0; index < charts.count(); index++) {
if (charts[index] == (GcChartWindow*)(chart)) {
chartbar->setColor(index, RGBColor(QColor(charts[index]->property("color").toString())));
return;
}
}
}
}

void
Perspective::rideSelected()
{
Expand Down
3 changes: 3 additions & 0 deletions src/Gui/Perspective.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class QTextStream;
class DataFilter;
class SearchBox;
class TrendsView;
class UserChartWindow;

class Perspective : public GcWindow
{
Expand Down Expand Up @@ -131,6 +132,8 @@ class Perspective : public GcWindow
void closeWindow(GcWindow*);
void showControls();

void userChartConfigChanged(UserChartWindow *);

//notifiction that been made visible
void selected();

Expand Down