MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / getDatasetColor

Method getDatasetColor

app/src/SerialStudio.cpp:692–715  ·  view source on GitHub ↗

* @brief Retrieves the appropriate color for a dataset based on its index. */

Source from the content-addressed store, hash-verified

690 * @brief Retrieves the appropriate color for a dataset based on its index.
691 */
692QColor SerialStudio::getDatasetColor(const int index)
693{
694 static const auto* theme = &Misc::ThemeManager::instance();
695 const auto idx = index - 1;
696 const auto colors = theme->widgetColors();
697
698 if (colors.isEmpty())
699 return QColor(Qt::gray);
700
701 if (idx < 0)
702 return QColor(Qt::gray);
703
704 const auto count = colors.count();
705 if (idx < count)
706 return colors.at(idx);
707
708 else {
709 const auto cycle = idx / count;
710 const auto position = idx % count;
711 const auto offset = (cycle * 7) % count;
712 const auto colorIdx = (position + offset) % count;
713 return colors.at(colorIdx);
714 }
715}
716
717/**
718 * @brief Returns the top gradient color for the given device source index.

Callers

nothing calls this directly

Calls 2

isEmptyMethod · 0.80
countMethod · 0.45

Tested by

no test coverage detected