QLabel: Use pmf-style connects
Port all string-based signal/slots connections to pmf-style connects. Change-Id: I888fe3d0022fddbe7ba391dc6841c3ea6b9d1d4b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 7efd3c2718a3d0dd656038ee7cd4eb992a6f2f80) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
a91c2b8c71
commit
2e9347dfce
@ -1171,12 +1171,14 @@ void QLabel::setBuddy(QWidget *buddy)
|
||||
Q_D(QLabel);
|
||||
|
||||
if (d->buddy)
|
||||
disconnect(d->buddy, SIGNAL(destroyed()), this, SLOT(_q_buddyDeleted()));
|
||||
QObjectPrivate::disconnect(d->buddy, &QObject::destroyed,
|
||||
d, &QLabelPrivate::buddyDeleted);
|
||||
|
||||
d->buddy = buddy;
|
||||
|
||||
if (buddy)
|
||||
connect(buddy, SIGNAL(destroyed()), this, SLOT(_q_buddyDeleted()));
|
||||
QObjectPrivate::connect(buddy, &QObject::destroyed,
|
||||
d, &QLabelPrivate::buddyDeleted);
|
||||
|
||||
if (d->isTextLabel) {
|
||||
if (d->shortcutId)
|
||||
@ -1219,7 +1221,7 @@ void QLabelPrivate::updateShortcut()
|
||||
}
|
||||
|
||||
|
||||
void QLabelPrivate::_q_buddyDeleted()
|
||||
void QLabelPrivate::buddyDeleted()
|
||||
{
|
||||
Q_Q(QLabel);
|
||||
q->setBuddy(nullptr);
|
||||
@ -1228,7 +1230,7 @@ void QLabelPrivate::_q_buddyDeleted()
|
||||
#endif // QT_NO_SHORTCUT
|
||||
|
||||
#if QT_CONFIG(movie)
|
||||
void QLabelPrivate::_q_movieUpdated(const QRect& rect)
|
||||
void QLabelPrivate::movieUpdated(const QRect &rect)
|
||||
{
|
||||
Q_Q(QLabel);
|
||||
if (movie && movie->isValid()) {
|
||||
@ -1251,12 +1253,12 @@ void QLabelPrivate::_q_movieUpdated(const QRect& rect)
|
||||
}
|
||||
}
|
||||
|
||||
void QLabelPrivate::_q_movieResized(const QSize& size)
|
||||
void QLabelPrivate::movieResized(const QSize &size)
|
||||
{
|
||||
Q_Q(QLabel);
|
||||
q->update(); //we need to refresh the whole background in case the new size is smaller
|
||||
valid_hints = false;
|
||||
_q_movieUpdated(QRect(QPoint(0,0), size));
|
||||
movieUpdated(QRect(QPoint(0,0), size));
|
||||
q->updateGeometry();
|
||||
}
|
||||
|
||||
@ -1278,8 +1280,10 @@ void QLabel::setMovie(QMovie *movie)
|
||||
return;
|
||||
|
||||
d->movie = movie;
|
||||
connect(movie, SIGNAL(resized(QSize)), this, SLOT(_q_movieResized(QSize)));
|
||||
connect(movie, SIGNAL(updated(QRect)), this, SLOT(_q_movieUpdated(QRect)));
|
||||
d->movieConnections = {
|
||||
QObjectPrivate::connect(movie, &QMovie::resized, d, &QLabelPrivate::movieResized),
|
||||
QObjectPrivate::connect(movie, &QMovie::updated, d, &QLabelPrivate::movieUpdated),
|
||||
};
|
||||
|
||||
// Assume that if the movie is running,
|
||||
// resize/update signals will come soon enough
|
||||
@ -1317,10 +1321,8 @@ void QLabelPrivate::clearContents()
|
||||
shortcutId = 0;
|
||||
#endif
|
||||
#if QT_CONFIG(movie)
|
||||
if (movie) {
|
||||
QObject::disconnect(movie, SIGNAL(resized(QSize)), q, SLOT(_q_movieResized(QSize)));
|
||||
QObject::disconnect(movie, SIGNAL(updated(QRect)), q, SLOT(_q_movieUpdated(QRect)));
|
||||
}
|
||||
for (const auto &conn : std::as_const(movieConnections))
|
||||
QObject::disconnect(conn);
|
||||
movie = nullptr;
|
||||
#endif
|
||||
#ifndef QT_NO_CURSOR
|
||||
@ -1580,12 +1582,12 @@ void QLabelPrivate::ensureTextControl() const
|
||||
control->setOpenExternalLinks(openExternalLinks);
|
||||
control->setPalette(q->palette());
|
||||
control->setFocus(q->hasFocus());
|
||||
QObject::connect(control, SIGNAL(updateRequest(QRectF)),
|
||||
q, SLOT(update()));
|
||||
QObject::connect(control, SIGNAL(linkHovered(QString)),
|
||||
q, SLOT(_q_linkHovered(QString)));
|
||||
QObject::connect(control, SIGNAL(linkActivated(QString)),
|
||||
q, SIGNAL(linkActivated(QString)));
|
||||
QObject::connect(control, &QWidgetTextControl::updateRequest,
|
||||
q, qOverload<>(&QLabel::update));
|
||||
QObject::connect(control, &QWidgetTextControl::linkActivated,
|
||||
q, &QLabel::linkActivated);
|
||||
QObjectPrivate::connect(control, &QWidgetTextControl::linkHovered,
|
||||
this, &QLabelPrivate::linkHovered);
|
||||
textLayoutDirty = true;
|
||||
textDirty = true;
|
||||
}
|
||||
@ -1601,7 +1603,7 @@ void QLabelPrivate::sendControlEvent(QEvent *e)
|
||||
control->processEvent(e, -layoutRect().topLeft(), q);
|
||||
}
|
||||
|
||||
void QLabelPrivate::_q_linkHovered(const QString &anchor)
|
||||
void QLabelPrivate::linkHovered(const QString &anchor)
|
||||
{
|
||||
Q_Q(QLabel);
|
||||
#ifndef QT_NO_CURSOR
|
||||
|
@ -130,15 +130,6 @@ protected:
|
||||
private:
|
||||
Q_DISABLE_COPY(QLabel)
|
||||
Q_DECLARE_PRIVATE(QLabel)
|
||||
#if QT_CONFIG(movie)
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_movieUpdated(const QRect&))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_movieResized(const QSize&))
|
||||
#endif
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_linkHovered(const QString &))
|
||||
|
||||
#ifndef QT_NO_SHORTCUT
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_buddyDeleted())
|
||||
#endif
|
||||
friend class QTipLabel;
|
||||
friend class QMessageBoxPrivate;
|
||||
friend class QBalloonTip;
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
#include <QtCore/qpointer.h>
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@ -52,12 +53,12 @@ public:
|
||||
QSize sizeForWidth(int w) const;
|
||||
|
||||
#if QT_CONFIG(movie)
|
||||
void _q_movieUpdated(const QRect&);
|
||||
void _q_movieResized(const QSize&);
|
||||
void movieUpdated(const QRect &rect);
|
||||
void movieResized(const QSize &size);
|
||||
#endif
|
||||
#ifndef QT_NO_SHORTCUT
|
||||
void updateShortcut();
|
||||
void _q_buddyDeleted();
|
||||
void buddyDeleted();
|
||||
#endif
|
||||
inline bool needTextControl() const {
|
||||
Q_Q(const QLabel);
|
||||
@ -72,7 +73,7 @@ public:
|
||||
void ensureTextControl() const;
|
||||
void sendControlEvent(QEvent *e);
|
||||
|
||||
void _q_linkHovered(const QString &link);
|
||||
void linkHovered(const QString &link);
|
||||
|
||||
QRectF layoutRect() const;
|
||||
QRect documentRect() const;
|
||||
@ -93,6 +94,7 @@ public:
|
||||
#endif
|
||||
#if QT_CONFIG(movie)
|
||||
QPointer<QMovie> movie;
|
||||
std::array<QMetaObject::Connection, 2> movieConnections;
|
||||
#endif
|
||||
mutable QWidgetTextControl *control;
|
||||
mutable QTextCursor shortcutCursor;
|
||||
|
Loading…
x
Reference in New Issue
Block a user