Skip to content

Commit

Permalink
Cleanup barcode colors list
Browse files Browse the repository at this point in the history
  • Loading branch information
emericg committed Jan 30, 2024
1 parent f1cdfff commit fd9131c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/BarcodeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,14 @@ QString BarcodeManager::getAvailableColor()
if (m_colorsLeft.size())
{
// unique colors
int clr_id = QRandomGenerator::global()->bounded(m_colorsLeft.size());
int clr_id = QRandomGenerator::global()->bounded(m_colorsLeft.size() - 1);
clr_str = m_colorsLeft.at(clr_id);
m_colorsLeft.remove(clr_id);
}
else
{
// start reusing colors
clr_str = m_colorsAvailable.at(QRandomGenerator::global()->bounded(m_colorsAvailable.size()));
clr_str = m_colorsAvailable.at(QRandomGenerator::global()->bounded(m_colorsAvailable.size()) - 1);
}

return clr_str;
Expand Down
14 changes: 4 additions & 10 deletions src/BarcodeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,10 @@ class BarcodeManager: public QObject
QNetworkReply *firmwareReply = nullptr;

QStringList m_colorsAvailable = {
"HotPink", "Tomato", "Yellow", "Orange", "Gold", "LimeGreen",
"HotPink", "White", "Tomato", "Yellow", "Red", "Orange", "Gold", "LimeGreen", "Green",
"MediumOrchid", "Purple", "YellowGreen", "LightYellow", "MediumVioletRed", "PeachPuff", "DodgerBlue",
"Indigo", "Ivory", "DeepSkyBlue", "MistyRose", "DarkBlue", "MintCream", "Black", "OrangeRed",
"PaleGreen", "Gainsboro", "PaleVioletRed", "Lavender", "Cyan", "MidnightBlue", "LightPink",
"FireBrick", "Crimson", "DarkMagenta", "SteelBlue", "GreenYellow", "Brown", "DarkOrange",
"Goldenrod", "DarkSeaGreen", "DarkRed", "LavenderBlush", "Violet", "Maroon", "Khaki",
"WhiteSmoke", "Salmon", "Olive", "Orchid", "Fuchsia", "Pink", "LawnGreen", "Peru",
"Grey", "Moccasin", "Beige", "Magenta", "DarkOrchid", "LightCyan", "RosyBrown", "GhostWhite",
"MediumSeaGreen", "LemonChiffon", "Chocolate", "BurlyWood"
"HotPink", "Tomato", "Yellow", "Orange", "OrangeRed", "DarkOrange",
"LimeGreen", "PaleGreen", "GreenYellow", "LawnGreen",
"MediumVioletRed", "Indigo", "Magenta", "Violet", "Fuchsia",
"DodgerBlue", "DeepSkyBlue", "MidnightBlue"
};
QStringList m_colorsLeft;
QString getAvailableColor();
Expand Down

0 comments on commit fd9131c

Please sign in to comment.