mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-20 05:14:16 +02:00
Fix Save writing a .qetz beside an opened .qet: keep the .qet
A project opened from a .qet was saved as a .qetz beside it, with a notice, and the .qet left as it was: a project kept in git did not stay a .qet. Save now writes the format the project was opened in; only Save As changes it (scorpio810, discussion #1512). A .qetz is saved as a .qetz as before. The save-beside path goes: the flag set on opening, the .qetz path made from the .qet's, write()'s switch to it and back on failure, and the notice and replace question in ProjectView::doSave(). tst_resaveunchanged::qetSavedAsQetzBeside becomes qetSavedAsQet: Save of an opened .qet writes no .qetz and the .qet holds what a plain save of it holds (it fails without the fix: a .qetz is written beside). tst_changedondisk makes its .qetz with Save As, as Save no longer does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+1
-27
@@ -795,7 +795,7 @@ QETResult ProjectView::writeProject(bool *cancelled)
|
||||
return(m_project -> write());
|
||||
}
|
||||
|
||||
const QString name = QFileInfo(m_project -> writeTarget()).fileName();
|
||||
const QString name = QFileInfo(m_project -> filePath()).fileName();
|
||||
QMessageBox box(QMessageBox::Warning,
|
||||
tr("File changed on disk", "message box title"),
|
||||
tr("Someone else changed %1 on disk at %2 since you opened it.\n\n"
|
||||
@@ -838,32 +838,6 @@ QETResult ProjectView::doSave()
|
||||
return(saveAs());
|
||||
}
|
||||
|
||||
//A project read from a .qet is saved as a .qetz beside it: say so,
|
||||
//and ask before replacing a .qetz already there
|
||||
if (m_project->savesBesideOpenedFile()) {
|
||||
const QString beside = m_project->besideContainerPath();
|
||||
if (!refuseIfLockedByOther(beside)) return(QETResult());
|
||||
const QString message = tr("This project was opened from %1. It is saved as %2, "
|
||||
"beside it, in the zipped project format; %1 stays as "
|
||||
"it is.\n\nTo write a file for a version of "
|
||||
"QElectroTech that cannot open %2, use File > Save a "
|
||||
"copy for an older QElectroTech.")
|
||||
.arg(QFileInfo(m_project->filePath()).fileName(), QFileInfo(beside).fileName());
|
||||
if (QFileInfo::exists(beside)) {
|
||||
if (QET::QetMessageBox::question(
|
||||
this, tr("Save as a zipped project", "message box title"),
|
||||
message + QStringLiteral("\n\n")
|
||||
+ tr("%1 already exists. Replace it?").arg(QFileInfo(beside).fileName()),
|
||||
QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel)
|
||||
!= QMessageBox::Yes) {
|
||||
return(QETResult());
|
||||
}
|
||||
} else {
|
||||
QET::QetMessageBox::information(
|
||||
this, tr("Save as a zipped project", "message box title"), message);
|
||||
}
|
||||
}
|
||||
|
||||
// write to file
|
||||
bool cancelled = false;
|
||||
QETResult result = writeProject(&cancelled);
|
||||
|
||||
Reference in New Issue
Block a user