From 28e1a3e634236bf271cab8fa7ef4178656c9f506 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 16 Sep 2020 12:24:28 +0100 Subject: [PATCH] Correctly fix reverse url numering --- src/filterHotSpots/FilterChain.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/filterHotSpots/FilterChain.cpp b/src/filterHotSpots/FilterChain.cpp index b8f49636..bd21e7b6 100644 --- a/src/filterHotSpots/FilterChain.cpp +++ b/src/filterHotSpots/FilterChain.cpp @@ -249,15 +249,12 @@ void FilterChain::paint(TerminalDisplay* td, QPainter& painter) const auto spots = hotSpots(); int urlNumber; - int urlNumInc; // TODO: Remove _reverseUrllHints from TerminalDisplay. if (_reverseUrlHints) { // TODO: Access reverseUrlHints from the profile, here. urlNumber = count(HotSpot::Link); - urlNumInc = -1; } else { urlNumber = 0; - urlNumInc = 1; } for (const auto &spot : spots) { @@ -267,9 +264,12 @@ void FilterChain::paint(TerminalDisplay* td, QPainter& painter) region = spotRegion.first; QRect r = spotRegion.second; - // TODO: Move this paint code to HotSpot->drawHint(); - // TODO: Fix the Url Hints access from the Profile. if (_showUrlHint && spot->type() == HotSpot::Link) { + // if we are in reverse url hints mode, we need to get the proper number, + // before trying to display the hint. if we don't do that we miss mint nr. '0'. + if (_reverseUrlHints) { + urlNumber -= 1; + } if (urlNumber >= 0 && urlNumber < 10) { // Position at the beginning of the URL QRect hintRect(*region.begin()); @@ -279,7 +279,10 @@ void FilterChain::paint(TerminalDisplay* td, QPainter& painter) painter.drawRect(hintRect.adjusted(0, 0, -1, -1)); painter.drawText(hintRect, Qt::AlignCenter, QString::number(urlNumber)); } - urlNumber += urlNumInc; + // But if we are not in reverse mode, we need to increase it later. + if (!_reverseUrlHints) { + urlNumber += 1; + } } }