mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Switch frontend to use backend links
This commit is contained in:
parent
55e1f178ef
commit
d8d69a3810
5 changed files with 14 additions and 34 deletions
|
@ -6,6 +6,7 @@ persistent = no
|
||||||
ignored-classes=
|
ignored-classes=
|
||||||
BrowserColumns,
|
BrowserColumns,
|
||||||
BrowserRow,
|
BrowserRow,
|
||||||
|
HelpPage,
|
||||||
FormatTimespanRequest,
|
FormatTimespanRequest,
|
||||||
CardAnswer,
|
CardAnswer,
|
||||||
QueuedCards,
|
QueuedCards,
|
||||||
|
|
|
@ -14,6 +14,7 @@ import anki.cards_pb2
|
||||||
import anki.collection_pb2
|
import anki.collection_pb2
|
||||||
import anki.decks_pb2
|
import anki.decks_pb2
|
||||||
import anki.deckconfig_pb2
|
import anki.deckconfig_pb2
|
||||||
|
import anki.links_pb2
|
||||||
import anki.notes_pb2
|
import anki.notes_pb2
|
||||||
import anki.notetypes_pb2
|
import anki.notetypes_pb2
|
||||||
import anki.scheduler_pb2
|
import anki.scheduler_pb2
|
||||||
|
@ -195,6 +196,7 @@ service_modules = dict(
|
||||||
CARD_RENDERING=anki.card_rendering_pb2,
|
CARD_RENDERING=anki.card_rendering_pb2,
|
||||||
TAGS=anki.tags_pb2,
|
TAGS=anki.tags_pb2,
|
||||||
MEDIA=anki.media_pb2,
|
MEDIA=anki.media_pb2,
|
||||||
|
LINKS=anki.links_pb2,
|
||||||
)
|
)
|
||||||
|
|
||||||
for service in anki.backend_pb2.ServiceIndex.DESCRIPTOR.values:
|
for service in anki.backend_pb2.ServiceIndex.DESCRIPTOR.values:
|
||||||
|
@ -236,6 +238,7 @@ import anki.cards_pb2
|
||||||
import anki.collection_pb2
|
import anki.collection_pb2
|
||||||
import anki.decks_pb2
|
import anki.decks_pb2
|
||||||
import anki.deckconfig_pb2
|
import anki.deckconfig_pb2
|
||||||
|
import anki.links_pb2
|
||||||
import anki.notes_pb2
|
import anki.notes_pb2
|
||||||
import anki.notetypes_pb2
|
import anki.notetypes_pb2
|
||||||
import anki.scheduler_pb2
|
import anki.scheduler_pb2
|
||||||
|
|
|
@ -12,12 +12,14 @@ from anki import (
|
||||||
collection_pb2,
|
collection_pb2,
|
||||||
config_pb2,
|
config_pb2,
|
||||||
generic_pb2,
|
generic_pb2,
|
||||||
|
links_pb2,
|
||||||
search_pb2,
|
search_pb2,
|
||||||
stats_pb2,
|
stats_pb2,
|
||||||
)
|
)
|
||||||
from anki._legacy import DeprecatedNamesMixin, deprecated
|
from anki._legacy import DeprecatedNamesMixin, deprecated
|
||||||
|
|
||||||
# protobuf we publicly export - listed first to avoid circular imports
|
# protobuf we publicly export - listed first to avoid circular imports
|
||||||
|
HelpPage = links_pb2.HelpPageLinkRequest
|
||||||
SearchNode = search_pb2.SearchNode
|
SearchNode = search_pb2.SearchNode
|
||||||
Progress = collection_pb2.Progress
|
Progress = collection_pb2.Progress
|
||||||
EmptyCardsReport = card_rendering_pb2.EmptyCardsReport
|
EmptyCardsReport = card_rendering_pb2.EmptyCardsReport
|
||||||
|
|
1
pylib/anki/links_pb2.pyi
Normal file
1
pylib/anki/links_pb2.pyi
Normal file
|
@ -0,0 +1 @@
|
||||||
|
../../bazel-bin/pylib/anki/links_pb2.pyi
|
|
@ -34,7 +34,7 @@ from PyQt5.QtWidgets import (
|
||||||
)
|
)
|
||||||
|
|
||||||
import aqt
|
import aqt
|
||||||
from anki.collection import Collection
|
from anki.collection import Collection, HelpPage
|
||||||
from anki.lang import TR, tr_legacyglobal # pylint: disable=unused-import
|
from anki.lang import TR, tr_legacyglobal # pylint: disable=unused-import
|
||||||
from anki.utils import invalidFilename, isMac, isWin, noBundledLibs, versionWithBuild
|
from anki.utils import invalidFilename, isMac, isWin, noBundledLibs, versionWithBuild
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
|
@ -69,42 +69,15 @@ def locale_dir() -> str:
|
||||||
# shortcut to access Fluent translations; set as
|
# shortcut to access Fluent translations; set as
|
||||||
tr = tr_legacyglobal
|
tr = tr_legacyglobal
|
||||||
|
|
||||||
|
HelpPageArgument = Union["HelpPage.HelpPage.V", str]
|
||||||
class HelpPage(Enum):
|
|
||||||
NOTE_TYPE = "getting-started#note-types"
|
|
||||||
BROWSING = "browsing"
|
|
||||||
BROWSING_FIND_AND_REPLACE = "browsing#find-and-replace"
|
|
||||||
BROWSING_NOTES_MENU = "browsing#notes"
|
|
||||||
KEYBOARD_SHORTCUTS = "studying#keyboard-shortcuts"
|
|
||||||
EDITING = "editing"
|
|
||||||
ADDING_CARD_AND_NOTE = "editing#adding-cards-and-notes"
|
|
||||||
ADDING_A_NOTE_TYPE = "editing#adding-a-note-type"
|
|
||||||
LATEX = "math#latex"
|
|
||||||
PREFERENCES = "preferences"
|
|
||||||
INDEX = ""
|
|
||||||
TEMPLATES = "templates/intro"
|
|
||||||
FILTERED_DECK = "filtered-decks"
|
|
||||||
IMPORTING = "importing"
|
|
||||||
CUSTOMIZING_FIELDS = "editing#customizing-fields"
|
|
||||||
DECK_OPTIONS = "deck-options"
|
|
||||||
EDITING_FEATURES = "editing#features"
|
|
||||||
|
|
||||||
|
|
||||||
HelpPageArgument = Optional[Union[HelpPage, str]]
|
|
||||||
"""This type represents what can be used as argument expecting a specific help page. Anki code should use HelpPage as
|
|
||||||
argument. However, add-on may use string, and we want to accept this.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def openHelp(section: HelpPageArgument) -> None:
|
def openHelp(section: HelpPageArgument) -> None:
|
||||||
link = aqt.appHelpSite
|
if isinstance(section, str):
|
||||||
if section:
|
page = HelpPage(literal=section)
|
||||||
if isinstance(section, HelpPage):
|
else:
|
||||||
link += section.value
|
page = HelpPage(variant=section)
|
||||||
else:
|
openLink(tr.backend().help_page_link(page))
|
||||||
link += section
|
|
||||||
openLink(link)
|
|
||||||
|
|
||||||
|
|
||||||
def openLink(link: Union[str, QUrl]) -> None:
|
def openLink(link: Union[str, QUrl]) -> None:
|
||||||
|
|
Loading…
Reference in a new issue