From 9ab2b0b8cce043a21c057fb4ad032979b779b7fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Est=C3=A9vez?= Date: Tue, 10 Oct 2023 22:50:02 +0200 Subject: [PATCH] Handle tooltip comments of overlapping annotations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This handles the tooltips displaying the comments of overlapping annotations, as long as only one of the annotations that contain the mouse cursor has a tooltip. Before, SpectrogramPlot::getAnnotationComment() would return the comment of the first annotation that contains the mouse cursor, even if such a comment is an empty QString. The empty QString would cause that no tooltip is displayed. Now SpectrogramPlot::getAnnotationComment() only returns non-empty comments. Therefore, if only one annotation with a comment contains the mouse cursor, the tooltip for that comment will be displayed. This still does not handle the case when multiple annotations with comments contain the mouse cursor, since it is not clear what is best to do in this case. For now, SpectrogramPlot::getAnnotationComment() simply returns one of the applicable comments. Signed-off-by: Daniel Estévez --- src/spectrogramplot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spectrogramplot.cpp b/src/spectrogramplot.cpp index 3ab57ec..a0c9931 100644 --- a/src/spectrogramplot.cpp +++ b/src/spectrogramplot.cpp @@ -211,7 +211,7 @@ QString *SpectrogramPlot::mouseAnnotationComment(const QMouseEvent *event) { int mouse_y = pos.y(); for (auto& a : visibleAnnotationLocations) { - if (a.isInside(mouse_x, mouse_y)) { + if (!a.annotation.comment.isEmpty() && a.isInside(mouse_x, mouse_y)) { return &a.annotation.comment; } }