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
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2002-03-01 18:47:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2002-09-24 13:57:09 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2002-03-01 18:47:56 +00:00
|
|
|
#include <qmessagebox.h>
|
|
|
|
#include <qlabel.h>
|
|
|
|
#include <qlineedit.h>
|
|
|
|
#include "ui/QAskForTextDialog.h"
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-03-01 18:47:56 +00:00
|
|
|
#include <algorithm>
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-03-01 18:47:56 +00:00
|
|
|
#include <gettext.h>
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-03-01 18:47:56 +00:00
|
|
|
#include "Alert.h"
|
2002-03-21 21:21:28 +00:00
|
|
|
#include "Alert_pimpl.h"
|
|
|
|
|
2002-11-27 10:30:28 +00:00
|
|
|
#include "BoostFormat.h"
|
|
|
|
|
|
|
|
|
2002-03-01 18:47:56 +00:00
|
|
|
using std::pair;
|
|
|
|
using std::make_pair;
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-03-01 18:47:56 +00:00
|
|
|
void alert_pimpl(string const & s1, string const & s2, string const & s3)
|
|
|
|
{
|
2002-10-20 01:48:28 +00:00
|
|
|
QMessageBox::warning(0, "LyX",
|
2002-11-27 10:30:28 +00:00
|
|
|
(s1 + '\n' + '\n' + s2 + '\n' + s3).c_str());
|
2002-03-01 18:47:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool askQuestion_pimpl(string const & s1, string const & s2, string const & s3)
|
|
|
|
{
|
2002-11-27 10:30:28 +00:00
|
|
|
return !(QMessageBox::information(0, "LyX", (s1 + '\n' + s2 + '\n' + s3).c_str(),
|
2002-03-01 18:47:56 +00:00
|
|
|
_("&Yes"), _("&No"), 0, 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int askConfirmation_pimpl(string const & s1, string const & s2, string const & s3)
|
|
|
|
{
|
2002-11-27 10:30:28 +00:00
|
|
|
return (QMessageBox::information(0, "LyX", (s1 + '\n' + s2 + '\n' + s3).c_str(),
|
2002-03-01 18:47:56 +00:00
|
|
|
_("&Yes"), _("&No"), _("&Cancel"), 0, 2)) + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2002-11-27 10:30:28 +00:00
|
|
|
#if USE_BOOST_FORMAT
|
|
|
|
boost::format fmt(_("LyX: %1$s"));
|
|
|
|
fmt % msg;
|
|
|
|
string const title = fmt.str();
|
|
|
|
#else
|
|
|
|
string const title = _("LyX: ") + msg;
|
|
|
|
#endif
|
2002-09-14 23:59:19 +00:00
|
|
|
QAskForTextDialog d(0, title.c_str(), true);
|
2002-03-01 18:47:56 +00:00
|
|
|
// less than ideal !
|
2002-11-27 10:30:28 +00:00
|
|
|
d.askLA->setText(('&' + msg).c_str());
|
2002-03-01 18:47:56 +00:00
|
|
|
d.askLE->setText(dflt.c_str());
|
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)
|
|
|
|
return make_pair<bool, string>(true, d.askLE->text().latin1());
|
|
|
|
else
|
|
|
|
return make_pair<bool, string>(false, string());
|
|
|
|
}
|