* 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
lyxerr << "Warning: " << to_utf8(title) << '\n'
<< "----------------------------------------\n"
<< to_utf8(message) << endl;
- if (use_gui)
- warning_pimpl(title, message);
+
+ warning_pimpl(title, message);
}
<< "----------------------------------------\n"
<< to_utf8(message) << endl;
- if (use_gui)
- error_pimpl(title, message);
+ error_pimpl(title, message);
}
#include "ui/QAskForTextUi.h"
#include "qt_helpers.h"
+#include "frontends/Application.h"
+
#include "gettext.h"
#include <QApplication>
{
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),
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),
frontend::Application * theApp()
{
if (singleton_)
- return &singleton_->application();
+ return singleton_->pimpl_->application_.get();
else
return 0;
}
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;
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;
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;
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