mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
With this commit, errors and warnings can use message box even before LyX is properly initialized. This is especially useful for missing sysdir and/or userdir directory.
* 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
This commit is contained in:
parent
66562be370
commit
6d7cd27910
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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),
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user