From: Manuel Nickschas Date: Tue, 24 Jul 2018 21:20:45 +0000 (+0200) Subject: qtui: Properly render hovered-upon clickables X-Git-Tag: 0.13-rc2~73 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=77f32bd74c6140060007ace39f70f2bbd8aeebe9 qtui: Properly render hovered-upon clickables Additional formats given to QTextLayout::draw() are not cumulative. Since we were using this feature for rendering both selections and active (hovered-upon) clickables, things would break when both overlapped. In particular, a highlighted *and* selected URL would vanish while being hovered. Fix this by explicitly calculating the range of affected formats for both selections and active clickables, taking overlap into account. Remove special handling in ContentsChatItem in favor of the more generic solution. Use the newly-introduced "hovered" message label to determine how an active clickable should be rendered, rather than hardcoding an underline. --- diff --git a/src/qtui/chatitem.cpp b/src/qtui/chatitem.cpp index 4da2bb47..10b7d780 100644 --- a/src/qtui/chatitem.cpp +++ b/src/qtui/chatitem.cpp @@ -20,6 +20,9 @@ #include "chatitem.h" +#include +#include + #include #include #include @@ -286,36 +289,92 @@ void ChatItem::overlayFormat(UiStyle::FormatList &fmtList, quint16 start, quint1 QVector ChatItem::additionalFormats() const { - return selectionFormats(); -} + // Calculate formats to overlay (only) if there's a selection, and/or a hovered clickable + if (!hasSelection() && !hasActiveClickable()) { + return {}; + } + using Label = UiStyle::MessageLabel; + using Format = UiStyle::Format; -QVector ChatItem::selectionFormats() const -{ - if (!hasSelection()) - return QVector(); + Label itemLabel = data(ChatLineModel::MsgLabelRole).value