Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/tiled/document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,11 @@ void Document::setIgnoreBrokenLinks(bool ignoreBrokenLinks)
emit ignoreBrokenLinksChanged(ignoreBrokenLinks);
}

void Document::refreshLastSaved(const QString &fileName)
{
mLastSaved = QFileInfo(fileName).lastModified();
}

void Document::setChangedOnDisk(bool changedOnDisk)
{
mChangedOnDisk = changedOnDisk;
Expand Down
1 change: 1 addition & 0 deletions src/tiled/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class Document : public QObject,
virtual FileFormat *writerFormat() const = 0;

QDateTime lastSaved() const { return mLastSaved; }
void refreshLastSaved(const QString &fileName);

QUndoStack *undoStack() const;
bool isModified() const;
Expand Down
13 changes: 11 additions & 2 deletions src/tiled/exporthelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "objectgroup.h"
#include "wangset.h"

#include <QFileInfo>

namespace Tiled {

/**
Expand Down Expand Up @@ -106,8 +108,15 @@ const Map *ExportHelper::prepareExportMap(const Map *map, std::unique_ptr<Map> &
// Make a copy to which export options are applied
exportMap = map->clone();

// We don't want to save the export options in the exported file
if (hasExportSettings) {
// We don't want to save the export options in the exported file,
// unless we're exporting to the same file (to preserve the export settings
// so they can be picked up again on the next save)
const auto canonicalMapFile = QFileInfo(map->fileName).canonicalFilePath();
const auto canonicalExportFile = QFileInfo(map->exportFileName).canonicalFilePath();
const bool isSelfExport = !canonicalMapFile.isEmpty()
&& canonicalMapFile == canonicalExportFile;

if (hasExportSettings && !isSelfExport) {
exportMap->exportFileName.clear();
exportMap->exportFormat.clear();
}
Expand Down
16 changes: 16 additions & 0 deletions src/tiled/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,10 @@ bool MainWindow::exportDocument(Document *document)

if (exportFormat->write(map, exportFileName, exportHelper.formatOptions())) {
statusBar()->showMessage(tr("Exported to %1").arg(exportFileName), 3000);
// When exporting to the same file, update the saved timestamp
// to avoid triggering an unnecessary auto-reload
if (exportFileName == document->fileName())
document->refreshLastSaved(exportFileName);
return true;
}

Expand All @@ -1356,6 +1360,10 @@ bool MainWindow::exportDocument(Document *document)

if (exportFormat->write(*tileset, exportFileName, exportHelper.formatOptions())) {
statusBar()->showMessage(tr("Exported to %1").arg(exportFileName), 3000);
// When exporting to the same file, update the saved timestamp
// to avoid triggering an unnecessary auto-reload
if (exportFileName == document->fileName())
document->refreshLastSaved(exportFileName);
return true;
}

Expand Down Expand Up @@ -2432,6 +2440,10 @@ void MainWindow::exportMapAs(MapDocument *mapDocument)
// Remember export parameters, so subsequent exports can be done faster
mapDocument->setLastExportFileName(exportDetails.mFileName);
mapDocument->setExportFormat(exportDetails.mFormat);
// When exporting to the same file, update the saved timestamp to avoid
// triggering an unnecessary auto-reload
if (exportDetails.mFileName == mapDocument->fileName())
mapDocument->refreshLastSaved(exportDetails.mFileName);
}
}

Expand Down Expand Up @@ -2471,6 +2483,10 @@ void MainWindow::exportTilesetAs(TilesetDocument *tilesetDocument)
// Remember export parameters, so subsequent exports can be done faster
tilesetDocument->setLastExportFileName(exportDetails.mFileName);
tilesetDocument->setExportFormat(exportDetails.mFormat);
// When exporting to the same file, update the saved timestamp to avoid
// triggering an unnecessary auto-reload
if (exportDetails.mFileName == tilesetDocument->fileName())
tilesetDocument->refreshLastSaved(exportDetails.mFileName);
}
}

Expand Down
Loading