}
-int doPrompt(docstring const & title0, docstring const & question,
- int default_button, int cancel_button,
+buttonid doPrompt(docstring const & title, docstring const & question,
+ buttonid default_button, buttonid cancel_button,
docstring const & b1, docstring const & b2,
docstring const & b3, docstring const & b4)
{
- //lyxerr << "PROMPT" << title0 << "FOCUS: " << qApp->focusWidget() << endl;
+ //lyxerr << "PROMPT" << title << "FOCUS: " << qApp->focusWidget() << endl;
if (!use_gui || lyxerr.debugging()) {
- lyxerr << toPlainText(title0) << '\n'
+ lyxerr << toPlainText(title) << '\n'
<< "----------------------------------------\n"
<< toPlainText(question) << endl;
return default_button;
}
- docstring const title = bformat(_("LyX: %1$s"), title0);
-
/// Long operation in progress prevents user from Ok-ing the error dialog
bool long_op = theApp()->longOperationStarted();
if (long_op)
// FIXME replace that with guiApp->currentView()
//LYXERR0("FOCUS: " << qApp->focusWidget());
- QPushButton * b[4] = { 0, 0, 0, 0 };
+ QPushButton * b[4] = { nullptr, nullptr, nullptr, nullptr };
+ const size_t numbuttons = sizeof(b)/sizeof(b[0]);
QMessageBox msg_box(QMessageBox::Information,
toqstr(title), toqstr(question),
QMessageBox::NoButton, qApp->focusWidget());
+#ifdef Q_OS_MAC
+ msg_box.setWindowModality(Qt::WindowModal);
+#endif
b[0] = msg_box.addButton(b1.empty() ? "OK" : toqstr(b1),
QMessageBox::ActionRole);
if (!b2.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();
+ if (default_button < numbuttons && nullptr != b[default_button])
+ msg_box.setDefaultButton(b[default_button]);
+ if (cancel_button < numbuttons && nullptr != b[cancel_button])
+ msg_box.setEscapeButton(static_cast<QAbstractButton *>(b[cancel_button]));
+ msg_box.exec();
+ const QAbstractButton * button = msg_box.clickedButton();
qApp->restoreOverrideCursor();
if (long_op)
theApp()->startLongOperation();
- // Qt bug: can return -1 on cancel or WM close, despite the docs.
- if (res == -1)
- res = cancel_button;
+ size_t res = cancel_button;
+
+ if (button == nullptr)
+ return res;
+ else {
+ // Convert selection of the button into an integer
+ for (size_t i = 0; i < numbuttons; i++) {
+ if (button == b[i]) {
+ res = i;
+ break;
+ }
+ }
+ }
+
return res;
}
-int prompt(docstring const & title0, docstring const & question,
- int default_button, int cancel_button,
+buttonid prompt(docstring const & title, docstring const & question,
+ buttonid default_button, buttonid cancel_button,
docstring const & b0, docstring const & b1,
docstring const & b2, docstring const & b3)
{
#else
return doPrompt(
#endif
- title0, question, default_button,
+ title, question, default_button,
cancel_button, b0, b1, b2, b3);
}
-void doWarning(docstring const & title0, docstring const & message,
- bool const & askshowagain)
+void doWarning(docstring const & title, docstring const & message,
+ bool askshowagain)
{
- lyxerr << "Warning: " << toPlainText(title0) << '\n'
+ lyxerr << "Warning: " << toPlainText(title) << '\n'
<< "----------------------------------------\n"
<< toPlainText(message) << endl;
if (!use_gui)
return;
- docstring const title = bformat(_("LyX: %1$s"), title0);
-
if (theApp() == 0) {
noAppDialog(toqstr(title), toqstr(message), QMessageBox::Warning);
return;
theApp()->startLongOperation();
}
-void warning(docstring const & title0, docstring const & message,
- bool const & askshowagain)
+void warning(docstring const & title, docstring const & message,
+ bool askshowagain)
{
#ifdef EXPORT_in_THREAD
InGuiThread<void>().call(&doWarning,
#else
doWarning(
#endif
- title0, message, askshowagain);
+ title, message, askshowagain);
}
-void doError(docstring const & title0, docstring const & message, bool backtrace)
+void doError(docstring const & title, docstring const & message, bool backtrace)
{
- lyxerr << "Error: " << toPlainText(title0) << '\n'
+ lyxerr << "Error: " << toPlainText(title) << '\n'
<< "----------------------------------------\n"
<< toPlainText(message) << endl;
if (!use_gui)
return;
- docstring const title = bformat(_("LyX: %1$s"), title0);
-
if (theApp() == 0) {
noAppDialog(toqstr(title), toqstr(message), QMessageBox::Critical);
return;
theApp()->startLongOperation();
}
-void error(docstring const & title0, docstring const & message, bool backtrace)
+void error(docstring const & title, docstring const & message, bool backtrace)
{
#ifdef EXPORT_in_THREAD
InGuiThread<void>().call(&doError,
#else
doError(
#endif
- title0, message, backtrace);
+ title, message, backtrace);
}
-void doInformation(docstring const & title0, docstring const & message)
+void doInformation(docstring const & title, docstring const & message)
{
if (!use_gui || lyxerr.debugging())
- lyxerr << toPlainText(title0) << '\n'
+ lyxerr << toPlainText(title) << '\n'
<< "----------------------------------------\n"
<< toPlainText(message) << endl;
if (!use_gui)
return;
- docstring const title = bformat(_("LyX: %1$s"), title0);
-
if (theApp() == 0) {
noAppDialog(toqstr(title), toqstr(message), QMessageBox::Information);
return;
theApp()->startLongOperation();
}
-void information(docstring const & title0, docstring const & message)
+void information(docstring const & title, docstring const & message)
{
#ifdef EXPORT_in_THREAD
InGuiThread<void>().call(&doInformation,
#else
doInformation(
#endif
- title0, message);
+ title, message);
}
bool doAskForText(docstring & response, docstring const & msg,
}
}
- docstring const title = bformat(_("LyX: %1$s"), msg);
+ docstring const title = bformat(from_utf8("%1$s"), msg);
/// Long operation in progress prevents user from Ok-ing the error dialog
bool long_op = theApp()->longOperationStarted();