Port QT_NO_TOOLTIP to QT_CONFIG(tooltip)

We remove the QT_NO_TOOLTIP check from qstandarditemmodel.h, because as
the 'tooltip' feature is in QtWidgets, we cannot use it properly in
QtGui. Also this affects just two non-virtual inline methods, i.e. it
has no effect on library size.

Task-number: QTBUG-82785
Change-Id: Ic166f14fb1cf3e9dd789573a6b9db6a87fb50e10
Reviewed-by: Tasuku Suzuki <tasuku.suzuki@kdab.com>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
This commit is contained in:
Joerg Bornemann 2020-04-07 17:49:43 +02:00
parent fbb7c98e91
commit 1c80d056e4
37 changed files with 96 additions and 76 deletions

View File

@ -79,12 +79,10 @@ public:
} }
inline void setIcon(const QIcon &icon); inline void setIcon(const QIcon &icon);
#ifndef QT_NO_TOOLTIP
inline QString toolTip() const { inline QString toolTip() const {
return qvariant_cast<QString>(data(Qt::ToolTipRole)); return qvariant_cast<QString>(data(Qt::ToolTipRole));
} }
inline void setToolTip(const QString &toolTip); inline void setToolTip(const QString &toolTip);
#endif
#ifndef QT_NO_STATUSTIP #ifndef QT_NO_STATUSTIP
inline QString statusTip() const { inline QString statusTip() const {
@ -260,10 +258,8 @@ inline void QStandardItem::setText(const QString &atext)
inline void QStandardItem::setIcon(const QIcon &aicon) inline void QStandardItem::setIcon(const QIcon &aicon)
{ setData(aicon, Qt::DecorationRole); } { setData(aicon, Qt::DecorationRole); }
#ifndef QT_NO_TOOLTIP
inline void QStandardItem::setToolTip(const QString &atoolTip) inline void QStandardItem::setToolTip(const QString &atoolTip)
{ setData(atoolTip, Qt::ToolTipRole); } { setData(atoolTip, Qt::ToolTipRole); }
#endif
#ifndef QT_NO_STATUSTIP #ifndef QT_NO_STATUSTIP
inline void QStandardItem::setStatusTip(const QString &astatusTip) inline void QStandardItem::setStatusTip(const QString &astatusTip)

View File

@ -57,7 +57,9 @@
#endif #endif
#include <qstyle.h> #include <qstyle.h>
#include <qstyleoption.h> #include <qstyleoption.h>
#if QT_CONFIG(tooltip)
#include <qtooltip.h> #include <qtooltip.h>
#endif
#if QT_CONFIG(whatsthis) #if QT_CONFIG(whatsthis)
#include <qwhatsthis.h> #include <qwhatsthis.h>
#endif #endif

View File

@ -48,7 +48,9 @@
#if QT_CONFIG(label) #if QT_CONFIG(label)
#include "qlabel.h" #include "qlabel.h"
#endif #endif
#if QT_CONFIG(tooltip)
#include "qtooltip.h" #include "qtooltip.h"
#endif
#if QT_CONFIG(whatsthis) #if QT_CONFIG(whatsthis)
#include "qwhatsthis.h" #include "qwhatsthis.h"
#endif #endif
@ -425,7 +427,7 @@ QString QAccessibleWidget::text(QAccessible::Text t) const
break; break;
case QAccessible::Description: case QAccessible::Description:
str = widget()->accessibleDescription(); str = widget()->accessibleDescription();
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
if (str.isEmpty()) if (str.isEmpty())
str = widget()->toolTip(); str = widget()->toolTip();
#endif #endif

View File

@ -545,7 +545,7 @@ void *QAccessibleDisplay::interface_cast(QAccessible::InterfaceType t)
/*! \internal */ /*! \internal */
QString QAccessibleDisplay::imageDescription() const QString QAccessibleDisplay::imageDescription() const
{ {
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
return widget()->toolTip(); return widget()->toolTip();
#else #else
return QString(); return QString();

View File

@ -2239,7 +2239,7 @@ bool QGraphicsItem::isBlockedByModalPanel(QGraphicsItem **blockingPanel) const
return false; return false;
} }
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
/*! /*!
Returns the item's tool tip, or an empty QString if no tool tip has been Returns the item's tool tip, or an empty QString if no tool tip has been
set. set.
@ -2263,7 +2263,7 @@ void QGraphicsItem::setToolTip(const QString &toolTip)
d_ptr->setExtra(QGraphicsItemPrivate::ExtraToolTip, toolTipVariant.toString()); d_ptr->setExtra(QGraphicsItemPrivate::ExtraToolTip, toolTipVariant.toString());
itemChange(ItemToolTipHasChanged, toolTipVariant); itemChange(ItemToolTipHasChanged, toolTipVariant);
} }
#endif // QT_NO_TOOLTIP #endif // QT_CONFIG(tooltip)
#ifndef QT_NO_CURSOR #ifndef QT_NO_CURSOR
/*! /*!

View File

@ -191,7 +191,7 @@ public:
void setPanelModality(PanelModality panelModality); void setPanelModality(PanelModality panelModality);
bool isBlockedByModalPanel(QGraphicsItem **blockingPanel = nullptr) const; bool isBlockedByModalPanel(QGraphicsItem **blockingPanel = nullptr) const;
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
QString toolTip() const; QString toolTip() const;
void setToolTip(const QString &toolTip); void setToolTip(const QString &toolTip);
#endif #endif

View File

@ -890,7 +890,7 @@ bool QGraphicsProxyWidget::event(QEvent *event)
} }
break; break;
} }
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
case QEvent::GraphicsSceneHelp: { case QEvent::GraphicsSceneHelp: {
// Propagate the help event (for tooltip) to the widget under mouse // Propagate the help event (for tooltip) to the widget under mouse
if (d->lastWidgetUnderMouse) { if (d->lastWidgetUnderMouse) {
@ -981,7 +981,7 @@ bool QGraphicsProxyWidget::eventFilter(QObject *object, QEvent *event)
d->styleChangeMode = QGraphicsProxyWidgetPrivate::NoMode; d->styleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
} }
break; break;
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
case QEvent::ToolTipChange: case QEvent::ToolTipChange:
// Propagate tooltip change to the proxy. // Propagate tooltip change to the proxy.
if (!d->tooltipChangeMode) { if (!d->tooltipChangeMode) {

View File

@ -238,7 +238,9 @@
#include <QtGui/qpolygon.h> #include <QtGui/qpolygon.h>
#include <QtGui/qtouchdevice.h> #include <QtGui/qtouchdevice.h>
#include <QtWidgets/qstyleoption.h> #include <QtWidgets/qstyleoption.h>
#if QT_CONFIG(tooltip)
#include <QtWidgets/qtooltip.h> #include <QtWidgets/qtooltip.h>
#endif
#include <QtGui/qtransform.h> #include <QtGui/qtransform.h>
#include <QtGui/qinputmethod.h> #include <QtGui/qinputmethod.h>
#include <private/qapplication_p.h> #include <private/qapplication_p.h>
@ -3729,7 +3731,7 @@ void QGraphicsScene::focusOutEvent(QFocusEvent *focusEvent)
*/ */
void QGraphicsScene::helpEvent(QGraphicsSceneHelpEvent *helpEvent) void QGraphicsScene::helpEvent(QGraphicsSceneHelpEvent *helpEvent)
{ {
#ifdef QT_NO_TOOLTIP #if !QT_CONFIG(tooltip)
Q_UNUSED(helpEvent); Q_UNUSED(helpEvent);
#else #else
// Find the first item that does tooltips // Find the first item that does tooltips
@ -3860,7 +3862,7 @@ bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEv
*/ */
void QGraphicsScenePrivate::leaveScene(QWidget *viewport) void QGraphicsScenePrivate::leaveScene(QWidget *viewport)
{ {
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
QToolTip::hideText(); QToolTip::hideText();
#endif #endif
QGraphicsView *view = qobject_cast<QGraphicsView *>(viewport->parent()); QGraphicsView *view = qobject_cast<QGraphicsView *>(viewport->parent());

View File

@ -2888,7 +2888,7 @@ bool QGraphicsView::viewportEvent(QEvent *event)
QCoreApplication::sendEvent(d->scene, event); QCoreApplication::sendEvent(d->scene, event);
break; break;
} }
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
case QEvent::ToolTip: { case QEvent::ToolTip: {
QHelpEvent *toolTip = static_cast<QHelpEvent *>(event); QHelpEvent *toolTip = static_cast<QHelpEvent *>(event);
QGraphicsSceneHelpEvent helpEvent(QEvent::GraphicsSceneHelp); QGraphicsSceneHelpEvent helpEvent(QEvent::GraphicsSceneHelp);

View File

@ -45,7 +45,9 @@
#if QT_CONFIG(whatsthis) #if QT_CONFIG(whatsthis)
#include <qwhatsthis.h> #include <qwhatsthis.h>
#endif #endif
#if QT_CONFIG(tooltip)
#include <qtooltip.h> #include <qtooltip.h>
#endif
#include <qevent.h> #include <qevent.h>
#include <qstring.h> #include <qstring.h>
#include <qdebug.h> #include <qdebug.h>
@ -369,7 +371,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
return false; return false;
Q_D(QAbstractItemDelegate); Q_D(QAbstractItemDelegate);
switch (event->type()) { switch (event->type()) {
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
case QEvent::ToolTip: { case QEvent::ToolTip: {
QHelpEvent *he = static_cast<QHelpEvent*>(event); QHelpEvent *he = static_cast<QHelpEvent*>(event);
const int precision = inherits("QItemDelegate") ? 10 : 6; // keep in sync with DBL_DIG in qitemdelegate.cpp const int precision = inherits("QItemDelegate") ? 10 : 6; // keep in sync with DBL_DIG in qitemdelegate.cpp

View File

@ -49,7 +49,9 @@
#endif #endif
#include <qevent.h> #include <qevent.h>
#include <qscrollbar.h> #include <qscrollbar.h>
#if QT_CONFIG(tooltip)
#include <qtooltip.h> #include <qtooltip.h>
#endif
#include <qdatetime.h> #include <qdatetime.h>
#if QT_CONFIG(lineedit) #if QT_CONFIG(lineedit)
#include <qlineedit.h> #include <qlineedit.h>

View File

@ -45,7 +45,9 @@
#include <qevent.h> #include <qevent.h>
#include <qpainter.h> #include <qpainter.h>
#include <qscrollbar.h> #include <qscrollbar.h>
#if QT_CONFIG(tooltip)
#include <qtooltip.h> #include <qtooltip.h>
#endif
#if QT_CONFIG(whatsthis) #if QT_CONFIG(whatsthis)
#include <qwhatsthis.h> #include <qwhatsthis.h>
#endif #endif
@ -2756,7 +2758,7 @@ bool QHeaderView::viewportEvent(QEvent *e)
{ {
Q_D(QHeaderView); Q_D(QHeaderView);
switch (e->type()) { switch (e->type()) {
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
case QEvent::ToolTip: { case QEvent::ToolTip: {
QHelpEvent *he = static_cast<QHelpEvent*>(e); QHelpEvent *he = static_cast<QHelpEvent*>(e);
int logical = logicalIndexAt(he->pos()); int logical = logicalIndexAt(he->pos());

View File

@ -93,7 +93,7 @@ public:
{ return data(Qt::StatusTipRole).toString(); } { return data(Qt::StatusTipRole).toString(); }
inline void setStatusTip(const QString &statusTip); inline void setStatusTip(const QString &statusTip);
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
inline QString toolTip() const inline QString toolTip() const
{ return data(Qt::ToolTipRole).toString(); } { return data(Qt::ToolTipRole).toString(); }
inline void setToolTip(const QString &toolTip); inline void setToolTip(const QString &toolTip);
@ -165,7 +165,7 @@ inline void QListWidgetItem::setIcon(const QIcon &aicon)
inline void QListWidgetItem::setStatusTip(const QString &astatusTip) inline void QListWidgetItem::setStatusTip(const QString &astatusTip)
{ setData(Qt::StatusTipRole, astatusTip); } { setData(Qt::StatusTipRole, astatusTip); }
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
inline void QListWidgetItem::setToolTip(const QString &atoolTip) inline void QListWidgetItem::setToolTip(const QString &atoolTip)
{ setData(Qt::ToolTipRole, atoolTip); } { setData(Qt::ToolTipRole, atoolTip); }
#endif #endif

View File

@ -113,7 +113,7 @@ public:
{ return data(Qt::StatusTipRole).toString(); } { return data(Qt::StatusTipRole).toString(); }
inline void setStatusTip(const QString &statusTip); inline void setStatusTip(const QString &statusTip);
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
inline QString toolTip() const inline QString toolTip() const
{ return data(Qt::ToolTipRole).toString(); } { return data(Qt::ToolTipRole).toString(); }
inline void setToolTip(const QString &toolTip); inline void setToolTip(const QString &toolTip);
@ -187,7 +187,7 @@ inline void QTableWidgetItem::setIcon(const QIcon &aicon)
inline void QTableWidgetItem::setStatusTip(const QString &astatusTip) inline void QTableWidgetItem::setStatusTip(const QString &astatusTip)
{ setData(Qt::StatusTipRole, astatusTip); } { setData(Qt::StatusTipRole, astatusTip); }
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
inline void QTableWidgetItem::setToolTip(const QString &atoolTip) inline void QTableWidgetItem::setToolTip(const QString &atoolTip)
{ setData(Qt::ToolTipRole, atoolTip); } { setData(Qt::ToolTipRole, atoolTip); }
#endif #endif

View File

@ -113,7 +113,7 @@ public:
{ return data(column, Qt::StatusTipRole).toString(); } { return data(column, Qt::StatusTipRole).toString(); }
inline void setStatusTip(int column, const QString &statusTip); inline void setStatusTip(int column, const QString &statusTip);
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
inline QString toolTip(int column) const inline QString toolTip(int column) const
{ return data(column, Qt::ToolTipRole).toString(); } { return data(column, Qt::ToolTipRole).toString(); }
inline void setToolTip(int column, const QString &toolTip); inline void setToolTip(int column, const QString &toolTip);
@ -220,7 +220,7 @@ inline void QTreeWidgetItem::setStatusTip(int column, const QString &astatusTip)
{ setData(column, Qt::StatusTipRole, astatusTip); } { setData(column, Qt::StatusTipRole, astatusTip); }
#endif #endif
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
inline void QTreeWidgetItem::setToolTip(int column, const QString &atoolTip) inline void QTreeWidgetItem::setToolTip(int column, const QString &atoolTip)
{ setData(column, Qt::ToolTipRole, atoolTip); } { setData(column, Qt::ToolTipRole, atoolTip); }
#endif #endif

View File

@ -58,7 +58,9 @@
#include "qstyle.h" #include "qstyle.h"
#include "qstyleoption.h" #include "qstyleoption.h"
#include "qstylefactory.h" #include "qstylefactory.h"
#if QT_CONFIG(tooltip)
#include "qtooltip.h" #include "qtooltip.h"
#endif
#include "qtranslator.h" #include "qtranslator.h"
#include "qvariant.h" #include "qvariant.h"
#include "qwidget.h" #include "qwidget.h"
@ -515,7 +517,7 @@ void QApplicationPrivate::init()
void qt_init_tooltip_palette() void qt_init_tooltip_palette()
{ {
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
if (const QPalette *toolTipPalette = QGuiApplicationPrivate::platformTheme()->palette(QPlatformTheme::ToolTipPalette)) if (const QPalette *toolTipPalette = QGuiApplicationPrivate::platformTheme()->palette(QPlatformTheme::ToolTipPalette))
QToolTip::setPalette(*toolTipPalette); QToolTip::setPalette(*toolTipPalette);
#endif #endif
@ -3157,7 +3159,7 @@ QT_WARNING_POP
break; break;
#endif // QT_CONFIG(tabletevent) #endif // QT_CONFIG(tabletevent)
#if !defined(QT_NO_TOOLTIP) || QT_CONFIG(whatsthis) #if QT_CONFIG(tooltip) || QT_CONFIG(whatsthis)
case QEvent::ToolTip: case QEvent::ToolTip:
case QEvent::WhatsThis: case QEvent::WhatsThis:
case QEvent::QueryWhatsThis: case QEvent::QueryWhatsThis:

View File

@ -57,7 +57,6 @@
#include <qpa/qplatformcursor.h> #include <qpa/qplatformcursor.h>
#include <private/qstylesheetstyle_p.h> #include <private/qstylesheetstyle_p.h>
#ifndef QT_NO_TOOLTIP
#include <qlabel.h> #include <qlabel.h>
#include <QtWidgets/private/qlabel_p.h> #include <QtWidgets/private/qlabel_p.h>
#include <QtGui/private/qhighdpiscaling_p.h> #include <QtGui/private/qhighdpiscaling_p.h>
@ -628,4 +627,3 @@ void QToolTip::setFont(const QFont &font)
QT_END_NAMESPACE QT_END_NAMESPACE
#include "qtooltip.moc" #include "qtooltip.moc"
#endif // QT_NO_TOOLTIP

View File

@ -43,11 +43,9 @@
#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h> #include <QtWidgets/qwidget.h>
QT_REQUIRE_CONFIG(tooltip);
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
#ifndef QT_NO_TOOLTIP
class Q_WIDGETS_EXPORT QToolTip class Q_WIDGETS_EXPORT QToolTip
{ {
QToolTip() = delete; QToolTip() = delete;
@ -67,8 +65,6 @@ public:
static void setFont(const QFont &); static void setFont(const QFont &);
}; };
#endif // QT_NO_TOOLTIP
QT_END_NAMESPACE QT_END_NAMESPACE
#endif // QTOOLTIP_H #endif // QTOOLTIP_H

View File

@ -64,7 +64,9 @@
#include <qpa/qplatformwindow.h> #include <qpa/qplatformwindow.h>
#include "private/qwidgetwindow_p.h" #include "private/qwidgetwindow_p.h"
#include "qpainter.h" #include "qpainter.h"
#if QT_CONFIG(tooltip)
#include "qtooltip.h" #include "qtooltip.h"
#endif
#if QT_CONFIG(whatsthis) #if QT_CONFIG(whatsthis)
#include "qwhatsthis.h" #include "qwhatsthis.h"
#endif #endif
@ -147,7 +149,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
#if !defined(QT_NO_IM) #if !defined(QT_NO_IM)
, imHints(Qt::ImhNone) , imHints(Qt::ImhNone)
#endif #endif
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
, toolTipDuration(-1) , toolTipDuration(-1)
#endif #endif
, directFontResolveMask(0) , directFontResolveMask(0)
@ -8972,7 +8974,7 @@ bool QWidget::event(QEvent *event)
} }
} }
break; break;
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
case QEvent::ToolTip: case QEvent::ToolTip:
if (!d->toolTip.isEmpty()) if (!d->toolTip.isEmpty())
QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), d->toolTip, this, QRect(), d->toolTipDuration); QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), d->toolTip, this, QRect(), d->toolTipDuration);
@ -11237,7 +11239,7 @@ void QWidgetPrivate::setWindowModified_helper()
} }
} }
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
/*! /*!
\property QWidget::toolTip \property QWidget::toolTip
@ -11294,7 +11296,7 @@ int QWidget::toolTipDuration() const
return d->toolTipDuration; return d->toolTipDuration;
} }
#endif // QT_NO_TOOLTIP #endif // QT_CONFIG(tooltip)
#if QT_CONFIG(statustip) #if QT_CONFIG(statustip)

View File

@ -182,7 +182,7 @@ class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice
Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText NOTIFY windowIconTextChanged) // deprecated Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText NOTIFY windowIconTextChanged) // deprecated
Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity) Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity)
Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified) Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified)
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip) Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip)
Q_PROPERTY(int toolTipDuration READ toolTipDuration WRITE setToolTipDuration) Q_PROPERTY(int toolTipDuration READ toolTipDuration WRITE setToolTipDuration)
#endif #endif
@ -382,7 +382,7 @@ public:
qreal windowOpacity() const; qreal windowOpacity() const;
bool isWindowModified() const; bool isWindowModified() const;
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
void setToolTip(const QString &); void setToolTip(const QString &);
QString toolTip() const; QString toolTip() const;
void setToolTipDuration(int msec); void setToolTipDuration(int msec);

View File

@ -654,7 +654,7 @@ public:
// Implicit pointers (shared_null/shared_empty). // Implicit pointers (shared_null/shared_empty).
QRegion opaqueChildren; QRegion opaqueChildren;
QRegion dirty; QRegion dirty;
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
QString toolTip; QString toolTip;
int toolTipDuration; int toolTipDuration;
#endif #endif

View File

@ -5351,7 +5351,7 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget
case SH_Menu_SupportsSections: case SH_Menu_SupportsSections:
ret = false; ret = false;
break; break;
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
case SH_ToolTip_WakeUpDelay: case SH_ToolTip_WakeUpDelay:
ret = 700; ret = 700;
break; break;

View File

@ -65,7 +65,9 @@
#include "private/qmath_p.h" #include "private/qmath_p.h"
#include <qabstractscrollarea.h> #include <qabstractscrollarea.h>
#include "private/qabstractscrollarea_p.h" #include "private/qabstractscrollarea_p.h"
#if QT_CONFIG(tooltip)
#include <qtooltip.h> #include <qtooltip.h>
#endif
#include <qshareddata.h> #include <qshareddata.h>
#if QT_CONFIG(toolbutton) #if QT_CONFIG(toolbutton)
#include <qtoolbutton.h> #include <qtoolbutton.h>
@ -987,7 +989,7 @@ QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QObject
int adj = -255; int adj = -255;
hasFont = v.extractFont(&font, &adj); hasFont = v.extractFont(&font, &adj);
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
if (object && qstrcmp(object->metaObject()->className(), "QTipLabel") == 0) if (object && qstrcmp(object->metaObject()->className(), "QTipLabel") == 0)
palette = QToolTip::palette(); palette = QToolTip::palette();
#endif #endif
@ -1508,7 +1510,7 @@ public:
if (isNullNode(node)) if (isNullNode(node))
return QStringList(); return QStringList();
const QMetaObject *metaObject = OBJECT_PTR(node)->metaObject(); const QMetaObject *metaObject = OBJECT_PTR(node)->metaObject();
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
if (qstrcmp(metaObject->className(), "QTipLabel") == 0) if (qstrcmp(metaObject->className(), "QTipLabel") == 0)
return QStringList(QLatin1String("QToolTip")); return QStringList(QLatin1String("QToolTip"));
#endif #endif
@ -1560,7 +1562,7 @@ public:
if (isNullNode(node)) if (isNullNode(node))
return false; return false;
const QMetaObject *metaObject = OBJECT_PTR(node)->metaObject(); const QMetaObject *metaObject = OBJECT_PTR(node)->metaObject();
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
if (qstrcmp(metaObject->className(), "QTipLabel") == 0) if (qstrcmp(metaObject->className(), "QTipLabel") == 0)
return nodeName == QLatin1String("QToolTip"); return nodeName == QLatin1String("QToolTip");
#endif #endif

View File

@ -308,7 +308,7 @@ void QSystemTrayIconPrivate::updateToolTip_sys()
} }
if (!sys) if (!sys)
return; return;
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
sys->setToolTip(toolTip); sys->setToolTip(toolTip);
#endif #endif
} }

View File

@ -2109,7 +2109,7 @@ bool QDockAreaLayoutInfo::updateTabBar() const
quintptr id = tabId(item); quintptr id = tabId(item);
if (tab_idx == tabBar->count()) { if (tab_idx == tabBar->count()) {
tabBar->insertTab(tab_idx, title); tabBar->insertTab(tab_idx, title);
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
tabBar->setTabToolTip(tab_idx, title); tabBar->setTabToolTip(tab_idx, title);
#endif #endif
tabBar->setTabData(tab_idx, id); tabBar->setTabData(tab_idx, id);
@ -2119,7 +2119,7 @@ bool QDockAreaLayoutInfo::updateTabBar() const
tabBar->removeTab(tab_idx); tabBar->removeTab(tab_idx);
else { else {
tabBar->insertTab(tab_idx, title); tabBar->insertTab(tab_idx, title);
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
tabBar->setTabToolTip(tab_idx, title); tabBar->setTabToolTip(tab_idx, title);
#endif #endif
tabBar->setTabData(tab_idx, id); tabBar->setTabData(tab_idx, id);
@ -2128,7 +2128,7 @@ bool QDockAreaLayoutInfo::updateTabBar() const
if (title != tabBar->tabText(tab_idx)) { if (title != tabBar->tabText(tab_idx)) {
tabBar->setTabText(tab_idx, title); tabBar->setTabText(tab_idx, title);
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
tabBar->setTabToolTip(tab_idx, title); tabBar->setTabToolTip(tab_idx, title);
#endif #endif
} }

View File

@ -154,7 +154,9 @@
#if QT_CONFIG(whatsthis) #if QT_CONFIG(whatsthis)
#include <QWhatsThis> #include <QWhatsThis>
#endif #endif
#if QT_CONFIG(tooltip)
#include <QToolTip> #include <QToolTip>
#endif
#if QT_CONFIG(mainwindow) #if QT_CONFIG(mainwindow)
#include <QMainWindow> #include <QMainWindow>
#endif #endif
@ -290,7 +292,7 @@ static inline bool isHoverControl(QStyle::SubControl control)
return control != QStyle::SC_None && control != QStyle::SC_TitleBarLabel; return control != QStyle::SC_None && control != QStyle::SC_TitleBarLabel;
} }
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
static void showToolTip(QHelpEvent *helpEvent, QWidget *widget, const QStyleOptionComplex &opt, static void showToolTip(QHelpEvent *helpEvent, QWidget *widget, const QStyleOptionComplex &opt,
QStyle::ComplexControl complexControl, QStyle::SubControl subControl) QStyle::ComplexControl complexControl, QStyle::SubControl subControl)
{ {
@ -355,7 +357,7 @@ static void showToolTip(QHelpEvent *helpEvent, QWidget *widget, const QStyleOpti
const QRect rect = widget->style()->subControlRect(complexControl, &opt, subControl, widget); const QRect rect = widget->style()->subControlRect(complexControl, &opt, subControl, widget);
QToolTip::showText(helpEvent->globalPos(), toolTip, widget, rect); QToolTip::showText(helpEvent->globalPos(), toolTip, widget, rect);
} }
#endif // QT_NO_TOOLTIP #endif // QT_CONFIG(tooltip)
namespace QMdi { namespace QMdi {
/* /*
@ -416,7 +418,7 @@ bool ControlLabel::event(QEvent *event)
updateWindowIcon(); updateWindowIcon();
setFixedSize(label.size()); setFixedSize(label.size());
} }
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
else if (event->type() == QEvent::ToolTip) { else if (event->type() == QEvent::ToolTip) {
QStyleOptionTitleBar options; QStyleOptionTitleBar options;
options.initFrom(this); options.initFrom(this);
@ -673,14 +675,14 @@ void ControllerWidget::leaveEvent(QEvent * /*event*/)
*/ */
bool ControllerWidget::event(QEvent *event) bool ControllerWidget::event(QEvent *event)
{ {
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
if (event->type() == QEvent::ToolTip) { if (event->type() == QEvent::ToolTip) {
QStyleOptionComplex opt; QStyleOptionComplex opt;
initStyleOption(&opt); initStyleOption(&opt);
QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event); QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);
showToolTip(helpEvent, this, opt, QStyle::CC_MdiControls, getSubControl(helpEvent->pos())); showToolTip(helpEvent, this, opt, QStyle::CC_MdiControls, getSubControl(helpEvent->pos()));
} }
#endif // QT_NO_TOOLTIP #endif // QT_CONFIG(tooltip)
return QWidget::event(event); return QWidget::event(event);
} }
@ -2874,7 +2876,7 @@ bool QMdiSubWindow::event(QEvent *event)
case QEvent::FontChange: case QEvent::FontChange:
d->font = font(); d->font = font();
break; break;
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
case QEvent::ToolTip: case QEvent::ToolTip:
showToolTip(static_cast<QHelpEvent *>(event), this, d->titleBarOptions(), showToolTip(static_cast<QHelpEvent *>(event), this, d->titleBarOptions(),
QStyle::CC_TitleBar, d->hoveredSubControl); QStyle::CC_TitleBar, d->hoveredSubControl);

View File

@ -73,7 +73,9 @@
#include "qtoolbutton.h" #include "qtoolbutton.h"
#endif #endif
#include "qpushbutton.h" #include "qpushbutton.h"
#if QT_CONFIG(tooltip)
#include "qtooltip.h" #include "qtooltip.h"
#endif
#include <qwindow.h> #include <qwindow.h>
#include <private/qpushbutton_p.h> #include <private/qpushbutton_p.h>
#include <private/qaction_p.h> #include <private/qaction_p.h>
@ -3029,7 +3031,7 @@ QMenu::event(QEvent *e)
if (d->currentAction) if (d->currentAction)
d->popupAction(d->currentAction, 0, false); d->popupAction(d->currentAction, 0, false);
break; break;
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
case QEvent::ToolTip: case QEvent::ToolTip:
if (d->toolTipsVisible) { if (d->toolTipsVisible) {
const QHelpEvent *ev = static_cast<const QHelpEvent*>(e); const QHelpEvent *ev = static_cast<const QHelpEvent*>(e);
@ -3041,7 +3043,7 @@ QMenu::event(QEvent *e)
} }
} }
break; break;
#endif // QT_NO_TOOLTIP #endif // QT_CONFIG(tooltip)
#if QT_CONFIG(whatsthis) #if QT_CONFIG(whatsthis)
case QEvent::QueryWhatsThis: case QEvent::QueryWhatsThis:
e->setAccepted(d->whatsThis.size()); e->setAccepted(d->whatsThis.size());

View File

@ -52,7 +52,9 @@
#if QT_CONFIG(tabwidget) #if QT_CONFIG(tabwidget)
#include "qtabwidget.h" #include "qtabwidget.h"
#endif #endif
#if QT_CONFIG(tooltip)
#include "qtooltip.h" #include "qtooltip.h"
#endif
#if QT_CONFIG(whatsthis) #if QT_CONFIG(whatsthis)
#include "qwhatsthis.h" #include "qwhatsthis.h"
#endif #endif
@ -1280,7 +1282,7 @@ void QTabBar::setTabIcon(int index, const QIcon & icon)
} }
} }
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
/*! /*!
Sets the tool tip of the tab at position \a index to \a tip. Sets the tool tip of the tab at position \a index to \a tip.
*/ */
@ -1302,7 +1304,7 @@ QString QTabBar::tabToolTip(int index) const
return tab->toolTip; return tab->toolTip;
return QString(); return QString();
} }
#endif // QT_NO_TOOLTIP #endif // QT_CONFIG(tooltip)
#if QT_CONFIG(whatsthis) #if QT_CONFIG(whatsthis)
/*! /*!
@ -1711,7 +1713,7 @@ bool QTabBar::event(QEvent *event)
update(oldHoverRect); update(oldHoverRect);
return true; return true;
} }
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
case QEvent::ToolTip: case QEvent::ToolTip:
if (const QTabBarPrivate::Tab *tab = d->at(tabAt(static_cast<QHelpEvent*>(event)->pos()))) { if (const QTabBarPrivate::Tab *tab = d->at(tabAt(static_cast<QHelpEvent*>(event)->pos()))) {
if (!tab->toolTip.isEmpty()) { if (!tab->toolTip.isEmpty()) {
@ -1720,7 +1722,7 @@ bool QTabBar::event(QEvent *event)
} }
} }
break; break;
#endif // QT_NO_TOOLTIP #endif // QT_CONFIG(tooltip)
#if QT_CONFIG(whatsthis) #if QT_CONFIG(whatsthis)
case QEvent::QEvent::QueryWhatsThis: { case QEvent::QEvent::QueryWhatsThis: {
const QTabBarPrivate::Tab *tab = d->at(d->indexAtPos(static_cast<QHelpEvent*>(event)->pos())); const QTabBarPrivate::Tab *tab = d->at(d->indexAtPos(static_cast<QHelpEvent*>(event)->pos()));
@ -2785,7 +2787,7 @@ CloseButton::CloseButton(QWidget *parent)
#ifndef QT_NO_CURSOR #ifndef QT_NO_CURSOR
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);
#endif #endif
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
setToolTip(tr("Close Tab")); setToolTip(tr("Close Tab"));
#endif #endif
resize(sizeHint()); resize(sizeHint());

View File

@ -120,7 +120,7 @@ public:
Qt::TextElideMode elideMode() const; Qt::TextElideMode elideMode() const;
void setElideMode(Qt::TextElideMode mode); void setElideMode(Qt::TextElideMode mode);
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
void setTabToolTip(int index, const QString &tip); void setTabToolTip(int index, const QString &tip);
QString tabToolTip(int index) const; QString tabToolTip(int index) const;
#endif #endif

View File

@ -117,7 +117,7 @@ public:
bool visible; bool visible;
int shortcutId; int shortcutId;
QString text; QString text;
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
QString toolTip; QString toolTip;
#endif #endif
#if QT_CONFIG(whatsthis) #if QT_CONFIG(whatsthis)

View File

@ -1209,7 +1209,7 @@ int QTabWidget::count() const
return d->tabs->count(); return d->tabs->count();
} }
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
/*! /*!
Sets the tab tool tip for the page at position \a index to \a tip. Sets the tab tool tip for the page at position \a index to \a tip.
@ -1232,7 +1232,7 @@ QString QTabWidget::tabToolTip(int index) const
Q_D(const QTabWidget); Q_D(const QTabWidget);
return d->tabs->tabToolTip(index); return d->tabs->tabToolTip(index);
} }
#endif // QT_NO_TOOLTIP #endif // QT_CONFIG(tooltip)
#if QT_CONFIG(whatsthis) #if QT_CONFIG(whatsthis)
/*! /*!

View File

@ -91,7 +91,7 @@ public:
QIcon tabIcon(int index) const; QIcon tabIcon(int index) const;
void setTabIcon(int index, const QIcon & icon); void setTabIcon(int index, const QIcon & icon);
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
void setTabToolTip(int index, const QString & tip); void setTabToolTip(int index, const QString & tip);
QString tabToolTip(int index) const; QString tabToolTip(int index) const;
#endif #endif

View File

@ -47,7 +47,9 @@
#include <qscrollarea.h> #include <qscrollarea.h>
#include <qstyle.h> #include <qstyle.h>
#include <qstyleoption.h> #include <qstyleoption.h>
#if QT_CONFIG(tooltip)
#include <qtooltip.h> #include <qtooltip.h>
#endif
#include <qabstractbutton.h> #include <qabstractbutton.h>
#include <private/qmemory_p.h> #include <private/qmemory_p.h>
@ -96,7 +98,7 @@ public:
inline void setText(const QString &text) { button->setText(text); } inline void setText(const QString &text) { button->setText(text); }
inline void setIcon(const QIcon &is) { button->setIcon(is); } inline void setIcon(const QIcon &is) { button->setIcon(is); }
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
inline void setToolTip(const QString &tip) { button->setToolTip(tip); } inline void setToolTip(const QString &tip) { button->setToolTip(tip); }
inline QString toolTip() const { return button->toolTip(); } inline QString toolTip() const { return button->toolTip(); }
#endif #endif
@ -638,7 +640,7 @@ void QToolBox::setItemIcon(int index, const QIcon &icon)
c->setIcon(icon); c->setIcon(icon);
} }
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
/*! /*!
Sets the tooltip of the item at position \a index to \a toolTip. Sets the tooltip of the item at position \a index to \a toolTip.
*/ */
@ -650,7 +652,7 @@ void QToolBox::setItemToolTip(int index, const QString &toolTip)
if (c) if (c)
c->setToolTip(toolTip); c->setToolTip(toolTip);
} }
#endif // QT_NO_TOOLTIP #endif // QT_CONFIG(tooltip)
/*! /*!
Returns \c true if the item at position \a index is enabled; otherwise returns \c false. Returns \c true if the item at position \a index is enabled; otherwise returns \c false.
@ -687,7 +689,7 @@ QIcon QToolBox::itemIcon(int index) const
return (c ? c->icon() : QIcon()); return (c ? c->icon() : QIcon());
} }
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
/*! /*!
Returns the tooltip of the item at position \a index, or an Returns the tooltip of the item at position \a index, or an
empty string if \a index is out of range. empty string if \a index is out of range.
@ -699,7 +701,7 @@ QString QToolBox::itemToolTip(int index) const
const QToolBoxPrivate::Page *c = d->page(index); const QToolBoxPrivate::Page *c = d->page(index);
return (c ? c->toolTip() : QString()); return (c ? c->toolTip() : QString());
} }
#endif // QT_NO_TOOLTIP #endif // QT_CONFIG(tooltip)
/*! \reimp */ /*! \reimp */
void QToolBox::showEvent(QShowEvent *e) void QToolBox::showEvent(QShowEvent *e)

