diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 212b7082b..46a7c7720 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -24,6 +24,7 @@ Erez Volk zjosua Arthur Milchior Yngve Hoiseth +Ijgnd ******************** diff --git a/qt/aqt/about.py b/qt/aqt/about.py index e4416148d..e6095ba60 100644 --- a/qt/aqt/about.py +++ b/qt/aqt/about.py @@ -2,10 +2,12 @@ # -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import platform +import time import aqt.forms from anki.lang import _ from anki.utils import versionWithBuild +from aqt.addons import AddonManager, AddonMeta from aqt.qt import * from aqt.utils import supportText, tooltip @@ -32,10 +34,51 @@ def show(mw): # Copy debug info ###################################################################### + def addon_fmt(addmgr: AddonManager, a: AddonMeta) -> str: + if a.installed_at: + t = time.strftime("%Y-%m-%dT%H:%M", time.localtime(a.installed_at)) + else: + t = "0" + if a.provided_name: + n = a.provided_name + else: + n = "''" + user = addmgr.getConfig(a.dir_name) + default = addmgr.addonConfigDefaults(a.dir_name) + if user == default: + confstat = "''" + else: + confstat = "mod" + return f"{n} ['{a.dir_name}', {t}, '{a.human_version}', {confstat}]" + def onCopy(): addmgr = mw.addonManager - addons = "\n".join(addmgr.annotatedName(d) for d in addmgr.allAddons()) - info = "\n".join((supportText(), "Add-ons:\n\n{}".format(addons))) + active = [] + activeids = [] + inactive = [] + for a in addmgr.all_addon_meta(): + if a.enabled: + active.append(addon_fmt(addmgr, a)) + if a.ankiweb_id(): + activeids.append(a.dir_name) + else: + inactive.append(addon_fmt(addmgr, a)) + newline = "\n" + info = f""" +{supportText()} + +===Add-ons (active)=== +(add-on provided name [Add-on folder, installed at, version, is config changed]) +{newline.join(sorted(active))} + +===Add-ons (active) Ankiweb-IDs=== +{" ".join(activeids)} + +===Add-ons (inactive)=== +(add-on provided name [Add-on folder, installed at, version, is config changed]) +{newline.join(sorted(inactive))} +""" + info = " " + " ".join(info.splitlines(True)) QApplication.clipboard().setText(info) tooltip(_("Copied to clipboard"), parent=dialog) diff --git a/qt/aqt/addons.py b/qt/aqt/addons.py index 3a43acef9..4b252da3a 100644 --- a/qt/aqt/addons.py +++ b/qt/aqt/addons.py @@ -101,6 +101,7 @@ class AddonMeta: min_point_version: int max_point_version: int branch_index: int + human_version: Optional[str] def human_name(self) -> str: return self.provided_name or self.dir_name @@ -132,6 +133,7 @@ class AddonMeta: min_point_version=json_meta.get("min_point_version", 0) or 0, max_point_version=json_meta.get("max_point_version", 0) or 0, branch_index=json_meta.get("branch_index", 0) or 0, + human_version=json_meta.get("human_version", ""), ) @@ -157,6 +159,8 @@ class AddonManager: "max_point_version": {"type": "number", "meta": True}, # AnkiWeb sends this to indicate which branch the user downloaded. "branch_index": {"type": "number", "meta": True}, + # version string set by the add-on creator + "human_version": {"type": "string", "meta": True}, }, "required": ["package", "name"], } @@ -236,6 +240,8 @@ When loading '%(name)s': json_obj["max_point_version"] = addon.max_point_version json_obj["min_point_version"] = addon.min_point_version json_obj["branch_index"] = addon.branch_index + if addon.human_version is not None: + json_obj["human_version"] = addon.human_version self.writeAddonMeta(addon.dir_name, json_obj) diff --git a/qt/aqt/utils.py b/qt/aqt/utils.py index 9143636cd..318f48b07 100644 --- a/qt/aqt/utils.py +++ b/qt/aqt/utils.py @@ -685,6 +685,7 @@ def qtMenuShortcutWorkaround(qmenu): def supportText(): import platform + import time from aqt import mw if isWin: @@ -700,10 +701,14 @@ def supportText(): except: return "?" + lc = mw.pm.last_addon_update_check() + lcfmt = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(lc)) + return """\ Anki {} Python {} Qt {} PyQt {} Platform: {} Flags: frz={} ao={} sv={} +Add-ons, last update check: {} """.format( versionWithBuild(), platform.python_version(), @@ -713,6 +718,7 @@ Flags: frz={} ao={} sv={} getattr(sys, "frozen", False), mw.addonManager.dirty, schedVer(), + lcfmt, )