diff --git a/src/Colors.cpp b/src/Colors.cpp index 2337f8852..15508b0d0 100644 --- a/src/Colors.cpp +++ b/src/Colors.cpp @@ -168,6 +168,25 @@ GCColor::GCColor(Context *context) : QObject(context) connect(context, SIGNAL(configChanged()), this, SLOT(readConfig())); } +QColor GCColor::invertColor(QColor bgColor) +{ + QColor cRGB = bgColor.convertTo(QColor::Rgb); + // lets work it out.. + int r = cRGB.red() < 128 ? 255 : 0; + int g = cRGB.green() < 128 ? 255 : 0; + int b = cRGB.blue() < 128 ? 255 : 0; + return QColor(r,g,b); +} + +QColor GCColor::alternateColor(QColor bgColor) +{ + //QColor color = QColor::fromHsv(bgColor.hue(), bgColor.saturation() * 2, bgColor.value()); + if (bgColor.value() < 128) + return QColor(Qt::darkGray); + else + return QColor(Qt::lightGray); +} + const Colors * GCColor::colorSet() { return ColorList; diff --git a/src/Colors.h b/src/Colors.h index 787d8fed5..9f0d89085 100644 --- a/src/Colors.h +++ b/src/Colors.h @@ -69,6 +69,9 @@ class GCColor : public QObject static void resetColors(); static QColor invert(QColor); static struct SizeSettings defaultSizes(int width, int height); + static QColor invertColor(QColor); // return the contrasting color + static QColor alternateColor(QColor); // return the alternate background + static QColor htmlCode(QColor x) { return x.name(); } // return the alternate background public slots: void readConfig(); diff --git a/src/GoldenCheetah.cpp b/src/GoldenCheetah.cpp index 896b8bef8..4115862f0 100644 --- a/src/GoldenCheetah.cpp +++ b/src/GoldenCheetah.cpp @@ -23,6 +23,7 @@ #include "Settings.h" #include +#include #include #include #include @@ -286,19 +287,7 @@ GcWindow::paintEvent(QPaintEvent * /*event*/) // pen color needs to contrast to background color QColor bgColor = property("color").value(); - QColor fgColor; - - if (bgColor == Qt::black) fgColor = Qt::white; - else if (bgColor == Qt::white) fgColor = Qt::black; - else { - - QColor cRGB = bgColor.convertTo(QColor::Rgb); - // lets work it out.. - int r = cRGB.red() < 128 ? 255 : 0; - int g = cRGB.green() < 128 ? 255 : 0; - int b = cRGB.blue() < 128 ? 255 : 0; - fgColor = QColor(r,g,b); - } + QColor fgColor = GCColor::invertColor(bgColor); // return the contrasting color painter.setPen(fgColor); painter.drawText(bar, heading, Qt::AlignVCenter | Qt::AlignCenter); @@ -765,12 +754,7 @@ GcChartWindow::GcChartWindow(Context *context) : GcWindow(context) void GcChartWindow::colorChanged(QColor z) { - QColor cRGB = z.convertTo(QColor::Rgb); - // lets work it out.. - int r = cRGB.red() < 128 ? 255 : 0; - int g = cRGB.green() < 128 ? 255 : 0; - int b = cRGB.blue() < 128 ? 255 : 0; - QColor fgColor = QColor(r,g,b); + QColor fgColor = GCColor::invertColor(z); // so z is color for bg and fgColor is for fg QString stylesheet = QString("color: rgb(%1, %2, %3); background-color: rgb(%4, %5, %6)") @@ -781,7 +765,7 @@ GcChartWindow::colorChanged(QColor z) .arg(z.green()) .arg(z.blue()); - menuButton->setStyleSheet(QString("QPushButton::menu-indicator { image: none; } QPushButton { border: 0px; padding: 0px; %1 }").arg(stylesheet)); + menuButton->setStyleSheet(QString("QPushButton { border: 0px; padding: 0px; %1 } QPushButton::menu-indicator { image: none; } ").arg(stylesheet)); _revealControls->setStyleSheet(stylesheet); menuButton->setStyleSheet(stylesheet); } diff --git a/src/GoogleMapControl.cpp b/src/GoogleMapControl.cpp index 62a4cc8c9..e22011be2 100644 --- a/src/GoogleMapControl.cpp +++ b/src/GoogleMapControl.cpp @@ -60,8 +60,10 @@ GoogleMapControl::GoogleMapControl(Context *context) : GcChartWindow(context), c connect(context, SIGNAL(intervalsChanged()), webBridge, SLOT(intervalsChanged())); connect(context, SIGNAL(intervalSelected()), webBridge, SLOT(intervalsChanged())); connect(context, SIGNAL(intervalZoom(IntervalItem*)), this, SLOT(zoomInterval(IntervalItem*))); + connect(context, SIGNAL(configChanged()), this, SLOT(configChanged())); first = true; + configChanged(); } GoogleMapControl::~GoogleMapControl() @@ -69,6 +71,12 @@ GoogleMapControl::~GoogleMapControl() delete webBridge; } +void +GoogleMapControl::configChanged() +{ + setProperty("color", GColor(CPLOTBACKGROUND)); +} + void GoogleMapControl::rideSelected() { diff --git a/src/GoogleMapControl.h b/src/GoogleMapControl.h index 5626cc293..653e52cd5 100644 --- a/src/GoogleMapControl.h +++ b/src/GoogleMapControl.h @@ -100,6 +100,7 @@ class GoogleMapControl : public GcChartWindow void createMarkers(); void drawShadedRoute(); void zoomInterval(IntervalItem*); + void configChanged(); private: Context *context; diff --git a/src/HomeWindow.cpp b/src/HomeWindow.cpp index 2b9f96117..6bdb10ccc 100644 --- a/src/HomeWindow.cpp +++ b/src/HomeWindow.cpp @@ -721,6 +721,8 @@ HomeWindow::eventFilter(QObject *object, QEvent *e) // mouse moved and tabbed -- should we show/hide chart popup controls? if (e->type() == QEvent::MouseMove && currentStyle == 0 && tabbed->currentIndex() >= 0) { + if (tabbed->currentIndex() >= charts.count()) return false; + QPoint pos = tabbed->widget(tabbed->currentIndex())->mapFromGlobal(QCursor::pos()); GcWindow *us = charts[tabbed->currentIndex()]; diff --git a/src/HrZones.cpp b/src/HrZones.cpp index 31a8eb81b..4c172fcae 100644 --- a/src/HrZones.cpp +++ b/src/HrZones.cpp @@ -599,7 +599,7 @@ QList HrZones::getZoneTrimps(int rnum) const { return return_values; } -QString HrZones::summarize(int rnum, QVector &time_in_zone) const +QString HrZones::summarize(int rnum, QVector &time_in_zone, QColor color) const { assert(rnum < ranges.size()); const HrZoneRange &range = ranges[rnum]; @@ -621,8 +621,6 @@ QString HrZones::summarize(int rnum, QVector &time_in_zone) const summary += tr("Time"); summary += tr("%"); summary += ""; - QColor color = QApplication::palette().alternateBase().color(); - color = QColor::fromHsv(color.hue(), color.saturation() * 2, color.value()); double duration = 0; foreach(double v, time_in_zone) { duration += v; } diff --git a/src/HrZones.h b/src/HrZones.h index 944050935..505f89092 100644 --- a/src/HrZones.h +++ b/src/HrZones.h @@ -184,7 +184,7 @@ class HrZones : public QObject QString &name, QString &description, int &low, int &high, double &trimp) const; - QString summarize(int rnum, QVector &time_in_zone) const; + QString summarize(int rnum, QVector &time_in_zone, QColor color = QColor(Qt::darkGray)) const; // get all highs/lows for zones (plot shading uses these) int lowsFromLT(QList *lows, int LT) const; diff --git a/src/LTMWindow.cpp b/src/LTMWindow.cpp index 4d607c8bd..acc23faac 100644 --- a/src/LTMWindow.cpp +++ b/src/LTMWindow.cpp @@ -851,8 +851,12 @@ LTMWindow::refreshDataTable() // now set to new (avoids a weird crash) QString summary; + QColor bgColor = GColor(CPLOTBACKGROUND); + QColor fgColor = GCColor::invertColor(bgColor); + QColor altColor = GCColor::alternateColor(bgColor); - summary = "
"; + summary = QString("
").arg(bgColor.name()) + .arg(fgColor.name()); // device summary for ride summary, otherwise how many activities? summary += "

" + settings.title + tr(" grouped by "); @@ -1022,8 +1026,6 @@ LTMWindow::refreshDataTable() if (aggregates.count()) { // formatting ... - QColor color = QApplication::palette().alternateBase().color(); - color = QColor::fromHsv(color.hue(), color.saturation() * 2, color.value()); LTMScaleDraw lsd(settings.start, groupForDate(settings.start.date()), settings.groupBy); // table and headings 50% for 1 metric, 70% for 2 metrics, 90% for 3 metrics or more @@ -1069,7 +1071,7 @@ LTMWindow::refreshDataTable() if (nonzero == false) continue; } - if (i%2) summary += ""; + if (i%2) summary += ""; else summary += ""; // date / month year etc diff --git a/src/MetadataWindow.cpp b/src/MetadataWindow.cpp index d24304a23..329a5b41f 100644 --- a/src/MetadataWindow.cpp +++ b/src/MetadataWindow.cpp @@ -17,6 +17,7 @@ */ #include "MetadataWindow.h" +#include "Colors.h" MetadataWindow::MetadataWindow(Context *context) : GcChartWindow(context), context(context) @@ -36,6 +37,10 @@ MetadataWindow::MetadataWindow(Context *context) : setChartLayout(vlayout); connect(this, SIGNAL(rideItemChanged(RideItem*)), this, SLOT(rideItemChanged())); + connect(context, SIGNAL(configChanged()), this, SLOT(configChanged())); + + // set colors + configChanged(); } void @@ -45,3 +50,9 @@ MetadataWindow::rideItemChanged() if (myRideItem) setIsBlank(false); else setIsBlank(true); } + +void +MetadataWindow::configChanged() +{ + setProperty("color", GColor(CPLOTBACKGROUND)); +} diff --git a/src/MetadataWindow.h b/src/MetadataWindow.h index 1ea669995..c3cfe008d 100644 --- a/src/MetadataWindow.h +++ b/src/MetadataWindow.h @@ -36,6 +36,7 @@ class MetadataWindow : public GcChartWindow protected slots: void rideItemChanged(); + void configChanged(); protected: diff --git a/src/RideEditor.cpp b/src/RideEditor.cpp index 7020908ba..a9696995e 100644 --- a/src/RideEditor.cpp +++ b/src/RideEditor.cpp @@ -23,6 +23,7 @@ #include "MainWindow.h" #include "Context.h" #include "Settings.h" +#include "Colors.h" #include #include @@ -80,8 +81,6 @@ RideEditor::RideEditor(Context *context) : GcChartWindow(context), data(NULL), r toolbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); toolbar->setFloatable(true); toolbar->setIconSize(QSize(18,18)); - toolbar->setStyleSheet("background: white;" - "border: 0px;"); QIcon saveIcon(":images/toolbar/save.png"); saveAct = new QAction(saveIcon, tr("Save"), this); @@ -145,6 +144,7 @@ RideEditor::RideEditor(Context *context) : GcChartWindow(context), data(NULL), r connect(this, SIGNAL(rideItemChanged(RideItem*)), this, SLOT(rideSelected())); connect(context, SIGNAL(rideDirty(RideItem*)), this, SLOT(rideDirty())); connect(context, SIGNAL(rideClean(RideItem*)), this, SLOT(rideClean())); + connect(context, SIGNAL(configChanged()), this, SLOT(configChanged())); // put find tool and anomaly list in the controls findTool = new FindDialog(this); @@ -154,10 +154,36 @@ RideEditor::RideEditor(Context *context) : GcChartWindow(context), data(NULL), r // allow us to jump to an anomaly connect(anomalyTool->anomalyList, SIGNAL(itemSelectionChanged()), this, SLOT(anomalySelected())); + + // set initial color config + configChanged(); } void -RideEditor::configChanged() {} +RideEditor::configChanged() +{ + setProperty("color", GColor(CPLOTBACKGROUND)); + + QPalette palette; + palette.setBrush(QPalette::Window, QBrush(GColor(CPLOTBACKGROUND))); + palette.setBrush(QPalette::Background, QBrush(GColor(CPLOTBACKGROUND))); + palette.setBrush(QPalette::Base, QBrush(GColor(CPLOTBACKGROUND))); + palette.setColor(QPalette::WindowText, GCColor::invertColor(GColor(CPLOTBACKGROUND))); + palette.setColor(QPalette::Text, GCColor::invertColor(GColor(CPLOTBACKGROUND))); + palette.setColor(QPalette::Normal, QPalette::Window, GCColor::invertColor(GColor(CPLOTBACKGROUND))); + setPalette(palette); + table->setPalette(palette); + table->setStyleSheet(QString("QTableView QTableCornerButton::section { background-color: %1; color: %2; border: %1 }") + .arg(GColor(CPLOTBACKGROUND).name()) + .arg(GCColor::invertColor(GColor(CPLOTBACKGROUND)).name())); + table->horizontalHeader()->setStyleSheet(QString("QHeaderView::section { background-color: %1; color: %2; border: 0px }") + .arg(GColor(CPLOTBACKGROUND).name()) + .arg(GCColor::invertColor(GColor(CPLOTBACKGROUND)).name())); + table->verticalHeader()->setStyleSheet(QString("QHeaderView::section { background-color: %1; color: %2; border: 0px }") + .arg(GColor(CPLOTBACKGROUND).name()) + .arg(GCColor::invertColor(GColor(CPLOTBACKGROUND)).name())); + toolbar->setStyleSheet(QString("background: %1; border: 0px;").arg(GColor(CPLOTBACKGROUND).name())); +} //---------------------------------------------------------------------- // RideEditor table/model/rideFile utility functions diff --git a/src/RideMetadata.cpp b/src/RideMetadata.cpp index 11ff9ab80..5abaf6cac 100644 --- a/src/RideMetadata.cpp +++ b/src/RideMetadata.cpp @@ -25,6 +25,7 @@ #include "Athlete.h" #include "RideSummaryWindow.h" #include "Settings.h" +#include "Colors.h" #include "Units.h" #include @@ -47,12 +48,6 @@ RideMetadata::RideMetadata(Context *context, bool singlecolumn) : mainLayout->setSpacing(0); mainLayout->setContentsMargins(0,0,0,0); - QPalette palette; - palette.setBrush(QPalette::Background, Qt::NoBrush); - - setAutoFillBackground(false); - setPalette(palette); - // setup the tabs widget tabs = new QTabWidget(this); tabs->setMovable(true); @@ -209,6 +204,24 @@ RideMetadata::metadataChanged() void RideMetadata::configUpdate() { + setProperty("color", GColor(CPLOTBACKGROUND)); + + palette = QPalette(); + + palette.setBrush(QPalette::Window, QBrush(GColor(CPLOTBACKGROUND))); + palette.setBrush(QPalette::Background, QBrush(GColor(CPLOTBACKGROUND))); + + // only change base if moved away from white plots + if (GColor(CPLOTBACKGROUND) != Qt::white) { + palette.setBrush(QPalette::Base, QBrush(GCColor::alternateColor(GColor(CPLOTBACKGROUND)))); + palette.setColor(QPalette::Normal, QPalette::Window, GCColor::invertColor(GColor(CPLOTBACKGROUND))); + } + + palette.setColor(QPalette::WindowText, GCColor::invertColor(GColor(CPLOTBACKGROUND))); + palette.setColor(QPalette::Text, GCColor::invertColor(GColor(CPLOTBACKGROUND))); + setPalette(palette); + tabs->setPalette(palette); + // use default font setFont(QFont()); @@ -422,6 +435,7 @@ FormField::FormField(FieldDefinition field, RideMetadata *meta) : definition(fie } label = new QLabel(QString("%1%2").arg(meta->sp.displayName(field.name)).arg(units), this); + label->setPalette(meta->palette); //label->setFont(font); //label->setFixedHeight(18); @@ -516,6 +530,8 @@ FormField::FormField(FieldDefinition field, RideMetadata *meta) : definition(fie connect(widget, SIGNAL(stateChanged(int)), this, SLOT(stateChanged(int))); break; } + + widget->setPalette(meta->palette); //widget->setFont(font); //connect(main, SIGNAL(rideSelected()), this, SLOT(rideSelected())); } diff --git a/src/RideMetadata.h b/src/RideMetadata.h index bbf842a3a..18e2869b0 100644 --- a/src/RideMetadata.h +++ b/src/RideMetadata.h @@ -144,6 +144,8 @@ class RideMetadata : public QWidget Context *context; SpecialTabs specialTabs; + QPalette palette; // to be applied to all widgets + public slots: void configUpdate(); void metadataChanged(); // when its changed elsewhere we need to refresh fields diff --git a/src/RideSummaryWindow.cpp b/src/RideSummaryWindow.cpp index 456272025..a113e8a8e 100644 --- a/src/RideSummaryWindow.cpp +++ b/src/RideSummaryWindow.cpp @@ -104,7 +104,15 @@ RideSummaryWindow::RideSummaryWindow(Context *context, bool ridesummary) : connect(dateSetting, SIGNAL(useStandardRange()), this, SLOT(useStandardRange())); } + connect(context, SIGNAL(configChanged()), this, SLOT(configChanged())); setChartLayout(vlayout); + configChanged(); // set colors +} + +void +RideSummaryWindow::configChanged() +{ + setProperty("color", GColor(CPLOTBACKGROUND)); // called on config change } #ifdef GC_HAVE_LUCENE @@ -264,6 +272,9 @@ QString RideSummaryWindow::htmlSummary() const { QString summary(""); + QColor bgColor = GColor(CPLOTBACKGROUND); + QColor fgColor = GCColor::invertColor(bgColor); + QColor altColor = GCColor::alternateColor(bgColor); RideItem *rideItem = myRideItem; RideFile *ride; @@ -285,8 +296,9 @@ RideSummaryWindow::htmlSummary() const return summary; } - // always centered - summary = "
"; + // set those colors + summary = QString("
").arg(bgColor.name()) + .arg(fgColor.name()); // device summary for ride summary, otherwise how many activities? if (ridesummary) summary += ("

" + tr("Device Type: ") + ride->deviceType() + "

"); @@ -544,14 +556,11 @@ RideSummaryWindow::htmlSummary() const } QList bests = SummaryMetrics::getBests(context, bestsColumn[i], 10, data, filterList, context->ishomefiltered || filtered, useMetricUnits); - QColor color = QApplication::palette().alternateBase().color(); - color = QColor::fromHsv(color.hue(), color.saturation() * 2, color.value()); - int pos=1; foreach(SummaryBest best, bests) { // alternating shading - if (pos%2) summary += ""; + if (pos%2) summary += ""; else summary += ""; summary += QString("%1.%2%3") @@ -611,7 +620,7 @@ RideSummaryWindow::htmlSummary() const } } summary += tr("

Power Zones

"); - summary += context->athlete->zones()->summarize(range, time_in_zone); //aggregating + summary += context->athlete->zones()->summarize(range, time_in_zone, altColor); //aggregating } // @@ -659,7 +668,7 @@ RideSummaryWindow::htmlSummary() const } summary += tr("

Heart Rate Zones

"); - summary += context->athlete->hrZones()->summarize(hrrange, time_in_zone); //aggregating + summary += context->athlete->hrZones()->summarize(hrrange, time_in_zone, altColor); //aggregating } // Only get interval summary for a ride summary @@ -723,9 +732,7 @@ RideSummaryWindow::htmlSummary() const if (even) summary += ""; else { - QColor color = QApplication::palette().alternateBase().color(); - color = QColor::fromHsv(color.hue(), color.saturation() * 2, color.value()); - summary += ""; + summary += ""; } even = !even; summary += "" + interval.name + ""; @@ -842,9 +849,7 @@ RideSummaryWindow::htmlSummary() const if (even) summary += ""; else { - QColor color = QApplication::palette().alternateBase().color(); - color = QColor::fromHsv(color.hue(), color.saturation() * 2, color.value()); - summary += ""; + summary += ""; } even = !even; @@ -896,6 +901,10 @@ RideSummaryWindow::htmlCompareSummary() const { QString summary; + QColor bgColor = GColor(CPLOTBACKGROUND); + QColor fgColor = GCColor::invertColor(bgColor); + QColor altColor = GCColor::alternateColor(bgColor); + // SETUP ALL THE METRICS WE WILL SHOW // All the metrics we will display -- same as non compare mode FOR NOW @@ -1006,12 +1015,8 @@ RideSummaryWindow::htmlCompareSummary() const } // LETS FORMAT THE HTML - summary = "
"; - - // used for alternate shding - QColor color = QApplication::palette().alternateBase().color(); - color = QColor::fromHsv(color.hue(), color.saturation() * 2, color.value()); - + summary = QString("
").arg(bgColor.name()) + .arg(fgColor.name()); // // TOTALS, AVERAGES, MAX, METRICS // @@ -1043,7 +1048,7 @@ RideSummaryWindow::htmlCompareSummary() const summary += ""; summary += ""; // removed the text as its blinking obvious.. but left code in // case we ever come back here or use it for other things. - summary += " "; // spacing + summary += " "; // spacing foreach (QString symbol, metricsList) { const RideMetric *m = factory.rideMetric(symbol); @@ -1071,11 +1076,11 @@ RideSummaryWindow::htmlCompareSummary() const } // alternating shading - if (rows%2) summary += ""; + if (rows%2) summary += ""; else summary += ""; summary += "" + context->compareIntervals[counter].name + ""; - summary += " "; // spacing + summary += " "; // spacing foreach (QString symbol, metricsList) { @@ -1118,7 +1123,7 @@ RideSummaryWindow::htmlCompareSummary() const } else { summary += ""; } - summary += " "; // spacing + summary += " "; // spacing } summary += ""; @@ -1147,11 +1152,11 @@ RideSummaryWindow::htmlCompareSummary() const // lets get some headings summary += ""; // ne need to have a heading for the interval name - summary += " "; // spacing + summary += " "; // spacing foreach (ZoneInfo zone, zones) { summary += QString("%1 (%2)").arg(zone.desc).arg(zone.name); - summary += " "; // spacing + summary += " "; // spacing } summary += ""; @@ -1166,11 +1171,11 @@ RideSummaryWindow::htmlCompareSummary() const continue; } - if (rows%2) summary += ""; + if (rows%2) summary += ""; else summary += ""; summary += "" + context->compareIntervals[counter].name + ""; - summary += " "; // spacing + summary += " "; // spacing int idx=0; foreach (ZoneInfo zone, zones) { @@ -1187,8 +1192,7 @@ RideSummaryWindow::htmlCompareSummary() const .arg(time_to_string(fabs(dt))); else summary += ""; - - summary += " "; // spacing + summary += " "; // spacing } summary += ""; @@ -1220,11 +1224,11 @@ RideSummaryWindow::htmlCompareSummary() const // lets get some headings summary += ""; // ne need to have a heading for the interval name - summary += " "; // spacing + summary += " "; // spacing foreach (HrZoneInfo zone, zones) { summary += QString("%1 (%2)").arg(zone.desc).arg(zone.name); - summary += " "; // spacing + summary += " "; // spacing } summary += ""; @@ -1239,11 +1243,11 @@ RideSummaryWindow::htmlCompareSummary() const continue; } - if (rows%2) summary += ""; + if (rows%2) summary += ""; else summary += ""; summary += "" + context->compareIntervals[counter].name + ""; - summary += " "; // spacing + summary += " "; // spacing int idx=0; foreach (HrZoneInfo zone, zones) { @@ -1261,7 +1265,7 @@ RideSummaryWindow::htmlCompareSummary() const else summary += ""; - summary += " "; // spacing + summary += " "; // spacing } summary += ""; @@ -1277,15 +1281,12 @@ RideSummaryWindow::htmlCompareSummary() const } else { // DATE RANGE COMPARE // LETS FORMAT THE HTML - summary = "
"; + summary = QString("
").arg(bgColor.name()) + .arg(fgColor.name()); // get metric details here ... RideMetricFactory &factory = RideMetricFactory::instance(); - // used for alternate shding - QColor color = QApplication::palette().alternateBase().color(); - color = QColor::fromHsv(color.hue(), color.saturation() * 2, color.value()); - // // TOTALS, AVERAGES, MAX, METRICS // @@ -1320,7 +1321,7 @@ RideSummaryWindow::htmlCompareSummary() const summary += ""; summary += ""; // removed the text as its blinking obvious.. but left code in // case we ever come back here or use it for other things. - summary += " "; // spacing + summary += " "; // spacing foreach (QString symbol, metricsList) { const RideMetric *m = factory.rideMetric(symbol); @@ -1344,11 +1345,11 @@ RideSummaryWindow::htmlCompareSummary() const if (!dr.isChecked()) continue; // alternating shading - if (counter%2) summary += ""; + if (counter%2) summary += ""; else summary += ""; summary += "" + dr.name + ""; - summary += " "; // spacing + summary += " "; // spacing foreach (QString symbol, metricsList) { @@ -1390,7 +1391,7 @@ RideSummaryWindow::htmlCompareSummary() const } else { summary += ""; } - summary += " "; // spacing + summary += " "; // spacing } summary += ""; @@ -1419,11 +1420,11 @@ RideSummaryWindow::htmlCompareSummary() const // lets get some headings summary += ""; // ne need to have a heading for the interval name - summary += " "; // spacing + summary += " "; // spacing foreach (ZoneInfo zone, zones) { summary += QString("%1 (%2)").arg(zone.desc).arg(zone.name); - summary += " "; // spacing + summary += " "; // spacing } summary += ""; @@ -1434,11 +1435,11 @@ RideSummaryWindow::htmlCompareSummary() const // skip if not checked if (!dr.isChecked()) continue; - if (counter%2) summary += ""; + if (counter%2) summary += ""; else summary += ""; summary += "" + dr.name + ""; - summary += " "; // spacing + summary += " "; // spacing int idx=0; foreach (ZoneInfo zone, zones) { @@ -1459,8 +1460,7 @@ RideSummaryWindow::htmlCompareSummary() const .arg(time_to_string(fabs(dt))); else summary += ""; - - summary += " "; // spacing + summary += " "; // spacing } summary += ""; @@ -1492,11 +1492,11 @@ RideSummaryWindow::htmlCompareSummary() const // lets get some headings summary += ""; // ne need to have a heading for the interval name - summary += " "; // spacing + summary += " "; // spacing foreach (HrZoneInfo zone, zones) { summary += QString("%1 (%2)").arg(zone.desc).arg(zone.name); - summary += " "; // spacing + summary += " "; // spacing } summary += ""; @@ -1507,11 +1507,11 @@ RideSummaryWindow::htmlCompareSummary() const // skip if not checked if (!dr.isChecked()) continue; - if (counter%2) summary += ""; + if (counter%2) summary += ""; else summary += ""; summary += "" + dr.name + ""; - summary += " "; // spacing + summary += " "; // spacing int idx=0; foreach (HrZoneInfo zone, zones) { @@ -1532,8 +1532,7 @@ RideSummaryWindow::htmlCompareSummary() const .arg(time_to_string(fabs(dt))); else summary += ""; - - summary += " "; // spacing + summary += " "; // spacing } summary += ""; diff --git a/src/RideSummaryWindow.h b/src/RideSummaryWindow.h index 90cb6d0d4..8d0d7c303 100644 --- a/src/RideSummaryWindow.h +++ b/src/RideSummaryWindow.h @@ -102,6 +102,9 @@ class RideSummaryWindow : public GcChartWindow // compare mode started or items to compare changed void compareChanged(); + // config changed + void configChanged(); + protected: QString htmlSummary() const; // summary of a ride or a date range diff --git a/src/ScatterPlot.cpp b/src/ScatterPlot.cpp index a022ee48d..d337a7645 100644 --- a/src/ScatterPlot.cpp +++ b/src/ScatterPlot.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -359,6 +360,14 @@ ScatterPlot::configChanged() { // setColors bg setCanvasBackground(GColor(CPLOTBACKGROUND)); + + QPalette palette; + palette.setBrush(QPalette::Window, QBrush(GColor(CPLOTBACKGROUND))); + palette.setColor(QPalette::WindowText, GColor(CPLOTMARKER)); + palette.setColor(QPalette::Text, GColor(CPLOTMARKER)); + + axisWidget(QwtPlot::xBottom)->setPalette(palette); + axisWidget(QwtPlot::yLeft)->setPalette(palette); } void diff --git a/src/ScatterWindow.cpp b/src/ScatterWindow.cpp index 2a44c59ec..5006f00da 100644 --- a/src/ScatterWindow.cpp +++ b/src/ScatterWindow.cpp @@ -20,6 +20,7 @@ #include "ScatterPlot.h" #include "Athlete.h" #include "Context.h" +#include "Colors.h" #include #include @@ -161,7 +162,22 @@ ScatterWindow::ScatterWindow(Context *context, const QDir &home) : connect(ignore, SIGNAL(stateChanged(int)), this, SLOT(setIgnore())); connect(rFrameInterval, SIGNAL(stateChanged(int)), this, SLOT(setrFrame())); connect(rIgnore, SIGNAL(stateChanged(int)), this, SLOT(setrIgnore())); + connect(context, SIGNAL(configChanged()), this, SLOT(configChanged())); + // set colors + configChanged(); +} + +void +ScatterWindow::configChanged() +{ + setProperty("color", GColor(CPLOTBACKGROUND)); + + QPalette palette; + palette.setBrush(QPalette::Window, QBrush(GColor(CPLOTBACKGROUND))); + palette.setColor(QPalette::WindowText, GColor(CPLOTMARKER)); + palette.setColor(QPalette::Text, GColor(CPLOTMARKER)); + setPalette(palette); } void diff --git a/src/ScatterWindow.h b/src/ScatterWindow.h index 3862bf01c..4f39f2e2d 100644 --- a/src/ScatterWindow.h +++ b/src/ScatterWindow.h @@ -94,6 +94,7 @@ class ScatterWindow : public GcChartWindow void rxSelectorChanged(int); void rySelectorChanged(int); + void configChanged(); // these set the plot when the properties change void setGrid(); diff --git a/src/Zones.cpp b/src/Zones.cpp index b8e20cef8..7a05cd99f 100644 --- a/src/Zones.cpp +++ b/src/Zones.cpp @@ -582,7 +582,7 @@ QList Zones::getZoneNames(int rnum) const { return return_values; } -QString Zones::summarize(int rnum, QVector &time_in_zone) const +QString Zones::summarize(int rnum, QVector &time_in_zone, QColor color) const { assert(rnum < ranges.size()); const ZoneRange &range = ranges[rnum]; @@ -604,8 +604,6 @@ QString Zones::summarize(int rnum, QVector &time_in_zone) const summary += tr("Time"); summary += tr("%"); summary += ""; - QColor color = QApplication::palette().alternateBase().color(); - color = QColor::fromHsv(color.hue(), color.saturation() * 2, color.value()); double duration = 0; foreach(double v, time_in_zone) { duration += v; } diff --git a/src/Zones.h b/src/Zones.h index ee1325075..8a7840988 100644 --- a/src/Zones.h +++ b/src/Zones.h @@ -170,7 +170,7 @@ class Zones : public QObject QString &name, QString &description, int &low, int &high) const; - QString summarize(int rnum, QVector &time_in_zone) const; + QString summarize(int rnum, QVector &time_in_zone, QColor color = QColor(Qt::darkGray)) const; // get all highs/lows for zones (plot shading uses these) int lowsFromCP(QList *lows, int CP) const;