static int checkOverwrite(FileName const & filename)
{
if (!filename.exists())
- return 0;
+ return 1;
docstring text = bformat(_("The file %1$s already exists.\n\n"
"Do you want to overwrite that file?"),
makeDisplayPath(filename.absFilename()));
- int choice = Alert::prompt(_("Overwrite file?"),
- text, 0, 2,
+ return Alert::prompt(_("Overwrite file?"),
+ text, 0, 3,
_("&Keep file"), _("&Overwrite"),
- _("&Cancel export"));
-
- if (choice == 0)
- return -1;
-
- if (choice == 1) {
- text = _("Should I continue asking for overwriting files?");
- return Alert::prompt(_("Overwrite all files?"),
- text, 0, 0,
- _("Continue &asking"), _("&Overwrite all"));
- }
- return choice;
+ _("Overwrite &all"), _("&Cancel export"));
}
if (!force) {
switch(checkOverwrite(destFile)) {
- case -1:
- return SUCCESS;
case 0:
+ return SUCCESS;
+ case 1:
ret = SUCCESS;
break;
- case 1:
+ case 2:
ret = FORCE;
break;
default:
*/
int prompt(docstring const & title, docstring const & question,
int default_button, int cancel_button,
- docstring const & b1, docstring const & b2, docstring const & b3 = docstring());
+ docstring const & b1, docstring const & b2,
+ docstring const & b3 = docstring(),
+ docstring const & b4 = docstring());
/**
* Display a warning to the user. Title should be a short (general) summary.
#include <QMessageBox>
#include <QLineEdit>
#include <QInputDialog>
+#include <QPushButton>
#include <QSettings>
#include <iomanip>
int prompt(docstring const & title0, docstring const & question,
int default_button, int cancel_button,
- docstring const & b1, docstring const & b2, docstring const & b3)
+ docstring const & b1, docstring const & b2,
+ docstring const & b3, docstring const & b4)
{
//lyxerr << "PROMPT" << title0 << "FOCUS: " << qApp->focusWidget() << endl;
if (!use_gui || lyxerr.debugging()) {
case 0: lyxerr << b1 << endl;
case 1: lyxerr << b2 << endl;
case 2: lyxerr << b3 << endl;
+ case 3: lyxerr << b4 << endl;
}
if (!use_gui)
return default_button;
// FIXME replace that with guiApp->currentView()
//LYXERR0("FOCUS: " << qApp->focusWidget());
- int res = QMessageBox::information(qApp->focusWidget(),
- toqstr(title),
- toqstr(formatted(question)),
- toqstr(b1),
- toqstr(b2),
- b3.empty() ? QString::null : toqstr(b3),
- default_button, cancel_button);
+ QPushButton * b[4] = { 0, 0, 0, 0 };
+ QMessageBox msg_box(QMessageBox::Information,
+ toqstr(title), toqstr(formatted(question)),
+ QMessageBox::NoButton, qApp->focusWidget());
+ b[0] = msg_box.addButton(b1.empty() ? "OK" : toqstr(b1),
+ QMessageBox::ActionRole);
+ if (!b2.empty())
+ b[1] = msg_box.addButton(toqstr(b2), QMessageBox::ActionRole);
+ if (!b3.empty())
+ b[2] = msg_box.addButton(toqstr(b3), QMessageBox::ActionRole);
+ if (!b4.empty())
+ b[3] = msg_box.addButton(toqstr(b4), QMessageBox::ActionRole);
+ msg_box.setDefaultButton(b[default_button]);
+ msg_box.setEscapeButton(static_cast<QAbstractButton *>(b[cancel_button]));
+ int res = msg_box.exec();
qApp->restoreOverrideCursor();