/usr/include/KF5/KWidgetsAddons/ktooltipwidget.h is in libkf5widgetsaddons-dev 5.44.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | /*
* This file is part of the KDE project
* Copyright (C) 2017 Elvis Angelaccio <elvis.angelaccio@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KTOOLTIPWIDGET_H
#define KTOOLTIPWIDGET_H
#include <kwidgetsaddons_export.h>
#include <QWidget>
/**
* @class KToolTipWidget ktooltipwidget.h KToolTipWidget
*
* @brief A tooltip that contains a QWidget.
*
* This widget allows to show a tooltip that contains another widget.
* If you only need to show text inside the tooltip, just use QWidget::setToolTip();
*
* To show the tooltip, you need to choose a position on the screen and also pass a
* transient parent window (recommended on X11 and required on Wayland).
* Use showAt() if you want to show the tooltip from a specific point.
* Use showUnder() if you want to show it under a given rectangle.
*
* You can use a single instance of this class to show as many tooltips as you want.
*
* The tooltip does not take ownership of the content widget if the latter already
* has a parent. While the tooltip is set as parent of the widget (by the layout),
* the old parent is restored when the widget is replaced by another widget
* and also when the tooltip is deleted.
*
* @since 5.30
* @author Elvis Angelaccio <elvis.angelaccio@kde.org>
*/
class KWIDGETSADDONS_EXPORT KToolTipWidget : public QWidget
{
Q_OBJECT
Q_PROPERTY(int hideDelay READ hideDelay WRITE setHideDelay)
public:
explicit KToolTipWidget(QWidget *parent = nullptr);
virtual ~KToolTipWidget();
/**
* Show a tooltip containing @p content. The pos() of the tooltip will be @p pos.
* You can call this method multiple times over the same KToolTipWidget instance
* (previously shown widgets will be removed from the tooltip's layout).
*
* @param transientParent will be set as the transient parent of the tooltip.
* @note The transient parent is required to show the tooltip on Wayland platforms.
*/
void showAt(const QPoint &pos, QWidget *content, QWindow *transientParent);
/**
* Show a tooltip containing @p content centered below @p rect. If there is not
* enough space in the screen below @p rect, the tooltip will be shown above
* @p rect, if possible, or at the bottom of the screen otherwise.
* You can call this method multiple times over the same KToolTipWidget instance
* (previously shown widgets will be removed from the tooltip's layout).
*
* Typically @p rect is the visualRect() of a QAbstractItemView:
* @snippet ktooltipwidget_test.cpp show_tooltip_widget
*
* @param transientParent will be set as the transient parent of the tooltip.
* @note The transient parent is required to show the tooltip on Wayland platforms.
*/
void showBelow(const QRect &rect, QWidget *content, QWindow *transientParent);
/**
* @return Delay (in ms) after which hideLater() will hide the tooltip. Default is 500.
* @see hideLater(), setHideDelay()
*/
int hideDelay() const;
public Q_SLOTS:
/**
* Hide the tooltip after a delay of hideDelay() ms (to allow interaction with the tooltip's widget).
* If hideDelay() is 0, this is equivalent to hide().
* @see hideDelay()
*/
void hideLater();
/**
* Set after how many ms hideLater() will hide the tooltip.
* @see hideLater(), hideDelay()
*/
void setHideDelay(int delay);
Q_SIGNALS:
/**
* The tooltip has been hidden and the tooltip's widget is no longer visible.
* This signal can be used to delete the tooltip's widget.
*/
void hidden();
protected:
void enterEvent(QEvent *) Q_DECL_OVERRIDE;
void hideEvent(QHideEvent *) Q_DECL_OVERRIDE;
void leaveEvent(QEvent *) Q_DECL_OVERRIDE;
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
private:
class KToolTipWidgetPrivate;
QScopedPointer<KToolTipWidgetPrivate> d;
Q_DISABLE_COPY(KToolTipWidget)
};
#endif
|