From 82cade48776705e0b1dd39369447ddbd82f23d53 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Tue, 10 Jul 2018 15:00:25 +0200 Subject: [PATCH] Use QMessageBox for toggleWarning if possible Qt 5.2 introduces the possibility to place a checkbox on a QMessageBox, so we need no longer to use our own crude dialog. (cherry picked from commit 0148ef7e6c2f01ce96b91567af5e2b160f9d070a) --- src/frontends/qt4/GuiProgress.cpp | 23 ++++++++++++++++++++--- status.23x | 2 ++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/frontends/qt4/GuiProgress.cpp b/src/frontends/qt4/GuiProgress.cpp index 466d20668f..a21baf338c 100644 --- a/src/frontends/qt4/GuiProgress.cpp +++ b/src/frontends/qt4/GuiProgress.cpp @@ -32,9 +32,10 @@ namespace lyx { namespace frontend { -// FIXME: This dialog has issues with line breaking and size, in particular with -// html. But it could easily be reimplemented as a QMessageBox using -// QMessageBox::setCheckBox() available starting from Qt 5.2 +// This dialog is only a fallback for Qt < 5.2, which does not feature +// QMessageBox::setCheckBox() yet. Note that it has issues with line +// breaking and size, in particular with html. +#if QT_VERSION < 0x050200 class GuiToggleWarningDialog : public QDialog, public Ui::ToggleWarningUi { public: @@ -44,6 +45,7 @@ public: QDialog::setModal(true); } }; +#endif GuiProgress::GuiProgress() @@ -172,6 +174,9 @@ void GuiProgress::doToggleWarning(QString const & title, QString const & msg, QS if (settings.value("hidden_warnings/" + msg, false).toBool()) return; +// Qt < 5.2 does not feature QMessageBox::setCheckBox() yet, +// so we roll our own dialog. +#if QT_VERSION < 0x050200 GuiToggleWarningDialog * dlg = new GuiToggleWarningDialog(qApp->focusWidget()); @@ -183,6 +188,18 @@ void GuiProgress::doToggleWarning(QString const & title, QString const & msg, QS if (dlg->dontShowAgainCB->isChecked()) settings.setValue("hidden_warnings/" + msg, true); +#else + QCheckBox * dontShowAgainCB = new QCheckBox(); + dontShowAgainCB->setText(qt_("&Do not show this warning again!")); + dontShowAgainCB->setToolTip(qt_("If you check this, LyX will not warn you again in the given case.")); + QMessageBox box(QMessageBox::Warning, title, formatted, + QMessageBox::Ok, qApp->focusWidget()); + box.setCheckBox(dontShowAgainCB); + if (box.exec() == QMessageBox::Ok) + if (dontShowAgainCB->isChecked()) + settings.setValue("hidden_warnings/" + + msg, true); +#endif } diff --git a/status.23x b/status.23x index 752b79cab6..37799e5d37 100644 --- a/status.23x +++ b/status.23x @@ -267,6 +267,8 @@ What's new - Fix "New Inset" function in the Nomenclature list dialog. +- Improve warning message dialogs. + * INTERNALS