" % node.deck_id
)
# children
if not node.collapsed:
for child in node.children:
buf += self._render_deck_node(child, ctx)
return buf
def _topLevelDragRow(self) -> str:
return "
"
# Options
##########################################################################
def _showOptions(self, did: str) -> None:
m = QMenu(self.mw)
a = m.addAction(tr.actions_rename())
qconnect(a.triggered, lambda b, did=did: self._rename(DeckID(int(did))))
a = m.addAction(tr.actions_options())
qconnect(a.triggered, lambda b, did=did: self._options(DeckID(int(did))))
a = m.addAction(tr.actions_export())
qconnect(a.triggered, lambda b, did=did: self._export(DeckID(int(did))))
a = m.addAction(tr.actions_delete())
qconnect(a.triggered, lambda b, did=did: self._delete(DeckID(int(did))))
gui_hooks.deck_browser_will_show_options_menu(m, int(did))
m.exec_(QCursor.pos())
def _export(self, did: DeckID) -> None:
self.mw.onExport(did=did)
def _rename(self, did: DeckID) -> None:
deck = self.mw.col.decks.get(did)
current_name = deck["name"]
new_name = getOnlyText(tr.decks_new_deck_name(), default=current_name)
if not new_name or new_name == current_name:
return
rename_deck(mw=self.mw, deck_id=did, new_name=new_name)
def _options(self, did: DeckID) -> None:
# select the deck first, because the dyn deck conf assumes the deck
# we're editing is the current one
self.mw.col.decks.select(did)
self.mw.onDeckConf()
def _collapse(self, did: DeckID) -> None:
self.mw.col.decks.collapse(did)
node = self.mw.col.decks.find_deck_in_tree(self._dueTree, did)
if node:
node.collapsed = not node.collapsed
self._renderPage(reuse=True)
def _handle_drag_and_drop(self, source: DeckID, target: DeckID) -> None:
reparent_decks(mw=self.mw, parent=self.mw, deck_ids=[source], new_parent=target)
def _delete(self, did: DeckID) -> None:
remove_decks(mw=self.mw, parent=self.mw, deck_ids=[did])
# Top buttons
######################################################################
drawLinks = [
["", "shared", tr.decks_get_shared()],
["", "create", tr.decks_create_deck()],
["Ctrl+Shift+I", "import", tr.decks_import_file()],
]
def _drawButtons(self) -> None:
buf = ""
drawLinks = deepcopy(self.drawLinks)
for b in drawLinks:
if b[0]:
b[0] = tr.actions_shortcut_key(val=shortcut(b[0]))
buf += """
""" % tuple(
b
)
self.bottom.draw(
buf=buf,
link_handler=self._linkHandler,
web_context=DeckBrowserBottomBar(self),
)
def _onShared(self) -> None:
openLink(f"{aqt.appShared}decks/")
def _on_create(self) -> None:
add_deck_dialog(mw=self.mw, parent=self.mw)
######################################################################
def _v1_upgrade_message(self) -> str:
if self.mw.col.schedVer() == 2:
return ""
if (intTime() - self._v1_message_dismissed_at) < 86_400:
return ""
return f"""
{tr.scheduling_update_soon()}
"""
def _confirm_upgrade(self) -> None:
self.mw.col.modSchema(check=True)
self.mw.col.upgrade_to_v2_scheduler()
# not translated, as 2.15 should not be too far off
if askUser(
"Do you use AnkiDroid <= 2.14, or plan to use it in the near future? If unsure, choose No. You can adjust the setting later in the preferences screen.",
defaultno=True,
):
prefs = self.mw.col.get_preferences()
prefs.scheduling.new_timezone = False
self.mw.col.set_preferences(prefs)
showInfo(tr.scheduling_update_done())
self.refresh()