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 "ui/QAskForTextDialog.h"
17 #include "qt_helpers.h"
21 #include <qmessagebox.h>
23 #include <qlineedit.h>
27 using lyx::support::bformat;
34 int prompt_pimpl(string const & tit, string const & question,
35 int default_button, int cancel_button,
36 string const & b1, string const & b2, string const & b3)
38 string const title = bformat(_("LyX: %1$s"), tit);
40 int res = QMessageBox::information(0, toqstr(title), toqstr(formatted(question)),
41 toqstr(b1), toqstr(b2), b3.empty() ? QString::null : toqstr(b3),
42 default_button, cancel_button);
44 // Qt bug: can return -1 on cancel or WM close, despite the docs.
51 void warning_pimpl(string const & tit, string const & message)
53 string const title = bformat(_("LyX: %1$s"), tit);
54 QMessageBox::warning(0, toqstr(title), toqstr(formatted(message)));
58 void error_pimpl(string const & tit, string const & message)
60 string const title = bformat(_("LyX: %1$s"), tit);
61 QMessageBox::critical(0, toqstr(title), toqstr(formatted(message)));
65 void information_pimpl(string const & tit, string const & message)
67 string const title = bformat(_("LyX: %1$s"), tit);
68 QMessageBox::information(0, toqstr(title), toqstr(formatted(message)));
72 pair<bool, string> const
73 askForText_pimpl(string const & msg, string const & dflt)
75 string const title = bformat(_("LyX: %1$s"), msg);
76 QAskForTextDialog d(0, toqstr(title), true);
78 d.askLA->setText(toqstr('&' + msg));
79 d.askLE->setText(toqstr(dflt));
86 return make_pair<bool, string>(true, fromqstr(d.askLE->text()));
88 return make_pair<bool, string>(false, string());