2 * \file qt4/Alert_pimpl.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Abdelrazak Younes
9 * Full author contact details are available in file CREDITS.
14 #include "Alert_pimpl.h"
17 #include "ui/QAskForTextUi.h"
18 #include "qt_helpers.h"
22 #include <QApplication>
23 #include <QMessageBox>
27 #include <QInputDialog>
34 using lyx::support::bformat;
41 int prompt_pimpl(docstring const & tit, docstring const & question,
42 int default_button, int cancel_button,
43 docstring const & b1, docstring const & b2, docstring const & b3)
45 docstring const title = bformat(_("LyX: %1$s"), tit);
47 // FIXME replace that with theApp->gui()->currentView()
48 int res = QMessageBox::information(qApp->focusWidget(),
50 toqstr(formatted(question)),
53 b3.empty() ? QString::null : toqstr(b3),
54 default_button, cancel_button);
56 // Qt bug: can return -1 on cancel or WM close, despite the docs.
63 void warning_pimpl(docstring const & tit, docstring const & message)
65 docstring const title = bformat(_("LyX: %1$s"), tit);
66 QMessageBox::warning(qApp->focusWidget(),
68 toqstr(formatted(message)));
72 void error_pimpl(docstring const & tit, docstring const & message)
74 docstring const title = bformat(_("LyX: %1$s"), tit);
75 QMessageBox::critical(qApp->focusWidget(),
77 toqstr(formatted(message)));
81 void information_pimpl(docstring const & tit, docstring const & message)
83 docstring const title = bformat(_("LyX: %1$s"), tit);
84 QMessageBox::information(qApp->focusWidget(),
86 toqstr(formatted(message)));
90 pair<bool, docstring> const
91 askForText_pimpl(docstring const & msg, docstring const & dflt)
93 docstring const title = bformat(_("LyX: %1$s"), msg);
96 QString text = QInputDialog::getText(qApp->focusWidget(),
98 toqstr(lyx::char_type('&') + msg),
102 if (ok && !text.isEmpty())
103 return make_pair<bool, docstring>(true, qstring_to_ucs4(text));
105 return make_pair<bool, docstring>(false, docstring());