diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-10-18 08:41:54 +0200 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-10-18 08:41:54 +0200 |
| commit | c1d950f2765cde614c8411b4effb3850146ba598 (patch) | |
| tree | 408372166c170bfabc3e23a02d8aaa48b662696c | |
| parent | a8799cfee2de8ac53cc07c571c56ae5d9c98cbbd (diff) | |
ui loading animation for model request
| -rw-r--r-- | TODO | 19 | ||||
| -rw-r--r-- | libs/imgui-1.92.1/imgui.cpp | 2 | ||||
| -rw-r--r-- | libs/imgui-1.92.1/imgui.h | 4 | ||||
| -rw-r--r-- | run.bat | 4 | ||||
| -rw-r--r-- | src/countries/nl.cpp | 6 | ||||
| -rw-r--r-- | src/locales/en.cpp | 2 | ||||
| -rw-r--r-- | src/ui/ui_settings.cpp | 24 | ||||
| -rw-r--r-- | tests/administration_rw_tests.cpp | 1 |
8 files changed, 35 insertions, 27 deletions
@@ -2,6 +2,10 @@ TODO: Refactor: - Can we get rid of taxrate id in invoice? this would avoid reference conflicts. +- refactor _add functions to use _import functions +- replace memset with memops function +- replace strncpy and similar with strops functions +- There is alot of memory leakage Testing: - write tests for all NL tax categories @@ -10,24 +14,17 @@ Testing: - it is possible a referenced tax rate is loaded after an invoice is loaded. This means all invoices need to be recalculated after file load. (try to write a test for this). Improvements: -- There is alot of memory leakage -- for invoice importing using AI: all address data should be editable because import is not perfect -- for invoice importing using AI: file path should not be editable as it is imported -- real error logging for OpenAI and importing in general -- log_set_depth function so data can be grouped -- log elapsed time for ai requests -- refactor _add functions to use _import functions -- replace memset with memops function -- replace strncpy and similar with strops functions +- AI importer: all address data should be editable because import is not perfect +- AI importer: file path should not be editable as it is imported +- AI importer: real error logging for OpenAI and importing in general +- AI importer: log elapsed time for ai requests Features: - error log for tax report to display invoices not yet supported for tax generation or invoices with invalid tax rates - minimum invoice date for tax report generation, show warnings for unsupported invoices -- Tax rates for private usage - create invoice PDF for NL https://goedestartbelastingdienst.nl/wiki/view/50bdccd8-f9a0-4297-b57f-3a6651cbe05c/factuureisen - toggle on invoice form wether price is inclusive of tax. - retrieve available balance from AI api & show in settings/services. -- let user choose the model to use in settings/services/ai - Send invoice by email - create invoice from image of receipt - create invoice from UBL file diff --git a/libs/imgui-1.92.1/imgui.cpp b/libs/imgui-1.92.1/imgui.cpp index b41a167..93094eb 100644 --- a/libs/imgui-1.92.1/imgui.cpp +++ b/libs/imgui-1.92.1/imgui.cpp @@ -16690,7 +16690,7 @@ void ImGui::LoadingIndicatorCircle(const char* label, const float indicator_radi const ImGuiID id = window->GetID(label); const ImVec2 pos = window->DC.CursorPos; - const float circle_radius = indicator_radius / 15.0f; + const float circle_radius = indicator_radius / 12.0f; const float updated_indicator_radius = indicator_radius - 4.0f * circle_radius; const ImRect bb(pos, ImVec2(pos.x + indicator_radius * 2.0f, pos.y + indicator_radius * 2.0f)); ItemSize(bb); diff --git a/libs/imgui-1.92.1/imgui.h b/libs/imgui-1.92.1/imgui.h index 29c89b9..bfc70d4 100644 --- a/libs/imgui-1.92.1/imgui.h +++ b/libs/imgui-1.92.1/imgui.h @@ -375,7 +375,9 @@ IM_MSVC_RUNTIME_CHECKS_RESTORE namespace ImGui { - IMGUI_API void LoadingIndicatorCircle(const char* label, const float indicator_radius, + IMGUI_API bool BeginComboPreview(); + IMGUI_API void EndComboPreview(); + IMGUI_API void LoadingIndicatorCircle(const char* label, const float indicator_radius, const ImVec4& main_color, const ImVec4& backdrop_color, const int circle_count, const float speed); @@ -1,3 +1,4 @@ +@echo off if "%1"=="docs" ( cd manual @@ -8,7 +9,6 @@ if "%1"=="docs" ( exit ) -@echo off REM Find the latest Visual Studio installation path for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -property installationPath`) do ( set VSPath=%%i @@ -40,7 +40,7 @@ set LIB_SOURCES=libs\imgui-1.92.1\backends\imgui_impl_dx11.cpp^ libs\tinyfiledialogs\tinyfiledialogs.c @set SOURCES= src\*.cpp src\ui\*.cpp src\locales\*.cpp src\ai_providers\*.cpp @set LIBS=opengl32.lib Advapi32.lib Shell32.lib Ole32.lib User32.lib Pathcch.lib D3D11.lib Comdlg32.lib Kernel32.lib /LIBPATH:"libs/openssl-3.6.0-beta1/x64/lib" libssl.lib libcrypto.lib -@set FLAGS=/nologo /Ob0 /MD /Oy- /Zi /FS /W4 /EHsc /utf-8 /F4000000 +@set FLAGS=/nologo /Ob0 /MD /Oy- /Zi /FS /W4 /EHsc /utf-8 /F8000000 @set INCLUDE_DIRS=/I"libs/imgui-1.92.1" /I"libs/imgui-1.92.1/backends" /I"/" /I"libs/openssl-3.6.0-beta1/x64/include" /I"libs/cpp-httplib" /I"libs/timer_lib" /I"libs/greatest" /I"libs/simclist-1.5" /I"libs/tinyfiledialogs" /I"libs/zip/src" /I"libs/xml.c/src" /I"libs/" /Iinclude @set DEFINITIONS=/D_BUILD_DATE_=\"%date%\" /D_COMMIT_=\"%COMMIT_ID%\" /D_PLATFORM_=\"win64\" /D_CRT_SECURE_NO_WARNINGS diff --git a/src/countries/nl.cpp b/src/countries/nl.cpp index cf79ee2..62f947f 100644 --- a/src/countries/nl.cpp +++ b/src/countries/nl.cpp @@ -82,14 +82,14 @@ bool _nl_add_billing_item_to_tax_report(tax_report* report, invoice* inv, billin a5->total_tax += totals.tax; } - // TODO 1c else if (rate.rate > 0.0f) { - tax_line* tl = administration::get_tax_line_from_report(report, "1d"); + tax_line* tl = administration::get_tax_line_from_report(report, "1c"); tl->total_net += totals.net; tl->total_tax += totals.tax; - + a5->total_tax += totals.tax; } + // NOTE: category '1d' for private usage is not supported. else if (rate.rate == 0.0f) { tax_line* tl = administration::get_tax_line_from_report(report, "1e"); tl->total_net += totals.net; diff --git a/src/locales/en.cpp b/src/locales/en.cpp index 4abcab8..5b78ec9 100644 --- a/src/locales/en.cpp +++ b/src/locales/en.cpp @@ -212,7 +212,7 @@ locale_entry en_locales[] = { {"import.error.upload","Failure: Upload failed"}, {"import.error.query","Failure: Querying service failed"}, - {"import.error.import","Failure: Failed to import result from service"}, + {"import.error.import","Failure: Service returned unparseable response. Try using another model."}, // Tax statement strings. {"taxes.total", "Total"}, diff --git a/src/ui/ui_settings.cpp b/src/ui/ui_settings.cpp index cf27b49..a4b5748 100644 --- a/src/ui/ui_settings.cpp +++ b/src/ui/ui_settings.cpp @@ -16,7 +16,6 @@ #include "ui.hpp" -#include "imgui.h" #include "strops.hpp" #include "memops.hpp" #include "locales.hpp" @@ -396,15 +395,24 @@ static void draw_services() } else { ImGui::BeginDisabled(); - if (ImGui::BeginCombo(locale::get("settings.services.ai_service.model"), new_service.model_name)) + ImGui::BeginCombo(locale::get("settings.services.ai_service.model"), NULL, 1 << 20); { - ImGui::EndCombo(); - } - if (model_request->status != importer::status::IMPORT_DONE) { - ImGui::SameLine(); + if (ImGui::BeginComboPreview()) + { + if (model_request->status != importer::status::IMPORT_DONE) { + float radius = 10.0f; + const ImVec4 col = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); + const ImVec4 bg = ImGui::GetStyleColorVec4(ImGuiCol_Button); + ImGui::LoadingIndicatorCircle("##loadingAnim", radius, bg, col, 6, 4.0f); + + ImGui::SameLine(); + } + ImGui::TextUnformatted(new_service.model_name); + + ImGui::EndComboPreview(); + } - // TODO replace with LoadingIndicatorCircle - ImGui::Text("%c", "|/-\\"[(int)(ImGui::GetTime() / 0.05f) & 3]); + //ImGui::EndCombo(); } ImGui::EndDisabled(); } diff --git a/tests/administration_rw_tests.cpp b/tests/administration_rw_tests.cpp index 6d12b45..36353f7 100644 --- a/tests/administration_rw_tests.cpp +++ b/tests/administration_rw_tests.cpp @@ -153,6 +153,7 @@ TEST _administration_rw_info(void) ai_service ss = {0}; ss.provider = AI_PROVIDER_OPENAI; strops::copy(ss.api_key_public, "123", sizeof(ss.api_key_public)); + strops::copy(ss.model_name, "321", sizeof(ss.model_name)); administration::set_ai_service(ss); ais = administration::get_ai_service(); |
