mirror of https://github.com/vitalif/openscad
Add Mac standard Cmd-D shortcut for the 'Don't Save' button
parent
6ec9934365
commit
9ccde53749
|
@ -2105,13 +2105,24 @@ MainWindow::maybeSave()
|
||||||
{
|
{
|
||||||
if (editor->isContentModified()) {
|
if (editor->isContentModified()) {
|
||||||
QMessageBox::StandardButton ret;
|
QMessageBox::StandardButton ret;
|
||||||
ret = QMessageBox::warning(this, "Application",
|
QMessageBox box(this);
|
||||||
"The document has been modified.\n"
|
box.setText("The document has been modified.");
|
||||||
"Do you want to save your changes?",
|
box.setInformativeText("Do you want to save your changes?");
|
||||||
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
box.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
||||||
|
box.setDefaultButton(QMessageBox::Save);
|
||||||
|
box.setIcon(QMessageBox::Warning);
|
||||||
|
box.setWindowModality(Qt::ApplicationModal);
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
// Cmd-D is the standard shortcut for this button on Mac
|
||||||
|
box.button(QMessageBox::Discard)->setShortcut(QKeySequence("Ctrl+D"));
|
||||||
|
box.button(QMessageBox::Discard)->setShortcutEnabled(true);
|
||||||
|
#endif
|
||||||
|
ret = (QMessageBox::StandardButton) box.exec();
|
||||||
|
|
||||||
if (ret == QMessageBox::Save) {
|
if (ret == QMessageBox::Save) {
|
||||||
actionSave();
|
actionSave();
|
||||||
return true; // FIXME: Should return false on error
|
// Returns false on failed save
|
||||||
|
return !editor->isContentModified();
|
||||||
}
|
}
|
||||||
else if (ret == QMessageBox::Cancel) {
|
else if (ret == QMessageBox::Cancel) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue