show file changed warning once at a time
This commit is contained in:
parent
401d2e4884
commit
4d2fa5ee38
3 changed files with 7 additions and 1 deletions
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue