add File>Reload Project

This commit is contained in:
garakmon
2020-04-07 20:25:09 -04:00
parent ca5a0247f7
commit 6026266afd
5 changed files with 46 additions and 4 deletions

View File

@@ -306,7 +306,10 @@ bool MainWindow::openProject(QString dir) {
&& populateMapList()
&& setMap(getDefaultMap(), true);
} else {
success = loadDataStructures() && populateMapList() && setMap(editor->map->name, true);
QString open_map = editor->map->name;
editor->project->clearMapCache();
editor->project->clearTilesetCache();
success = loadDataStructures() && populateMapList() && setMap(open_map, true);
}
if (success) {
@@ -373,6 +376,19 @@ void MainWindow::on_action_Open_Project_triggered()
}
}
void MainWindow::on_action_Reload_Project_triggered() {
// TODO: when undo history is complete show only if has unsaved changes
QMessageBox warning(this);
warning.setText("WARNING");
warning.setInformativeText("Reloading this project will discard any unsaved changes.");
warning.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
warning.setIcon(QMessageBox::Warning);
if (warning.exec() == QMessageBox::Ok) {
openProject(editor->project->root);
}
}
bool MainWindow::setMap(QString map_name, bool scrollTreeView) {
logInfo(QString("Setting map to '%1'").arg(map_name));
if (map_name.isEmpty()) {