mirror of
https://github.com/fergalmoran/picard.git
synced 2026-01-08 17:43:58 +00:00
Add CAA provider options UI, not yet used
- Set CAA Release Group provider OPTIONS to None, as it is shared with CAA provider
This commit is contained in:
@@ -28,11 +28,13 @@ from PyQt4 import QtCore, QtGui
|
||||
from PyQt4.QtNetwork import QNetworkReply
|
||||
from picard import config, log
|
||||
from picard.const import CAA_HOST, CAA_PORT
|
||||
from picard.coverart.providers import CoverArtProvider
|
||||
from picard.coverart.providers import CoverArtProvider, ProviderOptions
|
||||
from picard.coverart.image import CaaCoverArtImage, CaaThumbnailCoverArtImage
|
||||
from picard.coverart.utils import CAA_TYPES, translate_caa_type
|
||||
from picard.ui.ui_provider_options_caa import Ui_CaaOptions
|
||||
from picard.ui.util import StandardButton
|
||||
from picard.util import webbrowser2
|
||||
from picard.ui.options import OptionsPage, OptionsCheckError, register_options_page
|
||||
|
||||
|
||||
_CAA_THUMBNAIL_SIZE_MAP = {
|
||||
@@ -123,12 +125,64 @@ class CAATypesSelectorDialog(QtGui.QDialog):
|
||||
result = dialog.exec_()
|
||||
return (dialog.get_selected_types(), result == QtGui.QDialog.Accepted)
|
||||
|
||||
|
||||
class ProviderOptionsCaa(ProviderOptions):
|
||||
"""
|
||||
Options for Cover Art Archive cover art provider
|
||||
"""
|
||||
|
||||
options = [
|
||||
config.BoolOption("setting", "caa_approved_only", False),
|
||||
config.BoolOption("setting", "caa_image_type_as_filename", False),
|
||||
config.IntOption("setting", "caa_image_size", 1),
|
||||
config.ListOption("setting", "caa_image_types", [u"front"]),
|
||||
config.BoolOption("setting", "caa_restrict_image_types", True),
|
||||
]
|
||||
|
||||
_options_ui = Ui_CaaOptions
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(ProviderOptionsCaa, self).__init__(parent)
|
||||
self.ui.restrict_images_types.clicked.connect(self.update_caa_types)
|
||||
self.ui.select_caa_types.clicked.connect(self.select_caa_types)
|
||||
|
||||
def load(self):
|
||||
self.ui.cb_image_size.setCurrentIndex(config.setting["caa_image_size"])
|
||||
self.ui.cb_approved_only.setChecked(config.setting["caa_approved_only"])
|
||||
self.ui.cb_type_as_filename.setChecked(config.setting["caa_image_type_as_filename"])
|
||||
self.ui.restrict_images_types.setChecked(
|
||||
config.setting["caa_restrict_image_types"])
|
||||
self.update_caa_types()
|
||||
|
||||
def save(self):
|
||||
config.setting["caa_image_size"] =\
|
||||
self.ui.cb_image_size.currentIndex()
|
||||
config.setting["caa_approved_only"] =\
|
||||
self.ui.cb_approved_only.isChecked()
|
||||
config.setting["caa_image_type_as_filename"] = \
|
||||
self.ui.cb_type_as_filename.isChecked()
|
||||
config.setting["caa_restrict_image_types"] = \
|
||||
self.ui.restrict_images_types.isChecked()
|
||||
|
||||
def update_caa_types(self):
|
||||
enabled = self.ui.restrict_images_types.isChecked()
|
||||
self.ui.select_caa_types.setEnabled(enabled)
|
||||
|
||||
def select_caa_types(self):
|
||||
(types, ok) = CAATypesSelectorDialog.run(
|
||||
self, config.setting["caa_image_types"])
|
||||
if ok:
|
||||
config.setting["caa_image_types"] = types
|
||||
|
||||
|
||||
|
||||
class CoverArtProviderCaa(CoverArtProvider):
|
||||
|
||||
"""Get cover art from Cover Art Archive using release mbid"""
|
||||
|
||||
NAME = "Cover Art Archive"
|
||||
TITLE = N_(u'Cover Art Archive')
|
||||
OPTIONS = ProviderOptionsCaa
|
||||
|
||||
ignore_json_not_found_error = False
|
||||
coverartimage_class = CaaCoverArtImage
|
||||
|
||||
@@ -39,6 +39,8 @@ class CoverArtProviderCaaReleaseGroup(CoverArtProviderCaa):
|
||||
|
||||
NAME = "CaaReleaseGroup"
|
||||
TITLE = N_(u"CAA Release Group")
|
||||
# FIXME: caa release group uses the same options than caa
|
||||
OPTIONS = None
|
||||
|
||||
ignore_json_not_found_error = True
|
||||
coverartimage_class = CaaCoverArtImageRg
|
||||
|
||||
91
picard/ui/ui_provider_options_caa.py
Normal file
91
picard/ui/ui_provider_options_caa.py
Normal file
@@ -0,0 +1,91 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Automatically generated - don't edit.
|
||||
# Use `python setup.py build_ui` to update it.
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
try:
|
||||
_fromUtf8 = QtCore.QString.fromUtf8
|
||||
except AttributeError:
|
||||
def _fromUtf8(s):
|
||||
return s
|
||||
|
||||
try:
|
||||
_encoding = QtGui.QApplication.UnicodeUTF8
|
||||
def _translate(context, text, disambig):
|
||||
return QtGui.QApplication.translate(context, text, disambig, _encoding)
|
||||
except AttributeError:
|
||||
def _translate(context, text, disambig):
|
||||
return QtGui.QApplication.translate(context, text, disambig)
|
||||
|
||||
class Ui_CaaOptions(object):
|
||||
def setupUi(self, CaaOptions):
|
||||
CaaOptions.setObjectName(_fromUtf8("CaaOptions"))
|
||||
CaaOptions.resize(586, 194)
|
||||
self.verticalLayout = QtGui.QVBoxLayout(CaaOptions)
|
||||
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
|
||||
self.select_caa_types_group = QtGui.QHBoxLayout()
|
||||
self.select_caa_types_group.setObjectName(_fromUtf8("select_caa_types_group"))
|
||||
self.restrict_images_types = QtGui.QCheckBox(CaaOptions)
|
||||
self.restrict_images_types.setObjectName(_fromUtf8("restrict_images_types"))
|
||||
self.select_caa_types_group.addWidget(self.restrict_images_types)
|
||||
spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.select_caa_types_group.addItem(spacerItem)
|
||||
self.select_caa_types = QtGui.QPushButton(CaaOptions)
|
||||
self.select_caa_types.setEnabled(False)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(100)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.select_caa_types.sizePolicy().hasHeightForWidth())
|
||||
self.select_caa_types.setSizePolicy(sizePolicy)
|
||||
self.select_caa_types.setObjectName(_fromUtf8("select_caa_types"))
|
||||
self.select_caa_types_group.addWidget(self.select_caa_types)
|
||||
self.verticalLayout.addLayout(self.select_caa_types_group)
|
||||
self.horizontalLayout = QtGui.QHBoxLayout()
|
||||
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
|
||||
self.label = QtGui.QLabel(CaaOptions)
|
||||
self.label.setObjectName(_fromUtf8("label"))
|
||||
self.horizontalLayout.addWidget(self.label)
|
||||
spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.horizontalLayout.addItem(spacerItem1)
|
||||
self.cb_image_size = QtGui.QComboBox(CaaOptions)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.cb_image_size.sizePolicy().hasHeightForWidth())
|
||||
self.cb_image_size.setSizePolicy(sizePolicy)
|
||||
self.cb_image_size.setObjectName(_fromUtf8("cb_image_size"))
|
||||
self.cb_image_size.addItem(_fromUtf8(""))
|
||||
self.cb_image_size.addItem(_fromUtf8(""))
|
||||
self.cb_image_size.addItem(_fromUtf8(""))
|
||||
self.horizontalLayout.addWidget(self.cb_image_size)
|
||||
self.verticalLayout.addLayout(self.horizontalLayout)
|
||||
self.cb_approved_only = QtGui.QCheckBox(CaaOptions)
|
||||
self.cb_approved_only.setObjectName(_fromUtf8("cb_approved_only"))
|
||||
self.verticalLayout.addWidget(self.cb_approved_only)
|
||||
self.cb_type_as_filename = QtGui.QCheckBox(CaaOptions)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.cb_type_as_filename.sizePolicy().hasHeightForWidth())
|
||||
self.cb_type_as_filename.setSizePolicy(sizePolicy)
|
||||
self.cb_type_as_filename.setObjectName(_fromUtf8("cb_type_as_filename"))
|
||||
self.verticalLayout.addWidget(self.cb_type_as_filename)
|
||||
spacerItem2 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||
self.verticalLayout.addItem(spacerItem2)
|
||||
|
||||
self.retranslateUi(CaaOptions)
|
||||
QtCore.QMetaObject.connectSlotsByName(CaaOptions)
|
||||
|
||||
def retranslateUi(self, CaaOptions):
|
||||
CaaOptions.setWindowTitle(_("Form"))
|
||||
self.restrict_images_types.setText(_("Download only cover art images matching selected types"))
|
||||
self.select_caa_types.setText(_("Select types..."))
|
||||
self.label.setText(_("Only use images of the following size:"))
|
||||
self.cb_image_size.setItemText(0, _("250 px"))
|
||||
self.cb_image_size.setItemText(1, _("500 px"))
|
||||
self.cb_image_size.setItemText(2, _("Full size"))
|
||||
self.cb_approved_only.setText(_("Download only approved images"))
|
||||
self.cb_type_as_filename.setText(_("Use the first image type as the filename. This will not change the filename of front images."))
|
||||
|
||||
143
ui/provider_options_caa.ui
Normal file
143
ui/provider_options_caa.ui
Normal file
@@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CaaOptions</class>
|
||||
<widget class="QWidget" name="CaaOptions">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>586</width>
|
||||
<height>194</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="select_caa_types_group">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="restrict_images_types">
|
||||
<property name="text">
|
||||
<string>Download only cover art images matching selected types</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="select_caa_types">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>100</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Select types...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Only use images of the following size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cb_image_size">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>250 px</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>500 px</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Full size</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_approved_only">
|
||||
<property name="text">
|
||||
<string>Download only approved images</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_type_as_filename">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use the first image type as the filename. This will not change the filename of front images.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user