From f11f19429549fef747d14d17a08772c6f3e67c65 Mon Sep 17 00:00:00 2001 From: Bryant Date: Tue, 4 Jun 2013 11:42:13 -0700 Subject: [PATCH] Curve colors are only displayed when curves are being plotted. Also fixed bug when generating CSS coloring from color. --- src/ui/linechart/LinechartWidget.cc | 40 +++++++++++++++-------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/ui/linechart/LinechartWidget.cc b/src/ui/linechart/LinechartWidget.cc index f30de05e0..38a8efc54 100644 --- a/src/ui/linechart/LinechartWidget.cc +++ b/src/ui/linechart/LinechartWidget.cc @@ -775,17 +775,13 @@ void LinechartWidget::recolor() foreach (QString key, colorIcons.keys()) { - - // FIXME -// if (activePlot) - QString colorstyle; - QColor color = activePlot->getColorForCurve(key); - colorstyle = colorstyle.sprintf("QWidget { background-color: #%X%X%X; }", color.red(), color.green(), color.blue()); QWidget* colorIcon = colorIcons.value(key, 0); - if (colorIcon) + if (colorIcon && !colorIcon->styleSheet().isEmpty()) { + QString colorstyle; + QColor color = activePlot->getColorForCurve(key); + colorstyle = colorstyle.sprintf("QWidget { background-color: #%02X%02X%02X; }", color.red(), color.green(), color.blue()); colorIcon->setStyleSheet(colorstyle); - colorIcon->setAutoFillBackground(true); } } } @@ -975,8 +971,9 @@ void LinechartWidget::setPlotInterval(quint64 interval) /** * @brief Take the click of a curve activation / deactivation button. - * This method allows to map a button to a plot curve.The text of the - * button must equal the curve name to activate / deactivate. + * This method allows to map a button to a plot curve. The text of the + * button must equal the curve name to activate / deactivate. If the checkbox + * was clicked, show the curve color, otherwise clear the coloring. * * @param checked The visibility of the curve: true to display the curve, false otherwise **/ @@ -988,17 +985,22 @@ void LinechartWidget::takeButtonClick(bool checked) if(button != NULL) { activePlot->setVisible(button->objectName(), checked); - - QColor color = activePlot->getColorForCurve(button->objectName()); - if(color.isValid()) + QWidget* colorIcon = colorIcons.value(button->objectName(), 0); + if (colorIcon) { - QString colorstyle; - colorstyle = colorstyle.sprintf("QWidget { background-color: #%X%X%X; }", color.red(), color.green(), color.blue()); - QWidget* colorIcon = colorIcons.value(button->objectName(), 0); - if (colorIcon) + if (checked) + { + QColor color = activePlot->getColorForCurve(button->objectName()); + if (color.isValid()) + { + QString colorstyle; + colorstyle = colorstyle.sprintf("QWidget { background-color: #%02X%02X%02X; }", color.red(), color.green(), color.blue()); + colorIcon->setStyleSheet(colorstyle); + } + } + else { - colorIcon->setStyleSheet(colorstyle); - colorIcon->setAutoFillBackground(true); + colorIcon->setStyleSheet(""); } } } -- 2.22.0