mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-28 03:21:56 +00:00
Reuse metadata widget when creating tooltips
Currently any time we hover the mouse over a file we create a new DolphinFileMetaDataWidget (even when we don't actually show a tooltip). That is quite wasteful Instead we can reuse the existing instance and only change the URL
This commit is contained in:
parent
f509d41baf
commit
b7fbd19a76
|
@ -61,6 +61,13 @@ ToolTipManager::ToolTipManager(QWidget* parent) :
|
||||||
connect(m_contentRetrievalTimer, &QTimer::timeout, this, &ToolTipManager::startContentRetrieval);
|
connect(m_contentRetrievalTimer, &QTimer::timeout, this, &ToolTipManager::startContentRetrieval);
|
||||||
|
|
||||||
Q_ASSERT(m_contentRetrievalTimer->interval() < m_showToolTipTimer->interval());
|
Q_ASSERT(m_contentRetrievalTimer->interval() < m_showToolTipTimer->interval());
|
||||||
|
|
||||||
|
// Only start the retrieving of the content, when the mouse has been over this
|
||||||
|
// item for 200 milliseconds. This prevents a lot of useless preview jobs and
|
||||||
|
// meta data retrieval, when passing rapidly over a lot of items.
|
||||||
|
m_fileMetaDataWidget = new DolphinFileMetaDataWidget(parent);
|
||||||
|
connect(m_fileMetaDataWidget, &DolphinFileMetaDataWidget::metaDataRequestFinished, this, &ToolTipManager::slotMetaDataRequestFinished);
|
||||||
|
connect(m_fileMetaDataWidget, &DolphinFileMetaDataWidget::urlActivated, this, &ToolTipManager::urlActivated);
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolTipManager::~ToolTipManager()
|
ToolTipManager::~ToolTipManager()
|
||||||
|
@ -69,7 +76,7 @@ ToolTipManager::~ToolTipManager()
|
||||||
|
|
||||||
void ToolTipManager::showToolTip(const KFileItem& item, const QRectF& itemRect, QWindow *transientParent)
|
void ToolTipManager::showToolTip(const KFileItem& item, const QRectF& itemRect, QWindow *transientParent)
|
||||||
{
|
{
|
||||||
hideToolTip();
|
hideToolTip(HideBehavior::Instantly);
|
||||||
|
|
||||||
m_itemRect = itemRect.toRect();
|
m_itemRect = itemRect.toRect();
|
||||||
|
|
||||||
|
@ -78,15 +85,6 @@ void ToolTipManager::showToolTip(const KFileItem& item, const QRectF& itemRect,
|
||||||
|
|
||||||
m_transientParent = transientParent;
|
m_transientParent = transientParent;
|
||||||
|
|
||||||
// Only start the retrieving of the content, when the mouse has been over this
|
|
||||||
// item for 200 milliseconds. This prevents a lot of useless preview jobs and
|
|
||||||
// meta data retrieval, when passing rapidly over a lot of items.
|
|
||||||
m_fileMetaDataWidget.reset(new DolphinFileMetaDataWidget());
|
|
||||||
connect(m_fileMetaDataWidget.data(), &DolphinFileMetaDataWidget::metaDataRequestFinished,
|
|
||||||
this, &ToolTipManager::slotMetaDataRequestFinished);
|
|
||||||
connect(m_fileMetaDataWidget.data(), &DolphinFileMetaDataWidget::urlActivated,
|
|
||||||
this, &ToolTipManager::urlActivated);
|
|
||||||
|
|
||||||
m_contentRetrievalTimer->start();
|
m_contentRetrievalTimer->start();
|
||||||
m_showToolTipTimer->start();
|
m_showToolTipTimer->start();
|
||||||
m_toolTipRequested = true;
|
m_toolTipRequested = true;
|
||||||
|
@ -220,7 +218,7 @@ void ToolTipManager::showToolTip()
|
||||||
if (!m_tooltipWidget) {
|
if (!m_tooltipWidget) {
|
||||||
m_tooltipWidget.reset(new KToolTipWidget());
|
m_tooltipWidget.reset(new KToolTipWidget());
|
||||||
}
|
}
|
||||||
m_tooltipWidget->showBelow(m_itemRect, m_fileMetaDataWidget.data(), m_transientParent);
|
m_tooltipWidget->showBelow(m_itemRect, m_fileMetaDataWidget, m_transientParent);
|
||||||
m_toolTipRequested = false;
|
m_toolTipRequested = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ private:
|
||||||
QWindow* m_transientParent;
|
QWindow* m_transientParent;
|
||||||
|
|
||||||
QScopedPointer<KToolTipWidget> m_tooltipWidget;
|
QScopedPointer<KToolTipWidget> m_tooltipWidget;
|
||||||
QScopedPointer<DolphinFileMetaDataWidget> m_fileMetaDataWidget;
|
DolphinFileMetaDataWidget *m_fileMetaDataWidget;
|
||||||
|
|
||||||
bool m_toolTipRequested;
|
bool m_toolTipRequested;
|
||||||
bool m_metaDataRequested;
|
bool m_metaDataRequested;
|
||||||
|
|
Loading…
Reference in a new issue