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:
xtemp09
2025-05-09 04:59:11 +07:00
committed by GitHub
parent 340cfc6feb
commit 54fdd62fc7
3 changed files with 39 additions and 13 deletions

View File

@@ -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)