From a0bc76d98344c3198668ff3d4fbd81c72b94d05d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 19 Sep 2023 22:05:16 +0200 Subject: [PATCH] refresh tooltip --- src/library/basetracktablemodel.cpp | 2 +- src/widget/wlibrarytableview.cpp | 23 +++++++++++++++++++++++ src/widget/wlibrarytableview.h | 5 +++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/library/basetracktablemodel.cpp b/src/library/basetracktablemodel.cpp index ae2cffe22b19..83243cb740ed 100644 --- a/src/library/basetracktablemodel.cpp +++ b/src/library/basetracktablemodel.cpp @@ -567,7 +567,7 @@ QVariant BaseTrackTableModel::composeCoverArtToolTipHtml( this, coverInfo, absoluteHeightOfCoverartToolTip); - return QVariant(); + return tr("Fetching image ..."); } QByteArray data; QBuffer buffer(&data); diff --git a/src/widget/wlibrarytableview.cpp b/src/widget/wlibrarytableview.cpp index 9b1943cc5d98..fd8b774769ed 100644 --- a/src/widget/wlibrarytableview.cpp +++ b/src/widget/wlibrarytableview.cpp @@ -1,10 +1,13 @@ #include "widget/wlibrarytableview.h" +#include #include #include #include +#include #include #include +#include #include "library/trackmodel.h" #include "moc_wlibrarytableview.cpp" @@ -391,3 +394,23 @@ QModelIndex WLibraryTableView::moveCursor(CursorAction cursorAction, return QTableView::moveCursor(cursorAction, modifiers); } + +void WLibraryTableView::dataChanged( + const QModelIndex& topLeft, + const QModelIndex& bottomRight, + const QVector& roles) { + for (auto& role : roles) { + // If the tooltip is still visible update with the loaded cover. + if (role == Qt::ToolTipRole && QToolTip::isVisible()) { + QPoint globalPos = QCursor::pos(); + QWidget* pViewPort = QApplication::widgetAt(QCursor::pos()); + if (pViewPort) { + QHelpEvent toolTipEvent(QEvent::ToolTip, + pViewPort->mapFromGlobal(globalPos), + globalPos); + viewportEvent(&toolTipEvent); + } + } + } + QAbstractItemView::dataChanged(topLeft, bottomRight, roles); +}; diff --git a/src/widget/wlibrarytableview.h b/src/widget/wlibrarytableview.h index c48a9c171753..4fb63b3932ba 100644 --- a/src/widget/wlibrarytableview.h +++ b/src/widget/wlibrarytableview.h @@ -52,6 +52,11 @@ class WLibraryTableView : public QTableView, public virtual LibraryView { /// @param optional: index, otherwise row/column member vars are used void restoreCurrentIndex(const QModelIndex& index = QModelIndex()); + void dataChanged( + const QModelIndex& topLeft, + const QModelIndex& bottomRight, + const QVector& roles = QVector()) override; + signals: void loadTrack(TrackPointer pTrack); void loadTrackToPlayer(TrackPointer pTrack, const QString& group, bool play = false);