]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiAlert.cpp
Typos etc.
[lyx.git] / src / frontends / qt4 / GuiAlert.cpp
index 5c128bc7d13973bd896f7c64921cac312239a51f..fdb2065c084f1fa40ad9ad1902cf472b2b77b44a 100644 (file)
@@ -4,6 +4,7 @@
  * Licence details can be found in the file COPYING.
  *
  * \author John Levon
+ * \author Jürgen Spitzmüller
  * \author Abdelrazak Younes
  *
  * Full author contact details are available in file CREDITS.
@@ -13,6 +14,7 @@
 
 #include "alert.h"
 
+
 #include "frontends/Application.h"
 
 #include "qt_helpers.h"
 #include "support/debug.h"
 #include "support/docstring.h"
 #include "support/lstrings.h"
+#include "support/ProgressInterface.h"
 
 #include <QApplication>
+#include <QCheckBox>
 #include <QMessageBox>
 #include <QLineEdit>
 #include <QInputDialog>
+#include <QSettings>
 
 #include <iomanip>
 #include <iostream>
@@ -39,6 +44,8 @@ namespace lyx {
 namespace frontend {
 
 
+
+
 static docstring const formatted(docstring const & text)
 {
        const int w = 80;
@@ -99,6 +106,21 @@ static docstring const formatted(docstring const & text)
 }
 
 
+void noAppDialog(QString const & title, QString const & msg, QMessageBox::Icon mode)
+{
+       int argc = 1;
+       char * argv[1];
+       QApplication app(argc, argv);
+       switch (mode)
+       {
+               case QMessageBox::Information: QMessageBox::information(0, title, msg); break;
+               case QMessageBox::Warning: QMessageBox::warning(0, title, msg); break;
+               case QMessageBox::Critical: QMessageBox::critical(0, title, msg); break;
+               default: break;
+       }
+}
+
+
 namespace Alert {
 
 int prompt(docstring const & title0, docstring const & question,
@@ -145,7 +167,8 @@ int prompt(docstring const & title0, docstring const & question,
 }
 
 
-void warning(docstring const & title0, docstring const & message)
+void warning(docstring const & title0, docstring const & message,
+            bool const & askshowagain)
 {
        lyxerr << "Warning: " << title0 << '\n'
               << "----------------------------------------\n"
@@ -157,22 +180,22 @@ void warning(docstring const & title0, docstring const & message)
        docstring const title = bformat(_("LyX: %1$s"), title0);
 
        if (theApp() == 0) {
-               int argc = 1;
-               char * argv[1];
-               QApplication app(argc, argv);
-               QMessageBox::warning(0,
-                       toqstr(title),
-                       toqstr(formatted(message)));
+               noAppDialog(toqstr(title), toqstr(formatted(message)), QMessageBox::Warning);
                return;
        }
-       QMessageBox::warning(qApp->focusWidget(),
-                            toqstr(title),
-                            toqstr(formatted(message)));
-}
 
+       if (!askshowagain) {
+               ProgressInterface::instance()->warning(
+                               toqstr(title),
+                               toqstr(formatted(message)));
+       } else {
+               ProgressInterface::instance()->toggleWarning(
+                               toqstr(title),
+                               toqstr(message),
+                               toqstr(formatted(message)));
+       }
+}
 
-int argc = 1;
-char * argv[1];
 
 void error(docstring const & title0, docstring const & message)
 {
@@ -184,16 +207,15 @@ void error(docstring const & title0, docstring const & message)
                return;
 
        docstring const title = bformat(_("LyX: %1$s"), title0);
+
        if (theApp() == 0) {
-               QApplication app(argc, argv);
-               QMessageBox::critical(0,
-                       toqstr(title),
-                       toqstr(formatted(message)));
+               noAppDialog(toqstr(title), toqstr(formatted(message)), QMessageBox::Critical);
                return;
        }
-       QMessageBox::critical(qApp->focusWidget(),
-                             toqstr(title),
-                             toqstr(formatted(message)));
+
+       ProgressInterface::instance()->error(
+               toqstr(title),
+               toqstr(formatted(message)));
 }
 
 
@@ -208,9 +230,15 @@ void information(docstring const & title0, docstring const & message)
                return;
 
        docstring const title = bformat(_("LyX: %1$s"), title0);
-       QMessageBox::information(qApp->focusWidget(),
-                                toqstr(title),
-                                toqstr(formatted(message)));
+
+       if (theApp() == 0) {
+               noAppDialog(toqstr(title), toqstr(formatted(message)), QMessageBox::Information);
+               return;
+       }
+
+       ProgressInterface::instance()->information(
+               toqstr(title),
+               toqstr(formatted(message)));
 }