From 14f6697583ede3c1793cf3055fe7ed6a3284173d Mon Sep 17 00:00:00 2001 From: Jarrett Ye Date: Fri, 26 Apr 2024 14:22:23 +0800 Subject: [PATCH] Feat/contact author & rate add-on --- __init__.py | 21 +++++++++++++++++++-- config.json | 3 ++- configuration.py | 10 ++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/__init__.py b/__init__.py index 15a36a4..26c39ee 100644 --- a/__init__.py +++ b/__init__.py @@ -1,7 +1,7 @@ from aqt.gui_hooks import deck_browser_will_show_options_menu, state_did_change from aqt import mw from aqt.qt import QAction -from aqt.utils import tooltip +from aqt.utils import tooltip, openLink from typing import Callable from .dsr_state import init_dsr_status_hook @@ -21,7 +21,6 @@ from .browser.browser import init_browser from .configuration import Config, run_on_configuration_change - """ Acknowledgement to Arthur Milchior, Carlos Duarte and oakkitten. I learnt a lot from their add-ons. @@ -149,6 +148,20 @@ def reschedule_recent(did): menu_disperse_siblings = build_action(disperse_siblings, "Disperse all siblings") +def contact_author(did=None): + openLink("https://github.com/open-spaced-repetition/fsrs4anki-helper") + + +menu_contact = build_action(contact_author, "Contact Author on GitHub") + + +def rate_on_ankiweb(did=None): + openLink("https://ankiweb.net/shared/review/759844606") + config.has_rated = True + + +menu_rate = build_action(rate_on_ankiweb, "Rate Add-on on AnkiWeb") + menu_for_helper = mw.form.menuTools.addMenu("FSRS4Anki Helper") menu_for_helper.addAction(menu_auto_reschedule_after_sync) menu_for_helper.addAction(menu_auto_disperse_after_sync) @@ -166,6 +179,10 @@ def reschedule_recent(did): menu_for_helper.addAction(menu_advance) menu_for_helper.addAction(menu_reset) menu_for_helper.addAction(menu_disperse_siblings) +menu_for_helper.addSeparator() +menu_for_helper.addAction(menu_contact) +if not config.has_rated: + menu_for_helper.addAction(menu_rate) menu_apply_easy_days = build_action(easy_days, "Apply easy days now") diff --git a/config.json b/config.json index fe82c2e..8471b3b 100644 --- a/config.json +++ b/config.json @@ -11,5 +11,6 @@ "debug_notify": false, "fsrs_stats": true, "display_memory_state": false, - "auto_easy_days": false + "auto_easy_days": false, + "has_rated": false } \ No newline at end of file diff --git a/configuration.py b/configuration.py index cd7a9b9..01b3d84 100644 --- a/configuration.py +++ b/configuration.py @@ -15,6 +15,7 @@ FSRS_STATS = "fsrs_stats" DISPLAY_MEMORY_STATE = "display_memory_state" AUTO_EASY_DAYS = "auto_easy_days" +HAS_RATED = "has_rated" def load_config(): @@ -157,3 +158,12 @@ def auto_easy_days(self): def auto_easy_days(self, value): self.data[AUTO_EASY_DAYS] = value self.save() + + @property + def has_rated(self): + return self.data[HAS_RATED] + + @has_rated.setter + def has_rated(self, value): + self.data[HAS_RATED] = value + self.save()