Add button to delete an anime from a list
This commit is contained in:
parent
4c6942552d
commit
fa5fb4edad
3 changed files with 15 additions and 1 deletions
|
@ -141,6 +141,11 @@ public:
|
||||||
addAnimeWindow->show();
|
addAnimeWindow->show();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ui->global<ui::State>().on_remove_anime([&](int animeIndex) {
|
||||||
|
int currentListIndex = ui->global<ui::State>().get_current_list().index;
|
||||||
|
removeAnimeFromList(currentListIndex, animeIndex);
|
||||||
|
});
|
||||||
|
|
||||||
addAnimeWindow->on_import_anilist_anime([&] (slint::SharedString animeIdStr) {
|
addAnimeWindow->on_import_anilist_anime([&] (slint::SharedString animeIdStr) {
|
||||||
int animeId = stoi(std::string(animeIdStr));
|
int animeId = stoi(std::string(animeIdStr));
|
||||||
int currentListIndex = ui->global<ui::State>().get_current_list().index;
|
int currentListIndex = ui->global<ui::State>().get_current_list().index;
|
||||||
|
@ -280,6 +285,14 @@ public:
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void removeAnimeFromList(int currentListIndex, int animeIndex) {
|
||||||
|
rei::json::JsonArray& listJson = json.getArray("lists").getObject(currentListIndex).getArray("animes");
|
||||||
|
listJson.remove(animeIndex);
|
||||||
|
selectList(currentListIndex);
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
slint::Image getAnimeImage(int animeId, std::string imageUrl) {
|
slint::Image getAnimeImage(int animeId, std::string imageUrl) {
|
||||||
//std::println("Get image for anime {}", animeId);
|
//std::println("Get image for anime {}", animeId);
|
||||||
std::string imagePath = imageDirectory + "/" + std::to_string(animeId);
|
std::string imagePath = imageDirectory + "/" + std::to_string(animeId);
|
||||||
|
|
|
@ -176,7 +176,7 @@ export component AppWindow inherits Window {
|
||||||
icon-size: 1.5rem;
|
icon-size: 1.5rem;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
clicked => {
|
clicked => {
|
||||||
// TODO : Missing feature to delete json value in rei-json
|
State.remove-anime(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ export global State {
|
||||||
callback add-local-list(AddLocalListParams);
|
callback add-local-list(AddLocalListParams);
|
||||||
|
|
||||||
callback open-add-anime-window();
|
callback open-add-anime-window();
|
||||||
|
callback remove-anime(int);
|
||||||
|
|
||||||
callback config-changed();
|
callback config-changed();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue