use enum for color coding

This commit is contained in:
itsmattkc
2021-10-06 13:06:34 -07:00
parent e68fa8abb2
commit 2acf261ebf
3 changed files with 48 additions and 28 deletions
+13 -12
View File
@@ -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());
+16 -16
View File
@@ -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");
}
+19
View File
@@ -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);