From c4e7d40cd7566dab44817e4c8b2c4572a0a1004a Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Tue, 27 Jun 2023 14:16:43 +0200 Subject: [PATCH] Add more Qt6 qualifying --- addon/bridge_actions.py | 2 +- addon/create_cards_from_notes_dialog.py | 18 +++++++++++++----- addon/mark_known_dialog.py | 4 ++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/addon/bridge_actions.py b/addon/bridge_actions.py index 937710c..cb13e0d 100644 --- a/addon/bridge_actions.py +++ b/addon/bridge_actions.py @@ -107,7 +107,7 @@ def arg_from(i): if reviewer: aqt.mw.requireReset() r = CustomKeywordsDialog(character, parent).exec() - if r == QDialog.Accepted: + if r == QDialog.DialogCode.Accepted: if reviewer: aqt.mw.maybeReset() else: diff --git a/addon/create_cards_from_notes_dialog.py b/addon/create_cards_from_notes_dialog.py index 652c0c8..0cbc74f 100644 --- a/addon/create_cards_from_notes_dialog.py +++ b/addon/create_cards_from_notes_dialog.py @@ -1,5 +1,13 @@ import aqt -from aqt.qt import * +from aqt.qt import ( + QDialog, + QVBoxLayout, + QLabel, + QListWidget, + QListWidgetItem, + QDialogButtonBox, + Qt, +) import anki.find @@ -41,9 +49,9 @@ def __init__(self, note_ids, parent=None): for field_name in anki.find.fieldNamesForNotes(aqt.mw.col, note_ids): itm = QListWidgetItem(field_name) itm.setCheckState( - Qt.Checked + Qt.CheckState.Checked if (field_name in last_checked and last_checked[field_name]) - else Qt.Unchecked + else Qt.CheckState.Unchecked ) self.list_box.addItem(itm) lyt.addWidget(self.list_box) @@ -86,14 +94,14 @@ def create_cards(self): new_kanji = aqt.mw.migaku_kanji_db.new_characters(card_type, kanji) if len(new_kanji): - r = aqt.qt.QMessageBox.question( + response = aqt.qt.QMessageBox.question( self, "Migaku Kanji", f"Do you want to create kanji {card_type.label} cards for these kanji?\n\n" + " ".join(new_kanji), ) - if r == aqt.qt.QMessageBox.StandardButton.Yes: + if response == aqt.qt.QMessageBox.StandardButton.Yes: util.error_msg_on_error( self, aqt.mw.migaku_kanji_db.make_cards_from_characters, diff --git a/addon/mark_known_dialog.py b/addon/mark_known_dialog.py index 615050e..f971862 100644 --- a/addon/mark_known_dialog.py +++ b/addon/mark_known_dialog.py @@ -147,7 +147,7 @@ def __init__(self, note_ids, parent=None): self.list_box = QListWidget() for field_name in anki.find.fieldNamesForNotes(aqt.mw.col, note_ids): itm = QListWidgetItem(field_name) - itm.setCheckState(Qt.Unchecked) + itm.setCheckState(Qt.CheckState.Unchecked) self.list_box.addItem(itm) lyt.addWidget(self.list_box) @@ -182,7 +182,7 @@ def on_ok(self): dlg = MarkKnownDialog(kanji, self) r = dlg.exec() - if r == QDialog.Accepted: + if r == QDialog.DialogCode.Accepted: self.accept() @classmethod