2002-03-01 18:47:56 +00:00
|
|
|
/**
|
2002-03-11 22:47:41 +00:00
|
|
|
* \file qt2/Alert_pimpl.C
|
2002-09-24 13:57:09 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-01 18:47:56 +00:00
|
|
|
*
|
2002-10-20 01:48:28 +00:00
|
|
|
* \author John Levon
|
2002-09-24 13:57:09 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-03-01 18:47:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2003-09-05 14:56:51 +00:00
|
|
|
#include "Alert_pimpl.h"
|
|
|
|
#include "Alert.h"
|
|
|
|
|
2002-03-01 18:47:56 +00:00
|
|
|
#include "ui/QAskForTextDialog.h"
|
2002-12-17 20:37:13 +00:00
|
|
|
#include "qt_helpers.h"
|
2004-05-20 09:36:28 +00:00
|
|
|
|
2002-12-18 23:26:21 +00:00
|
|
|
#include "gettext.h"
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2004-05-20 09:36:28 +00:00
|
|
|
#include <qmessagebox.h>
|
|
|
|
#include <qlabel.h>
|
|
|
|
#include <qlineedit.h>
|
|
|
|
|
2002-03-01 18:47:56 +00:00
|
|
|
#include <algorithm>
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
using lyx::support::bformat;
|
|
|
|
|
2002-03-01 18:47:56 +00:00
|
|
|
using std::pair;
|
|
|
|
using std::make_pair;
|
2003-10-06 15:43:21 +00:00
|
|
|
using std::string;
|
|
|
|
|
2002-03-01 18:47:56 +00:00
|
|
|
|
2003-03-29 07:09:13 +00:00
|
|
|
int prompt_pimpl(string const & tit, string const & question,
|
2003-04-27 16:40:50 +00:00
|
|
|
int default_button, int cancel_button,
|
2003-03-29 07:09:13 +00:00
|
|
|
string const & b1, string const & b2, string const & b3)
|
2002-03-01 18:47:56 +00:00
|
|
|
{
|
2003-07-10 12:14:47 +00:00
|
|
|
string const title = bformat(_("LyX: %1$s"), tit);
|
2002-03-01 18:47:56 +00:00
|
|
|
|
2003-04-27 16:40:50 +00:00
|
|
|
int res = QMessageBox::information(0, toqstr(title), toqstr(formatted(question)),
|
2003-03-29 07:09:13 +00:00
|
|
|
toqstr(b1), toqstr(b2), b3.empty() ? QString::null : toqstr(b3),
|
2003-04-27 16:40:50 +00:00
|
|
|
default_button, cancel_button);
|
|
|
|
|
|
|
|
// Qt bug: can return -1 on cancel or WM close, despite the docs.
|
|
|
|
if (res == -1)
|
|
|
|
res = cancel_button;
|
|
|
|
return res;
|
2002-03-01 18:47:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-29 09:02:08 +00:00
|
|
|
void warning_pimpl(string const & tit, string const & message)
|
|
|
|
{
|
2003-07-10 12:14:47 +00:00
|
|
|
string const title = bformat(_("LyX: %1$s"), tit);
|
2003-03-29 09:02:08 +00:00
|
|
|
QMessageBox::warning(0, toqstr(title), toqstr(formatted(message)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void error_pimpl(string const & tit, string const & message)
|
|
|
|
{
|
2003-07-10 12:14:47 +00:00
|
|
|
string const title = bformat(_("LyX: %1$s"), tit);
|
2003-03-29 09:02:08 +00:00
|
|
|
QMessageBox::critical(0, toqstr(title), toqstr(formatted(message)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void information_pimpl(string const & tit, string const & message)
|
|
|
|
{
|
2003-07-10 12:14:47 +00:00
|
|
|
string const title = bformat(_("LyX: %1$s"), tit);
|
2003-03-29 09:02:08 +00:00
|
|
|
QMessageBox::information(0, toqstr(title), toqstr(formatted(message)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
pair<bool, string> const
|
|
|
|
askForText_pimpl(string const & msg, string const & dflt)
|
2002-03-01 18:47:56 +00:00
|
|
|
{
|
2003-07-10 12:14:47 +00:00
|
|
|
string const title = bformat(_("LyX: %1$s"), msg);
|
2002-12-17 20:37:13 +00:00
|
|
|
QAskForTextDialog d(0, toqstr(title), true);
|
2002-03-01 18:47:56 +00:00
|
|
|
// less than ideal !
|
2002-12-17 20:37:13 +00:00
|
|
|
d.askLA->setText(toqstr('&' + msg));
|
|
|
|
d.askLE->setText(toqstr(dflt));
|
2002-09-11 17:42:45 +00:00
|
|
|
d.askLE->setFocus();
|
2002-03-01 18:47:56 +00:00
|
|
|
int ret = d.exec();
|
|
|
|
|
|
|
|
d.hide();
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-03-01 18:47:56 +00:00
|
|
|
if (ret)
|
2002-12-17 20:37:13 +00:00
|
|
|
return make_pair<bool, string>(true, fromqstr(d.askLE->text()));
|
2002-03-01 18:47:56 +00:00
|
|
|
else
|
|
|
|
return make_pair<bool, string>(false, string());
|
|
|
|
}
|