Skip to content

Commit

Permalink
Port QT_NO_TOOLTIP to QT_CONFIG(tooltip)
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Kai Koehne <[email protected]>
  • Loading branch information
jobor committed Apr 21, 2020
1 parent fbb7c98 commit 1c80d05
Show file tree
Hide file tree
Showing 37 changed files with 96 additions and 76 deletions.
4 changes: 0 additions & 4 deletions src/gui/itemmodels/qstandarditemmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,10 @@ class Q_GUI_EXPORT QStandardItem
}
inline void setIcon(const QIcon &icon);

#ifndef QT_NO_TOOLTIP
inline QString toolTip() const {
return qvariant_cast<QString>(data(Qt::ToolTipRole));
}
inline void setToolTip(const QString &toolTip);
#endif

#ifndef QT_NO_STATUSTIP
inline QString statusTip() const {
Expand Down Expand Up @@ -260,10 +258,8 @@ inline void QStandardItem::setText(const QString &atext)
inline void QStandardItem::setIcon(const QIcon &aicon)
{ setData(aicon, Qt::DecorationRole); }

#ifndef QT_NO_TOOLTIP
inline void QStandardItem::setToolTip(const QString &atoolTip)
{ setData(atoolTip, Qt::ToolTipRole); }
#endif

#ifndef QT_NO_STATUSTIP
inline void QStandardItem::setStatusTip(const QString &astatusTip)
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/accessible/complexwidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
#endif
#include <qstyle.h>
#include <qstyleoption.h>
#if QT_CONFIG(tooltip)
#include <qtooltip.h>
#endif
#if QT_CONFIG(whatsthis)
#include <qwhatsthis.h>
#endif
Expand Down
4 changes: 3 additions & 1 deletion src/widgets/accessible/qaccessiblewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
#if QT_CONFIG(label)
#include "qlabel.h"
#endif
#if QT_CONFIG(tooltip)
#include "qtooltip.h"
#endif
#if QT_CONFIG(whatsthis)
#include "qwhatsthis.h"
#endif
Expand Down Expand Up @@ -425,7 +427,7 @@ QString QAccessibleWidget::text(QAccessible::Text t) const
break;
case QAccessible::Description:
str = widget()->accessibleDescription();
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
if (str.isEmpty())
str = widget()->toolTip();
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/accessible/simplewidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ void *QAccessibleDisplay::interface_cast(QAccessible::InterfaceType t)
/*! \internal */
QString QAccessibleDisplay::imageDescription() const
{
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
return widget()->toolTip();
#else
return QString();
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/graphicsview/qgraphicsitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2239,7 +2239,7 @@ bool QGraphicsItem::isBlockedByModalPanel(QGraphicsItem **blockingPanel) const
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
set.
Expand All @@ -2263,7 +2263,7 @@ void QGraphicsItem::setToolTip(const QString &toolTip)
d_ptr->setExtra(QGraphicsItemPrivate::ExtraToolTip, toolTipVariant.toString());
itemChange(ItemToolTipHasChanged, toolTipVariant);
}
#endif // QT_NO_TOOLTIP
#endif // QT_CONFIG(tooltip)

#ifndef QT_NO_CURSOR
/*!
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/graphicsview/qgraphicsitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class Q_WIDGETS_EXPORT QGraphicsItem
void setPanelModality(PanelModality panelModality);
bool isBlockedByModalPanel(QGraphicsItem **blockingPanel = nullptr) const;

#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
QString toolTip() const;
void setToolTip(const QString &toolTip);
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/graphicsview/qgraphicsproxywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ bool QGraphicsProxyWidget::event(QEvent *event)
}
break;
}
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
case QEvent::GraphicsSceneHelp: {
// Propagate the help event (for tooltip) to the widget under mouse
if (d->lastWidgetUnderMouse) {
Expand Down Expand Up @@ -981,7 +981,7 @@ bool QGraphicsProxyWidget::eventFilter(QObject *object, QEvent *event)
d->styleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
}
break;
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
case QEvent::ToolTipChange:
// Propagate tooltip change to the proxy.
if (!d->tooltipChangeMode) {
Expand Down
6 changes: 4 additions & 2 deletions src/widgets/graphicsview/qgraphicsscene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@
#include <QtGui/qpolygon.h>
#include <QtGui/qtouchdevice.h>
#include <QtWidgets/qstyleoption.h>
#if QT_CONFIG(tooltip)
#include <QtWidgets/qtooltip.h>
#endif
#include <QtGui/qtransform.h>
#include <QtGui/qinputmethod.h>
#include <private/qapplication_p.h>
Expand Down Expand Up @@ -3729,7 +3731,7 @@ void QGraphicsScene::focusOutEvent(QFocusEvent *focusEvent)
*/
void QGraphicsScene::helpEvent(QGraphicsSceneHelpEvent *helpEvent)
{
#ifdef QT_NO_TOOLTIP
#if !QT_CONFIG(tooltip)
Q_UNUSED(helpEvent);
#else
// Find the first item that does tooltips
Expand Down Expand Up @@ -3860,7 +3862,7 @@ bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEv
*/
void QGraphicsScenePrivate::leaveScene(QWidget *viewport)
{
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
QToolTip::hideText();
#endif
QGraphicsView *view = qobject_cast<QGraphicsView *>(viewport->parent());
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/graphicsview/qgraphicsview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2888,7 +2888,7 @@ bool QGraphicsView::viewportEvent(QEvent *event)
QCoreApplication::sendEvent(d->scene, event);
break;
}
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
case QEvent::ToolTip: {
QHelpEvent *toolTip = static_cast<QHelpEvent *>(event);
QGraphicsSceneHelpEvent helpEvent(QEvent::GraphicsSceneHelp);
Expand Down
4 changes: 3 additions & 1 deletion src/widgets/itemviews/qabstractitemdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
#if QT_CONFIG(whatsthis)
#include <qwhatsthis.h>
#endif
#if QT_CONFIG(tooltip)
#include <qtooltip.h>
#endif
#include <qevent.h>
#include <qstring.h>
#include <qdebug.h>
Expand Down Expand Up @@ -369,7 +371,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
return false;
Q_D(QAbstractItemDelegate);
switch (event->type()) {
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
case QEvent::ToolTip: {
QHelpEvent *he = static_cast<QHelpEvent*>(event);
const int precision = inherits("QItemDelegate") ? 10 : 6; // keep in sync with DBL_DIG in qitemdelegate.cpp
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/itemviews/qabstractitemview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
#endif
#include <qevent.h>
#include <qscrollbar.h>
#if QT_CONFIG(tooltip)
#include <qtooltip.h>
#endif
#include <qdatetime.h>
#if QT_CONFIG(lineedit)
#include <qlineedit.h>
Expand Down
4 changes: 3 additions & 1 deletion src/widgets/itemviews/qheaderview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
#include <qevent.h>
#include <qpainter.h>
#include <qscrollbar.h>
#if QT_CONFIG(tooltip)
#include <qtooltip.h>
#endif
#if QT_CONFIG(whatsthis)
#include <qwhatsthis.h>
#endif
Expand Down Expand Up @@ -2756,7 +2758,7 @@ bool QHeaderView::viewportEvent(QEvent *e)
{
Q_D(QHeaderView);
switch (e->type()) {
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
case QEvent::ToolTip: {
QHelpEvent *he = static_cast<QHelpEvent*>(e);
int logical = logicalIndexAt(he->pos());
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/itemviews/qlistwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class Q_WIDGETS_EXPORT QListWidgetItem
{ return data(Qt::StatusTipRole).toString(); }
inline void setStatusTip(const QString &statusTip);

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

#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
inline void QListWidgetItem::setToolTip(const QString &atoolTip)
{ setData(Qt::ToolTipRole, atoolTip); }
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/itemviews/qtablewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class Q_WIDGETS_EXPORT QTableWidgetItem
{ return data(Qt::StatusTipRole).toString(); }
inline void setStatusTip(const QString &statusTip);

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

#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
inline void QTableWidgetItem::setToolTip(const QString &atoolTip)
{ setData(Qt::ToolTipRole, atoolTip); }
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/itemviews/qtreewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class Q_WIDGETS_EXPORT QTreeWidgetItem
{ return data(column, Qt::StatusTipRole).toString(); }
inline void setStatusTip(int column, const QString &statusTip);

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

#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
inline void QTreeWidgetItem::setToolTip(int column, const QString &atoolTip)
{ setData(column, Qt::ToolTipRole, atoolTip); }
#endif
Expand Down
6 changes: 4 additions & 2 deletions src/widgets/kernel/qapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@
#include "qstyle.h"
#include "qstyleoption.h"
#include "qstylefactory.h"
#if QT_CONFIG(tooltip)
#include "qtooltip.h"
#endif
#include "qtranslator.h"
#include "qvariant.h"
#include "qwidget.h"
Expand Down Expand Up @@ -515,7 +517,7 @@ void QApplicationPrivate::init()

void qt_init_tooltip_palette()
{
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
if (const QPalette *toolTipPalette = QGuiApplicationPrivate::platformTheme()->palette(QPlatformTheme::ToolTipPalette))
QToolTip::setPalette(*toolTipPalette);
#endif
Expand Down Expand Up @@ -3157,7 +3159,7 @@ QT_WARNING_POP
break;
#endif // QT_CONFIG(tabletevent)

#if !defined(QT_NO_TOOLTIP) || QT_CONFIG(whatsthis)
#if QT_CONFIG(tooltip) || QT_CONFIG(whatsthis)
case QEvent::ToolTip:
case QEvent::WhatsThis:
case QEvent::QueryWhatsThis:
Expand Down
2 changes: 0 additions & 2 deletions src/widgets/kernel/qtooltip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
#include <qpa/qplatformcursor.h>
#include <private/qstylesheetstyle_p.h>

#ifndef QT_NO_TOOLTIP
#include <qlabel.h>
#include <QtWidgets/private/qlabel_p.h>
#include <QtGui/private/qhighdpiscaling_p.h>
Expand Down Expand Up @@ -628,4 +627,3 @@ void QToolTip::setFont(const QFont &font)
QT_END_NAMESPACE

#include "qtooltip.moc"
#endif // QT_NO_TOOLTIP
6 changes: 1 addition & 5 deletions src/widgets/kernel/qtooltip.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@
#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>

QT_REQUIRE_CONFIG(tooltip);
QT_BEGIN_NAMESPACE


#ifndef QT_NO_TOOLTIP

class Q_WIDGETS_EXPORT QToolTip
{
QToolTip() = delete;
Expand All @@ -67,8 +65,6 @@ class Q_WIDGETS_EXPORT QToolTip
static void setFont(const QFont &);
};

#endif // QT_NO_TOOLTIP

QT_END_NAMESPACE

#endif // QTOOLTIP_H
10 changes: 6 additions & 4 deletions src/widgets/kernel/qwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@
#include <qpa/qplatformwindow.h>
#include "private/qwidgetwindow_p.h"
#include "qpainter.h"
#if QT_CONFIG(tooltip)
#include "qtooltip.h"
#endif
#if QT_CONFIG(whatsthis)
#include "qwhatsthis.h"
#endif
Expand Down Expand Up @@ -147,7 +149,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
#if !defined(QT_NO_IM)
, imHints(Qt::ImhNone)
#endif
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
, toolTipDuration(-1)
#endif
, directFontResolveMask(0)
Expand Down Expand Up @@ -8972,7 +8974,7 @@ bool QWidget::event(QEvent *event)
}
}
break;
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
case QEvent::ToolTip:
if (!d->toolTip.isEmpty())
QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), d->toolTip, this, QRect(), d->toolTipDuration);
Expand Down Expand Up @@ -11237,7 +11239,7 @@ void QWidgetPrivate::setWindowModified_helper()
}
}

#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
/*!
\property QWidget::toolTip

Expand Down Expand Up @@ -11294,7 +11296,7 @@ int QWidget::toolTipDuration() const
return d->toolTipDuration;
}

#endif // QT_NO_TOOLTIP
#endif // QT_CONFIG(tooltip)


#if QT_CONFIG(statustip)
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/kernel/qwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(double windowOpacity READ windowOpacity WRITE setWindowOpacity)
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(int toolTipDuration READ toolTipDuration WRITE setToolTipDuration)
#endif
Expand Down Expand Up @@ -382,7 +382,7 @@ public Q_SLOTS:
qreal windowOpacity() const;

bool isWindowModified() const;
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
void setToolTip(const QString &);
QString toolTip() const;
void setToolTipDuration(int msec);
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/kernel/qwidget_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ class Q_WIDGETS_EXPORT QWidgetPrivate : public QObjectPrivate
// Implicit pointers (shared_null/shared_empty).
QRegion opaqueChildren;
QRegion dirty;
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
QString toolTip;
int toolTipDuration;
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/styles/qcommonstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5351,7 +5351,7 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget
case SH_Menu_SupportsSections:
ret = false;
break;
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
case SH_ToolTip_WakeUpDelay:
ret = 700;
break;
Expand Down
Loading

0 comments on commit 1c80d05

Please sign in to comment.