mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Fix formatting, use shortcut on preview before displaying
This commit is contained in:
parent
097fa16783
commit
ace61835de
3 changed files with 20 additions and 15 deletions
|
@ -868,18 +868,24 @@ QTableView {{ gridline-color: {grid} }}
|
|||
def setupEditor(self):
|
||||
def add_preview_button(leftbuttons, editor):
|
||||
preview_shortcut = "Ctrl+Shift+P"
|
||||
leftbuttons.insert(0, editor.addButton(
|
||||
None,
|
||||
"preview",
|
||||
lambda _editor: self.onTogglePreview(),
|
||||
tr(TR.BROWSING_PREVIEW_SELECTED_CARD, val=preview_shortcut),
|
||||
tr(TR.ACTIONS_PREVIEW),
|
||||
id="previewButton",
|
||||
keys=preview_shortcut,
|
||||
disables=False,
|
||||
rightside=False,
|
||||
toggleable=True,
|
||||
))
|
||||
leftbuttons.insert(
|
||||
0,
|
||||
editor.addButton(
|
||||
None,
|
||||
"preview",
|
||||
lambda _editor: self.onTogglePreview(),
|
||||
tr(
|
||||
TR.BROWSING_PREVIEW_SELECTED_CARD,
|
||||
val=shortcut(preview_shortcut),
|
||||
),
|
||||
tr(TR.ACTIONS_PREVIEW),
|
||||
id="previewButton",
|
||||
keys=preview_shortcut,
|
||||
disables=False,
|
||||
rightside=False,
|
||||
toggleable=True,
|
||||
),
|
||||
)
|
||||
|
||||
gui_hooks.editor_did_init_left_buttons.append(add_preview_button)
|
||||
self.editor = aqt.editor.Editor(self.mw, self.form.fieldsArea, self)
|
||||
|
|
|
@ -253,6 +253,7 @@ class Editor:
|
|||
if func:
|
||||
self._links[cmd] = func
|
||||
if keys:
|
||||
|
||||
def on_activated():
|
||||
func(self)
|
||||
|
||||
|
@ -263,6 +264,7 @@ class Editor:
|
|||
def on_hotkey():
|
||||
on_activated()
|
||||
self.web.eval(f'toggleEditorButton("#{id}");')
|
||||
|
||||
else:
|
||||
on_hotkey = on_activated
|
||||
|
||||
|
|
|
@ -309,9 +309,6 @@ class BrowserPreviewer(MultiCardPreviewer):
|
|||
self._last_card_id = c.id
|
||||
return changed
|
||||
|
||||
def _on_finished(self, ok):
|
||||
super()._on_finished(ok)
|
||||
|
||||
def _on_prev_card(self):
|
||||
self._parent.editor.saveNow(
|
||||
lambda: self._parent._moveCur(QAbstractItemView.MoveUp)
|
||||
|
|
Loading…
Reference in a new issue