From 4c6942552df4414023292bd4f71783c6efa86c62 Mon Sep 17 00:00:00 2001 From: Vyn Date: Fri, 22 Nov 2024 18:05:29 +0100 Subject: [PATCH] Update dependencies --- external/rei-json | 2 +- external/selenite | 2 +- src/Anilist.h | 4 ++-- src/AppWindow.h | 14 +++++++------- src/AppWindow.slint | 25 +++++++++++++++++++++---- 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/external/rei-json b/external/rei-json index 90c2f0e..2041a0a 160000 --- a/external/rei-json +++ b/external/rei-json @@ -1 +1 @@ -Subproject commit 90c2f0e783b4f5e4a346a6a94a1319a5b2b66d61 +Subproject commit 2041a0aafe85085dcf35a37437db493898f1be3c diff --git a/external/selenite b/external/selenite index 9cba85a..3fb5f62 160000 --- a/external/selenite +++ b/external/selenite @@ -1 +1 @@ -Subproject commit 9cba85a21aa6c2eee6101dd38252249283816327 +Subproject commit 3fb5f620fdc3e422d468642263858ffce72cdbb9 diff --git a/src/Anilist.h b/src/Anilist.h index e4f02fa..ce70e51 100644 --- a/src/Anilist.h +++ b/src/Anilist.h @@ -31,7 +31,7 @@ public: const std::string graphqlQuery = "query Query($userName: String $type: MediaType) {\\n MediaListCollection(userName: $userName, type: $type) {\\n lists {\\n name\\n entries {\\n media {\\n id\\n title {\\n romaji\\n }\\n description\\n episodes\\n genres\\n status\\n startDate {\\n year\\n month\\n day\\n }\\n endDate {\\n year\\n month\\n day\\n }\\n coverImage {\\n extraLarge\\n }\\n idMal\\n isAdult\\n siteUrl\\n bannerImage\\n }\\n }\\n }\\n }\\n}"; variables.set("type", "ANIME").set("userName", userName); - body.set("query", graphqlQuery).addObject("variables", variables); + body.set("query", graphqlQuery).set("variables", variables); auto res = cli.Post("/", rei::json::toString(body), "application/json"); if (res.error() != httplib::Error::Success) { @@ -71,7 +71,7 @@ public: const std::string graphqlQuery = "query Query($mediaId: Int) {\\n Media(id: $mediaId) {\\n id\\n title {\\n romaji\\n }\\n description\\n episodes\\n genres\\n status\\n startDate {\\n year\\n month\\n day\\n }\\n endDate {\\n year\\n month\\n day\\n }\\n coverImage {\\n extraLarge\\n }\\n idMal\\n isAdult\\n siteUrl\\n bannerImage\\n }\\n}"; variables.set("mediaId", id); - body.set("query", graphqlQuery).addObject("variables", variables); + body.set("query", graphqlQuery).set("variables", variables); auto res = cli.Post("/", rei::json::toString(body), "application/json"); if (res.error() != httplib::Error::Success) { diff --git a/src/AppWindow.h b/src/AppWindow.h index d759634..da501ae 100644 --- a/src/AppWindow.h +++ b/src/AppWindow.h @@ -94,7 +94,7 @@ public: std::println(std::cerr, "can't open file {}", saveFilePath); json = rei::json::JsonObject{}; json.set("version", 1); - json.addArray("lists", rei::json::JsonArray{}); + json.set("lists", rei::json::JsonArray{}); return; } std::stringstream buffer; @@ -226,10 +226,10 @@ public: rei::json::JsonArray animesJson{}; field.asObject().getArray("entries").forEach([&](rei::json::FieldValue& value, int index) { auto animeJson = value.asObject().getObject("media"); - animesJson.pushObject(animeJson); + animesJson.push(animeJson); }); - listJson.addArray("animes", animesJson); + listJson.set("animes", animesJson); }); std::optional existingListIndex; json.getArray("lists").forEach([&](rei::json::FieldValue& value, int index) { @@ -241,7 +241,7 @@ public: json.getArray("lists").getObject(existingListIndex.value()) = listJson; selectList(existingListIndex.value()); } else { - json.getArray("lists").pushObject(listJson); + json.getArray("lists").push(listJson); listsSlint->push_back(ui::List{ .name = slint::SharedString(listName), .selected = false @@ -256,9 +256,9 @@ public: listJson.set("name", listName); listJson.set("source", "local"); listJson.set("type", "animes"); - listJson.addArray("animes", rei::json::JsonArray{}); + listJson.set("animes", rei::json::JsonArray{}); - json.getArray("lists").pushObject(listJson); + json.getArray("lists").push(listJson); listsSlint->push_back(ui::List{ .name = slint::SharedString(listName), .selected = false @@ -275,7 +275,7 @@ public: std::println("{}", rei::json::toString(res.value())); rei::json::JsonArray& listJson = json.getArray("lists").getObject(currentListIndex).getArray("animes"); - listJson.pushObject(res.value().getObject("data").getObject("Media")); + listJson.push(res.value().getObject("data").getObject("Media")); selectList(currentListIndex); save(); } diff --git a/src/AppWindow.slint b/src/AppWindow.slint index 68d83ae..42dc918 100644 --- a/src/AppWindow.slint +++ b/src/AppWindow.slint @@ -1,5 +1,5 @@ import { State, ListSource } from "./state.slint"; -import { VText, VTextInput , VButton, ToggleButton, VActionButton, Svg, Palette } from "@selenite"; +import { VText, VTextInput , VButton, ToggleButton, VActionButton, VPopupIconMenu, Svg, Palette } from "@selenite"; import { ComboBox } from "std-widgets.slint"; export component AppWindow inherits Window { @@ -139,7 +139,7 @@ export component AppWindow inherits Window { private property number-of-items: State.current-list.animes.length; private property grid-spacing: 16px; - private property item-min-width: 300px; + private property item-min-width: 256px; private property item-per-row: floor(self.viewport-width / (item-min-width + grid-spacing)); private property item-width: (parent.width - ((item-per-row - 1) * grid-spacing)) / item-per-row; @@ -155,8 +155,6 @@ export component AppWindow inherits Window { height: item-height; //background: #444444; - - VerticalLayout { height: parent.height; width: parent.width; @@ -171,6 +169,25 @@ export component AppWindow inherits Window { source: anime.image; image-fit: ImageFit.cover; } + popup := VPopupIconMenu { + VActionButton { + icon-svg: Svg.trash; + icon-colorize: Colors.red; + icon-size: 1.5rem; + border-radius: 0; + clicked => { + // TODO : Missing feature to delete json value in rei-json + } + } + } + TouchArea { + pointer-event(e) => { + if (e.button == PointerEventButton.right && e.kind == PointerEventKind.up) { + popup.show(self.mouse-x, self.mouse-y); + } + } + } + } animeTitle := VText { text: anime.title;