Optimization MaybeSave() method for Mac OS.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-12-02 21:51:19 +02:00
parent 6cd674ec0f
commit 1ccb8f3452
2 changed files with 49 additions and 20 deletions

View File

@ -2014,17 +2014,32 @@ bool TMainWindow::MaybeSave()
return true;// Don't ask if file was created without modifications.
}
QMessageBox::StandardButton ret;
ret = QMessageBox::warning(this, tr("Unsaved changes"), tr("Measurements have been modified.\n"
"Do you want to save your changes?"),
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
if (ret == QMessageBox::Save)
QMessageBox *messageBox = new QMessageBox(tr("Unsaved changes"),
tr("Measurements have been modified.\n"
"Do you want to save your changes?"),
QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No,
QMessageBox::Cancel, this, Qt::Sheet);
messageBox->setDefaultButton(QMessageBox::Yes);
messageBox->setEscapeButton(QMessageBox::Cancel);
messageBox->setButtonText(QMessageBox::Yes, curFile.isEmpty() ? tr("Save...") : tr("Save"));
messageBox->setButtonText(QMessageBox::No, tr("Don't Save"));
messageBox->setWindowModality(Qt::ApplicationModal);
const QMessageBox::StandardButton ret = static_cast<QMessageBox::StandardButton>(messageBox->exec());
switch (ret)
{
FileSave();
}
else if (ret == QMessageBox::Cancel)
{
return false;
case QMessageBox::Yes:
FileSave();
return true;
case QMessageBox::No:
return true;
case QMessageBox::Cancel:
return false;
default:
break;
}
}
return true;

View File

@ -2909,17 +2909,31 @@ bool MainWindow::MaybeSave()
{
if (this->isWindowModified() && guiEnabled)
{
QMessageBox::StandardButton ret;
ret = QMessageBox::warning(this, tr("Unsaved changes"), tr("The pattern has been modified.\n"
"Do you want to save your changes?"),
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
if (ret == QMessageBox::Save)
QMessageBox *messageBox = new QMessageBox(tr("Unsaved changes"),
tr("The pattern has been modified.\n"
"Do you want to save your changes?"),
QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No,
QMessageBox::Cancel, this, Qt::Sheet);
messageBox->setDefaultButton(QMessageBox::Yes);
messageBox->setEscapeButton(QMessageBox::Cancel);
messageBox->setButtonText(QMessageBox::Yes, curFile.isEmpty() ? tr("Save...") : tr("Save"));
messageBox->setButtonText(QMessageBox::No, tr("Don't Save"));
messageBox->setWindowModality(Qt::ApplicationModal);
const QMessageBox::StandardButton ret = static_cast<QMessageBox::StandardButton>(messageBox->exec());
switch (ret)
{
return Save();
}
else if (ret == QMessageBox::Cancel)
{
return false;
case QMessageBox::Yes:
return Save();
case QMessageBox::No:
return true;
case QMessageBox::Cancel:
return false;
default:
break;
}
}
return true;