From 2855642dd16cea260f3b32351f0529328a0bcb15 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sat, 4 Oct 2025 15:54:30 +0200 Subject: namespacing locale, config, file_templates --- src/ui/ui_contacts.cpp | 58 +++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'src/ui/ui_contacts.cpp') diff --git a/src/ui/ui_contacts.cpp b/src/ui/ui_contacts.cpp index ffed39a..e282374 100644 --- a/src/ui/ui_contacts.cpp +++ b/src/ui/ui_contacts.cpp @@ -32,11 +32,11 @@ static contact active_contact; void ui_draw_address_form(address* buffer, a_err last_err) { - ImGui::FormInputTextWithErrorHint(localize("contact.form.address1"), buffer->address1, IM_ARRAYSIZE(buffer->address1), last_err & A_ERR_MISSING_ADDRESS1); - ImGui::FormInputTextWithErrorHint(localize("contact.form.address2"), buffer->address2, IM_ARRAYSIZE(buffer->address2), 0); - ImGui::FormInputTextWithErrorHint(localize("contact.form.city"), buffer->city, IM_ARRAYSIZE(buffer->city), last_err & A_ERR_MISSING_CITY); - ImGui::FormInputTextWithErrorHint(localize("contact.form.postal"), buffer->postal, IM_ARRAYSIZE(buffer->postal), last_err & A_ERR_MISSING_POSTAL); - ImGui::FormInputTextWithErrorHint(localize("contact.form.region"), buffer->region, IM_ARRAYSIZE(buffer->region), 0); + ImGui::FormInputTextWithErrorHint(locale::get("contact.form.address1"), buffer->address1, IM_ARRAYSIZE(buffer->address1), last_err & A_ERR_MISSING_ADDRESS1); + ImGui::FormInputTextWithErrorHint(locale::get("contact.form.address2"), buffer->address2, IM_ARRAYSIZE(buffer->address2), 0); + ImGui::FormInputTextWithErrorHint(locale::get("contact.form.city"), buffer->city, IM_ARRAYSIZE(buffer->city), last_err & A_ERR_MISSING_CITY); + ImGui::FormInputTextWithErrorHint(locale::get("contact.form.postal"), buffer->postal, IM_ARRAYSIZE(buffer->postal), last_err & A_ERR_MISSING_POSTAL); + ImGui::FormInputTextWithErrorHint(locale::get("contact.form.region"), buffer->region, IM_ARRAYSIZE(buffer->region), 0); ImGui::FormCountryCombo(buffer->country_code, IM_ARRAYSIZE(buffer->country_code)); } @@ -59,7 +59,7 @@ void draw_addressee_form_ex(delivery_info* buffer, bool viewing_only = false) if (!viewing_only) ImGui::EndDisabled(); - ImGui::FormInputTextWithErrorHint(localize("contact.form.fullname"), buffer->name, IM_ARRAYSIZE(buffer->name), last_err & A_ERR_MISSING_NAME); + ImGui::FormInputTextWithErrorHint(locale::get("contact.form.fullname"), buffer->name, IM_ARRAYSIZE(buffer->name), last_err & A_ERR_MISSING_NAME); ui_draw_address_form(&buffer->address, last_err); @@ -79,7 +79,7 @@ void draw_contact_form_ex(contact* buffer, bool viewing_only = false, bool with_ if (!viewing_only) ImGui::EndDisabled(); if (with_autocomplete) ImGui::FormContactAutocomplete(buffer, last_err & A_ERR_MISSING_NAME); - else ImGui::FormInputTextWithErrorHint(localize("contact.form.fullname"), buffer->name, IM_ARRAYSIZE(buffer->name), last_err & A_ERR_MISSING_NAME); + else ImGui::FormInputTextWithErrorHint(locale::get("contact.form.fullname"), buffer->name, IM_ARRAYSIZE(buffer->name), last_err & A_ERR_MISSING_NAME); ui_draw_address_form(&buffer->address, last_err); @@ -88,13 +88,13 @@ void draw_contact_form_ex(contact* buffer, bool viewing_only = false, bool with_ // Fields only required for businesses. if (buffer->type == contact_type::CONTACT_BUSINESS) { - ImGui::FormInputTextWithErrorHint(localize("contact.form.taxnumber"), buffer->taxid, IM_ARRAYSIZE(buffer->taxid), last_err & A_ERR_MISSING_TAXID); - ImGui::FormInputTextWithErrorHint(localize("contact.form.businessnumber"), buffer->businessid, IM_ARRAYSIZE(buffer->businessid), last_err & A_ERR_MISSING_BUSINESSID); + ImGui::FormInputTextWithErrorHint(locale::get("contact.form.taxnumber"), buffer->taxid, IM_ARRAYSIZE(buffer->taxid), last_err & A_ERR_MISSING_TAXID); + ImGui::FormInputTextWithErrorHint(locale::get("contact.form.businessnumber"), buffer->businessid, IM_ARRAYSIZE(buffer->businessid), last_err & A_ERR_MISSING_BUSINESSID); } - ImGui::FormInputTextWithErrorHint(localize("contact.form.email"), buffer->email, IM_ARRAYSIZE(buffer->email), last_err & A_ERR_MISSING_EMAIL); - ImGui::FormInputTextWithErrorHint(localize("contact.form.phonenumber"), buffer->phone_number, IM_ARRAYSIZE(buffer->phone_number), 0); - ImGui::FormInputTextWithErrorHint(localize("contact.form.bankaccount"), buffer->bank_account, IM_ARRAYSIZE(buffer->bank_account), 0); + ImGui::FormInputTextWithErrorHint(locale::get("contact.form.email"), buffer->email, IM_ARRAYSIZE(buffer->email), last_err & A_ERR_MISSING_EMAIL); + ImGui::FormInputTextWithErrorHint(locale::get("contact.form.phonenumber"), buffer->phone_number, IM_ARRAYSIZE(buffer->phone_number), 0); + ImGui::FormInputTextWithErrorHint(locale::get("contact.form.bankaccount"), buffer->bank_account, IM_ARRAYSIZE(buffer->bank_account), 0); if (viewing_only) ImGui::EndDisabled(); ImGui::PopID(); @@ -113,7 +113,7 @@ static void draw_contact_list() if (max_page == 0) max_page = 1; // Table header controls: create button and pagination. - if (ImGui::Button(localize("form.create"))) + if (ImGui::Button(locale::get("form.create"))) { current_view_state = view_state::CREATE; active_contact = administration_contact_create_empty(); @@ -126,7 +126,7 @@ static void draw_contact_list() ImGui::SameLine(); bool enable_prev = current_page > 0; if (!enable_prev) ImGui::BeginDisabled(); - if (ImGui::Button(localize("ui.prev")) && current_page > 0) current_page--; + if (ImGui::Button(locale::get("ui.prev")) && current_page > 0) current_page--; if (!enable_prev) ImGui::EndDisabled(); ImGui::SameLine(); @@ -136,16 +136,16 @@ static void draw_contact_list() ImGui::SameLine(); bool enable_next = current_page < max_page-1; if (!enable_next) ImGui::BeginDisabled(); - if (ImGui::Button(localize("ui.next")) && current_page < max_page-1) current_page++; + if (ImGui::Button(locale::get("ui.next")) && current_page < max_page-1) current_page++; if (!enable_next) ImGui::EndDisabled(); ImGui::Spacing(); if (ImGui::BeginTable("TableContacts", 4, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg)) { - ImGui::TableSetupColumn(localize("contact.table.identifier"), ImGuiTableColumnFlags_WidthFixed, 80); - ImGui::TableSetupColumn(localize("contact.table.name"), ImGuiTableColumnFlags_WidthStretch); - ImGui::TableSetupColumn(localize("contact.table.address"), ImGuiTableColumnFlags_WidthStretch); + ImGui::TableSetupColumn(locale::get("contact.table.identifier"), ImGuiTableColumnFlags_WidthFixed, 80); + ImGui::TableSetupColumn(locale::get("contact.table.name"), ImGuiTableColumnFlags_WidthStretch); + ImGui::TableSetupColumn(locale::get("contact.table.address"), ImGuiTableColumnFlags_WidthStretch); ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 160); ImGui::TableHeadersRow(); @@ -163,7 +163,7 @@ static void draw_contact_list() ImGui::TableSetColumnIndex(3); char btn_name[20]; - snprintf(btn_name, sizeof(btn_name), "%s##%d", localize("form.view"), i); + snprintf(btn_name, sizeof(btn_name), "%s##%d", locale::get("form.view"), i); if (ImGui::Button(btn_name)) { active_contact = c; current_view_state = view_state::VIEW; @@ -171,14 +171,14 @@ static void draw_contact_list() ImGui::SameLine(); - snprintf(btn_name, sizeof(btn_name), "%s##%d", localize("form.change"), i); + snprintf(btn_name, sizeof(btn_name), "%s##%d", locale::get("form.change"), i); if (ImGui::Button(btn_name)) { active_contact = c; current_view_state = view_state::EDIT; } ImGui::SameLine(); - snprintf(btn_name, sizeof(btn_name), "%s##%d", localize("form.delete"), i); + snprintf(btn_name, sizeof(btn_name), "%s##%d", locale::get("form.delete"), i); if (ImGui::Button(btn_name)) { selected_for_removal = c; ImGui::OpenPopup("ConfirmDeletePopup"); @@ -187,15 +187,15 @@ static void draw_contact_list() // Confirmation popup before contact is deleted definitively. if (ImGui::BeginPopupModal("ConfirmDeletePopup", nullptr, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoTitleBar)) { - ImGui::Text(localize("form.confirmDelete")); + ImGui::Text(locale::get("form.confirmDelete")); ImGui::Separator(); - if (ImGui::Button(localize("form.yes"), ImVec2(120, 0))) { + if (ImGui::Button(locale::get("form.yes"), ImVec2(120, 0))) { administration_contact_remove(selected_for_removal); ImGui::CloseCurrentPopup(); } ImGui::SameLine(); - if (ImGui::Button(localize("form.no"), ImVec2(120, 0))) { + if (ImGui::Button(locale::get("form.no"), ImVec2(120, 0))) { ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); @@ -207,7 +207,7 @@ static void draw_contact_list() static void ui_draw_contacts_create() { - if (ImGui::Button(localize("form.back"))) { + if (ImGui::Button(locale::get("form.back"))) { current_view_state = view_state::LIST; } @@ -218,7 +218,7 @@ static void ui_draw_contacts_create() if (!can_save) ImGui::BeginDisabled(); // Save button ImGui::Spacing(); - if (ImGui::Button(localize("form.save"))) { + if (ImGui::Button(locale::get("form.save"))) { administration_contact_add(active_contact); current_view_state = view_state::LIST; } @@ -227,7 +227,7 @@ static void ui_draw_contacts_create() static void ui_draw_contacts_update() { - if (ImGui::Button(localize("form.back"))) { + if (ImGui::Button(locale::get("form.back"))) { current_view_state = view_state::LIST; } @@ -238,7 +238,7 @@ static void ui_draw_contacts_update() if (!can_save) ImGui::BeginDisabled(); // Save button ImGui::Spacing(); - if (ImGui::Button(localize("form.save"))) { + if (ImGui::Button(locale::get("form.save"))) { administration_contact_update(active_contact); current_view_state = view_state::LIST; } @@ -254,7 +254,7 @@ void ui_draw_contacts() case view_state::EDIT: ui_draw_contacts_update(); break; case view_state::VIEW: - if (ImGui::Button(localize("form.back"))) { + if (ImGui::Button(locale::get("form.back"))) { current_view_state = view_state::LIST; } -- cgit v1.2.3-70-g09d2