Skip to content

Commit

Permalink
Replace CAATypesSelectorDialog.run() static method with module level …
Browse files Browse the repository at this point in the history
…function

New function is named display_caa_types_selector()
All keyword arguments are passed to CAATypesSelectorDialog constructor
  • Loading branch information
zas committed Sep 13, 2023
1 parent 091871d commit db0ccaf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
14 changes: 8 additions & 6 deletions picard/coverart/providers/caa.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
)
from picard.webservice import ratecontrol

from picard.ui.caa_types_selector import CAATypesSelectorDialog
from picard.ui.caa_types_selector import display_caa_types_selector
from picard.ui.ui_provider_options_caa import Ui_CaaOptions


Expand Down Expand Up @@ -176,11 +176,13 @@ def update_caa_types(self):

def select_caa_types(self):
known_types = {t['name']: translate_caa_type(t['name']) for t in CAA_TYPES}
(types, types_to_omit, ok) = CAATypesSelectorDialog.run(
self,
types_include=self.caa_image_types, types_exclude=self.caa_image_types_to_omit,
default_include=_CAA_IMAGE_TYPE_DEFAULT_INCLUDE, default_exclude=_CAA_IMAGE_TYPE_DEFAULT_EXCLUDE,
known_types=known_types
(types, types_to_omit, ok) = display_caa_types_selector(
parent=self,
types_include=self.caa_image_types,
types_exclude=self.caa_image_types_to_omit,
default_include=_CAA_IMAGE_TYPE_DEFAULT_INCLUDE,
default_exclude=_CAA_IMAGE_TYPE_DEFAULT_EXCLUDE,
known_types=known_types,
)
if ok:
self.caa_image_types = types
Expand Down
21 changes: 6 additions & 15 deletions picard/ui/caa_types_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def __init__(
types_exclude = []
self._default_include = default_include or []
self._default_exclude = default_exclude or []
self._known_types = known_types or []
self._known_types = known_types or {}

self.setWindowTitle(_("Cover art types"))
self.setWindowModality(QtCore.Qt.WindowModality.WindowModal)
Expand Down Expand Up @@ -348,17 +348,8 @@ def set_buttons_enabled_state(self):
self.arrows_exclude.button_remove.setEnabled(has_items_exclude and has_selected_exclude)
self.arrows_exclude.button_remove_all.setEnabled(has_items_exclude)

@staticmethod
def run(
parent=None,
types_include=None, types_exclude=None,
default_include=None, default_exclude=None,
known_types=None):
dialog = CAATypesSelectorDialog(
parent,
types_include=types_include, types_exclude=types_exclude,
default_include=default_include, default_exclude=default_exclude,
known_types=known_types
)
result = dialog.exec_()
return (dialog.get_selected_types_include(), dialog.get_selected_types_exclude(), result == QtWidgets.QDialog.DialogCode.Accepted)

def display_caa_types_selector(**kwargs):
dialog = CAATypesSelectorDialog(**kwargs)
result = dialog.exec_()
return (dialog.get_selected_types_include(), dialog.get_selected_types_exclude(), result == QtWidgets.QDialog.DialogCode.Accepted)

0 comments on commit db0ccaf

Please sign in to comment.