Refuse to overwrite imported file with multiple subpages

This commit is contained in:
Gavin MacGregor
2025-03-05 18:41:39 +00:00
parent 564243822e
commit 10059e5d0b
4 changed files with 18 additions and 3 deletions

View File

@@ -332,6 +332,7 @@ void MainWindow::init()
setAttribute(Qt::WA_DeleteOnClose);
m_isUntitled = true;
m_reExportWarning = false;
m_textWidget = new TeletextWidget;
@@ -1087,6 +1088,8 @@ void MainWindow::loadFile(const QString &fileName)
if (!loadingFormat->warningStrings().isEmpty())
QMessageBox::warning(this, QApplication::applicationDisplayName(), tr("The following issues were encountered when loading<br>%1:<ul><li>%2</li></ul>").arg(QDir::toNativeSeparators(fileName), loadingFormat->warningStrings().join("</li><li>")));
m_reExportWarning = loadingFormat->reExportWarning();
setCurrentFile(fileName);
statusBar()->showMessage(tr("File loaded"), 2000);
}
@@ -1228,9 +1231,14 @@ void MainWindow::exportFile(bool fromAuto)
QString exportFileName;
SaveFormat *exportFormat = nullptr;
if (fromAuto)
if (fromAuto) {
if (m_reExportWarning) {
QMessageBox::StandardButton ret = QMessageBox::warning(this, QApplication::applicationDisplayName(), tr("Will not overwrite imported file %1:\nAll other subpages in that file would be erased.\nPlease save or export to a different file.").arg(strippedName(m_exportAutoFileName)));
return;
}
exportFileName = m_exportAutoFileName;
else {
} else {
if (m_exportAutoFileName.isEmpty())
exportFileName = m_curFile;
else
@@ -1284,6 +1292,7 @@ void MainWindow::exportFile(bool fromAuto)
MainWindow::prependToRecentFiles(exportFileName);
m_exportAutoFileName = exportFileName;
m_reExportWarning = false;
statusBar()->showMessage(tr("File exported"), 2000);
}