Skip to content

Commit

Permalink
Merge pull request #203 from aplaice/qt6_code_compat
Browse files Browse the repository at this point in the history
Replace Qt5 attributes with Qt6 ones
  • Loading branch information
aplaice authored Oct 29, 2023
2 parents 7ca9027 + fc9ddca commit 30a82ec
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion crowd_anki/anki/overrides/change_model_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, collection, note_id_list, old_model=None, parent=None):
# todo consider extracting UI file
self.form = aqt.forms.changemodel.Ui_Dialog()
self.form.setupUi(self)
self.setWindowModality(Qt.WindowModal)
self.setWindowModality(Qt.WindowModality.WindowModal)
self.setup()

self.pauseUpdate = False
Expand Down
2 changes: 1 addition & 1 deletion crowd_anki/importer/anki_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def read_import_config(directory_path, deck_json):
import_dict = yaml.full_load(meta_file)

import_dialog = ImportDialog(deck_json, import_dict)
if import_dialog.exec_() == QDialog.Rejected:
if import_dialog.exec() == QDialog.DialogCode.Rejected:
return None

return import_dialog.final_import_config
Expand Down
12 changes: 6 additions & 6 deletions crowd_anki/importer/import_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ def setup_personal_field_selection(self):

def add_header(name):
heading_ui = QListWidgetItem(name)
heading_ui.setFlags(Qt.ItemIsEnabled)
heading_ui.setFlags(Qt.ItemFlag.ItemIsEnabled)
heading_ui.setSizeHint(QSize(self.form.list_personal_fields.width(), 30))
heading_ui.setFont(heading_font)
self.form.list_personal_fields.addItem(heading_ui)

def add_field(name, is_personal) -> QListWidgetItem:
field_ui = QListWidgetItem(name)
field_ui.setCheckState(Qt.Checked if is_personal else Qt.Unchecked)
field_ui.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
field_ui.setCheckState(Qt.CheckState.Checked if is_personal else Qt.CheckState.Unchecked)
field_ui.setFlags(Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsUserCheckable)
self.form.list_personal_fields.addItem(field_ui)
return field_ui

Expand All @@ -121,7 +121,7 @@ def setup_misc(self):
self.form.import_message_textbox.setText(self.import_defaults.import_message)

if self.import_defaults.suggest_tag_imported_cards:
self.form.cb_tag_cards.setCheckState(Qt.Checked)
self.form.cb_tag_cards.setCheckState(Qt.CheckState.Checked)
self.form.cb_tag_cards.setText("Tag Cards (Suggested by Deck Maintainer!)")
# else:
# set as default from config settings
Expand All @@ -131,7 +131,7 @@ def setup_misc(self):

def setup_deck_part_checkboxes(self):
def set_checked_and_text(checkbox, text, count, checked: bool = True):
checkbox.setCheckState(Qt.Checked if checked else Qt.Unchecked)
checkbox.setCheckState(Qt.CheckState.Checked if checked else Qt.CheckState.Unchecked)
if count is not None:
text = f"{text}: {'{:,}'.format(count)}"
checkbox.setText(text)
Expand Down Expand Up @@ -159,5 +159,5 @@ def read_import_config(self):
def read_personal_fields(self, config):
for model_name, fields_dict in self.personal_field_ui_dict.items():
for field_name, widget_item in fields_dict.items():
if widget_item.checkState() == Qt.Checked:
if widget_item.checkState() == Qt.CheckState.Checked:
config.add_field(model_name, field_name)
2 changes: 1 addition & 1 deletion crowd_anki/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def invoke_config_window():
"""
Launch custom GUI on config change instead of default Anki JSON editor
"""
mw.crowd_anki_config.exec_()
mw.crowd_anki_config.exec()


def initialize_config_window(config: ConfigSettings):
Expand Down
2 changes: 1 addition & 1 deletion crowd_anki/representation/note.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def on_accepted():
NoteModel.ModelMap(dialog.get_field_map(), dialog.get_template_map())

dialog.accepted.connect(on_accepted)
dialog.exec_()
dialog.exec()
# todo process cancel

# To get an updated note to work with
Expand Down
2 changes: 1 addition & 1 deletion crowd_anki/representation/note_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ def update_cards(self, collection, old_model):

# todo signals instead of direct dialog creation?

ChangeModelDialog(collection, collection.models.nids(old_model), old_model).exec_()
ChangeModelDialog(collection, collection.models.nids(old_model), old_model).exec()

0 comments on commit 30a82ec

Please sign in to comment.