2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2006-04-24 13:25:50 +00:00
|
|
|
* \file qt4/Alert_pimpl.C
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
* \author Abdelrazak Younes
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "Alert_pimpl.h"
|
|
|
|
#include "Alert.h"
|
|
|
|
|
|
|
|
#include "ui/QAskForTextUi.h"
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
|
|
|
#include "gettext.h"
|
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QDialog>
|
|
|
|
#include <QInputDialog>
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
using lyx::support::bformat;
|
|
|
|
|
|
|
|
using std::pair;
|
|
|
|
using std::make_pair;
|
|
|
|
using std::string;
|
|
|
|
|
|
|
|
|
|
|
|
int prompt_pimpl(string const & tit, string const & question,
|
|
|
|
int default_button, int cancel_button,
|
|
|
|
string const & b1, string const & b2, string const & b3)
|
|
|
|
{
|
2006-09-09 15:27:44 +00:00
|
|
|
string const title = bformat(lyx::to_utf8(_("LyX: %1$s")), tit);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-08-17 08:37:26 +00:00
|
|
|
// FIXME replace that with theApp->gui()->currentView()
|
|
|
|
int res = QMessageBox::information(qApp->focusWidget(),
|
2006-03-05 17:24:44 +00:00
|
|
|
toqstr(title),
|
|
|
|
toqstr(formatted(question)),
|
|
|
|
toqstr(b1),
|
|
|
|
toqstr(b2),
|
|
|
|
b3.empty() ? QString::null : toqstr(b3),
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void warning_pimpl(string const & tit, string const & message)
|
|
|
|
{
|
2006-09-09 15:27:44 +00:00
|
|
|
string const title = bformat(lyx::to_utf8(_("LyX: %1$s")), tit);
|
2006-08-17 08:37:26 +00:00
|
|
|
QMessageBox::warning(qApp->focusWidget(),
|
2006-03-05 17:24:44 +00:00
|
|
|
toqstr(title),
|
|
|
|
toqstr(formatted(message)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void error_pimpl(string const & tit, string const & message)
|
|
|
|
{
|
2006-09-09 15:27:44 +00:00
|
|
|
string const title = bformat(lyx::to_utf8(_("LyX: %1$s")), tit);
|
2006-08-17 08:37:26 +00:00
|
|
|
QMessageBox::critical(qApp->focusWidget(),
|
2006-03-05 17:24:44 +00:00
|
|
|
toqstr(title),
|
|
|
|
toqstr(formatted(message)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void information_pimpl(string const & tit, string const & message)
|
|
|
|
{
|
2006-09-09 15:27:44 +00:00
|
|
|
string const title = bformat(lyx::to_utf8(_("LyX: %1$s")), tit);
|
2006-08-17 08:37:26 +00:00
|
|
|
QMessageBox::information(qApp->focusWidget(),
|
2006-03-05 17:24:44 +00:00
|
|
|
toqstr(title),
|
|
|
|
toqstr(formatted(message)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pair<bool, string> const
|
|
|
|
askForText_pimpl(string const & msg, string const & dflt)
|
|
|
|
{
|
2006-09-09 15:27:44 +00:00
|
|
|
string const title = bformat(lyx::to_utf8(_("LyX: %1$s")), msg);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
bool ok;
|
2006-08-17 08:37:26 +00:00
|
|
|
QString text = QInputDialog::getText(qApp->focusWidget(),
|
2006-03-05 17:24:44 +00:00
|
|
|
toqstr(title),
|
|
|
|
toqstr('&' + msg),
|
|
|
|
QLineEdit::Normal,
|
|
|
|
toqstr(dflt), &ok);
|
|
|
|
|
|
|
|
if (ok && !text.isEmpty())
|
|
|
|
return make_pair<bool, string>(true, fromqstr(text));
|
|
|
|
else
|
|
|
|
return make_pair<bool, string>(false, string());
|
|
|
|
}
|