diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2023-12-22 19:49:28 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2024-01-10 03:11:52 +0000 |
commit | e5c40ec5c117376f401c01069f05780046d07094 (patch) | |
tree | 13cd79cdedf4422d18bb5297fec170ee4dc818b8 | |
parent | f2dba1919427bcc0f510d7f60e3fafbd6f41430d (diff) |
QMessageBox: Use pmf-style connects
Port all string-based signal/slots connections to pmf-style connects.
Pick-to: 6.7
Change-Id: I7d77c2a10ed0c27422893403dfc9c5a6d43ea798
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
-rw-r--r-- | src/widgets/dialogs/qmessagebox.cpp | 34 | ||||
-rw-r--r-- | src/widgets/dialogs/qmessagebox.h | 3 |
2 files changed, 14 insertions, 23 deletions
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 31fad4c5ac..9277c5e42a 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -98,8 +98,8 @@ public: layout->addWidget(textEdit); setLayout(layout); - connect(textEdit, SIGNAL(copyAvailable(bool)), - this, SLOT(textCopyAvailable(bool))); + connect(textEdit, &TextEdit::copyAvailable, + this, &QMessageBoxDetailsText::textCopyAvailable); } void setText(const QString &text) { textEdit->setPlainText(text); } QString text() const { return textEdit->toPlainText(); } @@ -178,8 +178,8 @@ public: void init(const QString &title = QString(), const QString &text = QString()); void setupLayout(); - void _q_buttonClicked(QAbstractButton *); - void _q_helperClicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role); + void buttonClicked(QAbstractButton *); + void helperClicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role); void setClickedButton(QAbstractButton *button); QAbstractButton *findButton(int button0, int button1, int button2, int flags); @@ -257,8 +257,8 @@ void QMessageBoxPrivate::init(const QString &title, const QString &text) buttonBox = new QDialogButtonBox; buttonBox->setObjectName("qt_msgbox_buttonbox"_L1); buttonBox->setCenterButtons(q->style()->styleHint(QStyle::SH_MessageBox_CenterButtons, nullptr, q)); - QObject::connect(buttonBox, SIGNAL(clicked(QAbstractButton*)), - q, SLOT(_q_buttonClicked(QAbstractButton*))); + QObjectPrivate::connect(buttonBox, &QDialogButtonBox::clicked, + this, &QMessageBoxPrivate::buttonClicked); setupLayout(); if (!title.isEmpty() || !text.isEmpty()) { q->setWindowTitle(title); @@ -462,7 +462,7 @@ int QMessageBoxPrivate::dialogCode() const return QDialogPrivate::dialogCode(); } -void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button) +void QMessageBoxPrivate::buttonClicked(QAbstractButton *button) { Q_Q(QMessageBox); #if QT_CONFIG(textedit) @@ -496,7 +496,7 @@ void QMessageBoxPrivate::setClickedButton(QAbstractButton *button) q->done(resultCode); } -void QMessageBoxPrivate::_q_helperClicked(QPlatformDialogHelper::StandardButton helperButton, QPlatformDialogHelper::ButtonRole role) +void QMessageBoxPrivate::helperClicked(QPlatformDialogHelper::StandardButton helperButton, QPlatformDialogHelper::ButtonRole role) { Q_UNUSED(role); Q_Q(QMessageBox); @@ -511,7 +511,7 @@ void QMessageBoxPrivate::_q_helperClicked(QPlatformDialogHelper::StandardButton // Simulate click by explicitly clicking the button. This will ensure that // any logic of the button that responds to the click is respected, including - // plumbing back to _q_buttonClicked above based on the clicked() signal. + // plumbing back to buttonClicked above based on the clicked() signal. dialogButton->click(); } @@ -2766,19 +2766,13 @@ QPixmap QMessageBoxPrivate::standardIcon(QMessageBox::Icon icon, QMessageBox *mb void QMessageBoxPrivate::initHelper(QPlatformDialogHelper *h) { - Q_Q(QMessageBox); - QObject::connect(h, SIGNAL(clicked(QPlatformDialogHelper::StandardButton,QPlatformDialogHelper::ButtonRole)), - q, SLOT(_q_helperClicked(QPlatformDialogHelper::StandardButton,QPlatformDialogHelper::ButtonRole))); - auto *messageDialogHelper = static_cast<QPlatformMessageDialogHelper *>(h); - QObject::connect(messageDialogHelper, &QPlatformMessageDialogHelper::checkBoxStateChanged, q, - [this](Qt::CheckState state) { - if (checkbox) - checkbox->setCheckState(state); - } - ); + QObjectPrivate::connect(messageDialogHelper, &QPlatformMessageDialogHelper::clicked, + this, &QMessageBoxPrivate::helperClicked); + QObject::connect(messageDialogHelper, &QPlatformMessageDialogHelper::checkBoxStateChanged, + checkbox, &QCheckBox::setCheckState); - static_cast<QPlatformMessageDialogHelper *>(h)->setOptions(options); + messageDialogHelper->setOptions(options); } static QMessageDialogOptions::StandardIcon helperIcon(QMessageBox::Icon i) diff --git a/src/widgets/dialogs/qmessagebox.h b/src/widgets/dialogs/qmessagebox.h index 45e7a47cb8..5db4f6e67e 100644 --- a/src/widgets/dialogs/qmessagebox.h +++ b/src/widgets/dialogs/qmessagebox.h @@ -314,9 +314,6 @@ protected: void changeEvent(QEvent *event) override; private: - Q_PRIVATE_SLOT(d_func(), void _q_buttonClicked(QAbstractButton *)) - Q_PRIVATE_SLOT(d_func(), void _q_helperClicked(QPlatformDialogHelper::StandardButton, QPlatformDialogHelper::ButtonRole)) - Q_DISABLE_COPY(QMessageBox) Q_DECLARE_PRIVATE(QMessageBox) }; |