diff options
-rw-r--r-- | src/widgets/dialogs/qmessagebox.cpp | 5 | ||||
-rw-r--r-- | src/widgets/dialogs/qmessagebox.h | 66 | ||||
-rw-r--r-- | tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp | 9 |
3 files changed, 61 insertions, 19 deletions
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 1a8006944b..f3c3c487d7 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -2049,6 +2049,7 @@ void QMessageBoxPrivate::retranslateStrings() #endif } +#if QT_DEPRECATED_SINCE(6,2) /*! \obsolete @@ -2497,6 +2498,8 @@ void QMessageBox::setButtonText(int button, const QString &text) addButton(QMessageBox::Ok)->setText(text); } } +#endif // QT_DEPRECATED_SINCE(6,2) + #if QT_CONFIG(textedit) /*! @@ -2724,6 +2727,7 @@ void QMessageBoxPrivate::helperDone(QDialog::DialogCode code, QPlatformDialogHel clickedButton = button; } +#if QT_DEPRECATED_SINCE(6,2) /*! \obsolete @@ -2741,6 +2745,7 @@ QPixmap QMessageBox::standardIcon(Icon icon) { return QMessageBoxPrivate::standardIcon(icon, nullptr); } +#endif /*! \typedef QMessageBox::Button diff --git a/src/widgets/dialogs/qmessagebox.h b/src/widgets/dialogs/qmessagebox.h index 0a2edb1eee..eeb0da7df8 100644 --- a/src/widgets/dialogs/qmessagebox.h +++ b/src/widgets/dialogs/qmessagebox.h @@ -127,7 +127,9 @@ public: FlagMask = 0x00000300, // obsolete ButtonMask = ~FlagMask // obsolete }; - typedef StandardButton Button; // obsolete +#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) + typedef StandardButton Button; +#endif Q_DECLARE_FLAGS(StandardButtons, StandardButton) Q_FLAG(StandardButtons) @@ -185,28 +187,59 @@ public: static StandardButton information(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton); +#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) // needed as long as we have int overloads + inline static StandardButton information(QWidget *parent, const QString &title, + const QString& text, + StandardButton button0, StandardButton button1 = NoButton) + { return information(parent, title, text, StandardButtons(button0), button1); } +#endif + static StandardButton question(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons = StandardButtons(Yes | No), StandardButton defaultButton = NoButton); +#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) + inline static int question(QWidget *parent, const QString &title, + const QString& text, + StandardButton button0, StandardButton button1) + { return question(parent, title, text, StandardButtons(button0), button1); } +#endif + static StandardButton warning(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton); +#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) + inline static int warning(QWidget *parent, const QString &title, + const QString& text, + StandardButton button0, StandardButton button1) + { return warning(parent, title, text, StandardButtons(button0), button1); } +#endif + static StandardButton critical(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton); +#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) + inline static int critical(QWidget *parent, const QString &title, + const QString& text, + StandardButton button0, StandardButton button1) + { return critical(parent, title, text, StandardButtons(button0), button1); } +#endif + static void about(QWidget *parent, const QString &title, const QString &text); static void aboutQt(QWidget *parent, const QString &title = QString()); +#if QT_DEPRECATED_SINCE(6,2) // the following functions are obsolete: - + QT_DEPRECATED_VERSION_X_6_2("Use the overload taking StandardButtons instead.") QMessageBox(const QString &title, const QString &text, Icon icon, int button0, int button1, int button2, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); + QT_DEPRECATED_VERSION_X_6_2("Use the overload taking StandardButtons instead.") static int information(QWidget *parent, const QString &title, const QString& text, int button0, int button1 = 0, int button2 = 0); + QT_DEPRECATED_VERSION_X_6_2("Use the overload taking StandardButtons instead.") static int information(QWidget *parent, const QString &title, const QString& text, const QString& button0Text, @@ -214,14 +247,12 @@ public: const QString& button2Text = QString(), int defaultButtonNumber = 0, int escapeButtonNumber = -1); - inline static StandardButton information(QWidget *parent, const QString &title, - const QString& text, - StandardButton button0, StandardButton button1 = NoButton) - { return information(parent, title, text, StandardButtons(button0), button1); } + QT_DEPRECATED_VERSION_X_6_2("Use the overload taking StandardButtons instead.") static int question(QWidget *parent, const QString &title, const QString& text, int button0, int button1 = 0, int button2 = 0); + QT_DEPRECATED_VERSION_X_6_2("Use the overload taking StandardButtons instead.") static int question(QWidget *parent, const QString &title, const QString& text, const QString& button0Text, @@ -229,14 +260,12 @@ public: const QString& button2Text = QString(), int defaultButtonNumber = 0, int escapeButtonNumber = -1); - inline static int question(QWidget *parent, const QString &title, - const QString& text, - StandardButton button0, StandardButton button1) - { return question(parent, title, text, StandardButtons(button0), button1); } + QT_DEPRECATED_VERSION_X_6_2("Use the overload taking StandardButtons instead.") static int warning(QWidget *parent, const QString &title, const QString& text, int button0, int button1, int button2 = 0); + QT_DEPRECATED_VERSION_X_6_2("Use the overload taking StandardButtons instead.") static int warning(QWidget *parent, const QString &title, const QString& text, const QString& button0Text, @@ -244,14 +273,12 @@ public: const QString& button2Text = QString(), int defaultButtonNumber = 0, int escapeButtonNumber = -1); - inline static int warning(QWidget *parent, const QString &title, - const QString& text, - StandardButton button0, StandardButton button1) - { return warning(parent, title, text, StandardButtons(button0), button1); } + QT_DEPRECATED_VERSION_X_6_2("Use the overload taking StandardButtons instead.") static int critical(QWidget *parent, const QString &title, const QString& text, int button0, int button1, int button2 = 0); + QT_DEPRECATED_VERSION_X_6_2("Use the overload taking StandardButtons instead.") static int critical(QWidget *parent, const QString &title, const QString& text, const QString& button0Text, @@ -259,13 +286,12 @@ public: const QString& button2Text = QString(), int defaultButtonNumber = 0, int escapeButtonNumber = -1); - inline static int critical(QWidget *parent, const QString &title, - const QString& text, - StandardButton button0, StandardButton button1) - { return critical(parent, title, text, StandardButtons(button0), button1); } + QT_DEPRECATED_VERSION_X_6_2("Use button() and QPushButton::text() instead.") QString buttonText(int button) const; + QT_DEPRECATED_VERSION_X_6_2("Use addButton() instead.") void setButtonText(int button, const QString &text); +#endif QString informativeText() const; void setInformativeText(const QString &text); @@ -278,8 +304,10 @@ public: void setWindowTitle(const QString &title); void setWindowModality(Qt::WindowModality windowModality); - +#if QT_DEPRECATED_SINCE(6,2) + QT_DEPRECATED_VERSION_X_6_2("Use QStyle::standardIcon() instead.") static QPixmap standardIcon(Icon icon); +#endif Q_SIGNALS: void buttonClicked(QAbstractButton *button); diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp index ce84459973..4210c428ec 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp +++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp @@ -388,6 +388,8 @@ void tst_QMessageBox::staticSourceCompat() int ret; // source compat tests for < 4.2 +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED ExecCloseHelper closeHelper; closeHelper.start(Qt::Key_Enter); ret = QMessageBox::information(nullptr, "title", "text", QMessageBox::Yes, QMessageBox::No); @@ -438,10 +440,13 @@ void tst_QMessageBox::staticSourceCompat() QCOMPARE(ret, 1); QVERIFY(closeHelper.done()); } +QT_WARNING_POP } void tst_QMessageBox::instanceSourceCompat() { +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QMessageBox mb("Application name here", "Saving the file will overwrite the original file on the disk.\n" "Do you really want to save?", @@ -466,6 +471,7 @@ void tst_QMessageBox::instanceSourceCompat() closeHelper.start(QKeyCombination(Qt::ALT | Qt::Key_Z).toCombined(), &mb); QCOMPARE(mb.exec(), 1); #endif +QT_WARNING_POP } void tst_QMessageBox::detailsText() @@ -546,8 +552,11 @@ void tst_QMessageBox::incorrectDefaultButton() closeHelper.start(Qt::Key_Escape); QTest::ignoreMessage(QtWarningMsg, "QDialogButtonBox::createButton: Invalid ButtonRole, button not added"); QTest::ignoreMessage(QtWarningMsg, "QDialogButtonBox::createButton: Invalid ButtonRole, button not added"); +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED //do not crash here -> call old function of QMessageBox in this case QMessageBox::question(nullptr, "", "I've been hit!",QMessageBox::Ok | QMessageBox::Cancel,QMessageBox::Save | QMessageBox::Cancel,QMessageBox::Ok); +QT_WARNING_POP QVERIFY(closeHelper.done()); } |