]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiProgress.cpp
Use QMessageBox for toggleWarning if possible
[lyx.git] / src / frontends / qt4 / GuiProgress.cpp
index c7b556e4e7ec16e01c591a84afa314c80e406ab9..a21baf338c3042426f2429c4dc2c5bdbd989cab4 100644 (file)
@@ -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()
@@ -53,7 +55,7 @@ GuiProgress::GuiProgress()
        connect(this, SIGNAL(appendMessage(QString const &)), SLOT(doAppendMessage(QString const &)));
        connect(this, SIGNAL(appendError(QString const &)), SLOT(doAppendError(QString const &)));
        connect(this, SIGNAL(clearMessages()), SLOT(doClearMessages()));
-       
+
        // Alert interface
        connect(this, SIGNAL(warning(QString const &, QString const &)),
                SLOT(doWarning(QString const &, QString const &)));
@@ -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
 }