]> git.lyx.org Git - features.git/commitdiff
With this commit, errors and warnings can use message box even before LyX is properly...
authorAbdelrazak Younes <younes@lyx.org>
Tue, 23 Jan 2007 12:38:20 +0000 (12:38 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Tue, 23 Jan 2007 12:38:20 +0000 (12:38 +0000)
* Alert.C:
  - error(): calls error_pimpl() in any case.
  - warning(): calls warning_pimpl() in any case.

* Alert_pimpl.C:
  - error_pimpl(): construct a QApplication if LyX is not initialized yet.
  - warning_pimpl(): ditto.

* lyx_main.C:
  - parse_sysdir(): replace lyxerr with Alert::error().
  - parse_userdir(): ditto.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16823 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/Alert.C
src/frontends/qt4/Alert_pimpl.C
src/lyx_main.C
src/lyx_main.h

index 3a43ade5a81f6f22276b930c1b33bba75d385c87..8c5980297740b909ece91396370b9ee6abf9ec99 100644 (file)
@@ -57,8 +57,8 @@ void Alert::warning(docstring const & title, docstring const & message)
                lyxerr << "Warning: " << to_utf8(title) << '\n'
                       << "----------------------------------------\n"
                       << to_utf8(message) << endl;
-       if (use_gui)
-               warning_pimpl(title, message);
+
+       warning_pimpl(title, message);
 }
 
 
@@ -69,8 +69,7 @@ void Alert::error(docstring const & title, docstring const & message)
                       << "----------------------------------------\n"
                       << to_utf8(message) << endl;
 
-       if (use_gui)
-               error_pimpl(title, message);
+       error_pimpl(title, message);
 }
 
 
index aeb9fba8c7041161af848f72659e67f7ebc4de07..eb32f5ab66d13e9455660e8ddce4b83c45ffc343 100644 (file)
@@ -17,6 +17,8 @@
 #include "ui/QAskForTextUi.h"
 #include "qt_helpers.h"
 
+#include "frontends/Application.h"
+
 #include "gettext.h"
 
 #include <QApplication>
@@ -84,6 +86,15 @@ void warning_pimpl(docstring const & tit, docstring const & message)
 {
        docstring const title = bformat(_("LyX: %1$s"), tit);
 
+       if (theApp() == 0) {
+               int argc = 1;
+               char * argv[1];
+               QApplication app(argc, argv);
+               QMessageBox::warning(0,
+                       toqstr(title),
+                       toqstr(formatted(message)));
+               return;
+       }
        MessageBox mb;
        mb.warning(qApp->focusWidget(),
                             toqstr(title),
@@ -94,6 +105,15 @@ void warning_pimpl(docstring const & tit, docstring const & message)
 void error_pimpl(docstring const & tit, docstring const & message)
 {
        docstring const title = bformat(_("LyX: %1$s"), tit);
+       if (theApp() == 0) {
+               int argc = 1;
+               char * argv[1];
+               QApplication app(argc, argv);
+               QMessageBox::critical(0,
+                       toqstr(title),
+                       toqstr(formatted(message)));
+               return;
+       }
        MessageBox mb;
        mb.critical(qApp->focusWidget(),
                              toqstr(title),
index 1deaa8ca251cef5ab784c43b0bf8b3f3cb6093dc..b0a6b1713ada4db0815b9b6014ee6c6ea47ee550 100644 (file)
@@ -197,7 +197,7 @@ struct LyX::Singletons
 frontend::Application * theApp()
 {
        if (singleton_)
-               return &singleton_->application();
+               return singleton_->pimpl_->application_.get();
        else
                return 0;
 }
@@ -1313,7 +1313,8 @@ int parse_version(string const &, string const &)
 int parse_sysdir(string const & arg, string const &)
 {
        if (arg.empty()) {
-               lyxerr << to_utf8(_("Missing directory for -sysdir switch")) << endl;
+               Alert::error(_("No system directory"),
+                       _("Missing directory for -sysdir switch"));
                exit(1);
        }
        cl_system_support = arg;
@@ -1323,7 +1324,8 @@ int parse_sysdir(string const & arg, string const &)
 int parse_userdir(string const & arg, string const &)
 {
        if (arg.empty()) {
-               lyxerr << to_utf8(_("Missing directory for -userdir switch")) << endl;
+               Alert::error(_("No user directory"),
+                       _("Missing directory for -userdir switch"));
                exit(1);
        }
        cl_user_support = arg;
@@ -1333,7 +1335,8 @@ int parse_userdir(string const & arg, string const &)
 int parse_execute(string const & arg, string const &)
 {
        if (arg.empty()) {
-               lyxerr << to_utf8(_("Missing command string after --execute switch")) << endl;
+               Alert::error(_("Incomplete command"),
+                       _("Missing command string after --execute switch"));
                exit(1);
        }
        batch = arg;
index b4f3c0ddb4e0ec03f95bddb25a934061df158862..4145c78b842991f0f48065cebe6677cc2ad1df53 100644 (file)
@@ -169,6 +169,7 @@ private:
        friend Mover const & getMover(std::string  const & fmt);
        friend void setMover(std::string const & fmt, std::string const & command);
        friend Movers & theSystemMovers();
+       friend frontend::Application * theApp();
 };
 
 } // namespace lyx