From b278d242d03ba614779243ec9e9495fc95abea3d Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sun, 5 Oct 2025 15:15:55 +0200 Subject: strops format --- src/ui/ui_settings.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/ui/ui_settings.cpp') diff --git a/src/ui/ui_settings.cpp b/src/ui/ui_settings.cpp index cb6cdf5..8177f07 100644 --- a/src/ui/ui_settings.cpp +++ b/src/ui/ui_settings.cpp @@ -15,13 +15,13 @@ */ #include -#include #include "strops.hpp" #include "ui.hpp" #include "imgui.h" #include "administration.hpp" #include "locales.hpp" +#include "importer.hpp" #include "administration_writer.hpp" extern void draw_contact_form(contact* buffer, bool viewing_only = false); @@ -103,7 +103,7 @@ static void draw_vat_rates() ImGui::TableNextRow(); char locale_buf[20]; - snprintf(locale_buf, sizeof(locale_buf), "country.%s", c.country_code); + strops::format(locale_buf, sizeof(locale_buf), "country.%s", c.country_code); ImGui::TableSetColumnIndex(0); ImGui::Text(locale::get(locale_buf)); @@ -112,7 +112,7 @@ static void draw_vat_rates() { ImGui::SameLine(); char btn_name[20]; - snprintf(btn_name, sizeof(btn_name), "+##%d",i); + strops::format(btn_name, sizeof(btn_name), "+##%d",i); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0,0)); if (ImGui::Button(btn_name, ImVec2(20,20))) { is_adding_item = true; @@ -131,7 +131,7 @@ static void draw_vat_rates() ImGui::TableSetColumnIndex(0); char category_code_desc[MAX_LEN_LONG_DESC]; - snprintf(category_code_desc, MAX_LEN_LONG_DESC, "taxcategory.%s", c.category_code); + strops::format(category_code_desc, MAX_LEN_LONG_DESC, "taxcategory.%s", c.category_code); ImGui::Text(can_be_modified ? "" : locale::get(category_code_desc)); @@ -338,18 +338,17 @@ static void draw_services() // AI service if (ImGui::CollapsingHeader(locale::get("settings.services.ai_service"))) { - // TODO: get this from iterator over ai_get_impl - char* services[2] = { - "OpenAI", - "DeepSeek", - }; + char* ai_service_names[AI_PROVIDER_END]; + for (u32 i = 0; i < AI_PROVIDER_END; i++) { + ai_service_names[i] = importer::get_ai_provider_implementation((ai_provider)i).provider_name; + } - if (ImGui::BeginCombo(locale::get("settings.services.ai_service.provider"), services[new_service.provider])) + if (ImGui::BeginCombo(locale::get("settings.services.ai_service.provider"), ai_service_names[new_service.provider])) { for (u32 n = 0; n < 2; n++) { bool is_selected = n == (uint32_t)new_service.provider; - if (ImGui::Selectable(services[n], is_selected)) { + if (ImGui::Selectable(ai_service_names[n], is_selected)) { new_service.provider = (ai_provider)n; } } -- cgit v1.2.3-70-g09d2