From 4d2fa5ee385169d2e4d699ac8ab284882966e956 Mon Sep 17 00:00:00 2001 From: garakmon Date: Mon, 20 Apr 2020 22:02:14 -0400 Subject: [PATCH] show file changed warning once at a time --- src/config.cpp | 2 +- src/mainwindow.cpp | 1 + src/project.cpp | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/config.cpp b/src/config.cpp index f96c3f2a..de8a2f56 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -159,7 +159,7 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) { } } else if (key == "monitor_files") { bool ok; - this->showCursorTile = value.toInt(&ok); + this->monitorFiles = value.toInt(&ok); if (!ok) { logWarn(QString("Invalid config value for monitor_files: '%1'. Must be 0 or 1.").arg(value)); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 49bc1779..2643004f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -306,6 +306,7 @@ bool MainWindow::openProject(QString dir) { editor->project = new Project(this); QObject::connect(editor->project, SIGNAL(reloadProject()), this, SLOT(on_action_Reload_Project_triggered())); QObject::connect(editor->project, &Project::uncheckMonitorFilesAction, [this] () { ui->actionMonitor_Project_Files->setChecked(false); }); + on_actionMonitor_Project_Files_triggered(porymapConfig.getMonitorFiles()); editor->project->set_root(dir); success = loadDataStructures() && populateMapList() diff --git a/src/project.cpp b/src/project.cpp index f20b1a64..2a69469e 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -88,6 +88,9 @@ Project::~Project() void Project::initSignals() { // detect changes to specific filepaths being monitored QObject::connect(&fileWatcher, &QFileSystemWatcher::fileChanged, [this](QString changed){ + static bool showing = false; + if (showing) return; + QMessageBox notice(this->parent); notice.setText("File Changed"); notice.setInformativeText(QString("The file %1 has changed on disk. Would you like to reload the project?") @@ -98,6 +101,7 @@ void Project::initSignals() { QCheckBox showAgainCheck("Do not ask again."); notice.setCheckBox(&showAgainCheck); + showing = true; int choice = notice.exec(); if (choice == QMessageBox::Yes) { emit reloadProject(); @@ -108,6 +112,7 @@ void Project::initSignals() { emit uncheckMonitorFilesAction(); } } + showing = false; }); }