2 * \file qt3/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 <qapplication.h>
22 #include <qmessagebox.h>
24 #include <qlineedit.h>
28 using lyx::support::bformat;
35 int prompt_pimpl(string const & tit, string const & question,
36 int default_button, int cancel_button,
37 string const & b1, string const & b2, string const & b3)
39 string const title = bformat(_("LyX: %1$s"), tit);
41 QWidget * const parent = qApp->focusWidget() ?
42 qApp->focusWidget() : qApp->mainWidget();
44 int res = QMessageBox::information(parent,
46 toqstr(formatted(question)),
49 b3.empty() ? QString::null : toqstr(b3),
50 default_button, cancel_button);
52 // Qt bug: can return -1 on cancel or WM close, despite the docs.
59 void warning_pimpl(string const & tit, string const & message)
61 QWidget * const parent = qApp->focusWidget() ?
62 qApp->focusWidget() : qApp->mainWidget();
64 string const title = bformat(_("LyX: %1$s"), tit);
65 QMessageBox::warning(parent,
67 toqstr(formatted(message)));
71 void error_pimpl(string const & tit, string const & message)
73 QWidget * const parent = qApp->focusWidget() ?
74 qApp->focusWidget() : qApp->mainWidget();
76 string const title = bformat(_("LyX: %1$s"), tit);
77 QMessageBox::critical(parent,
79 toqstr(formatted(message)));
83 void information_pimpl(string const & tit, string const & message)
85 QWidget * const parent = qApp->focusWidget() ?
86 qApp->focusWidget() : qApp->mainWidget();
88 string const title = bformat(_("LyX: %1$s"), tit);
89 QMessageBox::information(parent,
91 toqstr(formatted(message)));
95 pair<bool, string> const
96 askForText_pimpl(string const & msg, string const & dflt)
98 QWidget * const parent = qApp->focusWidget() ?
99 qApp->focusWidget() : qApp->mainWidget();
101 string const title = bformat(_("LyX: %1$s"), msg);
102 QAskForTextDialog d(parent, toqstr(title), true);
104 d.askLA->setText(toqstr('&' + msg));
105 d.askLE->setText(toqstr(dflt));
112 return make_pair<bool, string>(true, fromqstr(d.askLE->text()));
114 return make_pair<bool, string>(false, string());