move fileWatcher signals to project class, block when saving

This commit is contained in:
garakmon
2020-04-11 20:39:50 -04:00
parent 96a870552e
commit df8dac965f
3 changed files with 57 additions and 27 deletions

View File

@@ -300,28 +300,8 @@ bool MainWindow::openProject(QString dir) {
bool already_open = isProjectOpen() && (editor->project->root == dir);
if (!already_open) {
editor->closeProject();
editor->project = new Project;
QObject::connect(&editor->project->fileWatcher, &QFileSystemWatcher::fileChanged, [this](QString changed){
QMessageBox notice(this);
notice.setText("File Changed");
notice.setInformativeText(QString("The file %1 has changed on disk. Would you like to reload the project?")
.arg(changed.remove(editor->project->root + "/")));
notice.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
notice.setIcon(QMessageBox::Question);
QCheckBox showAgainCheck("Do not ask again.");
notice.setCheckBox(&showAgainCheck);
int choice = notice.exec();
if (choice == QMessageBox::Yes) {
on_action_Reload_Project_triggered();
} else if (choice == QMessageBox::No) {
if (showAgainCheck.isChecked()) {
porymapConfig.setMonitorFiles(false);
this->editor->project->fileWatcher.blockSignals(true);
}
}
});
editor->project = new Project(this);
QObject::connect(editor->project, SIGNAL(reloadProject), this, SLOT(on_action_Reload_Project_triggered));
editor->project->set_root(dir);
success = loadDataStructures()
&& populateMapList()