Skip to content

Commit

Permalink
Check if cursor is still on the tooltip index
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Nov 16, 2023
1 parent d8c4912 commit 62eb600
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/widget/wlibrarytableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,16 +396,21 @@ void WLibraryTableView::dataChanged(
const QModelIndex& topLeft,
const QModelIndex& bottomRight,
const QVector<int>& roles) {
for (auto& role : roles) {
// If the tooltip is still visible update with the loaded cover.
if (role == Qt::ToolTipRole && QToolTip::isVisible()) {
for (const auto& role : roles) {
// Note: At this point the tooltip is already showing
// "Fetching image ..." or still in an effect progress.
// QToolTip::isVisible() is false for the later.
if (role == Qt::ToolTipRole) {
QPoint globalPos = QCursor::pos();
QWidget* pViewPort = QApplication::widgetAt(QCursor::pos());
QWidget* pViewPort = QApplication::widgetAt(globalPos);
if (pViewPort) {
QHelpEvent toolTipEvent(QEvent::ToolTip,
pViewPort->mapFromGlobal(globalPos),
globalPos);
viewportEvent(&toolTipEvent);
QPoint viewPortPos = pViewPort->mapFromGlobal(globalPos);
if (indexAt(viewPortPos) == topLeft) {
QHelpEvent toolTipEvent(QEvent::ToolTip,
pViewPort->mapFromGlobal(globalPos),
globalPos);
viewportEvent(&toolTipEvent);
}
}
}
}
Expand Down

0 comments on commit 62eb600

Please sign in to comment.