Skip to content

Commit

Permalink
Check if preset already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwyriel committed Nov 21, 2022
1 parent 5c735f5 commit b632ac5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/MainWindow/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
7 changes: 7 additions & 0 deletions src/presetandconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 2 additions & 0 deletions src/presetandconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class ConfigManager

static bool isThereItemsToSave();

static bool doesPresetAlreadyExists(const QString &presetName);

private:
static PresetsAndConfig defaultPresetsAndConfig;
static QString PresetsAndConfigFileName;
Expand Down

0 comments on commit b632ac5

Please sign in to comment.