mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12: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 setupEditor(self):
|
||||||
def add_preview_button(leftbuttons, editor):
|
def add_preview_button(leftbuttons, editor):
|
||||||
preview_shortcut = "Ctrl+Shift+P"
|
preview_shortcut = "Ctrl+Shift+P"
|
||||||
leftbuttons.insert(0, editor.addButton(
|
leftbuttons.insert(
|
||||||
|
0,
|
||||||
|
editor.addButton(
|
||||||
None,
|
None,
|
||||||
"preview",
|
"preview",
|
||||||
lambda _editor: self.onTogglePreview(),
|
lambda _editor: self.onTogglePreview(),
|
||||||
tr(TR.BROWSING_PREVIEW_SELECTED_CARD, val=preview_shortcut),
|
tr(
|
||||||
|
TR.BROWSING_PREVIEW_SELECTED_CARD,
|
||||||
|
val=shortcut(preview_shortcut),
|
||||||
|
),
|
||||||
tr(TR.ACTIONS_PREVIEW),
|
tr(TR.ACTIONS_PREVIEW),
|
||||||
id="previewButton",
|
id="previewButton",
|
||||||
keys=preview_shortcut,
|
keys=preview_shortcut,
|
||||||
disables=False,
|
disables=False,
|
||||||
rightside=False,
|
rightside=False,
|
||||||
toggleable=True,
|
toggleable=True,
|
||||||
))
|
),
|
||||||
|
)
|
||||||
|
|
||||||
gui_hooks.editor_did_init_left_buttons.append(add_preview_button)
|
gui_hooks.editor_did_init_left_buttons.append(add_preview_button)
|
||||||
self.editor = aqt.editor.Editor(self.mw, self.form.fieldsArea, self)
|
self.editor = aqt.editor.Editor(self.mw, self.form.fieldsArea, self)
|
||||||
|
|
|
@ -253,6 +253,7 @@ class Editor:
|
||||||
if func:
|
if func:
|
||||||
self._links[cmd] = func
|
self._links[cmd] = func
|
||||||
if keys:
|
if keys:
|
||||||
|
|
||||||
def on_activated():
|
def on_activated():
|
||||||
func(self)
|
func(self)
|
||||||
|
|
||||||
|
@ -263,6 +264,7 @@ class Editor:
|
||||||
def on_hotkey():
|
def on_hotkey():
|
||||||
on_activated()
|
on_activated()
|
||||||
self.web.eval(f'toggleEditorButton("#{id}");')
|
self.web.eval(f'toggleEditorButton("#{id}");')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
on_hotkey = on_activated
|
on_hotkey = on_activated
|
||||||
|
|
||||||
|
|
|
@ -309,9 +309,6 @@ class BrowserPreviewer(MultiCardPreviewer):
|
||||||
self._last_card_id = c.id
|
self._last_card_id = c.id
|
||||||
return changed
|
return changed
|
||||||
|
|
||||||
def _on_finished(self, ok):
|
|
||||||
super()._on_finished(ok)
|
|
||||||
|
|
||||||
def _on_prev_card(self):
|
def _on_prev_card(self):
|
||||||
self._parent.editor.saveNow(
|
self._parent.editor.saveNow(
|
||||||
lambda: self._parent._moveCur(QAbstractItemView.MoveUp)
|
lambda: self._parent._moveCur(QAbstractItemView.MoveUp)
|
||||||
|
|
Loading…
Reference in a new issue