diff --git a/.gitmodules b/.gitmodules index 6127d55..1fee2e3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "external/rei-json"] path = external/rei-json url = https://codeberg.org/vyn/rei-json.git +[submodule "external/evalyte-cpp-common"] + path = external/evalyte-cpp-common + url = https://codeberg.org/vyn/evalyte-cpp-common.git diff --git a/CMakeLists.txt b/CMakeLists.txt index e76225d..618e2cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,8 +30,11 @@ slint_target_sources( LIBRARY_PATHS selenite=${CMAKE_CURRENT_SOURCE_DIR}/external/selenite/components/index.slint ) -add_subdirectory(external/rei-json) +add_subdirectory(external/evalyte-cpp-common) +target_include_directories(lali PRIVATE "external/evalyte-cpp-common/include") +target_link_libraries(lali PRIVATE evalyte-cpp-common) +add_subdirectory(external/rei-json) target_include_directories(lali PRIVATE "external/rei-json/include") target_link_libraries(lali PRIVATE rei-json) diff --git a/external/evalyte-cpp-common b/external/evalyte-cpp-common new file mode 160000 index 0000000..20e766b --- /dev/null +++ b/external/evalyte-cpp-common @@ -0,0 +1 @@ +Subproject commit 20e766badc8f400ac7db8487486b5e8990cefbbe diff --git a/run-release.sh b/run-release.sh new file mode 100644 index 0000000..c5b7160 --- /dev/null +++ b/run-release.sh @@ -0,0 +1 @@ +cmake -DCMAKE_BUILD_TYPE=Release -S . -B ./build -G Ninja && cd build && ninja && cd - && build/lali diff --git a/src/AppWindow.h b/src/AppWindow.h index edd5114..d759634 100644 --- a/src/AppWindow.h +++ b/src/AppWindow.h @@ -3,6 +3,7 @@ #include #include #include +#include "evalyte-cpp-common/evalyte.h" #include "rei-json/Field.h" #include "rei-json/Object.h" #include "ui.h" @@ -85,11 +86,12 @@ public: } void loadDataFromDisk() { - std::filesystem::create_directories("./imgs"); + evalyte::createRequiredDirectories("lali"); + std::filesystem::create_directories(imageDirectory); - std::ifstream file("./save.json"); + std::ifstream file(saveFilePath); if (!file.is_open()) { - std::println(std::cerr, "can't open file"); + std::println(std::cerr, "can't open file {}", saveFilePath); json = rei::json::JsonObject{}; json.set("version", 1); json.addArray("lists", rei::json::JsonArray{}); @@ -107,11 +109,6 @@ public: ui->global().set_lists(listsSlint); animesSlint = std::make_shared>(); - ui->global().set_current_list({ - .index = 0, - .name = "ok", - .animes = animesSlint - }); auto& lists = json.getArray("lists"); @@ -285,7 +282,7 @@ public: slint::Image getAnimeImage(int animeId, std::string imageUrl) { //std::println("Get image for anime {}", animeId); - std::string imagePath = "./imgs/" + std::to_string(animeId); + std::string imagePath = imageDirectory + "/" + std::to_string(animeId); if (imageUrl.ends_with(".jpg") || imageUrl.ends_with(".jpeg")) { imagePath += ".jpg"; @@ -328,7 +325,7 @@ public: } void save() { - std::ofstream save("./save.json"); + std::ofstream save(saveFilePath); if (!save.is_open()) { throw std::runtime_error("Can't save data"); } @@ -348,4 +345,7 @@ private: std::mutex continueAnimeLock[THREAD_COUNT]; bool shouldStopLoadingImages[THREAD_COUNT] = {false}; std::thread thread_object[THREAD_COUNT]; + + const std::string imageDirectory = evalyte::cacheDirectoryPath("lali") + "/images"; + const std::string saveFilePath = evalyte::dataDirectoryPath("lali") + "/save.json"; };