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:
Akash Reddy 2023-11-20 12:06:25 +05:30 committed by GitHub
parent 9785dfb850
commit 9fd25a87ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 25 deletions

View file

@ -149,6 +149,7 @@ Gustaf Carefall <https://github.com/Gustaf-C>
virinci <github.com/virinci>
snowtimeglass <snowtimeglass@gmail.com>
Ben Olson <github.com/grepgrok>
Akash Reddy <github.com/akashreddy03>
********************

View file

@ -114,11 +114,6 @@ class AddCards(QMainWindow):
qconnect(self.compat_add_shorcut.activated, self.addButton.click)
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
self.closeButton = QPushButton(tr.actions_close())
self.closeButton.setAutoDefault(False)
@ -140,17 +135,6 @@ class AddCards(QMainWindow):
b.setEnabled(False)
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:
self.editor.set_note(note, focusTo=0)
@ -210,9 +194,6 @@ class AddCards(QMainWindow):
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:
note = self._new_note()
if old_note := sticky_fields_from:
@ -274,6 +255,11 @@ class AddCards(QMainWindow):
aqt.dialogs.open("Browser", self.mw, search=(SearchNode(nid=nid),))
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)
def _add_current_note(self) -> None:
@ -372,11 +358,6 @@ class AddCards(QMainWindow):
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
@property