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 <qmessagebox.h>
15 #include <qlineedit.h>
16 #include "ui/QAskForTextDialog.h"
17 #include "qt_helpers.h"
23 #include "Alert_pimpl.h"
25 #include "support/BoostFormat.h"
31 int prompt_pimpl(string const & tit, string const & question,
32 int default_button, int cancel_button,
33 string const & b1, string const & b2, string const & b3)
36 boost::format fmt(_("LyX: %1$s"));
38 string const title = fmt.str();
40 string const title = _("LyX: ") + tit;
43 int res = QMessageBox::information(0, toqstr(title), toqstr(formatted(question)),
44 toqstr(b1), toqstr(b2), b3.empty() ? QString::null : toqstr(b3),
45 default_button, cancel_button);
47 // Qt bug: can return -1 on cancel or WM close, despite the docs.
54 void warning_pimpl(string const & tit, string const & message)
57 boost::format fmt(_("LyX: %1$s"));
59 string const title = fmt.str();
61 string const title = _("LyX: ") + tit;
63 QMessageBox::warning(0, toqstr(title), toqstr(formatted(message)));
67 void error_pimpl(string const & tit, string const & message)
70 boost::format fmt(_("LyX: %1$s"));
72 string const title = fmt.str();
74 string const title = _("LyX: ") + tit;
76 QMessageBox::critical(0, toqstr(title), toqstr(formatted(message)));
80 void information_pimpl(string const & tit, string const & message)
83 boost::format fmt(_("LyX: %1$s"));
85 string const title = fmt.str();
87 string const title = _("LyX: ") + tit;
89 QMessageBox::information(0, toqstr(title), toqstr(formatted(message)));
93 pair<bool, string> const
94 askForText_pimpl(string const & msg, string const & dflt)
97 boost::format fmt(_("LyX: %1$s"));
99 string const title = fmt.str();
101 string const title = _("LyX: ") + msg;
103 QAskForTextDialog d(0, toqstr(title), true);
105 d.askLA->setText(toqstr('&' + msg));
106 d.askLE->setText(toqstr(dflt));
113 return make_pair<bool, string>(true, fromqstr(d.askLE->text()));
115 return make_pair<bool, string>(false, string());