diff --git a/src/MainWindow/mainwindow.cpp b/src/MainWindow/mainwindow.cpp index 37d1d3b..a7dfaea 100644 --- a/src/MainWindow/mainwindow.cpp +++ b/src/MainWindow/mainwindow.cpp @@ -137,6 +137,10 @@ void MainWindow::btnNewPresetClicked(){ btnNewPresetClicked(); return; } + if(ConfigManager::doesPresetAlreadyExists(dialog.OutputString)){ + Utility::showError(this, tr("Error"), tr("A preset with that name already exists")); + return; + } ConfigManager::AddNewPreset(dialog.OutputString); setUiWidgetValues(); threadPool->start(new SaveConfigToFileTask(ui->comboBoxPresets->currentIndex())); diff --git a/src/presetandconfig.cpp b/src/presetandconfig.cpp index 4ca49b6..6cc82e9 100644 --- a/src/presetandconfig.cpp +++ b/src/presetandconfig.cpp @@ -208,3 +208,10 @@ bool ConfigManager::isThereItemsToSave(){ } return filesToSave; } + +bool ConfigManager::doesPresetAlreadyExists(const QString &presetName){ + for(auto& preset : presetsAndConfig.Presets) + if(preset.PresetName == presetName) + return true; + return false; +} diff --git a/src/presetandconfig.h b/src/presetandconfig.h index 344aa03..49e7c4b 100644 --- a/src/presetandconfig.h +++ b/src/presetandconfig.h @@ -71,6 +71,8 @@ class ConfigManager static bool isThereItemsToSave(); + static bool doesPresetAlreadyExists(const QString &presetName); + private: static PresetsAndConfig defaultPresetsAndConfig; static QString PresetsAndConfigFileName;