mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Fix switching of add & history buttons when selecting IO notetype (#2833)
* Fix switching of add & history buttons when selecting IO notetype * Update CONTRIBUTORS
This commit is contained in:
parent
9785dfb850
commit
9fd25a87ec
2 changed files with 7 additions and 25 deletions
|
@ -149,6 +149,7 @@ Gustaf Carefall <https://github.com/Gustaf-C>
|
||||||
virinci <github.com/virinci>
|
virinci <github.com/virinci>
|
||||||
snowtimeglass <snowtimeglass@gmail.com>
|
snowtimeglass <snowtimeglass@gmail.com>
|
||||||
Ben Olson <github.com/grepgrok>
|
Ben Olson <github.com/grepgrok>
|
||||||
|
Akash Reddy <github.com/akashreddy03>
|
||||||
|
|
||||||
********************
|
********************
|
||||||
|
|
||||||
|
|
|
@ -114,11 +114,6 @@ class AddCards(QMainWindow):
|
||||||
qconnect(self.compat_add_shorcut.activated, self.addButton.click)
|
qconnect(self.compat_add_shorcut.activated, self.addButton.click)
|
||||||
self.addButton.setToolTip(shortcut(tr.adding_add_shortcut_ctrlandenter()))
|
self.addButton.setToolTip(shortcut(tr.adding_add_shortcut_ctrlandenter()))
|
||||||
|
|
||||||
# add io button
|
|
||||||
self.io_add_button = bb.addButton(f"{tr.actions_add()}", ar)
|
|
||||||
qconnect(self.io_add_button.clicked, self.add_io_note)
|
|
||||||
self.io_add_button.setShortcut(QKeySequence("Ctrl+Shift+I"))
|
|
||||||
|
|
||||||
# close
|
# close
|
||||||
self.closeButton = QPushButton(tr.actions_close())
|
self.closeButton = QPushButton(tr.actions_close())
|
||||||
self.closeButton.setAutoDefault(False)
|
self.closeButton.setAutoDefault(False)
|
||||||
|
@ -140,17 +135,6 @@ class AddCards(QMainWindow):
|
||||||
b.setEnabled(False)
|
b.setEnabled(False)
|
||||||
self.historyButton = b
|
self.historyButton = b
|
||||||
|
|
||||||
# hide io buttons for note type other than image occlusion
|
|
||||||
self.show_hide_add_buttons()
|
|
||||||
|
|
||||||
def show_hide_add_buttons(self) -> None:
|
|
||||||
if self.editor.current_notetype_is_image_occlusion():
|
|
||||||
self.addButton.setVisible(False)
|
|
||||||
self.io_add_button.setVisible(True)
|
|
||||||
else:
|
|
||||||
self.addButton.setVisible(True)
|
|
||||||
self.io_add_button.setVisible(False)
|
|
||||||
|
|
||||||
def setAndFocusNote(self, note: Note) -> None:
|
def setAndFocusNote(self, note: Note) -> None:
|
||||||
self.editor.set_note(note, focusTo=0)
|
self.editor.set_note(note, focusTo=0)
|
||||||
|
|
||||||
|
@ -210,9 +194,6 @@ class AddCards(QMainWindow):
|
||||||
self, old_note.note_type(), new_note.note_type()
|
self, old_note.note_type(), new_note.note_type()
|
||||||
)
|
)
|
||||||
|
|
||||||
# update buttons for image occlusion on note type change
|
|
||||||
self.show_hide_add_buttons()
|
|
||||||
|
|
||||||
def _load_new_note(self, sticky_fields_from: Optional[Note] = None) -> None:
|
def _load_new_note(self, sticky_fields_from: Optional[Note] = None) -> None:
|
||||||
note = self._new_note()
|
note = self._new_note()
|
||||||
if old_note := sticky_fields_from:
|
if old_note := sticky_fields_from:
|
||||||
|
@ -274,6 +255,11 @@ class AddCards(QMainWindow):
|
||||||
aqt.dialogs.open("Browser", self.mw, search=(SearchNode(nid=nid),))
|
aqt.dialogs.open("Browser", self.mw, search=(SearchNode(nid=nid),))
|
||||||
|
|
||||||
def add_current_note(self) -> None:
|
def add_current_note(self) -> None:
|
||||||
|
if self.editor.current_notetype_is_image_occlusion():
|
||||||
|
self.editor.update_occlusions_field()
|
||||||
|
self.editor.call_after_note_saved(self._add_current_note)
|
||||||
|
self.editor.reset_image_occlusion()
|
||||||
|
else:
|
||||||
self.editor.call_after_note_saved(self._add_current_note)
|
self.editor.call_after_note_saved(self._add_current_note)
|
||||||
|
|
||||||
def _add_current_note(self) -> None:
|
def _add_current_note(self) -> None:
|
||||||
|
@ -372,11 +358,6 @@ class AddCards(QMainWindow):
|
||||||
|
|
||||||
self.ifCanClose(doClose)
|
self.ifCanClose(doClose)
|
||||||
|
|
||||||
def add_io_note(self) -> None:
|
|
||||||
self.editor.update_occlusions_field()
|
|
||||||
self.add_current_note()
|
|
||||||
self.editor.reset_image_occlusion()
|
|
||||||
|
|
||||||
# legacy aliases
|
# legacy aliases
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
Loading…
Reference in a new issue