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);
|
Q_D(QLabel);
|
||||||
|
|
||||||
if (d->buddy)
|
if (d->buddy)
|
||||||
disconnect(d->buddy, SIGNAL(destroyed()), this, SLOT(_q_buddyDeleted()));
|
QObjectPrivate::disconnect(d->buddy, &QObject::destroyed,
|
||||||
|
d, &QLabelPrivate::buddyDeleted);
|
||||||
|
|
||||||
d->buddy = buddy;
|
d->buddy = buddy;
|
||||||
|
|
||||||
if (buddy)
|
if (buddy)
|
||||||
connect(buddy, SIGNAL(destroyed()), this, SLOT(_q_buddyDeleted()));
|
QObjectPrivate::connect(buddy, &QObject::destroyed,
|
||||||
|
d, &QLabelPrivate::buddyDeleted);
|
||||||
|
|
||||||
if (d->isTextLabel) {
|
if (d->isTextLabel) {
|
||||||
if (d->shortcutId)
|
if (d->shortcutId)
|
||||||
@ -1219,7 +1221,7 @@ void QLabelPrivate::updateShortcut()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QLabelPrivate::_q_buddyDeleted()
|
void QLabelPrivate::buddyDeleted()
|
||||||
{
|
{
|
||||||
Q_Q(QLabel);
|
Q_Q(QLabel);
|
||||||
q->setBuddy(nullptr);
|
q->setBuddy(nullptr);
|
||||||
@ -1228,7 +1230,7 @@ void QLabelPrivate::_q_buddyDeleted()
|
|||||||
#endif // QT_NO_SHORTCUT
|
#endif // QT_NO_SHORTCUT
|
||||||
|
|
||||||
#if QT_CONFIG(movie)
|
#if QT_CONFIG(movie)
|
||||||
void QLabelPrivate::_q_movieUpdated(const QRect& rect)
|
void QLabelPrivate::movieUpdated(const QRect &rect)
|
||||||
{
|
{
|
||||||
Q_Q(QLabel);
|
Q_Q(QLabel);
|
||||||
if (movie && movie->isValid()) {
|
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_Q(QLabel);
|
||||||
q->update(); //we need to refresh the whole background in case the new size is smaller
|
q->update(); //we need to refresh the whole background in case the new size is smaller
|
||||||
valid_hints = false;
|
valid_hints = false;
|
||||||
_q_movieUpdated(QRect(QPoint(0,0), size));
|
movieUpdated(QRect(QPoint(0,0), size));
|
||||||
q->updateGeometry();
|
q->updateGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1278,8 +1280,10 @@ void QLabel::setMovie(QMovie *movie)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
d->movie = movie;
|
d->movie = movie;
|
||||||
connect(movie, SIGNAL(resized(QSize)), this, SLOT(_q_movieResized(QSize)));
|
d->movieConnections = {
|
||||||
connect(movie, SIGNAL(updated(QRect)), this, SLOT(_q_movieUpdated(QRect)));
|
QObjectPrivate::connect(movie, &QMovie::resized, d, &QLabelPrivate::movieResized),
|
||||||
|
QObjectPrivate::connect(movie, &QMovie::updated, d, &QLabelPrivate::movieUpdated),
|
||||||
|
};
|
||||||
|
|
||||||
// Assume that if the movie is running,
|
// Assume that if the movie is running,
|
||||||
// resize/update signals will come soon enough
|
// resize/update signals will come soon enough
|
||||||
@ -1317,10 +1321,8 @@ void QLabelPrivate::clearContents()
|
|||||||
shortcutId = 0;
|
shortcutId = 0;
|
||||||
#endif
|
#endif
|
||||||
#if QT_CONFIG(movie)
|
#if QT_CONFIG(movie)
|
||||||
if (movie) {
|
for (const auto &conn : std::as_const(movieConnections))
|
||||||
QObject::disconnect(movie, SIGNAL(resized(QSize)), q, SLOT(_q_movieResized(QSize)));
|
QObject::disconnect(conn);
|
||||||
QObject::disconnect(movie, SIGNAL(updated(QRect)), q, SLOT(_q_movieUpdated(QRect)));
|
|
||||||
}
|
|
||||||
movie = nullptr;
|
movie = nullptr;
|
||||||
#endif
|
#endif
|
||||||
#ifndef QT_NO_CURSOR
|
#ifndef QT_NO_CURSOR
|
||||||
@ -1580,12 +1582,12 @@ void QLabelPrivate::ensureTextControl() const
|
|||||||
control->setOpenExternalLinks(openExternalLinks);
|
control->setOpenExternalLinks(openExternalLinks);
|
||||||
control->setPalette(q->palette());
|
control->setPalette(q->palette());
|
||||||
control->setFocus(q->hasFocus());
|
control->setFocus(q->hasFocus());
|
||||||
QObject::connect(control, SIGNAL(updateRequest(QRectF)),
|
QObject::connect(control, &QWidgetTextControl::updateRequest,
|
||||||
q, SLOT(update()));
|
q, qOverload<>(&QLabel::update));
|
||||||
QObject::connect(control, SIGNAL(linkHovered(QString)),
|
QObject::connect(control, &QWidgetTextControl::linkActivated,
|
||||||
q, SLOT(_q_linkHovered(QString)));
|
q, &QLabel::linkActivated);
|
||||||
QObject::connect(control, SIGNAL(linkActivated(QString)),
|
QObjectPrivate::connect(control, &QWidgetTextControl::linkHovered,
|
||||||
q, SIGNAL(linkActivated(QString)));
|
this, &QLabelPrivate::linkHovered);
|
||||||
textLayoutDirty = true;
|
textLayoutDirty = true;
|
||||||
textDirty = true;
|
textDirty = true;
|
||||||
}
|
}
|
||||||
@ -1601,7 +1603,7 @@ void QLabelPrivate::sendControlEvent(QEvent *e)
|
|||||||
control->processEvent(e, -layoutRect().topLeft(), q);
|
control->processEvent(e, -layoutRect().topLeft(), q);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QLabelPrivate::_q_linkHovered(const QString &anchor)
|
void QLabelPrivate::linkHovered(const QString &anchor)
|
||||||
{
|
{
|
||||||
Q_Q(QLabel);
|
Q_Q(QLabel);
|
||||||
#ifndef QT_NO_CURSOR
|
#ifndef QT_NO_CURSOR
|
||||||
|
@ -130,15 +130,6 @@ protected:
|
|||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(QLabel)
|
Q_DISABLE_COPY(QLabel)
|
||||||
Q_DECLARE_PRIVATE(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 QTipLabel;
|
||||||
friend class QMessageBoxPrivate;
|
friend class QMessageBoxPrivate;
|
||||||
friend class QBalloonTip;
|
friend class QBalloonTip;
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include <QtCore/qpointer.h>
|
#include <QtCore/qpointer.h>
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@ -52,12 +53,12 @@ public:
|
|||||||
QSize sizeForWidth(int w) const;
|
QSize sizeForWidth(int w) const;
|
||||||
|
|
||||||
#if QT_CONFIG(movie)
|
#if QT_CONFIG(movie)
|
||||||
void _q_movieUpdated(const QRect&);
|
void movieUpdated(const QRect &rect);
|
||||||
void _q_movieResized(const QSize&);
|
void movieResized(const QSize &size);
|
||||||
#endif
|
#endif
|
||||||
#ifndef QT_NO_SHORTCUT
|
#ifndef QT_NO_SHORTCUT
|
||||||
void updateShortcut();
|
void updateShortcut();
|
||||||
void _q_buddyDeleted();
|
void buddyDeleted();
|
||||||
#endif
|
#endif
|
||||||
inline bool needTextControl() const {
|
inline bool needTextControl() const {
|
||||||
Q_Q(const QLabel);
|
Q_Q(const QLabel);
|
||||||
@ -72,7 +73,7 @@ public:
|
|||||||
void ensureTextControl() const;
|
void ensureTextControl() const;
|
||||||
void sendControlEvent(QEvent *e);
|
void sendControlEvent(QEvent *e);
|
||||||
|
|
||||||
void _q_linkHovered(const QString &link);
|
void linkHovered(const QString &link);
|
||||||
|
|
||||||
QRectF layoutRect() const;
|
QRectF layoutRect() const;
|
||||||
QRect documentRect() const;
|
QRect documentRect() const;
|
||||||
@ -93,6 +94,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
#if QT_CONFIG(movie)
|
#if QT_CONFIG(movie)
|
||||||
QPointer<QMovie> movie;
|
QPointer<QMovie> movie;
|
||||||
|
std::array<QMetaObject::Connection, 2> movieConnections;
|
||||||
#endif
|
#endif
|
||||||
mutable QWidgetTextControl *control;
|
mutable QWidgetTextControl *control;
|
||||||
mutable QTextCursor shortcutCursor;
|
mutable QTextCursor shortcutCursor;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user