From 1fac03cc248bef4f1803b355b9643ffbceec6209 Mon Sep 17 00:00:00 2001 From: Bas Rieter Date: Fri, 20 Dec 2024 13:40:27 +0100 Subject: [PATCH 1/2] Added: Allow clearing of search history or history items (Fixes #1874). --- addon.xml | 12 +++++++++++- .../resource.language.en_gb/strings.po | 10 ++++++++++ resources/lib/actions/addonaction.py | 1 + resources/lib/actions/folderaction.py | 1 + resources/lib/menu.py | 19 +++++++++++++++++++ retromenu.py | 4 ++++ 6 files changed, 46 insertions(+), 1 deletion(-) diff --git a/addon.xml b/addon.xml index cc5384694..1fa6102b3 100644 --- a/addon.xml +++ b/addon.xml @@ -46,6 +46,16 @@ ListItem.Property(RetrospectCloaked) + + + ListItem.Property(RetrospectSearchFolder) + + + + + ListItem.Property(RetrospectSearchFolder) + + @@ -119,7 +129,7 @@ - true + false all GPL-3.0-or-later en nl de sv no lt lv fi diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index 95e879c8d..3ad5df221 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -794,6 +794,16 @@ msgctxt "#30376" msgid "Continue Watching" msgstr "" +msgctxt "#30377" +msgid "Clear Search History" +msgstr "" + +msgctxt "#30378" +msgid "Remove Search Item" +msgstr "" + + + # empty strings from id 30377 to 30400 msgctxt "#30401" diff --git a/resources/lib/actions/addonaction.py b/resources/lib/actions/addonaction.py index 8f102b2a9..f0aeafce1 100644 --- a/resources/lib/actions/addonaction.py +++ b/resources/lib/actions/addonaction.py @@ -27,6 +27,7 @@ def __init__(self, parameter_parser): self._propertyRetrospectCategory = "RetrospectCategory" self._propertyRetrospectFavorite = "RetrospectFavorite" self._propertyRetrospectAdaptive = "RetrospectAdaptive" + self._propertyRetrospectSearchFolder = "RetrospectSearchFolder" self.parameter_parser = parameter_parser if self.parameter_parser is None: diff --git a/resources/lib/actions/folderaction.py b/resources/lib/actions/folderaction.py index a99c28917..3d6a17208 100644 --- a/resources/lib/actions/folderaction.py +++ b/resources/lib/actions/folderaction.py @@ -246,6 +246,7 @@ def __set_kodi_properties(self, kodi_item, media_item, is_folder, is_favourite): kodi_item.setProperty(self._propertyRetrospect, "true") if media_item.is_search_folder: + kodi_item.setProperty(self._propertyRetrospectSearchFolder, "true") # Search folders don't need more. return diff --git a/resources/lib/menu.py b/resources/lib/menu.py index 8e83d0cab..48c4eea34 100644 --- a/resources/lib/menu.py +++ b/resources/lib/menu.py @@ -2,6 +2,8 @@ import os import sys +from typing import List + import xbmc import xbmcgui @@ -123,6 +125,23 @@ def show_settings(self): AddonSettings.show_settings() self.refresh() + def clear_search(self): + """ Clears the complete search history for a channel.""" + + settings = AddonSettings.store(LOCAL) + settings.set_setting("search", [], self.channelObject) + self.refresh() + + def remove_search_item(self): + """ Removes a single item from the search history for a folder """ + + settings = AddonSettings.store(LOCAL) + history: List[str] = settings.get_setting("search", self.channelObject, []) # type: ignore + needle = self.params[keyword.NEEDLE] + history.remove(needle) + settings.set_setting("search", history, self.channelObject) + self.refresh() + def channel_settings(self): """ Shows the channel settings for the selected channel. Refreshes the list after closing the settings. """ diff --git a/retromenu.py b/retromenu.py index f19244e28..c5b9af4fb 100644 --- a/retromenu.py +++ b/retromenu.py @@ -49,5 +49,9 @@ m.show_country_settings() elif command == "settings": m.show_settings() + elif command == "clear_search": + m.clear_search() + elif command == "remove_search_item": + m.remove_search_item() else: raise IndexError("Missing command in sys.argv: {}".format(sys.argv)) From ea6a1f9cf66c58d11ed1b79424736240052f261b Mon Sep 17 00:00:00 2001 From: Bas Rieter Date: Fri, 20 Dec 2024 17:21:17 +0100 Subject: [PATCH 2/2] Updated: Translation for search history removing (See #1874). --- addon.xml | 2 +- resources/language/resource.language.en_gb/strings.po | 6 ++---- resources/language/resource.language.nl_nl/strings.po | 11 ++++++++++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/addon.xml b/addon.xml index 1fa6102b3..59d9c0723 100644 --- a/addon.xml +++ b/addon.xml @@ -129,7 +129,7 @@ - false + true all GPL-3.0-or-later en nl de sv no lt lv fi diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index 3ad5df221..c06176396 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -799,12 +799,10 @@ msgid "Clear Search History" msgstr "" msgctxt "#30378" -msgid "Remove Search Item" +msgid "Remove Item" msgstr "" - - -# empty strings from id 30377 to 30400 +# empty strings from id 30379 to 30400 msgctxt "#30401" msgid "Dutch" diff --git a/resources/language/resource.language.nl_nl/strings.po b/resources/language/resource.language.nl_nl/strings.po index db69b2647..d46145a6f 100644 --- a/resources/language/resource.language.nl_nl/strings.po +++ b/resources/language/resource.language.nl_nl/strings.po @@ -778,7 +778,16 @@ msgctxt "#30376" msgid "Continue Watching" msgstr "Doorgaan met kijken" -# empty strings from id 30373 to 30400 +msgctxt "#30377" +msgid "Clear Search History" +msgstr "Zoekhistorie wissen" + +msgctxt "#30378" +msgid "Remove Item" +msgstr "Verwijder" + +# empty strings from id 30379 to 30400 + msgctxt "#30401" msgid "Dutch" msgstr "Nederlands"