diff --git a/src/globalsearch/globalsearchwidget.cpp b/src/globalsearch/globalsearchwidget.cpp index 34a68b1c6..cd89fc32a 100644 --- a/src/globalsearch/globalsearchwidget.cpp +++ b/src/globalsearch/globalsearchwidget.cpp @@ -310,8 +310,10 @@ void GlobalSearchWidget::AddResults(int id, const SearchProvider::ResultList& re order_arrived_counter_ ++; - if (!closed_since_search_began_) + if (!closed_since_search_began_) { RepositionPopup(); + UpdateTooltipPosition(); + } } void GlobalSearchWidget::RepositionPopup() { @@ -690,12 +692,25 @@ void GlobalSearchWidget::UpdateTooltip() { tooltip_->SetActions(actions_); } + tooltip_->SetResults(results); + UpdateTooltipPosition(); +} + +void GlobalSearchWidget::UpdateTooltipPosition() { + if (!tooltip_ || !view_->isVisible()) + return; + + const QModelIndex current = view_->selectionModel()->currentIndex(); + if (!current.isValid()) { + tooltip_->hide(); + return; + } + const QRect item_rect = view_->visualRect(current); const QPoint popup_pos = item_rect.topRight() + QPoint(-GlobalSearchTooltip::kArrowWidth, item_rect.height() / 2); - tooltip_->SetResults(results); tooltip_->ShowAt(view_->mapToGlobal(popup_pos)); } diff --git a/src/globalsearch/globalsearchwidget.h b/src/globalsearch/globalsearchwidget.h index a6ac19a33..e2a6fc99a 100644 --- a/src/globalsearch/globalsearchwidget.h +++ b/src/globalsearch/globalsearchwidget.h @@ -99,6 +99,7 @@ private slots: void HidePopup(); void UpdateTooltip(); + void UpdateTooltipPosition(); void SwapModels(); diff --git a/src/translations/translations.pot b/src/translations/translations.pot index 79283ea0f..9dc461d65 100644 --- a/src/translations/translations.pot +++ b/src/translations/translations.pot @@ -4542,7 +4542,7 @@ msgstr "" msgid "does not contain" msgstr "" -#: globalsearch/globalsearchwidget.cpp:711 +#: globalsearch/globalsearchwidget.cpp:726 msgid "e.g." msgstr ""