View File

@ -76,7 +76,7 @@ public:
void setItemIcon(int index, const QIcon &icon); void setItemIcon(int index, const QIcon &icon);
QIcon itemIcon(int index) const; QIcon itemIcon(int index) const;
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
void setItemToolTip(int index, const QString &toolTip); void setItemToolTip(int index, const QString &toolTip);
QString itemToolTip(int index) const; QString itemToolTip(int index) const;
#endif #endif

View File

@ -49,7 +49,9 @@
#include <qpointer.h> #include <qpointer.h>
#include <qstyle.h> #include <qstyle.h>
#include <qstyleoption.h> #include <qstyleoption.h>
#if QT_CONFIG(tooltip)
#include <qtooltip.h> #include <qtooltip.h>
#endif
#if QT_CONFIG(mainwindow) #if QT_CONFIG(mainwindow)
#include <qmainwindow.h> #include <qmainwindow.h>
#endif #endif
@ -944,7 +946,7 @@ void QToolButton::setDefaultAction(QAction *action)
buttonText.replace(QLatin1String("&"), QLatin1String("&&")); buttonText.replace(QLatin1String("&"), QLatin1String("&&"));
setText(buttonText); setText(buttonText);
setIcon(action->icon()); setIcon(action->icon());
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
setToolTip(action->toolTip()); setToolTip(action->toolTip());
#endif #endif
#if QT_CONFIG(statustip) #if QT_CONFIG(statustip)

