mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Extend Alert::prompt such that 4 buttons are possible. Thus, when
exporting, the extra dialog appearing when choosing to overwrite a file is not necessary anymore. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34222 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
30792f994e
commit
87caf487e1
@ -40,26 +40,15 @@ namespace Alert = frontend::Alert;
|
||||
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"));
|
||||
}
|
||||
|
||||
|
||||
@ -89,12 +78,12 @@ CopyStatus copyFile(string const & format,
|
||||
|
||||
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:
|
||||
|
@ -32,7 +32,9 @@ namespace Alert {
|
||||
*/
|
||||
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.
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QLineEdit>
|
||||
#include <QInputDialog>
|
||||
#include <QPushButton>
|
||||
#include <QSettings>
|
||||
|
||||
#include <iomanip>
|
||||
@ -125,7 +126,8 @@ namespace Alert {
|
||||
|
||||
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()) {
|
||||
@ -138,6 +140,7 @@ int prompt(docstring const & title0, docstring const & question,
|
||||
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;
|
||||
@ -151,13 +154,21 @@ int prompt(docstring const & title0, docstring const & question,
|
||||
|
||||
// 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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user