diff --git a/picard/coverart/providers/__init__.py b/picard/coverart/providers/__init__.py index cbd8fa541..a94b70c9b 100644 --- a/picard/coverart/providers/__init__.py +++ b/picard/coverart/providers/__init__.py @@ -19,13 +19,51 @@ from picard import log, config from picard.plugin import ExtensionPoint +from picard.ui.options import OptionsPage, register_options_page _cover_art_providers = ExtensionPoint() +class ProviderOptions(OptionsPage): + + """ Template class for provider's options + + It works like OptionsPage for the most (options, load, save) + It will append the provider's options page as a child of the main + cover art's options page. + + The property _options_ui must be set to a valid Qt Ui class + containing the layout and widgets for defined provider's options. + + A specific provider class (inhereting from CoverArtProvider) has + to set the subclassed ProviderOptions as OPTIONS property. + Options will be registered at the same time as the provider. + + class MyProviderOptions(ProviderOptions): + _options_ui = Ui_MyProviderOptions + .... + + class MyProvider(CoverArtProvider): + OPTIONS = ProviderOptionsMyProvider + .... + + """ + + PARENT = "cover" + + def __init__(self, parent=None): + super(ProviderOptions, self).__init__(parent) + self.ui = self._options_ui() + self.ui.setupUi(self) + + def register_cover_art_provider(provider): _cover_art_providers.register(provider.__module__, provider) + if hasattr(provider, 'OPTIONS') and provider.OPTIONS: + provider.OPTIONS.NAME = provider.NAME + provider.OPTIONS.TITLE = provider.TITLE or provider.NAME + register_options_page(provider.OPTIONS) def cover_art_providers():