2 * \file qt2/Alert_pimpl.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "Alert_pimpl.h"
16 #include <qmessagebox.h>
18 #include <qlineedit.h>
19 #include "ui/QAskForTextDialog.h"
20 #include "qt_helpers.h"
25 using lyx::support::bformat;
32 int prompt_pimpl(string const & tit, string const & question,
33 int default_button, int cancel_button,
34 string const & b1, string const & b2, string const & b3)
36 string const title = bformat(_("LyX: %1$s"), tit);
38 int res = QMessageBox::information(0, toqstr(title), toqstr(formatted(question)),
39 toqstr(b1), toqstr(b2), b3.empty() ? QString::null : toqstr(b3),
40 default_button, cancel_button);
42 // Qt bug: can return -1 on cancel or WM close, despite the docs.
49 void warning_pimpl(string const & tit, string const & message)
51 string const title = bformat(_("LyX: %1$s"), tit);
52 QMessageBox::warning(0, toqstr(title), toqstr(formatted(message)));
56 void error_pimpl(string const & tit, string const & message)
58 string const title = bformat(_("LyX: %1$s"), tit);
59 QMessageBox::critical(0, toqstr(title), toqstr(formatted(message)));
63 void information_pimpl(string const & tit, string const & message)
65 string const title = bformat(_("LyX: %1$s"), tit);
66 QMessageBox::information(0, toqstr(title), toqstr(formatted(message)));
70 pair<bool, string> const
71 askForText_pimpl(string const & msg, string const & dflt)
73 string const title = bformat(_("LyX: %1$s"), msg);
74 QAskForTextDialog d(0, toqstr(title), true);
76 d.askLA->setText(toqstr('&' + msg));
77 d.askLE->setText(toqstr(dflt));
84 return make_pair<bool, string>(true, fromqstr(d.askLE->text()));
86 return make_pair<bool, string>(false, string());