From 2acf261ebf1c71009f2c5ac833c30959a0e453f6 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Wed, 6 Oct 2021 13:06:34 -0700 Subject: [PATCH] use enum for color coding --- app/config/config.cpp | 25 +++++++++++++------------ app/ui/colorcoding.cpp | 32 ++++++++++++++++---------------- app/ui/colorcoding.h | 19 +++++++++++++++++++ 3 files changed, 48 insertions(+), 28 deletions(-) diff --git a/app/config/config.cpp b/app/config/config.cpp index d86271af0..e0820c4c6 100644 --- a/app/config/config.cpp +++ b/app/config/config.cpp @@ -31,6 +31,7 @@ #include "common/filefunctions.h" #include "common/xmlutils.h" #include "core.h" +#include "ui/colorcoding.h" #include "ui/style/style.h" #include "window/mainwindow/mainwindow.h" @@ -102,18 +103,18 @@ void Config::SetDefaults() SetEntryInternal(QStringLiteral("AutoCacheDelay"), NodeValue::kInt, 1000); - SetEntryInternal(QStringLiteral("CatColor0"), NodeValue::kInt, 0); - SetEntryInternal(QStringLiteral("CatColor1"), NodeValue::kInt, 1); - SetEntryInternal(QStringLiteral("CatColor2"), NodeValue::kInt, 2); - SetEntryInternal(QStringLiteral("CatColor3"), NodeValue::kInt, 3); - SetEntryInternal(QStringLiteral("CatColor4"), NodeValue::kInt, 4); - SetEntryInternal(QStringLiteral("CatColor5"), NodeValue::kInt, 5); - SetEntryInternal(QStringLiteral("CatColor6"), NodeValue::kInt, 6); - SetEntryInternal(QStringLiteral("CatColor7"), NodeValue::kInt, 7); - SetEntryInternal(QStringLiteral("CatColor8"), NodeValue::kInt, 8); - SetEntryInternal(QStringLiteral("CatColor9"), NodeValue::kInt, 9); - SetEntryInternal(QStringLiteral("CatColor10"), NodeValue::kInt, 10); - SetEntryInternal(QStringLiteral("CatColor11"), NodeValue::kInt, 11); + SetEntryInternal(QStringLiteral("CatColor0"), NodeValue::kInt, ColorCoding::kRed); + SetEntryInternal(QStringLiteral("CatColor1"), NodeValue::kInt, ColorCoding::kMaroon); + SetEntryInternal(QStringLiteral("CatColor2"), NodeValue::kInt, ColorCoding::kOrange); + SetEntryInternal(QStringLiteral("CatColor3"), NodeValue::kInt, ColorCoding::kBrown); + SetEntryInternal(QStringLiteral("CatColor4"), NodeValue::kInt, ColorCoding::kYellow); + SetEntryInternal(QStringLiteral("CatColor5"), NodeValue::kInt, ColorCoding::kOlive); + SetEntryInternal(QStringLiteral("CatColor6"), NodeValue::kInt, ColorCoding::kLime); + SetEntryInternal(QStringLiteral("CatColor7"), NodeValue::kInt, ColorCoding::kGreen); + SetEntryInternal(QStringLiteral("CatColor8"), NodeValue::kInt, ColorCoding::kCyan); + SetEntryInternal(QStringLiteral("CatColor9"), NodeValue::kInt, ColorCoding::kTeal); + SetEntryInternal(QStringLiteral("CatColor10"), NodeValue::kInt, ColorCoding::kBlue); + SetEntryInternal(QStringLiteral("CatColor11"), NodeValue::kInt, ColorCoding::kNavy); SetEntryInternal(QStringLiteral("AudioOutput"), NodeValue::kText, QString()); SetEntryInternal(QStringLiteral("AudioInput"), NodeValue::kText, QString()); diff --git a/app/ui/colorcoding.cpp b/app/ui/colorcoding.cpp index 2a6c0c86d..5b13340c2 100644 --- a/app/ui/colorcoding.cpp +++ b/app/ui/colorcoding.cpp @@ -45,37 +45,37 @@ QString ColorCoding::GetColorName(int c) { // FIXME: I'm sure we could come up with more creative names for these colors switch (c) { - case 0: + case kRed: return tr("Red"); - case 1: + case kMaroon: return tr("Maroon"); - case 2: + case kOrange: return tr("Orange"); - case 3: + case kBrown: return tr("Brown"); - case 4: + case kYellow: return tr("Yellow"); - case 5: + case kOlive: return tr("Olive"); - case 6: + case kLime: return tr("Lime"); - case 7: + case kGreen: return tr("Green"); - case 8: + case kCyan: return tr("Cyan"); - case 9: + case kTeal: return tr("Teal"); - case 10: + case kBlue: return tr("Blue"); - case 11: + case kNavy: return tr("Navy"); - case 12: + case kPink: return tr("Pink"); - case 13: + case kPurple: return tr("Purple"); - case 14: + case kSilver: return tr("Silver"); - case 15: + case kGray: return tr("Gray"); } diff --git a/app/ui/colorcoding.h b/app/ui/colorcoding.h index 5df3ee6cb..42606c765 100644 --- a/app/ui/colorcoding.h +++ b/app/ui/colorcoding.h @@ -29,6 +29,25 @@ class ColorCoding : public QObject { Q_OBJECT public: + enum Code { + kRed, + kMaroon, + kOrange, + kBrown, + kYellow, + kOlive, + kLime, + kGreen, + kCyan, + kTeal, + kBlue, + kNavy, + kPink, + kPurple, + kSilver, + kGray + }; + static QString GetColorName(int c); static Color GetColor(int c);