diff --git a/src/Colors.cpp b/src/Colors.cpp index d9ac991d5..b4759264b 100644 --- a/src/Colors.cpp +++ b/src/Colors.cpp @@ -266,6 +266,12 @@ GCColor::getColor(int colornum) return ColorList[colornum].color; } +void +GCColor::setColor(int colornum, QColor color) +{ + ColorList[colornum].color = color; +} + Themes & GCColor::themes() { @@ -562,6 +568,90 @@ Themes::Themes() } +void +GCColor::applyTheme(int index) +{ + // now get the theme selected + ColorTheme theme = GCColor::themes().themes[index]; + + for (int i=0; ColorList[i].name != ""; i++) { + + QColor color; + + // apply theme to color + switch(i) { + + case CPLOTBACKGROUND: + case CRIDEPLOTBACKGROUND: + case CTRAINPLOTBACKGROUND: + color = theme.colors[0]; // background color + break; + + // fg color theme.colors[1] not used YET XXX + + case CPLOTSYMBOL: + case CRIDEPLOTXAXIS: + case CRIDEPLOTYAXIS: + case CPLOTMARKER: + color = theme.colors[2]; // accent color + break; + + case CPLOTSELECT: + case CPLOTTRACKER: + case CINTERVALHIGHLIGHTER: + color = theme.colors[3]; // select color + break; + + + case CPLOTGRID: // grid doesn't have a theme color + // we make it barely distinguishable from background + { + QColor bg = theme.colors[0]; + if(bg == QColor(Qt::black)) color = QColor(30,30,30); + else color = bg.darker(110); + } + break; + + case CCP: + case CWBAL: + case CRIDECP: + color = theme.colors[4]; + break; + + case CHEARTRATE: + color = theme.colors[5]; + break; + + case CSPEED: + color = theme.colors[6]; + break; + + case CPOWER: + color = theme.colors[7]; + break; + + case CCADENCE: + color = theme.colors[8]; + break; + + case CTORQUE: + color = theme.colors[9]; + break; + + default: + color = DefaultColorList[i].color; + } + + // theme applied ! + ColorList[i].color = color; + + QString colorstring = QString("%1:%2:%3").arg(color.red()) + .arg(color.green()) + .arg(color.blue()); + appsettings->setValue(ColorList[i].setting, colorstring); + } +} + // // ColorLabel - just paints a swatch of the first 5 colors // diff --git a/src/Colors.h b/src/Colors.h index 8cc623325..97f4127cb 100644 --- a/src/Colors.h +++ b/src/Colors.h @@ -98,6 +98,7 @@ class GCColor : public QObject public: GCColor(Context *); static QColor getColor(int); + static void setColor(int,QColor); static const Colors *colorSet(); static const Colors *defaultColorSet(); static void resetColors(); @@ -107,6 +108,7 @@ class GCColor : public QObject static QColor alternateColor(QColor); // return the alternate background static QColor htmlCode(QColor x) { return x.name(); } // return the alternate background static Themes &themes(); + static void applyTheme(int index); // for styling things with current preferences static bool isFlat(); diff --git a/src/GcCrashDialog.cpp b/src/GcCrashDialog.cpp index d6aba917f..22edbf503 100644 --- a/src/GcCrashDialog.cpp +++ b/src/GcCrashDialog.cpp @@ -137,6 +137,10 @@ QString GcCrashDialog::versionHTML() os += " Lion"; else if (QSysInfo::MacintoshVersion == 10) os += " Mountain Lion"; + else if (QSysInfo::MacintoshVersion == 11) + os += " Mavericks"; + else if (QSysInfo::MacintoshVersion == 12) + os += " Yosemite"; #endif diff --git a/src/GcUpgrade.cpp b/src/GcUpgrade.cpp index f88b6ab64..8220e7858 100644 --- a/src/GcUpgrade.cpp +++ b/src/GcUpgrade.cpp @@ -18,6 +18,7 @@ #include "GoldenCheetah.h" #include "Settings.h" +#include "Colors.h" #include "GcUpgrade.h" #include @@ -31,6 +32,10 @@ GcUpgrade::upgrade(const QDir &home) // for athlete directories from prior to Version 3 // and can essentially be used as a template for all major release // upgrades as it delets old stuff and sets clean + + //---------------------------------------------------------------------- + // 3.0 upgrade processing + //---------------------------------------------------------------------- if (!last || last < VERSION3_BUILD) { // For now we always do the same thing @@ -95,7 +100,9 @@ GcUpgrade::upgrade(const QDir &home) // Versions after 3 should add their upgrade processing at this point // DO NOT CHANGE THE VERSION 3 UPGRADE PROCESS ABOVE, ADD TO IT BELOW - // 3.0 SP1 upgrade processing + //---------------------------------------------------------------------- + // 3.0 SP2 upgrade processing + //---------------------------------------------------------------------- if (last < VERSION3_SP2) { // 2. Remove old CLucece 'index' @@ -109,6 +116,78 @@ GcUpgrade::upgrade(const QDir &home) if (db.exists()) db.remove(); } + //---------------------------------------------------------------------- + // 3.1 upgrade processing + //---------------------------------------------------------------------- + + if (false && last < VERSION31_BUILD) { // << note this is not activated yet + + // We sought to reset the user defaults in v3.1 to + // move away from the ugly default used since GC first + // released. This is the first time we actively applied + // a new theme and color setting for users. + + // For a full breakdown of all activities applied in VERSION 3.1 + // they are listed in detail on the associated gitub issue: + // see https://github.com/GoldenCheetah/GoldenCheetah/issues/883 + + // 1. Delete all backup, CPX, Metrics and Lucene Index + QStringList oldfiles; + oldfiles << "*.cpi"; + oldfiles << "*.bak"; + foreach (QString oldfile, home.entryList(oldfiles, QDir::Files)) { + QFile old(QString("%1/%2").arg(home.canonicalPath()).arg(oldfile)); + old.remove(); + } + + QFile index(QString("%1/index").arg(home.canonicalPath())); + if (index.exists()) { + removeIndex(index); + } + + QFile db(QString("%1/metricDBv3").arg(home.canonicalPath())); + if (db.exists()) db.remove(); + + + // 2. Remove any old charts.xml (it will be WRONG!) + QFile charts(QString("%1/charts.xml").arg(home.canonicalPath())); + if (charts.exists()) charts.remove(); + + // 3. Reset colour defaults ** + GCColor::applyTheme(0); // set to default theme + + // 4. Theme and Chrome Color + QString theme = "Flat"; + QColor chromeColor = QColor(Qt::darkGray); +#ifdef Q_OS_MAC + // Yosemite or earlier + if (QSysInfo::MacintoshVersion >= 12) { + + chromeColor = QColor(235,235,235); + } else { + + // prior to Yosemite .. metallic + theme = "Mac"; + chromeColor = QColor(215,215,215); + } +#endif + QString colorstring = QString("%1:%2:%3").arg(chromeColor.red()) + .arg(chromeColor.green()) + .arg(chromeColor.blue()); + appsettings->setValue("CCHROME", colorstring); + GCColor::setColor(CCHROME, chromeColor); + + // BELOW STILL TODO + // 5. Notes keywords + // 6. Set a default W' for the athlete / power.zones + // 7. Check for Power Zones that do not start from zero + // 8. Add TSS, and TISS to the 'Metrics' metadata tab (to avoid FAQ #1) + // 9. Add a W'bal chart to the ride view + // 10. Add a CP History chart to the trend view + // 11. Add a Library chart to the trend view + + } + return 0; } diff --git a/src/GcUpgrade.h b/src/GcUpgrade.h index c7fe16db4..36a7e26e8 100644 --- a/src/GcUpgrade.h +++ b/src/GcUpgrade.h @@ -40,6 +40,10 @@ #define VERSION3_BUILD 3010 // released #define VERSION3_SP1 3030 // released #define VERSION3_SP2 3032 // released +#define VERSION31_UPG 3055 // first build with 3.1 upgrade process (doesn't exist yet) + +// will keep changing during testing and before final release +#define VERSION31_BUILD VERSION31_UPG // these three will change until we release #define VERSION_LATEST 3051 diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index a6305883f..cbe00af7b 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -115,19 +115,19 @@ MainWindow::MainWindow(const QDir &home) // bootstrap Context *context = new Context(this); + GCColor *GCColorSet = new GCColor(context); // get/keep colorset, before athlete... context->athlete = new Athlete(context, home); setWindowIcon(QIcon(":images/gc.png")); setWindowTitle(context->athlete->home.dirName()); setContentsMargins(0,0,0,0); setAcceptDrops(true); - GCColor *GCColorSet = new GCColor(context); // get/keep colorset - GCColorSet->colorSet(); // shut up the compiler #ifdef GC_HAVE_WFAPI WFApi *w = WFApi::getInstance(); // ensure created on main thread w->apiVersion();//shutup compiler #endif + GCColorSet->colorSet(); // shut up the compiler Library::initialise(context->athlete->home); QNetworkProxyQuery npq(QUrl("http://www.google.com")); QList listOfProxies = QNetworkProxyFactory::systemProxyForQuery(npq);