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(string const & tit, string const & question,
39 int default_button, int cancel_button,
40 string const & b1, string const & b2, string const & b3)
42 string 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(string const & tit, string const & message)
62 string const title = bformat(_("LyX: %1$s"), tit);
63 QMessageBox::warning(qApp->focusWidget(),
65 toqstr(formatted(message)));
69 void error_pimpl(string const & tit, string const & message)
71 string const title = bformat(_("LyX: %1$s"), tit);
72 QMessageBox::critical(qApp->focusWidget(),
74 toqstr(formatted(message)));
78 void information_pimpl(string const & tit, string const & message)
80 string const title = bformat(_("LyX: %1$s"), tit);
81 QMessageBox::information(qApp->focusWidget(),
83 toqstr(formatted(message)));
87 pair<bool, string> const
88 askForText_pimpl(string const & msg, string const & dflt)
90 string const title = bformat(_("LyX: %1$s"), msg);
93 QString text = QInputDialog::getText(qApp->focusWidget(),
99 if (ok && !text.isEmpty())
100 return make_pair<bool, string>(true, fromqstr(text));
102 return make_pair<bool, string>(false, string());