Added SaveCopy command

This command saves a copy of the current document under a new name,
without modifying the document itself.

Available in menu File -> Save a Copy or from python with
FreeCAD.ActiveDocument.saveCopy(filename)
This commit is contained in:
Yorik van Havre
2015-09-02 13:38:14 -03:00
parent 3b433256e6
commit e122ea8bf7
9 changed files with 113 additions and 2 deletions

View File

@@ -644,6 +644,33 @@ bool Document::saveAs(void)
}
}
/// Save a copy of the document under a new file name
bool Document::saveCopy(void)
{
getMainWindow()->showMessage(QObject::tr("Save a copy of the document under new filename..."));
QString exe = qApp->applicationName();
QString fn = FileDialog::getSaveFileName(getMainWindow(), QObject::tr("Save %1 Document").arg(exe),
QString(), QObject::tr("%1 document (*.FCStd)").arg(exe));
if (!fn.isEmpty()) {
QFileInfo fi;
fi.setFile(fn);
const char * DocName = App::GetApplication().getDocumentName(getDocument());
// save as new file name
Gui::WaitCursor wc;
Command::doCommand(Command::Doc,"App.getDocument(\"%s\").saveCopy(\"%s\")"
, DocName, (const char*)fn.toUtf8());
return true;
}
else {
getMainWindow()->showMessage(QObject::tr("Saving aborted"), 2000);
return false;
}
}
unsigned int Document::getMemSize (void) const
{
unsigned int size = 0;