diff --git a/src/backend/worksheet/plots/cartesian/CartesianPlot.h b/src/backend/worksheet/plots/cartesian/CartesianPlot.h --- a/src/backend/worksheet/plots/cartesian/CartesianPlot.h +++ b/src/backend/worksheet/plots/cartesian/CartesianPlot.h @@ -250,6 +250,7 @@ void updateLegend(); void childAdded(const AbstractAspect*); void childRemoved(const AbstractAspect* parent, const AbstractAspect* before, const AbstractAspect* child); + void childHovered(); void xDataChanged(); void yDataChanged(); diff --git a/src/backend/worksheet/plots/cartesian/CartesianPlot.cpp b/src/backend/worksheet/plots/cartesian/CartesianPlot.cpp --- a/src/backend/worksheet/plots/cartesian/CartesianPlot.cpp +++ b/src/backend/worksheet/plots/cartesian/CartesianPlot.cpp @@ -1390,6 +1390,12 @@ updateLegend(); } + // must be done, because the hover for the curves is done in this class + // and they must be unhovered, if another child is selected + const WorksheetElement* element = dynamic_cast(child); + if (element) + connect(element, &WorksheetElement::hovered, + this, &CartesianPlot::childHovered); } if (!isLoading()) { @@ -1458,6 +1464,25 @@ } } +/*! + * \brief CartesianPlot::childHovered + * Unhover all curves, when another child was hovered. This unhover must be done here, + * because the hover of the curves is handled from the CartesianPlot it self (see hoverMoveEvent) + */ +void CartesianPlot::childHovered() { + Q_D(CartesianPlot); + bool curveSender = dynamic_cast(QObject::sender()) != nullptr; + if (!d->isSelected()) { + if (d->m_hovered) + d->m_hovered = false; + d->update(); + } + if (!curveSender) { + for (auto curve: children()) + curve->setHover(false); + } +} + void CartesianPlot::updateLegend() { if (m_legend) m_legend->retransform(); @@ -2684,6 +2709,9 @@ update(); } else if (mouseMode == CartesianPlot::MouseMode::SelectionMode) { // hover the nearest curve to the mousepointer + // this must be done here, because there exist no ignore + // like for the mousePressEvent, so to check all curves, this + // must be done here bool curve_hovered = false; QVector curves = q->children(); for (int i=curves.count() - 1; i >= 0; i--){ // because the last curve is above the other curves