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-12-17 20:37:13 +00:00
|
|
|
#include "qt_helpers.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 "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-12-17 20:37:13 +00:00
|
|
|
toqstr(s1 + '\n' + '\n' + s2 + '\n' + s3));
|
2002-03-01 18:47:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool askQuestion_pimpl(string const & s1, string const & s2, string const & s3)
|
|
|
|
{
|
2002-12-17 20:37:13 +00:00
|
|
|
return !(QMessageBox::information(0, "LyX", toqstr(s1 + '\n' + s2 + '\n' + s3),
|
|
|
|
qt_("&Yes"), qt_("&No"), 0, 1));
|
2002-03-01 18:47:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int askConfirmation_pimpl(string const & s1, string const & s2, string const & s3)
|
|
|
|
{
|
2002-12-17 20:37:13 +00:00
|
|
|
return (QMessageBox::information(0, "LyX", toqstr(s1 + '\n' + s2 + '\n' + s3),
|
|
|
|
qt_("&Yes"), qt_("&No"), qt_("&Cancel"), 0, 2)) + 1;
|
2002-03-01 18:47:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
2002-12-17 20:37:13 +00:00
|
|
|
boost::format fmt(qt_("LyX: %1$s"));
|
2002-11-27 10:30:28 +00:00
|
|
|
fmt % msg;
|
|
|
|
string const title = fmt.str();
|
|
|
|
#else
|
2002-12-17 20:37:13 +00:00
|
|
|
string const title = qt_("LyX: ") + msg;
|
2002-11-27 10:30:28 +00:00
|
|
|
#endif
|
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());
|
|
|
|
}
|