mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 15:02:21 -04:00
Accept .zip as an alias for .ankiaddon too (#1914)
This commit is contained in:
parent
ae69bb0834
commit
67f64740c4
2 changed files with 9 additions and 6 deletions
|
@ -177,7 +177,7 @@ def package_name_valid(name: str) -> bool:
|
||||||
# fixme: this class should not have any GUI code in it
|
# fixme: this class should not have any GUI code in it
|
||||||
class AddonManager:
|
class AddonManager:
|
||||||
|
|
||||||
ext: str = ".ankiaddon"
|
exts: list[str] = [".ankiaddon", ".zip"]
|
||||||
_manifest_schema: dict = {
|
_manifest_schema: dict = {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -774,8 +774,8 @@ class AddonsDialog(QDialog):
|
||||||
if not mime.hasUrls():
|
if not mime.hasUrls():
|
||||||
return None
|
return None
|
||||||
urls = mime.urls()
|
urls = mime.urls()
|
||||||
ext = self.mgr.ext
|
exts = self.mgr.exts
|
||||||
if all(url.toLocalFile().endswith(ext) for url in urls):
|
if all(any(url.toLocalFile().endswith(ext) for ext in exts) for url in urls):
|
||||||
event.acceptProposedAction()
|
event.acceptProposedAction()
|
||||||
|
|
||||||
def dropEvent(self, event: QDropEvent) -> None:
|
def dropEvent(self, event: QDropEvent) -> None:
|
||||||
|
@ -932,9 +932,11 @@ class AddonsDialog(QDialog):
|
||||||
|
|
||||||
def onInstallFiles(self, paths: list[str] | None = None) -> bool | None:
|
def onInstallFiles(self, paths: list[str] | None = None) -> bool | None:
|
||||||
if not paths:
|
if not paths:
|
||||||
key = f"{tr.addons_packaged_anki_addon()} (*{self.mgr.ext})"
|
filter = f"{tr.addons_packaged_anki_addon()} " + "({})".format(
|
||||||
|
" ".join(f"*{ext}" for ext in self.mgr.exts)
|
||||||
|
)
|
||||||
paths_ = getFile(
|
paths_ = getFile(
|
||||||
self, tr.addons_install_addons(), None, key, key="addons", multi=True
|
self, tr.addons_install_addons(), None, filter, key="addons", multi=True
|
||||||
)
|
)
|
||||||
paths = paths_ # type: ignore
|
paths = paths_ # type: ignore
|
||||||
if not paths:
|
if not paths:
|
||||||
|
|
|
@ -1790,7 +1790,8 @@ title="{}" {}>{}</button>""".format(
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _isAddon(self, buf: str) -> bool:
|
def _isAddon(self, buf: str) -> bool:
|
||||||
return buf.endswith(self.addonManager.ext)
|
# only accept primary extension here to avoid conflicts with deck packages
|
||||||
|
return buf.endswith(self.addonManager.exts[0])
|
||||||
|
|
||||||
def interactiveState(self) -> bool:
|
def interactiveState(self) -> bool:
|
||||||
"True if not in profile manager, syncing, etc."
|
"True if not in profile manager, syncing, etc."
|
||||||
|
|
Loading…
Reference in a new issue