2 * SPDX-FileCopyrightText: 2008 Konstantin Heil <konst.heil@stud.uni-heidelberg.de>
4 * SPDX-License-Identifier: GPL-2.0-or-later
7 #ifndef TOOLTIPMANAGER_H
8 #define TOOLTIPMANAGER_H
15 class DolphinFileMetaDataWidget
;
21 * @brief Manages the tooltips for an item view.
23 * When hovering an item, a tooltip is shown after
24 * a short timeout. The tooltip is hidden again when the
25 * viewport is hovered or the item view has been left.
27 class ToolTipManager
: public QObject
32 enum class HideBehavior
{ Instantly
, Later
};
34 explicit ToolTipManager(QWidget
*parent
);
35 ~ToolTipManager() override
;
38 * Triggers the showing of the tooltip for the item \p item
39 * where the item has the maximum boundaries of \p itemRect.
40 * The tooltip manager takes care that the tooltip is shown
41 * slightly delayed and with a proper \p transientParent.
43 void showToolTip(const KFileItem
&item
, const QRectF
&itemRect
, QWindow
*transientParent
);
46 * Hides the currently shown tooltip.
48 void hideToolTip(const HideBehavior behavior
= HideBehavior::Later
);
52 * Is emitted when the user clicks a tag or a link
53 * in the metadata widget.
55 void urlActivated(const QUrl
&url
);
58 void startContentRetrieval();
59 void setPreviewPix(const KFileItem
&item
, const QPixmap
&pix
);
61 void slotMetaDataRequestFinished();
65 /// Timeout from requesting a tooltip until the tooltip
67 QTimer
*m_showToolTipTimer
;
69 /// Timeout from requesting a tooltip until the retrieving of
70 /// the tooltip content like preview and meta data gets started.
71 QTimer
*m_contentRetrievalTimer
;
73 /// Transient parent of the tooltip, mandatory on Wayland.
74 QWindow
*m_transientParent
;
76 QScopedPointer
<KToolTipWidget
> m_tooltipWidget
;
77 DolphinFileMetaDataWidget
*m_fileMetaDataWidget
= nullptr;
79 /// Whether ownership of the metadata widget was transferred
80 /// over to the KToolTipWidget (i.e. we should not delete it
82 bool m_fileMetaDatWidgetOwnershipTransferred
= false;
84 bool m_toolTipRequested
;
85 bool m_metaDataRequested
;
86 bool m_appliedWaitCursor
;