View File

@ -84,7 +84,9 @@
#include <qurl.h> #include <qurl.h>
#include <qdesktopservices.h> #include <qdesktopservices.h>
#include <qinputmethod.h> #include <qinputmethod.h>
#if QT_CONFIG(tooltip)
#include <qtooltip.h> #include <qtooltip.h>
#endif
#include <qstyleoption.h> #include <qstyleoption.h>
#if QT_CONFIG(lineedit) #if QT_CONFIG(lineedit)
#include <QtWidgets/qlineedit.h> #include <QtWidgets/qlineedit.h>
@ -1074,13 +1076,13 @@ void QWidgetTextControl::processEvent(QEvent *e, const QTransform &transform, QW
d->isEnabled = e->isAccepted(); d->isEnabled = e->isAccepted();
break; break;
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
case QEvent::ToolTip: { case QEvent::ToolTip: {
QHelpEvent *ev = static_cast<QHelpEvent *>(e); QHelpEvent *ev = static_cast<QHelpEvent *>(e);
d->showToolTip(ev->globalPos(), transform.map(ev->pos()), contextWidget); d->showToolTip(ev->globalPos(), transform.map(ev->pos()), contextWidget);
break; break;
} }
#endif // QT_NO_TOOLTIP #endif // QT_CONFIG(tooltip)
#if QT_CONFIG(draganddrop) #if QT_CONFIG(draganddrop)
case QEvent::DragEnter: { case QEvent::DragEnter: {
@ -2948,7 +2950,7 @@ void QWidgetTextControlPrivate::activateLinkUnderCursor(QString href)
emit q_func()->linkActivated(href); emit q_func()->linkActivated(href);
} }
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
void QWidgetTextControlPrivate::showToolTip(const QPoint &globalPos, const QPointF &pos, QWidget *contextWidget) void QWidgetTextControlPrivate::showToolTip(const QPoint &globalPos, const QPointF &pos, QWidget *contextWidget)
{ {
const QString toolTip = q_func()->cursorForPosition(pos).charFormat().toolTip(); const QString toolTip = q_func()->cursorForPosition(pos).charFormat().toolTip();
@ -2956,7 +2958,7 @@ void QWidgetTextControlPrivate::showToolTip(const QPoint &globalPos, const QPoin
return; return;
QToolTip::showText(globalPos, toolTip, contextWidget); QToolTip::showText(globalPos, toolTip, contextWidget);
} }
#endif // QT_NO_TOOLTIP #endif // QT_CONFIG(tooltip)
bool QWidgetTextControlPrivate::isPreediting() const bool QWidgetTextControlPrivate::isPreediting() const
{ {

View File

@ -171,7 +171,7 @@ public:
void activateLinkUnderCursor(QString href = QString()); void activateLinkUnderCursor(QString href = QString());
#ifndef QT_NO_TOOLTIP #if QT_CONFIG(tooltip)
void showToolTip(const QPoint &globalPos, const QPointF &pos, QWidget *contextWidget); void showToolTip(const QPoint &globalPos, const QPointF &pos, QWidget *contextWidget);
#endif #endif