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>
31 using lyx::support::bformat;
38 int prompt_pimpl(docstring const & tit, docstring const & question,
39 int default_button, int cancel_button,
40 docstring const & b1, docstring const & b2, docstring const & b3)
42 docstring const title = bformat(_("LyX: %1$s"), tit);
44 // FIXME replace that with theApp->gui()->currentView()
45 int res = QMessageBox::information(qApp->focusWidget(),
47 toqstr(formatted(question)),
50 b3.empty() ? QString::null : toqstr(b3),
51 default_button, cancel_button);
53 // Qt bug: can return -1 on cancel or WM close, despite the docs.
60 void warning_pimpl(docstring const & tit, docstring const & message)
62 docstring const title = bformat(_("LyX: %1$s"), tit);
63 QMessageBox::warning(qApp->focusWidget(),
65 toqstr(formatted(message)));
69 void error_pimpl(docstring const & tit, docstring const & message)
71 docstring const title = bformat(_("LyX: %1$s"), tit);
72 QMessageBox::critical(qApp->focusWidget(),
74 toqstr(formatted(message)));
78 void information_pimpl(docstring const & tit, docstring const & message)
80 docstring const title = bformat(_("LyX: %1$s"), tit);
81 QMessageBox::information(qApp->focusWidget(),
83 toqstr(formatted(message)));
87 pair<bool, docstring> const
88 askForText_pimpl(docstring const & msg, docstring const & dflt)
90 docstring const title = bformat(_("LyX: %1$s"), msg);
93 QString text = QInputDialog::getText(qApp->focusWidget(),
95 toqstr(lyx::char_type('&') + msg),
99 if (ok && !text.isEmpty())
100 return make_pair<bool, docstring>(true, qstring_to_ucs4(text));
102 return make_pair<bool, docstring>(false, docstring());