From 40bad0f65d86ed76715063662437c8c0e883bc31 Mon Sep 17 00:00:00 2001 From: RumovZ Date: Fri, 17 Sep 2021 16:16:34 +0200 Subject: [PATCH] Disable unusable browser actions on row change --- qt/aqt/browser/browser.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/qt/aqt/browser/browser.py b/qt/aqt/browser/browser.py index a71cf2e15..0cc6dcf37 100644 --- a/qt/aqt/browser/browser.py +++ b/qt/aqt/browser/browser.py @@ -436,10 +436,39 @@ class Browser(QMainWindow): gui_hooks.browser_did_change_row(self) def _update_context_actions(self) -> None: + self._update_enabled_actions() self._update_flags_menu() self._update_toggle_mark_action() self._update_toggle_suspend_action() + def _update_enabled_actions(self) -> None: + has_rows = bool(self.table.len()) + self.form.actionSelectAll.setEnabled(has_rows) + self.form.actionInvertSelection.setEnabled(has_rows) + self.form.actionFirstCard.setEnabled(has_rows) + self.form.actionLastCard.setEnabled(has_rows) + + self.form.action_Info.setEnabled(bool(self.card)) + + self.form.actionPreviousCard.setEnabled(self.table.has_previous()) + + self.form.actionNextCard.setEnabled(self.table.has_next()) + + has_selection = bool(self.table.len_selection()) + self.form.actionSelectNotes.setEnabled(has_selection) + self.form.actionExport.setEnabled(has_selection) + self.form.actionAdd_Tags.setEnabled(has_selection) + self.form.actionRemove_Tags.setEnabled(has_selection) + self.form.actionToggle_Mark.setEnabled(has_selection) + self.form.actionChangeModel.setEnabled(has_selection) + self.form.actionDelete.setEnabled(has_selection) + self.form.actionChange_Deck.setEnabled(has_selection) + self.form.action_set_due_date.setEnabled(has_selection) + self.form.action_forget.setEnabled(has_selection) + self.form.actionReposition.setEnabled(has_selection) + self.form.actionToggle_Suspend.setEnabled(has_selection) + self.form.menuFlag.setEnabled(has_selection) + @ensure_editor_saved def on_table_state_changed(self, checked: bool) -> None: self.mw.progress.start()