undoing of notetype templates
This commit is contained in:
parent
9a46ad6352
commit
248373ef30
@ -839,8 +839,6 @@ where id in %s"""
|
||||
|
||||
def setupHooks(self) -> None:
|
||||
gui_hooks.undo_state_did_change.append(self.onUndoState)
|
||||
# fixme: remove this once all items are using `operation_did_execute`
|
||||
gui_hooks.sidebar_should_refresh_notetypes.append(self.on_item_added)
|
||||
gui_hooks.backend_will_block.append(self.table.on_backend_will_block)
|
||||
gui_hooks.backend_did_block.append(self.table.on_backend_did_block)
|
||||
gui_hooks.operation_did_execute.append(self.on_operation_did_execute)
|
||||
@ -848,15 +846,11 @@ where id in %s"""
|
||||
|
||||
def teardownHooks(self) -> None:
|
||||
gui_hooks.undo_state_did_change.remove(self.onUndoState)
|
||||
gui_hooks.sidebar_should_refresh_notetypes.remove(self.on_item_added)
|
||||
gui_hooks.backend_will_block.remove(self.table.on_backend_will_block)
|
||||
gui_hooks.backend_did_block.remove(self.table.on_backend_will_block)
|
||||
gui_hooks.operation_did_execute.remove(self.on_operation_did_execute)
|
||||
gui_hooks.focus_did_change.remove(self.on_focus_change)
|
||||
|
||||
def on_item_added(self, item: Any = None) -> None:
|
||||
self.sidebar.refresh()
|
||||
|
||||
# Undo
|
||||
######################################################################
|
||||
|
||||
|
@ -6,12 +6,13 @@ from concurrent.futures import Future
|
||||
from typing import Any, Dict, List, Match, Optional
|
||||
|
||||
import aqt
|
||||
from anki.collection import OpChanges
|
||||
from anki.consts import *
|
||||
from anki.errors import TemplateError
|
||||
from anki.lang import without_unicode_isolation
|
||||
from anki.notes import Note
|
||||
from aqt import AnkiQt, gui_hooks
|
||||
from aqt.forms.browserdisp import Ui_Dialog
|
||||
from aqt.operations.notetype import update_notetype_legacy
|
||||
from aqt.qt import *
|
||||
from aqt.schema_change_tracker import ChangeTracker
|
||||
from aqt.sound import av_player, play_clicked_audio
|
||||
@ -29,7 +30,6 @@ from aqt.utils import (
|
||||
saveSplitter,
|
||||
shortcut,
|
||||
showInfo,
|
||||
showWarning,
|
||||
tooltip,
|
||||
tr,
|
||||
)
|
||||
@ -784,22 +784,15 @@ class CardLayout(QDialog):
|
||||
######################################################################
|
||||
|
||||
def accept(self) -> None:
|
||||
def save() -> None:
|
||||
self.mm.save(self.model)
|
||||
|
||||
def on_done(fut: Future) -> None:
|
||||
try:
|
||||
fut.result()
|
||||
except TemplateError as e:
|
||||
showWarning(str(e))
|
||||
return
|
||||
self.mw.reset()
|
||||
def on_done(changes: OpChanges) -> None:
|
||||
tooltip(tr.card_templates_changes_saved(), parent=self.parentWidget())
|
||||
self.cleanup()
|
||||
gui_hooks.sidebar_should_refresh_notetypes()
|
||||
return QDialog.accept(self)
|
||||
QDialog.accept(self)
|
||||
|
||||
self.mw.taskman.with_progress(save, on_done)
|
||||
update_notetype_legacy(parent=self.mw, notetype=self.model).success(
|
||||
on_done
|
||||
).run_in_background()
|
||||
|
||||
def reject(self) -> None:
|
||||
if self.change_tracker.changed():
|
||||
|
@ -234,7 +234,7 @@ class FieldDialog(QDialog):
|
||||
self.saveField()
|
||||
|
||||
def on_done(changes: OpChanges) -> None:
|
||||
tooltip("Changes saved.", parent=self.mw)
|
||||
tooltip(tr.card_templates_changes_saved(), parent=self.parentWidget())
|
||||
QDialog.accept(self)
|
||||
|
||||
update_notetype_legacy(parent=self.mw, notetype=self.model).success(
|
||||
|
@ -916,7 +916,7 @@ gui_hooks.webview_did_inject_style_into_page.append(mytest)
|
||||
legacy_no_args=True,
|
||||
),
|
||||
Hook(name="sidebar_should_refresh_decks", doc="Legacy, do not use."),
|
||||
Hook(name="sidebar_should_refresh_notetypes"),
|
||||
Hook(name="sidebar_should_refresh_notetypes", doc="Legacy, do not use."),
|
||||
Hook(
|
||||
name="deck_browser_will_show_options_menu",
|
||||
args=["menu: QMenu", "deck_id: int"],
|
||||
|
Loading…
Reference in New Issue
Block a user