Gui: Add switching to the document when closing FreeCAD (#21135)
* Add switching to the document when closing FreeCAD Closes #20997 * Some update of language * camelCase every variable name used
This commit is contained in:
@@ -2256,8 +2256,7 @@ bool Document::canClose (bool checkModify, bool checkLink)
|
||||
|
||||
bool ok = true;
|
||||
if (checkModify && isModified() && !getDocument()->testStatus(App::Document::PartialDoc)) {
|
||||
const char *docName = getDocument()->Label.getValue();
|
||||
int res = getMainWindow()->confirmSave(docName, getActiveView());
|
||||
int res = getMainWindow()->confirmSave(getDocument(), getActiveView());
|
||||
switch (res)
|
||||
{
|
||||
case MainWindow::ConfirmSaveResult::Cancel:
|
||||
@@ -2267,11 +2266,14 @@ bool Document::canClose (bool checkModify, bool checkLink)
|
||||
case MainWindow::ConfirmSaveResult::Save:
|
||||
ok = save();
|
||||
if (!ok) {
|
||||
const QString docName = QString::fromStdString(getDocument()->Label.getStrValue());
|
||||
const QString text = (!docName.isEmpty()
|
||||
? QObject::tr("Failed to save document '%1'. Would you like to cancel the closure?").arg(docName)
|
||||
: QObject::tr("Document saving failed. Would you like to cancel the closure?"));
|
||||
int ret = QMessageBox::question(
|
||||
getActiveView(),
|
||||
QObject::tr("Document not saved"),
|
||||
QObject::tr("The document%1 could not be saved. Do you want to cancel closing it?")
|
||||
.arg(docName?(QStringLiteral(" ")+QString::fromUtf8(docName)):QString()),
|
||||
QObject::tr("Unable to save document"),
|
||||
text,
|
||||
QMessageBox::Discard | QMessageBox::Cancel,
|
||||
QMessageBox::Discard);
|
||||
if (ret == QMessageBox::Discard)
|
||||
|
||||
Reference in New Issue
Block a user