* @brief Retrieves the appropriate color for a dataset based on its index. */
| 690 | * @brief Retrieves the appropriate color for a dataset based on its index. |
| 691 | */ |
| 692 | QColor 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. |