From ff918167b596652c3984b684cd0dfaeabbdd7e66 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Sun, 8 Jun 2014 11:37:01 +0100 Subject: [PATCH] Calendar Chart now honours colour preferences .. think that is the last of all the charts now done. --- src/DiaryWindow.cpp | 32 ++++++++++++++++++++++++++++++++ src/GcCalendarModel.h | 9 +++++---- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/DiaryWindow.cpp b/src/DiaryWindow.cpp index 849b68c9b..ad7c78e2b 100644 --- a/src/DiaryWindow.cpp +++ b/src/DiaryWindow.cpp @@ -21,6 +21,7 @@ #include "RideMetadata.h" #include "Athlete.h" #include "Context.h" +#include "TabView.h" DiaryWindow::DiaryWindow(Context *context) : GcWindow(context), context(context), active(false) @@ -89,6 +90,9 @@ DiaryWindow::DiaryWindow(Context *context) : connect(context, SIGNAL(configChanged()), this, SLOT(configChanged())); connect(next, SIGNAL(clicked()), this, SLOT(nextClicked())); connect(prev, SIGNAL(clicked()), this, SLOT(prevClicked())); + + // get colors sorted + configChanged(); } void @@ -96,6 +100,34 @@ DiaryWindow::configChanged() { // get config fieldDefinitions = context->athlete->rideMetadata()->getFields(); + + // change colors to reflect preferences + 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); + monthlyView->setPalette(palette); + monthlyView->setStyleSheet(QString("QTableView QTableCornerButton::section { background-color: %1; color: %2; border: %1 }") + .arg(GColor(CPLOTBACKGROUND).name()) + .arg(GCColor::invertColor(GColor(CPLOTBACKGROUND)).name())); + monthlyView->horizontalHeader()->setStyleSheet(QString("QHeaderView::section { background-color: %1; color: %2; border: 0px }") + .arg(GColor(CPLOTBACKGROUND).name()) + .arg(GCColor::invertColor(GColor(CPLOTBACKGROUND)).name())); + monthlyView->verticalHeader()->setStyleSheet(QString("QHeaderView::section { background-color: %1; color: %2; border: 0px }") + .arg(GColor(CPLOTBACKGROUND).name()) + .arg(GCColor::invertColor(GColor(CPLOTBACKGROUND)).name())); +#ifndef Q_OS_MAC + monthlyView->verticalScrollBar()->setStyleSheet(TabView::ourStyleSheet()); + monthlyView->horizontalScrollBar()->setStyleSheet(TabView::ourStyleSheet()); +#endif + title->setStyleSheet(QString("background: %1; color: %2;").arg(GColor(CPLOTBACKGROUND).name()) + .arg(GColor(CPLOTMARKER).name())); } void diff --git a/src/GcCalendarModel.h b/src/GcCalendarModel.h index 45e28af7c..53b83babd 100644 --- a/src/GcCalendarModel.h +++ b/src/GcCalendarModel.h @@ -306,16 +306,16 @@ public: if (date(proxyIndex) == QDate::currentDate()) return GColor(CCALTODAY); if (date(proxyIndex).month() == month) - return GColor(CCALCELL); + return GColor(CPLOTBACKGROUND); else - return GColor(CCALHEAD); + return GColor(CPLOTBACKGROUND).darker(200); break; case HeaderColorRole: // what color for the cell heading if (date(proxyIndex).month() == month) - return GColor(CCALHEAD); + return GColor(CPLOTBACKGROUND); else - return GColor(CCALHEAD).darker(200); + return GColor(CPLOTBACKGROUND).darker(200); break; case FilenamesRole: @@ -485,6 +485,7 @@ class GcCalendarDelegate : public QItemDelegate // date... QString datestring = index.data(GcCalendarModel::DateStringRole).toString(); QTextOption textOption(Qt::AlignRight); + painter->setPen(GCColor::invertColor(hg)); painter->drawText(hd, datestring, textOption); // text