From c9244c0684b591ea8417b37b20c0ded5bf0190a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sat, 28 Mar 2020 23:28:39 +0100 Subject: [PATCH] Fixed broken graph color change when secondary graphs present --- src/GUI/graphview.cpp | 20 ++++++++++++++++++-- src/GUI/graphview.h | 1 - 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/GUI/graphview.cpp b/src/GUI/graphview.cpp index ded23632..61f6abf9 100644 --- a/src/GUI/graphview.cpp +++ b/src/GUI/graphview.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -494,8 +495,23 @@ void GraphView::setPalette(const Palette &palette) _palette = palette; _palette.reset(); - for (int i = 0; i < _graphs.count(); i++) - _graphs.at(i)->setColor(_palette.nextColor()); + QSet secondary; + for (int i = 0; i < _graphs.count(); i++) { + GraphItem *g = _graphs[i]; + if (g->secondaryGraph()) + secondary.insert(g->secondaryGraph()); + } + + for (int i = 0; i < _graphs.count(); i++) { + GraphItem *g = _graphs[i]; + if (secondary.contains(g)) + continue; + + QColor color(_palette.nextColor()); + g->setColor(color); + if (g->secondaryGraph()) + g->secondaryGraph()->setColor(color); + } } void GraphView::setGraphWidth(int width) diff --git a/src/GUI/graphview.h b/src/GUI/graphview.h index 3cdf51e7..05ac6cb0 100644 --- a/src/GUI/graphview.h +++ b/src/GUI/graphview.h @@ -3,7 +3,6 @@ #include #include -#include #include "data/graph.h" #include "palette.h" #include "units.h"