Warning, file /system/dolphin/src/views/tooltips/tooltipmanager.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * SPDX-FileCopyrightText: 2008 Konstantin Heil <konst.heil@stud.uni-heidelberg.de> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef TOOLTIPMANAGER_H 0008 #define TOOLTIPMANAGER_H 0009 0010 #include <KFileItem> 0011 0012 #include <QObject> 0013 #include <QRect> 0014 0015 class DolphinFileMetaDataWidget; 0016 class KToolTipWidget; 0017 class QTimer; 0018 class QWindow; 0019 0020 /** 0021 * @brief Manages the tooltips for an item view. 0022 * 0023 * When hovering an item, a tooltip is shown after 0024 * a short timeout. The tooltip is hidden again when the 0025 * viewport is hovered or the item view has been left. 0026 */ 0027 class ToolTipManager : public QObject 0028 { 0029 Q_OBJECT 0030 0031 public: 0032 enum class HideBehavior { Instantly, Later }; 0033 0034 explicit ToolTipManager(QWidget *parent); 0035 ~ToolTipManager() override; 0036 0037 /** 0038 * Triggers the showing of the tooltip for the item \p item 0039 * where the item has the maximum boundaries of \p itemRect. 0040 * The tooltip manager takes care that the tooltip is shown 0041 * slightly delayed and with a proper \p transientParent. 0042 */ 0043 void showToolTip(const KFileItem &item, const QRectF &itemRect, QWindow *transientParent); 0044 0045 /** 0046 * Hides the currently shown tooltip. 0047 */ 0048 void hideToolTip(const HideBehavior behavior = HideBehavior::Later); 0049 0050 Q_SIGNALS: 0051 /** 0052 * Is emitted when the user clicks a tag or a link 0053 * in the metadata widget. 0054 */ 0055 void urlActivated(const QUrl &url); 0056 0057 private Q_SLOTS: 0058 void startContentRetrieval(); 0059 void setPreviewPix(const KFileItem &item, const QPixmap &pix); 0060 void previewFailed(); 0061 void slotMetaDataRequestFinished(); 0062 void showToolTip(); 0063 0064 private: 0065 /// Timeout from requesting a tooltip until the tooltip 0066 /// should be shown 0067 QTimer *m_showToolTipTimer; 0068 0069 /// Timeout from requesting a tooltip until the retrieving of 0070 /// the tooltip content like preview and meta data gets started. 0071 QTimer *m_contentRetrievalTimer; 0072 0073 /// Transient parent of the tooltip, mandatory on Wayland. 0074 QWindow *m_transientParent; 0075 0076 QScopedPointer<KToolTipWidget> m_tooltipWidget; 0077 DolphinFileMetaDataWidget *m_fileMetaDataWidget = nullptr; 0078 0079 /// Whether ownership of the metadata widget was transferred 0080 /// over to the KToolTipWidget (i.e. we should not delete it 0081 /// anymore) 0082 bool m_fileMetaDatWidgetOwnershipTransferred = false; 0083 0084 bool m_toolTipRequested; 0085 bool m_metaDataRequested; 0086 bool m_appliedWaitCursor; 0087 int m_margin; 0088 KFileItem m_item; 0089 QRect m_itemRect; 0090 }; 0091 0092 #endif